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

770 lines
22 KiB
JavaScript
Raw Normal View History

/*
Zotero
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
http://chnm.gmu.edu/
*/
/*
* This object contains the various functions for the interface
*/
2006-05-30 22:06:33 +00:00
var ScholarPane = new function()
{
var collectionsView;
2006-05-30 22:06:33 +00:00
var itemsView;
//Privileged methods
this.onLoad = onLoad;
this.onUnload = onUnload;
this.toggleDisplay = toggleDisplay;
this.fullScreen = fullScreen;
2006-05-30 22:06:33 +00:00
this.newItem = newItem;
this.newCollection = newCollection;
this.newSearch = newSearch;
this.onCollectionSelected = onCollectionSelected;
2006-05-30 22:06:33 +00:00
this.itemSelected = itemSelected;
this.deleteSelectedItem = deleteSelectedItem;
this.deleteSelectedCollection = deleteSelectedCollection;
this.editSelectedCollection = editSelectedCollection;
2006-05-30 22:06:33 +00:00
this.search = search;
this.getCollectionsView = getCollectionsView;
this.getItemsView = getItemsView;
this.selectItem = selectItem;
this.getSelectedCollection = getSelectedCollection;
this.getSelectedSavedSearch = getSelectedSavedSearch;
this.getSelectedItems = getSelectedItems;
this.buildCollectionContextMenu = buildCollectionContextMenu;
this.buildItemContextMenu = buildItemContextMenu;
this.onDoubleClick = onDoubleClick;
this.openNoteWindow = openNoteWindow;
this.newNote = newNote;
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
this.addItemFromPage = addItemFromPage;
this.addAttachmentFromDialog = addAttachmentFromDialog;
this.addAttachmentFromPage = addAttachmentFromPage;
this.viewSelectedAttachment = viewSelectedAttachment;
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
this.showSelectedAttachmentInFilesystem = showSelectedAttachmentInFilesystem;
2006-05-30 22:06:33 +00:00
/*
* Called when the window is open
*/
function onLoad()
2006-05-30 22:06:33 +00:00
{
if(Scholar.Prefs.get("scholarPaneOnTop"))
{
var oldPane = document.getElementById('scholar-pane');
var oldSplitter = document.getElementById('scholar-splitter');
var appContent = document.getElementById('appcontent');
var newPane = document.createElement('hbox');
newPane.setAttribute('id','scholar-pane');
newPane.setAttribute('collapsed',true);
newPane.setAttribute('flex','1');
newPane.height = oldPane.height;
while(oldPane.hasChildNodes())
newPane.appendChild(oldPane.firstChild);
appContent.removeChild(oldPane);
appContent.insertBefore(newPane, document.getElementById('content'));
var newSplitter = document.createElement('splitter');
newSplitter.setAttribute('id','scholar-splitter');
newSplitter.setAttribute('collapsed',true);
newSplitter.setAttribute('resizebefore','closest');
newSplitter.setAttribute('resizeafter','closest');
appContent.removeChild(oldSplitter);
appContent.insertBefore(newSplitter, document.getElementById('content'));
document.getElementById('tb-fullscreen').setAttribute('scholartop','true');
}
//Initialize collections view
collectionsView = new Scholar.CollectionTreeView();
var collectionsTree = document.getElementById('collections-tree');
collectionsTree.view = collectionsView;
collectionsTree.controllers.appendController(new Scholar.CollectionTreeCommandController(collectionsTree));
var itemsTree = document.getElementById('items-tree');
itemsTree.controllers.appendController(new Scholar.ItemTreeCommandController(itemsTree));
// Create the New Item (+) menu with each item type
var addMenu = document.getElementById('tb-add').firstChild;
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
var separator = document.getElementById('tb-add').firstChild.firstChild;
var moreMenu = document.getElementById('tb-add-more');
var itemTypes = Scholar.ItemTypes.getPrimaryTypes();
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","ScholarPane.newItem("+itemTypes[i]['id']+")");
addMenu.insertBefore(menuitem, separator);
}
// Create submenu for secondary item types
var itemTypes = Scholar.ItemTypes.getSecondaryTypes();
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","ScholarPane.newItem("+itemTypes[i]['id']+")");
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
moreMenu.appendChild(menuitem);
}
2006-05-30 22:06:33 +00:00
}
/*
* Called when the window closes
*/
function onUnload()
{
collectionsView.unregister();
if(itemsView)
itemsView.unregister();
}
/*
* Hides/displays the Scholar interface
*/
function toggleDisplay()
{
var visible = document.getElementById('scholar-pane').getAttribute('collapsed') == 'true';
document.getElementById('scholar-pane').setAttribute('collapsed',!visible);
document.getElementById('scholar-splitter').setAttribute('collapsed',!visible);
if(!visible)
{
document.getElementById('content').setAttribute('collapsed', false);
document.getElementById('tb-fullscreen').setAttribute('fullscreenmode', false);
}
}
function fullScreen()
{
var visible = document.getElementById('content').getAttribute('collapsed') == 'true';
document.getElementById('content').setAttribute('collapsed', !visible);
document.getElementById('scholar-splitter').setAttribute('collapsed', !visible);
document.getElementById('tb-fullscreen').setAttribute('fullscreenmode', !visible);
}
/*
* Create a new item
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
*
* _data_ is an optional object with field:value for itemData
*/
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
function newItem(typeID, data)
2006-05-30 22:06:33 +00:00
{
var item = new Scholar.Item(typeID);
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
for (var i in data)
{
item.setField(i, data[i]);
}
item.save();
if(itemsView && itemsView._itemGroup.isCollection())
itemsView._itemGroup.ref.addItem(item.getID());
//set to Info tab
document.getElementById('scholar-view-item').selectedIndex = 0;
return item;
2006-05-30 22:06:33 +00:00
}
function newCollection()
2006-05-30 22:06:33 +00:00
{
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var untitled = Scholar.getString('pane.collections.untitled');
untitled = Scholar.DB.getNextName('collections', 'collectionName',
Scholar.getString('pane.collections.untitled'));
var newName = { value: untitled };
var result = promptService.prompt(window, "",
Scholar.getString('pane.collections.name'), newName, "", {});
if (!result)
{
return false;
}
if (!newName.value)
{
newName.value = untitled;
}
Scholar.Collections.add(newName.value);
2006-05-30 22:06:33 +00:00
}
function newSearch()
{
var s = new Scholar.Search();
s.addCondition('title','contains','');
var untitled = Scholar.getString('pane.collections.untitled');
untitled = Scholar.DB.getNextName('savedSearches', 'savedSearchName',
Scholar.getString('pane.collections.untitled'));
var io = {dataIn: {search: s, name: untitled}, dataOut: null};
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
}
function onCollectionSelected()
2006-05-30 22:06:33 +00:00
{
if(itemsView)
itemsView.unregister();
document.getElementById('tb-search').value = "";
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
2006-05-30 22:06:33 +00:00
{
var itemgroup = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
itemgroup.setSearch('');
itemsView = new Scholar.ItemTreeView(itemgroup);
2006-05-30 22:06:33 +00:00
document.getElementById('items-tree').view = itemsView;
document.getElementById('tb-collection-rename').disabled = itemgroup.isLibrary();
itemsView.selection.clearSelection();
2006-05-30 22:06:33 +00:00
}
else
{
document.getElementById('items-tree').view = itemsView = null;
document.getElementById('tb-collection-rename').disabled = true;
2006-05-30 22:06:33 +00:00
}
}
function itemSelected()
{
if(itemsView && itemsView.selection.count == 1 && itemsView.selection.currentIndex != -1)
2006-05-30 22:06:33 +00:00
{
var item = itemsView._getItemAtRow(itemsView.selection.currentIndex);
if(item.isNote())
{
var noteEditor = document.getElementById('scholar-note-editor');
noteEditor.item = null;
noteEditor.note = item.ref;
document.getElementById('scholar-view-note-button').setAttribute('noteID',item.ref.getID());
if(item.ref.getSource() != null)
document.getElementById('scholar-view-note-button').setAttribute('sourceID',item.ref.getSource());
else
document.getElementById('scholar-view-note-button').removeAttribute('sourceID');
document.getElementById('item-pane').selectedIndex = 2;
}
else if(item.isAttachment())
{
// Wrap title to multiple lines if necessary
var label = document.getElementById('scholar-attachment-label');
while (label.hasChildNodes())
{
label.removeChild(label.firstChild);
}
var val = item.getField('title');
var firstSpace = val.indexOf(" ");
// Crop long uninterrupted text
if ((firstSpace == -1 && val.length > 29 ) || firstSpace > 29)
{
label.setAttribute('crop', 'end');
label.setAttribute('value', val);
}
// Create a <description> element, essentially
else
{
label.appendChild(document.createTextNode(val));
}
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
// Metadata for URL's
if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_LINKED_URL
|| item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
{
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
// "View Page"/"View Snapshot" label
if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
{
var str = Scholar.getString('pane.item.attachments.view.snapshot');
}
else
{
var str = Scholar.getString('pane.item.attachments.view.link');
}
document.getElementById('scholar-attachment-show').setAttribute('hidden', true);
// URL
document.getElementById('scholar-attachment-url').setAttribute('value', item.getField('url'));
document.getElementById('scholar-attachment-url').setAttribute('hidden', false);
// Access date
document.getElementById('scholar-attachment-accessed').setAttribute('value',
Scholar.getString('itemFields.accessDate') + ': '
+ Scholar.Date.sqlToDate(item.getField('accessDate')).toLocaleString());
document.getElementById('scholar-attachment-accessed').setAttribute('hidden', false);
}
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
// Metadata for files
else
{
var str = Scholar.getString('pane.item.attachments.view.file');
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
document.getElementById('scholar-attachment-show').setAttribute('hidden', false);
document.getElementById('scholar-attachment-url').setAttribute('hidden', true);
document.getElementById('scholar-attachment-accessed').setAttribute('hidden', true);
}
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
document.getElementById('scholar-attachment-view').setAttribute('label', str);
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
var noteEditor = document.getElementById('scholar-attachment-note-editor');
noteEditor.item = null;
noteEditor.note = item.ref;
document.getElementById('item-pane').selectedIndex = 3;
}
else
{
ScholarItemPane.viewItem(item.ref);
document.getElementById('item-pane').selectedIndex = 1;
}
2006-05-30 22:06:33 +00:00
}
else
{
document.getElementById('item-pane').selectedIndex = 0;
var label = document.getElementById('scholar-view-selected-label');
if(itemsView && itemsView.selection.count)
label.value = Scholar.getString('pane.item.selected.multiple').replace('%1', itemsView.selection.count);
else
label.value = Scholar.getString('pane.item.selected.zero');
2006-05-30 22:06:33 +00:00
}
}
/*
* _force_ deletes item from DB even if removing from a collection or search
*/
function deleteSelectedItem(force)
2006-05-30 22:06:33 +00:00
{
if(itemsView && itemsView.selection.count > 0)
{
if (!force){
if (itemsView._itemGroup.isCollection()){
var noPrompt = true;
}
// Do nothing in search view
else if (itemsView._itemGroup.isSearch()){
return;
}
}
var eraseChildren = {value: true};
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var hasChildren;
if(!getSelectedCollection())
{
var start = new Object();
var end = new Object();
for (var i=0, len=itemsView.selection.getRangeCount(); i<len; i++)
{
itemsView.selection.getRangeAt(i,start,end);
for (var j=start.value; j<=end.value; j++)
if (itemsView._getItemAtRow(j).numChildren())
{
hasChildren = true;
break;
}
}
}
if (noPrompt || promptService.confirmCheck(
window,
Scholar.getString('pane.items.delete.title'),
Scholar.getString('pane.items.delete' + (itemsView.selection.count>1 ? '.multiple' : '')),
hasChildren ? Scholar.getString('pane.items.delete.attached') : '',
eraseChildren))
{
itemsView.deleteSelection(eraseChildren.value, force);
}
}
2006-05-30 22:06:33 +00:00
}
function deleteSelectedCollection()
{
if (collectionsView.selection.count == 1)
{
var row =
collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
if (row.isCollection())
{
if (confirm(Scholar.getString('pane.collections.delete')))
{
collectionsView.deleteSelection();
}
}
else if (row.isSearch())
{
if (confirm(Scholar.getString('pane.collections.deleteSearch')))
{
collectionsView.deleteSelection();
}
}
}
}
function editSelectedCollection()
{
if(collectionsView.selection.count > 0)
{
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
if(collection.isCollection())
{
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var newName = { value: collection.getName() };
var result = promptService.prompt(window, "",
Scholar.getString('pane.collections.rename'), newName, "", {});
if (result && newName.value)
{
collection.ref.rename(newName.value);
}
}
else
{
var s = new Scholar.Search();
s.load(collection.ref['id']);
var io = {dataIn: {search: s, name: collection.getName()}, dataOut: null};
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
if(io.dataOut)
onCollectionSelected(); //reload itemsView
}
}
}
2006-05-30 22:06:33 +00:00
function search()
{
if(itemsView)
{
var searchVal = document.getElementById('tb-search').value;
itemsView.searchText(searchVal);
document.getElementById('tb-search-cancel').hidden = searchVal == "";
}
}
function getCollectionsView()
{
return collectionsView;
}
function getItemsView()
{
return itemsView;
}
function selectItem(id)
{
if(itemsView)
{
if(!itemsView._itemGroup.isLibrary())
{
//select the Library if the item is not in the current collection
var item = Scholar.Items.get(id);
var collectionID = itemsView._itemGroup.ref.getID();
if(!item.isRegularItem())
{
if(!Scholar.Items.get(item.getSource()).inCollection(collectionID))
collectionsView.selection.select(0);
}
else if(!item.inCollection(collectionID))
collectionsView.selection.select(0);
}
itemsView.selectItem(id);
}
}
function getSelectedCollection()
{
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
{
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
if(collection && collection.isCollection())
return collection.ref;
}
}
function getSelectedSavedSearch()
{
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
{
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
if(collection && collection.isSearch())
{
return collection.ref;
}
}
}
function getSelectedItems()
{
if(itemsView)
{
var items = new Array();
var start = new Object();
var end = new Object();
for (var i=0, len=itemsView.selection.getRangeCount(); i<len; i++)
{
itemsView.selection.getRangeAt(i,start,end);
for (var j=start.value; j<=end.value; j++)
items.push(itemsView._getItemAtRow(j).ref);
}
}
return items;
}
function buildCollectionContextMenu()
{
var menu = document.getElementById('scholar-collectionmenu');
// Collection
if (collectionsView.selection.count == 1 &&
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isCollection())
{
var hide = [4,6,9,11,12];
var show = [3,5,7,8,10];
if (itemsView.rowCount>0)
{
var enable = [8,10];
}
else
{
var disable = [8,10];
}
}
// Saved Search
else if (collectionsView.selection.count == 1 &&
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isSearch())
{
var hide = [3,5,8,10,12];
var show = [4,6,7,9,11];
if (itemsView.rowCount>0)
{
var enable = [9,11];
}
else
{
var disable = [9,11];
}
}
// Library
else
{
var hide = [3,4,5,6,7,8,9,10,11];
var show = [12];
}
for (var i in disable)
{
menu.childNodes[disable[i]].setAttribute('disabled', true);
}
for (var i in enable)
{
menu.childNodes[enable[i]].setAttribute('disabled', false);
}
for (var i in hide)
{
menu.childNodes[hide[i]].setAttribute('hidden', true);
}
for (var i in show)
{
menu.childNodes[show[i]].setAttribute('hidden', false);
}
}
function buildItemContextMenu()
{
var menu = document.getElementById('scholar-itemmenu');
if(itemsView && itemsView.selection.count > 0)
{
menu.childNodes[2].removeAttribute('disabled');
menu.childNodes[3].removeAttribute('disabled');
menu.childNodes[5].removeAttribute('disabled');
menu.childNodes[6].removeAttribute('disabled');
}
else
{
menu.childNodes[2].setAttribute('disabled', true);
menu.childNodes[3].setAttribute('disabled', true);
menu.childNodes[5].setAttribute('disabled', true);
menu.childNodes[6].setAttribute('disabled', true);
}
var multiple = (itemsView && itemsView.selection.count > 1) ? '.multiple' : '';
if (itemsView._itemGroup.isCollection())
{
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove' + multiple));
menu.childNodes[2].setAttribute('hidden', false);
}
else
{
menu.childNodes[2].setAttribute('hidden', true);
}
menu.childNodes[3].setAttribute('label', Scholar.getString('pane.items.menu.erase' + multiple));
menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.export' + multiple));
menu.childNodes[6].setAttribute('label', Scholar.getString('pane.items.menu.createBib' + multiple));
}
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
function onDoubleClick(event, tree)
{
if (event && tree && (event.type == "click" || event.type == "dblclick"))
{
var row = {}, col = {}, obj = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
// obj.value == cell/text/image
// TODO: handle collection double-click
if (obj.value && itemsView && itemsView.selection.currentIndex > -1)
{
var item = getSelectedItems()[0];
if(item && item.isNote())
{
document.getElementById('scholar-view-note-button').doCommand();
}
else if(item && item.isAttachment())
{
viewSelectedAttachment();
}
}
}
}
function newNote(popup)
{
if (!popup)
{
var item = this.newItem(Scholar.ItemTypes.getID('note'));
document.getElementById('scholar-note-editor').focus();
}
else
{
var c = getSelectedCollection();
if (c)
{
openNoteWindow(null, c.getID());
}
else
{
openNoteWindow();
}
}
}
function openNoteWindow(id, parent)
{
window.open('chrome://scholar/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
}
function addAttachmentFromDialog(link, id)
{
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, Scholar.getString('pane.item.attachments.select'), nsIFilePicker.modeOpen);
if(fp.show() == nsIFilePicker.returnOK)
{
var attachmentID;
if(link)
attachmentID = Scholar.Attachments.linkFromFile(fp.file, id);
else
attachmentID = Scholar.Attachments.importFromFile(fp.file, id);
if(attachmentID && !id)
{
var c = getSelectedCollection();
if(c)
c.addItem(attachmentID);
}
}
}
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
function addItemFromPage()
{
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
var data = {
title: window.content.document.title,
url: window.content.document.location.href,
accessDate: "CURRENT_TIMESTAMP"
}
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
newItem(Scholar.ItemTypes.getID('webpage'), data);
Cross-posting to BC for discussion: http://chnm.grouphub.com/projects/310105/msg/cat/2114872/3538662/comments Changes as per my discussions with Dan: - Separated snapshot functionality into two individual buttons, Create New Item From Current Page and Take Snapshot of Current page - Updated schema to support primary, secondary and hidden item types (and future user customizations) - Reorganized New Item menu, moving secondary items into sub-menu - Removed ability to create link attachments, since it never really made much sense -- will simply use the webpage item type instead. Underlying functionality still exists for the time being, as people have existing links in their libraries--I think we're gonna have to just warn beta testers and delete them in a transition step, as converting nested links really wouldn't be worth the effort. - Moved file link/add functions into new item menu and removed attachment drop-down - Large, prominent View and Locate buttons in edit pane for going to an associated URL and looking up in OpenURL, respectively -- buttons gray out as appropriate - New Item from Page stores the URL and access date (Item.save() checks for the string "CURRENT_TIMESTAMP" for accessDate and doesn't bind it as a string) - "Website" to "Web Page" (do we prefer "Webpage"? they both look a bit funky in uppercase) More coming. Bugs/Known Issues: - Since snapshots from the toolbar are now top-level in the current collection, there needs to be a way to drag them into items - The camera icon for adding snapshots, despite being a famfamfam icon, really doesn't read too well (or perhaps just clashes with the rest of our icons). Anybody have a better one? (It also may be able to just be lightened up a bit.) - Trying the large View/Locate buttons after discussions with Dan, but this approach may not work -- 1) a large View button for the URL makes a lot less sense when you have a parent item with a child snapshot, since people will end up clicking it all the time when they really want to view the snapshot, and 2) the Locate button is awfully big for something that only applies to certain types of items, may not get used very often when it does, and probably won't work when it is - The access date is stored in UTC and displayed with toLocaleString() like Date Added and Date Modified, but, unlike those two, it's also user-editable. This is clearly a problem. Probably need to parse to Date on blur() with strToDate() and insert as UTC, discarding anything left over. - Item type itself is still "website" -- should probably change that while we still can Closes #253, OpenURL arrow should provide visual feedback on mouseover and/or look more button-like Addresses #304, change references to "website" to "web page" Addresses #207, openurl arrow functionality
2006-09-27 08:12:09 +00:00
}
function addAttachmentFromPage(link, id)
{
if(link)
{
var attachmentID =
Scholar.Attachments.linkFromDocument(window.content.document, id);
}
else
{
var attachmentID =
Scholar.Attachments.importFromDocument(window.content.document, id);
}
if (attachmentID && itemsView && itemsView._itemGroup.isCollection())
{
itemsView._itemGroup.ref.addItem(attachmentID);
}
}
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
function viewSelectedAttachment()
{
if(itemsView && itemsView.selection.count == 1)
{
var attachment = getSelectedItems()[0];
if(attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL)
{
var file = attachment.getFile();
if (Scholar.MIME.fileHasInternalHandler(file))
{
window.loadURI(attachment.getLocalFileURL());
}
else {
file.launch();
}
}
else
{
Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs)
2006-10-02 00:00:50 +00:00
window.loadURI(attachment.getField('url'));
}
}
}
function showSelectedAttachmentInFilesystem()
{
if(itemsView && itemsView.selection.count == 1)
{
var attachment = getSelectedItems()[0];
if (attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL)
{
var file = attachment.getFile();
file.reveal();
}
}
}
}
window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false);
window.addEventListener("unload", function(e) { ScholarPane.onUnload(e); }, false);