Chique

Subzero | Append topicId to first link

Jul 17th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. @session_start();
  3. if (isset($_GET["topic"]))
  4. {
  5. $_SESSION["topic"] = $_GET["topic"];
  6. }
  7. ?>
  8. <script>
  9. $(document).ready(function() {
  10. var QueryString = function () {
  11. // This function is anonymous, is executed immediately and
  12. // the return value is assigned to QueryString!
  13. var query_string = {};
  14. var query = window.location.search.substring(1);
  15. var vars = query.split("&");
  16. for (var i=0;i<vars.length;i++) {
  17. var pair = vars[i].split("=");
  18. // If first entry with this name
  19. if (typeof query_string[pair[0]] === "undefined") {
  20. query_string[pair[0]] = decodeURIComponent(pair[1]);
  21. // If second entry with this name
  22. } else if (typeof query_string[pair[0]] === "string") {
  23. var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
  24. query_string[pair[0]] = arr;
  25. // If third or later entry with this name
  26. } else {
  27. query_string[pair[0]].push(decodeURIComponent(pair[1]));
  28. }
  29. }
  30. return query_string;
  31. }();
  32.  
  33. var topicId = parseInt(QueryString.topic);
  34.  
  35. var linktxt = $(".body_message .body_content .post").find("a").first().attr("href");
  36. linktxt = linktxt.split("index.php?");
  37. if (linktxt[1]!=undefined)
  38. {
  39. linktxt = linktxt[0]+"index.php?topic="+topicId+"&"+linktxt[1];
  40. $(".body_message .body_content .post").find("a").first().attr("href",linktxt);
  41. }
  42. });
  43. </script>
Add Comment
Please, Sign In to add comment