![Dan Stillman](/assets/img/avatar_default.png)
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details. WARNING: This includes backwards-incompatible schema changes. An incomplete list of other changes: - Schema overhaul - Replace main tables with new versions with updated schema - Enable real foreign key support and remove previous triggers - Don't use NULLs for local libraryID, which broke the UNIQUE index preventing object key duplication. All code (Zotero and third-party) using NULL for the local library will need to be updated to use 0 instead (already done for Zotero code) - Add 'compatibility' DB version that can be incremented manually to break DB compatibility with previous versions. 'userdata' upgrades will no longer automatically break compatibility. - Demote creators and tags from first-class objects to item properties - New API syncing properties - 'synced'/'version' properties to data objects - 'etag' to groups - 'version' to libraries - Create Zotero.DataObject that other objects inherit from - Consolidate data object loading into Zotero.DataObjects - Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data) - Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey() - New function Zotero.serial(fn), to wrap an async function such that all calls are run serially - New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func) - Add tag selector loading message - Various API and name changes, since everything was breaking anyway Known broken things: - Syncing (will be completely rewritten for API syncing) - Translation architecture (needs promise-based rewrite) - Duplicates view - DB integrity check (from schema changes) - Dragging (may be difficult to fix) Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
113 lines
No EOL
3.3 KiB
JavaScript
113 lines
No EOL
3.3 KiB
JavaScript
/*
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
Copyright © 2009 Center for History and New Media
|
|
George Mason University, Fairfax, Virginia, USA
|
|
http://zotero.org
|
|
|
|
This file is part of Zotero.
|
|
|
|
Zotero is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Zotero is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***** END LICENSE BLOCK *****
|
|
*/
|
|
|
|
var noteEditor;
|
|
var notifierUnregisterID;
|
|
|
|
function onLoad() {
|
|
Zotero.spawn(function* () {
|
|
Zotero.debug('=-=-=');
|
|
var bar = yield Zotero.Promise.delay(1000).return('DONE');
|
|
Zotero.debug(bar);
|
|
Zotero.debug('-----');
|
|
});
|
|
|
|
noteEditor = document.getElementById('zotero-note-editor');
|
|
noteEditor.mode = 'edit';
|
|
noteEditor.focus();
|
|
|
|
// Set font size from pref
|
|
Zotero.setFontSize(noteEditor);
|
|
|
|
if (window.arguments) {
|
|
var io = window.arguments[0];
|
|
}
|
|
var itemID = io.itemID;
|
|
var collectionID = io.collectionID;
|
|
var parentItemKey = io.parentItemKey;
|
|
|
|
return Zotero.spawn(function* () {
|
|
if (itemID) {
|
|
var ref = yield Zotero.Items.getAsync(itemID);
|
|
|
|
var clearUndo = noteEditor.item ? noteEditor.item.id != ref.id : false;
|
|
|
|
noteEditor.item = ref;
|
|
|
|
// If loading new or different note, disable undo while we repopulate the text field
|
|
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
|
// undo content from another note into the current one.
|
|
if (clearUndo) {
|
|
noteEditor.clearUndo();
|
|
}
|
|
|
|
document.title = ref.getNoteTitle();
|
|
}
|
|
else {
|
|
if (parentItemKey) {
|
|
var ref = Zotero.Items.getByLibraryAndKey(parentItemKey);
|
|
noteEditor.parentItem = ref;
|
|
}
|
|
else {
|
|
if (collectionID && collectionID != '' && collectionID != 'undefined') {
|
|
noteEditor.collection = Zotero.Collections.get(collectionID);
|
|
}
|
|
}
|
|
noteEditor.refresh();
|
|
}
|
|
|
|
notifierUnregisterID = Zotero.Notifier.registerObserver(NotifyCallback, 'item');
|
|
});
|
|
}
|
|
|
|
function onUnload()
|
|
{
|
|
if(noteEditor && noteEditor.value)
|
|
noteEditor.save();
|
|
|
|
Zotero.Notifier.unregisterObserver(notifierUnregisterID);
|
|
}
|
|
|
|
var NotifyCallback = {
|
|
notify: function(action, type, ids){
|
|
if (noteEditor.item && ids.indexOf(noteEditor.item.id) != -1) {
|
|
noteEditor.item = noteEditor.item;
|
|
|
|
// If the document title hasn't yet been set, reset undo so
|
|
// undoing to empty isn't possible
|
|
var noteTitle = noteEditor.note.getNoteTitle();
|
|
if (!document.title && noteTitle != '') {
|
|
noteEditor.clearUndo();
|
|
document.title = noteTitle;
|
|
}
|
|
|
|
// Update the window name (used for focusing) in case this is a new note
|
|
window.name = 'zotero-note-' + noteEditor.item.id;
|
|
}
|
|
}
|
|
}
|
|
|
|
addEventListener("load", function(e) { onLoad(e); }, false);
|
|
addEventListener("unload", function(e) { onUnload(e); }, false); |