zotero/chrome/chromeFiles/content/scholar/scholar.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

var foldersView;
var itemsView;
2006-05-23 19:06:11 +00:00
function init()
{
foldersView = new Scholar.TreeView(0); //pass params here?
document.getElementById('folders-tree').view = foldersView;
itemsView = new Scholar.TreeView(0);
document.getElementById('items-tree').view = itemsView;
var addMenu = document.getElementById('tb-add').firstChild;
var itemTypes = Scholar.ItemTypes.getTypes();
for(var i = 0; i<itemTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","newItem("+itemTypes[i]['id']+")");
addMenu.appendChild(menuitem);
}
}
function newItem(typeID)
{
2006-05-24 13:31:39 +00:00
alert("new item of type: "+typeID);
}
function newFolder()
{
2006-05-24 13:31:39 +00:00
alert("new folder");
}
function folderSelected()
{
if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1)
{
itemsView = new Scholar.TreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex).getID());
document.getElementById('items-tree').view = itemsView;
}
else if(foldersView.selection.count == 0)
{
itemsView = new Scholar.TreeView(0);
document.getElementById('items-tree').view = itemsView;
}
else
{
document.getElementById('items-tree').view = null;
}
2006-05-24 13:31:39 +00:00
}
function itemSelected()
{
document.getElementById('view-pane').setAttribute('src','http://www.apple.com/');
}
function deleteSelection()
{
if(itemsView && itemsView.selection.count > 0 && confirm("Are you sure you want to delete the selection????"))
{
itemsView.deleteSelection();
2006-05-24 13:31:39 +00:00
}
2006-05-24 18:43:49 +00:00
}
function search()
{
//TO DO: reload items tree with a search instead of a root folder
alert(document.getElementById('tb-search').value);
2006-05-23 19:06:11 +00:00
}