Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. /**
  2. * Pervasive Publishing HTML5 Client library.
  3. *
  4. */
  5.  
  6. var PervPub = {
  7.  
  8. magazineXml: null,
  9.  
  10. init: function() {
  11.  
  12. //alert('PervPubClient started!');
  13. //PervPub.retrieveXml(PervPub.printIssues);
  14. PervPub.retrieveXml(function(){
  15. PervPub.printSections("TM 10/2010");
  16. });
  17. //PervPub.retrieveXml(PervPub.printSections);
  18. // PervPub.printIssues();
  19.  
  20. },
  21.  
  22. retrieveXml: function(callback) {
  23. //alert('test!');
  24.  
  25. $.ajax({
  26. type: 'GET',
  27. url: 'test-data.xml',
  28. dataType: 'xml',
  29. error: function() {
  30. alert('The client made a boo-boo ;__;');
  31. },
  32. success: function(data) {
  33. PervPub.magazineXml = $(data);
  34. if(callback) callback();
  35. }
  36. })
  37.  
  38. },
  39.  
  40. printIssues: function() {
  41. var issueList = $('#issues');
  42. PervPub.magazineXml.find('issue').each(function() {
  43. var issue = $('<li></li>');
  44. issue.html('<a href="#' + $(this).attr('pubDate') + '-section">' + $(this).attr('title') + '</a>');
  45. issueList.append(issue);
  46. })
  47. },
  48.  
  49. printSections: function(titleName) {
  50. var sectionList = $('#sections');
  51. var issue = PervPub.magazineXml.find("issue[title='" + titleName + "']");
  52. issue.find('section').each(function() {
  53. var section = $('<li></li>');
  54. section.html('<a href="#' + $(this).attr('title') + '">' + $(this).attr('title') + '</a>');
  55. sectionList.append(section);
  56. })
  57. },
  58.  
  59. }
  60.  
  61. $(PervPub.init); // Start the application on document ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement