$v
";
}
// The document skeleton
$qpdoc = htmlqp('doc.html', 'body');
$key = $_GET['key'];
// The jQuery categories that are used in QueryPath
$qparray = [
'Tree Traversal',
'Child Filter',
'Attribute',
'Content Filter',
'Basic Filter',
'Hierarchy',
'Basic',
'Filtering',
'Miscellaneous Traversing',
'DOM Insertion, Outside',
'DOM Insertion, Inside',
'Attributes',
'Style Properties',
];
$jqnames = [];
$qpnames = [];
// Search through the xml file to find any entries of jQuery entities
foreach (qp('querypath.xml', 'entry') as $entry) {
$qpnames[$entry->attr('name')] =
[
'desc' => $entry->find('desc')->innerXML(),
'jquery' => $entry->parent()->find('jquery')->innerXML(),
'querypath' => $entry->parent()->find('querypath')->innerXML(),
];
}
// Search through the xml file to find all entries of jQuery entities
foreach (htmlqp('http://api.jquery.com/api/', 'entry') as $entry) {
$category = false;
$category = array_search($entry->find('category:first')->attr('name'), $qparray);
while ($entry->next('category')->html() != null) {
$category = (array_search($entry->attr('name'), $qparray)) ? true : $category;
if ($category) {
break;
}
}
if ($category) {
$jqnames[$entry->parent()->attr('name')] =
[
'longdesc' => $entry->find('longdesc')->innerXML(),
'name' => $entry->parent()->find('category')->attr('name'),
];
}
}
// Map the keys & sort them
$jqkeys = array_keys($jqnames);
$jqkeys = array_map("addClasses", $jqkeys);
sort($jqkeys);
// Add the keys to the nav bar
$qpdoc->find('#leftbody');
foreach ($jqkeys as $k => $v) {
$qpdoc->append($v);
}
// Add the description to the main window if the key exists
if (array_key_exists($key, $jqnames)) {
if (array_key_exists($key, $qpnames)) {
$qpdoc->top()->find('#rightfunction')->text('Function: ' . ucfirst($key));
$qpdoc->top()->find('#rightdesc')->text($qpnames[$key]['desc']);
$qpdoc->top()->find('#righttitle')->text('How it\'s done in jQuery');
$qpdoc->top()->find('#righttext')->text($qpnames[$key]['jquery']);
$qpdoc->top()->find('#righttitle2')->text('How it\'s done in QueryPath');
$qpdoc->top()->find('#righttext2')->text($qpnames[$key]['querypath']);
} else {
$qpdoc->top()->find('#rightfunction')->text('Function: ' . ucfirst($key));
$qpdoc->top()->find('#rightdesc')->remove();
$qpdoc->top()->find('#righttitle')->text('jQuery Documentation');
$qpdoc->top()->find('#righttext')->append($jqnames[$key]['longdesc']);
}
}
// Write the document
$qpdoc->writeHTML();