You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
82 lines
2.9 KiB
<script type="application/javascript">
|
|
//<![CDATA[
|
|
$(function() {
|
|
$("#side3").accordion("activate", 0);
|
|
var pagination = tabid + " .pagination";
|
|
$('<div class="pagination"></div>').html('[loading...]').appendTo(tabid);
|
|
$.ajax({
|
|
type: "GET",
|
|
url: query,
|
|
dataType: "xml",
|
|
success: function(xml) {
|
|
alert($.browser.version);
|
|
if ($.browser.mozilla && ($.browser.version > 1.8)) {
|
|
var totalResults = parseInt($(xml).find('opensearch\\:totalResults').text().replace(".","","g"));
|
|
var startIndex = parseInt($(xml).find('opensearch\\:startIndex').text());
|
|
var itemsPerPage = parseInt($(xml).find('opensearch\\:itemsPerPage').text());
|
|
} else {
|
|
var totalResults = parseInt($(xml).find('totalResults').text().replace(".","","g"));
|
|
var startIndex = parseInt($(xml).find('startIndex').text());
|
|
var itemsPerPage = parseInt($(xml).find('itemsPerPage').text());
|
|
}
|
|
var query = $(xml).find('Query').attr('searchTerms');
|
|
var endIndex = startIndex+itemsPerPage;
|
|
if (endIndex > totalResults) {
|
|
endIndex = totalResults;
|
|
}
|
|
|
|
var totalPages = (totalResults/itemsPerPage)|0;
|
|
if (startIndex != 0) {
|
|
var currentPage = ((startIndex-1)/itemsPerPage);
|
|
} else {
|
|
var currentPage = 0;
|
|
}
|
|
$(pagination).pagination(totalResults, {
|
|
current_page:currentPage,
|
|
items_per_page:itemsPerPage,
|
|
num_edge_entries:1,
|
|
num_display_entries:10,
|
|
callback: loadContents
|
|
});
|
|
|
|
$(xml).find('item').each(function(){
|
|
var title = $(this).find('title').text();
|
|
var link = $(this).find('link').text();
|
|
var desc = $(this).find('description').text();
|
|
var guid = $(this).find('guid').text();
|
|
$('<div class="searchresults"></div>')
|
|
.html('<h3 class="linktitle"><a href="' +link+ '">' +title+ '</a></h3><p class="snippet">' +desc+ '</p><p class="url"><a href="' +link+ '" id="' +guid+ '" >' +link+ '</a></p>')
|
|
.prependTo(tabid);
|
|
}); //close each(
|
|
$(".linktitle a").faviconize({
|
|
position: "before",
|
|
defaultImage: "img-2/article.png",
|
|
className: "favicon"
|
|
});
|
|
}
|
|
}); //close $.ajax(
|
|
function loadContents(page_id, jq) {
|
|
var $tabs = $('#container ul');
|
|
var count = $(tabid).attr('count');
|
|
var offset = ((page_id*count)+1);
|
|
$(tabid).attr('offset', offset);
|
|
|
|
query = $(tabid).attr('resource')
|
|
+"&search="+$(tabid).attr('search')
|
|
+"&contentdom="+$(tabid).attr('contentdom')
|
|
+"&count="+$(tabid).attr('count')
|
|
+"&offset="+$(tabid).attr('offset')
|
|
+"&constraint="+$(tabid).attr('constraint')
|
|
+"&prefermaskfilter="+$(tabid).attr('prefermaskfilter')
|
|
+"&urlmaskfilter="+$(tabid).attr('urlmaskfilter');
|
|
|
|
var selected = $tabs.data('selected.tabs');
|
|
$tabs.tabs("load", selected);
|
|
$('#pagination').trigger("update");
|
|
return false;
|
|
}
|
|
}); //close $(
|
|
//]]>
|
|
</script>
|
|
|