|
|
|
<script type="text/javascript">
|
|
|
|
//<![CDATA[
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#side1").accordion("activate", 0);
|
|
|
|
$("#side2").accordion("activate", 0);
|
|
|
|
|
|
|
|
var height = document.documentElement.clientHeight - 180;
|
|
|
|
var url = $(tabid).attr('resource');
|
|
|
|
|
|
|
|
$(tabid+" .yresult").flexigrid({
|
|
|
|
url: url,
|
|
|
|
dataType: 'json',
|
|
|
|
method: 'GET',
|
|
|
|
query: $(tabid).attr('search'),
|
|
|
|
colModel: [
|
|
|
|
{display: 'Hash', name : 'hash', width : 50, sortable : false, align: 'center', hide: true},
|
|
|
|
{display: '', name : 'favicon', width : 25, sortable : true, align: 'center'},
|
|
|
|
{display: 'Title', name : 'title', width : 450, sortable : true, align: 'left'},
|
|
|
|
{display: 'Tags', name : 'tags', width : 240, sortable : false, align: 'left'},
|
|
|
|
{display: 'Folders', name : 'folders', width : 240, sortable : false, align: 'left', hide: true},
|
|
|
|
{display: 'Date', name : 'date', width : 100, sortable : true, align: 'left'}
|
|
|
|
],
|
|
|
|
buttons: [
|
|
|
|
{name: 'Crawl', bclass: 'crawl', onpress: yaction},
|
|
|
|
{name: 'Open', bclass: 'pictures', onpress: yaction},
|
|
|
|
{separator: true},
|
|
|
|
{name: 'Bookmark', bclass: 'bookmark', onpress: yaction},
|
|
|
|
{name: 'Blacklist', bclass: 'blacklist', onpress: yaction},
|
|
|
|
{separator: true},
|
|
|
|
{name: 'Help', bclass: 'help', onpress:yaction},
|
|
|
|
],
|
|
|
|
useRp: true,
|
|
|
|
rp: 10,
|
|
|
|
hideOnSubmit: false,
|
|
|
|
usepager: true,
|
|
|
|
striped: true,
|
|
|
|
nowrap: false,
|
|
|
|
height: height,
|
|
|
|
autoload: true,
|
|
|
|
onSuccess: function() {
|
|
|
|
$("#side2").accordion("activate", 2);
|
|
|
|
$("a.favicon").faviconize({
|
|
|
|
position: "before",
|
|
|
|
defaultImage: "img-2/article.png",
|
|
|
|
className: "favicon"
|
|
|
|
});
|
|
|
|
},
|
|
|
|
preProcess: function(data) {
|
|
|
|
var total = data.channels[0].totalResults.replace(/[,.]/,"");
|
|
|
|
var page = (data.channels[0].startIndex / data.channels[0].itemsPerPage) + 1;
|
|
|
|
var search = data.channels[0].searchTerms;
|
|
|
|
var rows = {};
|
|
|
|
var counter = 0;
|
|
|
|
$.each (
|
|
|
|
data.channels[0].items,
|
|
|
|
function(i,item) {
|
|
|
|
if (item) {
|
|
|
|
var title = "<h3 class='linktitle'><a href='"+item.link+"' target='_blank'>"+item.title+"</a></h3>";
|
|
|
|
var url = "<p class='url'><a href='"+item.link+"' target='_blank'>"+item.link+"</a></p>"
|
|
|
|
var desc = "<p class='desc'>"+item.description+"</p>";
|
|
|
|
var fav = "<a class='favicon' href='"+item.link+"'></a>";
|
|
|
|
var date = item.pubDate.substring(0,16);
|
|
|
|
// var tags = "<p id='tags-"+i+"' class='tag'></p>";
|
|
|
|
// getTags(item.link, i);
|
|
|
|
var tags = "Tags";
|
|
|
|
rows[i] = {id: item.guid, cell: [item.guid, fav, title+desc+url, tags, "Folders", date]};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (total < counter) total = counter;
|
|
|
|
var bhtml = "<li id='"+search+"'><span class='folder'>"+search+"</span><ul>";
|
|
|
|
$.each (
|
|
|
|
data.channels[0].topwords,
|
|
|
|
function(i,topword) {
|
|
|
|
if (topword) {
|
|
|
|
bhtml = bhtml + "<li><span class='topword'>"+topword.word+"</span></li>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
bhtml = bhtml + "</ul></li>";
|
|
|
|
var bfold = $(bhtml).prependTo("#topul");
|
|
|
|
$("#topwords").treeview({
|
|
|
|
add: bfold
|
|
|
|
});
|
|
|
|
|
|
|
|
var pdata = {
|
|
|
|
page: page,
|
|
|
|
total: total,
|
|
|
|
rows: rows
|
|
|
|
};
|
|
|
|
return pdata;
|
|
|
|
},
|
|
|
|
onSubmit: function() {
|
|
|
|
var p = this;
|
|
|
|
var g = $(tabid+" .yresult");
|
|
|
|
|
|
|
|
$('.pPageStat',this.pDiv).html(p.procmsg);
|
|
|
|
$('.pReload',this.pDiv).addClass('loading');
|
|
|
|
if (g.bDiv) $(g.block).css({top:g.bDiv.offsetTop});
|
|
|
|
if (p.hideOnSubmit) $(this.gDiv).prepend(g.block); //$(t).hide();
|
|
|
|
// if ($.browser.opera) $(t).css('visibility','hidden');
|
|
|
|
if (!p.newp) p.newp = 1;
|
|
|
|
if (p.page>p.pages) p.page = p.pages;
|
|
|
|
|
|
|
|
var offset = p.newp * p.rp -p.rp;
|
|
|
|
|
|
|
|
var param = [
|
|
|
|
{ name : 'startRecord', value : offset }
|
|
|
|
,{ name : 'maximumRecords', value : p.rp }
|
|
|
|
,{ name : 'search', value : p.query}
|
|
|
|
,{ name : 'urlmaskfilter', value : $(tabid).attr('urlmaskfilter')}
|
|
|
|
,{ name : 'prefermaskfilter', value : $(tabid).attr('prefermaskfilter')}
|
|
|
|
,{ name : 'contentdom', value : $(tabid).attr('contentdom')}
|
|
|
|
,{ name : 'constraint', value : $(tabid).attr('constraint')}
|
|
|
|
,{ name : 'language', value : $(tabid).attr('language')}
|
|
|
|
];
|
|
|
|
|
|
|
|
if (p.params) {
|
|
|
|
for (var pi = 0; pi < p.params.length; pi++) param[param.length] = p.params[pi];
|
|
|
|
}
|
|
|
|
|
|
|
|
$.getJSON(url, param,
|
|
|
|
function(json, status){
|
|
|
|
if (json[0]) data = json[0];
|
|
|
|
else data = json;
|
|
|
|
p.rp = parseInt(data.channels[0].itemsPerPage);
|
|
|
|
g.flexAddData(data);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
function yaction(com, grid) {
|
|
|
|
if (com == 'Bookmark') {
|
|
|
|
confirm('Add ' + $('.trSelected',grid).length + ' search results to bookmark(s)?')
|
|
|
|
$('.trSelected',grid).each(function(){
|
|
|
|
var url = $(this).find('.url').text();
|
|
|
|
var title = $(this).find('.linktitle').text();
|
|
|
|
var desc = $(this).find('.desc').text();
|
|
|
|
var tags = $(tabid).attr('search');
|
|
|
|
var path = "/searchResults";
|
|
|
|
var pub = "private";
|
|
|
|
var query = "&url="+url+"&title="+title+"&description="+desc+"&tags="+tags+"&path="+path+"&public="+pub+"&add=create";
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "/api/bookmarks/posts/add_p.xml?login="+query,
|
|
|
|
dataType: "xml",
|
|
|
|
success: function(xml) {
|
|
|
|
alert("Debug: posted bookmark for: "+url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (com =='Open') {
|
|
|
|
$('.trSelected',grid).each(function(){
|
|
|
|
var url = $(this).find('.url').text();
|
|
|
|
window.open(url);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
alert("Test!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getTags(url, i) {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: "/api/getpageinfo_p.xml?url="+url,
|
|
|
|
dataType: "xml",
|
|
|
|
success: function(xml) {
|
|
|
|
tags = "";
|
|
|
|
$(xml).find('tag').each(function(){
|
|
|
|
tags = tags + $(this).attr('name') + "<img src='img/tags/tag_blue.png' />";
|
|
|
|
});
|
|
|
|
var id = "#tags-"+i;
|
|
|
|
$(id).append(tags);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//]]>
|
|
|
|
</script>
|
|
|
|
<table class="yresult">
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|