
Changed "Scholar" to "Zotero", everywhere Apologies to anyone with working copy changes, but there are probably the fewer at this moment than there will be again. Hopefully this won't break anything, though existing prefs will be lost. I avoided scholar.google.com--if you know any other legitimate "scholar"s in the code, be sure to fix them once I'm done here. This is a multi-commit change--there's at least one more coming. *Do not update to this version! It won't work!*
94 lines
No EOL
2 KiB
JavaScript
94 lines
No EOL
2 KiB
JavaScript
/*
|
|
Zotero
|
|
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
|
|
http://chnm.gmu.edu/
|
|
*/
|
|
|
|
var itemsView;
|
|
var collectionsView;
|
|
var io;
|
|
|
|
/*
|
|
* window takes two arguments:
|
|
* io - used for input/output (dataOut is list of item IDs)
|
|
* sourcesOnly - whether only sources should be shown in the window
|
|
*/
|
|
function doLoad()
|
|
{
|
|
io = window.arguments[0];
|
|
|
|
collectionsView = new Zotero.CollectionTreeView();
|
|
document.getElementById('collections-tree').view = collectionsView;
|
|
|
|
// move to center of screen
|
|
window.sizeToContent();
|
|
window.moveTo(
|
|
(self.screen.width-window.innerWidth)/2,
|
|
(self.screen.height-window.innerHeight)/2
|
|
);
|
|
}
|
|
|
|
function doUnload()
|
|
{
|
|
collectionsView.unregister();
|
|
if(itemsView)
|
|
itemsView.unregister();
|
|
}
|
|
|
|
function onCollectionSelected()
|
|
{
|
|
if(itemsView)
|
|
itemsView.unregister();
|
|
|
|
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
|
|
{
|
|
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
|
|
collection.setSearch('');
|
|
|
|
itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
|
|
document.getElementById('items-tree').view = itemsView;
|
|
}
|
|
|
|
}
|
|
|
|
function onSearch()
|
|
{
|
|
if(itemsView)
|
|
{
|
|
var searchVal = document.getElementById('tb-search').value;
|
|
itemsView.searchText(searchVal);
|
|
|
|
document.getElementById('tb-search-cancel').hidden = searchVal == "";
|
|
}
|
|
}
|
|
|
|
function onItemSelected()
|
|
{
|
|
|
|
}
|
|
|
|
function getSelectedItems(byID) {
|
|
var start = new Object();
|
|
var end = new Object();
|
|
var returnArray = new Array();
|
|
|
|
for(var i = 0, rangeCount = itemsView.selection.getRangeCount(); i < rangeCount; i++)
|
|
{
|
|
itemsView.selection.getRangeAt(i,start,end);
|
|
for(var j = start.value; j <= end.value; j++)
|
|
{
|
|
if(byID) {
|
|
returnArray.push(itemsView._getItemAtRow(j).ref.getID());
|
|
} else {
|
|
returnArray.push(itemsView._getItemAtRow(j).ref);
|
|
}
|
|
}
|
|
}
|
|
|
|
return returnArray;
|
|
}
|
|
|
|
function doAccept()
|
|
{
|
|
io.dataOut = getSelectedItems(true);
|
|
} |