Guest User

Untitled

a guest
Jun 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function handleInit(event) {
  2. if (event.path != "/") {
  3. var hash = event.path.replace(///,"").replace(/?/g,"");
  4. getPage(hash);
  5. currentState.hash = hash;
  6. } else {
  7. currentState.id = 1;
  8. }
  9. SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleChange);
  10. }
  11.  
  12.  
  13. function chapter_forward() {
  14. if (!freeze) {
  15. freeze = true;
  16. getPage(currentState.id - 1);
  17. }
  18. }
  19.  
  20.  
  21. function ajax_data(id) {
  22. return typeof(id) == "string" ? "hash=" : "page=";
  23. }
  24.  
  25. function getPage(id) {
  26. $.ajax({
  27. method: "get",
  28. url: getPage.php,
  29. data: ajax_data(id) + id.toString(),
  30. dataType: 'json',
  31. timeout: 2000,
  32. error: function() {
  33. $("#space-3").html('40104 - Request Timeout');
  34. },
  35. complete: function() {},
  36. success: function(result) {
  37. handleContent(result);
  38. }
  39. });
  40. }
  41.  
  42. {"article_id":"3","hash":"music-in-your-ear","title":"Music in your ear.","html":"Blah blah article 3","modified":"Fri, 20 Mar 2009 02:46:00 GMT"}
Add Comment
Please, Sign In to add comment