J.P.A.L.

 

getAllPages

Page history last edited by Anonymous 2 yrs ago

getAllPages

 

Returns an object containing an array listing all pages in the wiki as a parameter in the specified handler function:

 

jpal.getAllPages(handler);

 

handler is a function taking one parameter (the object). The property pages is the array on success. Otherwise, error and errCode will be set. The following is an example:

 

function showPages(obj) {
//someElement is the id of a predefined HTML element
var html = '';
if (obj.error) { alert(obj.error); return; }
var pageList = obj.pages;
for (var i=0 ; i<pageList.length; i++) {
var l = pageList[i];
html+= '<a href="' + l + '">' + l + '</a><br />';
}
var container = document.getElementById('someElement');
container.innerHTML = html;
}
jpal.getAllPages(showPages);

 

jpal.getAllPages makes an API request for a list of all pages, which is sent to the function showPages. This function outputs links to all pages using innerHTMLand a simple for loop.

Comments (0)

You don't have permission to comment on this page.