Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Pervasive Publishing HTML5 Client library.
- *
- */
- var PervPub = {
- magazineXml: null,
- init: function() {
- //alert('PervPubClient started!');
- //PervPub.retrieveXml(PervPub.printIssues);
- PervPub.retrieveXml(function(){
- PervPub.printSections("TM 10/2010");
- });
- //PervPub.retrieveXml(PervPub.printSections);
- // PervPub.printIssues();
- },
- retrieveXml: function(callback) {
- //alert('test!');
- $.ajax({
- type: 'GET',
- url: 'test-data.xml',
- dataType: 'xml',
- error: function() {
- alert('The client made a boo-boo ;__;');
- },
- success: function(data) {
- PervPub.magazineXml = $(data);
- if(callback) callback();
- }
- })
- },
- printIssues: function() {
- var issueList = $('#issues');
- PervPub.magazineXml.find('issue').each(function() {
- var issue = $('<li></li>');
- issue.html('<a href="#' + $(this).attr('pubDate') + '-section">' + $(this).attr('title') + '</a>');
- issueList.append(issue);
- })
- },
- printSections: function(titleName) {
- var sectionList = $('#sections');
- var issue = PervPub.magazineXml.find("issue[title='" + titleName + "']");
- issue.find('section').each(function() {
- var section = $('<li></li>');
- section.html('<a href="#' + $(this).attr('title') + '">' + $(this).attr('title') + '</a>');
- sectionList.append(section);
- })
- },
- }
- $(PervPub.init); // Start the application on document ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement