mmainstreet /
jodel-web
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | error_reporting(-1); |
||
| 3 | include 'php/jodel-web.php'; |
||
| 4 | |||
| 5 | $location = new Location(); |
||
| 6 | $location->setLat('0.1'); |
||
| 7 | $location->setLng('0.1'); |
||
| 8 | $location->setCityName('Munich'); |
||
| 9 | |||
| 10 | isTokenFresh($location); |
||
| 11 | |||
| 12 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
||
| 13 | |||
| 14 | $accessToken; |
||
| 15 | $newPositionStatus; |
||
| 16 | |||
| 17 | if ($result->num_rows > 0) |
||
| 18 | { |
||
| 19 | // output data of each row |
||
| 20 | while($row = $result->fetch_assoc()) |
||
| 21 | { |
||
| 22 | $accessToken = $row["access_token"]; |
||
|
0 ignored issues
–
show
|
|||
| 23 | $newPositionStatus = $row['name']; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | else |
||
| 27 | { |
||
| 28 | echo "Error: 0 results"; |
||
| 29 | } |
||
| 30 | |||
| 31 | |||
| 32 | //createAccount(); |
||
| 33 | |||
| 34 | //Set Location |
||
| 35 | if(isset($_GET['city'])) { |
||
| 36 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
||
| 37 | $result = Requests::post($url); |
||
| 38 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
||
| 39 | { |
||
| 40 | $newPositionStatus = "0 results"; |
||
| 41 | } |
||
| 42 | else |
||
| 43 | { |
||
| 44 | $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
||
| 45 | $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 46 | $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 47 | |||
| 48 | $location = new Location(); |
||
| 49 | $location->setLat($lat); |
||
| 50 | $location->setLng($lng); |
||
| 51 | $location->setCityName($name); |
||
| 52 | $accountCreator = new UpdateLocation(); |
||
| 53 | $accountCreator->setLocation($location); |
||
| 54 | $accountCreator->setAccessToken($accessToken); |
||
| 55 | $data = $accountCreator->execute(); |
||
| 56 | |||
| 57 | //safe location to db |
||
| 58 | if($data == "Success") |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Success does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 59 | { |
||
| 60 | $result = $db->query("UPDATE accounts |
||
| 61 | SET name='" . $name . "', |
||
| 62 | lat='" . $lat . "', |
||
| 63 | lng='" . $lng . "' |
||
| 64 | WHERE id='1'"); |
||
| 65 | |||
| 66 | if($result === false) |
||
| 67 | { |
||
| 68 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Updating location failed: ( does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
Coding Style
Comprehensibility
introduced
by
The string literal
) does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 69 | } |
||
| 70 | else |
||
| 71 | { |
||
| 72 | $newPositionStatus = $name; |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | //Vote |
||
| 79 | if(isset($_GET['vote']) && isset($_GET['postID'])) { |
||
| 80 | if($_GET['vote'] == "up") { |
||
| 81 | $accountCreator = new Upvote(); |
||
| 82 | } |
||
| 83 | else if($_GET['vote'] == "down") { |
||
| 84 | $accountCreator = new Downvote(); |
||
| 85 | } |
||
| 86 | $accountCreator->setAccessToken($accessToken); |
||
| 87 | $data = $accountCreator->execute(); |
||
| 88 | |||
| 89 | header("Location: index.php#postId-" . htmlspecialchars($_GET['postID'])); |
||
| 90 | die(); |
||
| 91 | } |
||
| 92 | |||
| 93 | |||
| 94 | //SendJodel |
||
| 95 | if(isset($_POST['message'])) { |
||
| 96 | $accountCreator = new SendJodel(); |
||
| 97 | |||
| 98 | if(isset($_POST['ancestor'])) |
||
| 99 | { |
||
| 100 | $ancestor = $_POST['ancestor']; |
||
| 101 | $accountCreator->ancestor = $ancestor; |
||
| 102 | } |
||
| 103 | if(isset($_POST['color'])) |
||
| 104 | { |
||
| 105 | $color = $_POST['color']; |
||
| 106 | switch ($color) { |
||
| 107 | case '8ABDB0': |
||
| 108 | $color = '8ABDB0'; |
||
| 109 | break; |
||
| 110 | case '9EC41C': |
||
| 111 | $color = '9EC41C'; |
||
| 112 | break; |
||
| 113 | case '06A3CB': |
||
| 114 | $color = '06A3CB'; |
||
| 115 | break; |
||
| 116 | case 'FFBA00': |
||
| 117 | $color = 'FFBA00'; |
||
| 118 | break; |
||
| 119 | case 'DD5F5F': |
||
| 120 | $color = 'DD5F5F'; |
||
| 121 | break; |
||
| 122 | case 'FF9908': |
||
| 123 | $color = 'FF9908'; |
||
| 124 | break; |
||
| 125 | |||
| 126 | default: |
||
| 127 | $color = '8ABDB0'; |
||
| 128 | break; |
||
| 129 | } |
||
| 130 | $accountCreator->color = $color; |
||
| 131 | echo "Setting color:" . $color; |
||
| 132 | } |
||
| 133 | |||
| 134 | $location = new Location(); |
||
| 135 | $location->setLat('0.1'); |
||
| 136 | $location->setLng('0.1'); |
||
| 137 | $location->setCityName('Munich'); |
||
| 138 | |||
| 139 | $accountCreator->location = $location; |
||
| 140 | |||
| 141 | $accountCreator->setAccessToken($accessToken); |
||
| 142 | $data = $accountCreator->execute(); |
||
| 143 | } |
||
| 144 | ?> |
||
| 145 | <!DOCTYPE html> |
||
| 146 | <html lang="de"> |
||
| 147 | <head> |
||
| 148 | <title>JodelBlue WebClient - </title> |
||
| 149 | |||
| 150 | <meta charset="utf8" /> |
||
| 151 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
||
| 152 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
||
| 153 | |||
| 154 | <meta name="description" content=""/> |
||
| 155 | <meta name="keywords" content=""/> |
||
| 156 | |||
| 157 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous"> |
||
| 158 | <link rel="stylesheet" href="css/font-awesome.min.css"> |
||
| 159 | <link rel="stylesheet" href="style.css" type="text/css"> |
||
| 160 | |||
| 161 | <link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon"> |
||
| 162 | <link rel="icon" href="img/favicon/favicon.ico" type="image/x-icon"> |
||
| 163 | </head> |
||
| 164 | |||
| 165 | <body> |
||
| 166 | <header> |
||
| 167 | <nav class="navbar navbar-full navbar-dark navbar-fixed-top"> |
||
| 168 | <div class="container"> |
||
| 169 | <?php |
||
| 170 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
| 171 | { |
||
| 172 | echo '<a id="comment-back" href="index.php?view=' . $view . '#postId-' . htmlspecialchars($_GET['postID']) . '">'; |
||
| 173 | echo '<i class="fa fa-angle-left fa-3x"></i>'; |
||
| 174 | echo '</a>'; |
||
| 175 | echo '<h1>'; |
||
| 176 | echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postID=' . htmlspecialchars($_GET['postID']) . '" class="spinnable">'; |
||
| 177 | } |
||
| 178 | else |
||
| 179 | { |
||
| 180 | echo '<h1>'; |
||
| 181 | echo '<a href="index.php" class="spinnable">'; |
||
| 182 | } |
||
| 183 | ?> |
||
| 184 | JodelBlue <i class="fa fa-refresh fa-1x"></i></a> |
||
| 185 | </h1> |
||
| 186 | </div> |
||
| 187 | </nav> |
||
| 188 | </header> |
||
| 189 | |||
| 190 | <div class="mainContent container"> |
||
| 191 | <div class="content row"> |
||
| 192 | <article class="topContent col-sm-8"> |
||
| 193 | |||
| 194 | <content id="posts"> |
||
| 195 | <?php |
||
| 196 | $posts; |
||
| 197 | |||
| 198 | //Set View |
||
| 199 | View Code Duplication | if(isset($_GET['view'])) |
|
| 200 | { |
||
| 201 | switch ($_GET['view']) { |
||
| 202 | case 'comment': |
||
| 203 | $view = 'comment'; |
||
| 204 | break; |
||
| 205 | |||
| 206 | case 'upVote': |
||
| 207 | $view = 'upVote'; |
||
| 208 | break; |
||
| 209 | |||
| 210 | default: |
||
| 211 | $view = 'time'; |
||
| 212 | break; |
||
| 213 | } |
||
| 214 | } |
||
| 215 | else |
||
| 216 | { |
||
| 217 | $view = 'time'; |
||
| 218 | } |
||
| 219 | |||
| 220 | //Get Post Details |
||
| 221 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
| 222 | { |
||
| 223 | $accountCreator = new GetPostDetails(); |
||
| 224 | $accountCreator->setAccessToken($accessToken); |
||
| 225 | $data = $accountCreator->execute(); |
||
| 226 | |||
| 227 | $posts[0] = $data; |
||
| 228 | if(isset($data['children'])) { |
||
| 229 | foreach($data['children'] as $child) { |
||
| 230 | array_push($posts, $child); |
||
| 231 | } |
||
| 232 | $loops = $data['child_count'] + 1; |
||
| 233 | } |
||
| 234 | else $loops = 1; |
||
| 235 | $showCommentIcon = FALSE; |
||
| 236 | } |
||
| 237 | //Get Posts |
||
| 238 | else |
||
| 239 | { |
||
| 240 | View Code Duplication | if($view=='comment') |
|
| 241 | { |
||
| 242 | $url = "/v2/posts/location/discussed/"; |
||
| 243 | } |
||
| 244 | else |
||
| 245 | { |
||
| 246 | if($view=='upVote') |
||
| 247 | { |
||
| 248 | $url = "/v2/posts/location/popular/"; |
||
| 249 | } |
||
| 250 | else |
||
| 251 | { |
||
| 252 | $url = "/v2/posts/location/"; |
||
| 253 | } |
||
| 254 | } |
||
| 255 | |||
| 256 | $posts = getPosts($lastPostId, $accessToken, $url)['posts']; |
||
| 257 | $loops = 29; |
||
| 258 | $showCommentIcon = TRUE; |
||
| 259 | } |
||
| 260 | |||
| 261 | |||
| 262 | View Code Duplication | for($i = 0; $i<$loops; $i++) { |
|
| 263 | |||
| 264 | if(isset($posts[$i])) { |
||
| 265 | $lastPostId = $posts[$i]['post_id']; |
||
| 266 | |||
| 267 | |||
| 268 | $now = new DateTime(); |
||
| 269 | $d = new DateTime($posts[$i]["created_at"]); |
||
| 270 | |||
| 271 | |||
| 272 | //Time to time difference |
||
| 273 | $timediff = $now->diff($d); |
||
| 274 | |||
| 275 | $timediff_inSeconds = (string)$timediff->format('%s'); |
||
| 276 | $timediff_inMinutes = (string)$timediff->format('%i'); |
||
| 277 | $timediff_inHours = (string)$timediff->format('%h'); |
||
| 278 | $timediff_inDays = (string)$timediff->format('%d'); |
||
| 279 | $timediff_inMonth = (string)$timediff->format('%m'); |
||
| 280 | if($timediff_inMonth!=0) { |
||
| 281 | $timediff = $timediff_inMonth . "m"; |
||
| 282 | } |
||
| 283 | else |
||
| 284 | { |
||
| 285 | if($timediff_inDays!=0) |
||
| 286 | { |
||
| 287 | $timediff = $timediff_inDays . "d"; |
||
| 288 | } |
||
| 289 | else |
||
| 290 | { |
||
| 291 | if($timediff_inHours!=0) |
||
| 292 | { |
||
| 293 | $timediff = $timediff_inHours . "h"; |
||
| 294 | } |
||
| 295 | else |
||
| 296 | { |
||
| 297 | if($timediff_inMinutes!=0) |
||
| 298 | { |
||
| 299 | $timediff = $timediff_inMinutes . "m"; |
||
| 300 | } |
||
| 301 | else |
||
| 302 | { |
||
| 303 | $timediff = $timediff_inSeconds . "s"; |
||
| 304 | } |
||
| 305 | } |
||
| 306 | } |
||
| 307 | } |
||
| 308 | ?> |
||
| 309 | |||
| 310 | <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
||
| 311 | <content> |
||
| 312 | <?php |
||
| 313 | if(isset($posts[$i]["image_url"])) { |
||
| 314 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
||
| 315 | } |
||
| 316 | else { |
||
| 317 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($posts[$i]["message"]))); |
||
| 318 | } |
||
| 319 | ?> |
||
| 320 | </content> |
||
| 321 | <aside> |
||
| 322 | <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
||
| 323 | <i class="fa fa-angle-up fa-3x"></i> |
||
| 324 | </a> |
||
| 325 | <br /> |
||
| 326 | <?php echo $posts[$i]["vote_count"];?><br /> |
||
| 327 | <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
||
| 328 | <i class="fa fa-angle-down fa-3x"></i> |
||
| 329 | </a> |
||
| 330 | </aside> |
||
| 331 | |||
| 332 | <footer> |
||
| 333 | <table> |
||
| 334 | <tr> |
||
| 335 | <td class="time"> |
||
| 336 | <span data-tooltip="Time"> |
||
| 337 | <i class="fa fa-clock-o"></i> |
||
| 338 | <?php echo $timediff;?> |
||
| 339 | </span> |
||
| 340 | </td> |
||
| 341 | <td class="comments"> |
||
| 342 | <?php if($showCommentIcon) {?> |
||
| 343 | <span data-tooltip="Comments"> |
||
| 344 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
||
| 345 | <i class="fa fa-commenting-o"></i> |
||
| 346 | <?php if(array_key_exists("child_count", $posts[$i])) { |
||
| 347 | echo $posts[$i]["child_count"]; |
||
| 348 | } else echo "0"; |
||
| 349 | ?> |
||
| 350 | </a> |
||
| 351 | </span> |
||
| 352 | <?php } ?> |
||
| 353 | </td> |
||
| 354 | <td class="distance"> |
||
| 355 | <span data-tooltip="Distance"> |
||
| 356 | <i class="fa fa-map-marker"></i> |
||
| 357 | <?php echo $posts[$i]["distance"];?> km |
||
| 358 | </span> |
||
| 359 | </td> |
||
| 360 | </tr> |
||
| 361 | </table> |
||
| 362 | </footer> |
||
| 363 | </article> |
||
| 364 | |||
| 365 | |||
| 366 | |||
| 367 | <?php } |
||
| 368 | } ?> |
||
| 369 | |||
| 370 | </content> |
||
| 371 | |||
| 372 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
| 373 | <p id="loading"> |
||
| 374 | Loading… |
||
| 375 | </p> |
||
| 376 | <?php } ?> |
||
| 377 | </article> |
||
| 378 | |||
| 379 | <aside class="topSidebar col-sm-4 sidebar-outer"> |
||
| 380 | <div class="fixed"> |
||
| 381 | <article> |
||
| 382 | <div> |
||
| 383 | <h2>Position</h2> |
||
| 384 | <form method="get"> |
||
| 385 | <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
||
|
0 ignored issues
–
show
|
|||
| 386 | |||
| 387 | <input type="submit" value="Set Location" /> |
||
| 388 | </form> |
||
| 389 | </div> |
||
| 390 | </article> |
||
| 391 | |||
| 392 | <article> |
||
| 393 | <div> |
||
| 394 | <h2>Karma</h2> |
||
| 395 | <?php echo getKarma($accessToken); ?> |
||
| 396 | </div> |
||
| 397 | </article> |
||
| 398 | |||
| 399 | <article> |
||
| 400 | <div> |
||
| 401 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
||
| 402 | <h2>Comment on Jodel</h2> |
||
| 403 | <form method="POST"> |
||
| 404 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
||
| 405 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
||
| 406 | <br /> |
||
| 407 | <input type="submit" value="SEND" /> |
||
| 408 | </form> |
||
| 409 | <?php } else { ?> |
||
| 410 | <h2>New Jodel</h2> |
||
| 411 | <form method="POST"> |
||
| 412 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
||
| 413 | <br /> |
||
| 414 | <select id="postColorPicker" name="color"> |
||
| 415 | <option value="06A3CB">Blue</option> |
||
| 416 | <option value="8ABDB0">Teal</option> |
||
| 417 | <option value="9EC41C">Green</option> |
||
| 418 | <option value="FFBA00">Yellow</option> |
||
| 419 | <option value="DD5F5F">Red</option> |
||
| 420 | <option value="FF9908">Orange</option> |
||
| 421 | </select> |
||
| 422 | <br /> |
||
| 423 | <input type="submit" value="SEND" /> |
||
| 424 | </form> |
||
| 425 | <?php } ?> |
||
| 426 | </div> |
||
| 427 | </article> |
||
| 428 | |||
| 429 | <article> |
||
| 430 | <div> |
||
| 431 | <h2>Login</h2> |
||
| 432 | </div> |
||
| 433 | </article> |
||
| 434 | </div> |
||
| 435 | </aside> |
||
| 436 | </div> |
||
| 437 | <div id="sortJodelBy" class="row"> |
||
| 438 | <div class="col-sm-12"> |
||
| 439 | <div class="row"> |
||
| 440 | <div class="col-sm-3"> |
||
| 441 | <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
||
| 442 | </div> |
||
| 443 | <div class="col-sm-3"> |
||
| 444 | <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
||
| 445 | </div> |
||
| 446 | <div class="col-sm-3"> |
||
| 447 | <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
||
| 448 | </div> |
||
| 449 | <div class="col-sm-3"> |
||
| 450 | <nav> |
||
| 451 | <a href="./impressum.html">Impressum</a> | <a href="./datenschutz.html">Datenschutz</a> |
||
| 452 | </nav> |
||
| 453 | </div> |
||
| 454 | </div> |
||
| 455 | </div> |
||
| 456 | </div> |
||
| 457 | </div> |
||
| 458 | |||
| 459 | |||
| 460 | <!-- jQuery, Tether and Bootstrap JS --> |
||
| 461 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script> |
||
| 462 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script> |
||
| 463 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> |
||
| 464 | |||
| 465 | <script> |
||
| 466 | |||
| 467 | |||
| 468 | $('a').on('click', function(){ |
||
| 469 | $('a').removeClass('selected'); |
||
| 470 | $(this).addClass('selected'); |
||
| 471 | }); |
||
| 472 | |||
| 473 | function scrollToAnchor(aid){ |
||
| 474 | var aTag = $("article[id='"+ aid +"']"); |
||
| 475 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
||
| 476 | } |
||
| 477 | |||
| 478 | |||
| 479 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
| 480 | $(document).ready(function() { |
||
| 481 | var win = $(window); |
||
| 482 | var lastPostId = "<?php echo $lastPostId; ?>"; |
||
| 483 | var view = "<?php echo $view; ?>" |
||
| 484 | var old_lastPostId = ""; |
||
| 485 | var morePostsAvailable = true; |
||
| 486 | |||
| 487 | if(window.location.hash) |
||
| 488 | { |
||
| 489 | var hash = window.location.hash.slice(1); |
||
| 490 | |||
| 491 | if(!$("article[id='"+ hash +"']").length) |
||
| 492 | { |
||
| 493 | for (var i = 5; i >= 0; i--) |
||
| 494 | { |
||
| 495 | if(!$("article[id='"+ hash +"']").length) |
||
| 496 | { |
||
| 497 | $.ajax({ |
||
| 498 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
| 499 | dataType: 'html', |
||
| 500 | async: false, |
||
| 501 | success: function(html) { |
||
| 502 | var div = document.createElement('div'); |
||
| 503 | div.innerHTML = html; |
||
| 504 | var elements = div.childNodes; |
||
| 505 | old_lastPostId = lastPostId; |
||
| 506 | lastPostId = elements[3].textContent; |
||
| 507 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
| 508 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
| 509 | if(lastPostId == old_lastPostId) { |
||
| 510 | |||
| 511 | //morePostsAvailable = false; |
||
| 512 | } |
||
| 513 | else { |
||
| 514 | //alert(elements[3].textContent); |
||
| 515 | $('#posts').append(elements[1].innerHTML); |
||
| 516 | $('#posts').hide().show(0); |
||
| 517 | } |
||
| 518 | $('#loading').hide(); |
||
| 519 | } |
||
| 520 | }); |
||
| 521 | } |
||
| 522 | |||
| 523 | } |
||
| 524 | scrollToAnchor(hash); |
||
| 525 | |||
| 526 | } |
||
| 527 | } |
||
| 528 | |||
| 529 | // Each time the user scrolls |
||
| 530 | win.scroll(function() { |
||
| 531 | // End of the document reached? |
||
| 532 | if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) { |
||
| 533 | $('#loading').show(); |
||
| 534 | |||
| 535 | |||
| 536 | |||
| 537 | $.ajax({ |
||
| 538 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
| 539 | dataType: 'html', |
||
| 540 | async: true, |
||
| 541 | success: function(html) { |
||
| 542 | var div = document.createElement('div'); |
||
| 543 | div.innerHTML = html; |
||
| 544 | var elements = div.childNodes; |
||
| 545 | old_lastPostId = lastPostId; |
||
| 546 | lastPostId = elements[3].textContent; |
||
| 547 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
| 548 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
| 549 | if(lastPostId == old_lastPostId) { |
||
| 550 | |||
| 551 | //morePostsAvailable = false; |
||
| 552 | } |
||
| 553 | else { |
||
| 554 | //alert(elements[3].textContent); |
||
| 555 | $('#posts').append(elements[1].innerHTML); |
||
| 556 | } |
||
| 557 | $('#loading').hide(); |
||
| 558 | } |
||
| 559 | }); |
||
| 560 | } |
||
| 561 | }); |
||
| 562 | }); |
||
| 563 | <?php } ?> |
||
| 564 | </script> |
||
| 565 | |||
| 566 | </body> |
||
| 567 | </html> |
||
| 568 | |||
| 569 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.