Capitalize acronyms

This commit is contained in:
Martynas Bagdonas 2021-02-16 11:10:20 +02:00 committed by Dan Stillman
parent 1a4b2e8c7d
commit 8d87eeae35
4 changed files with 36 additions and 36 deletions

View file

@ -152,12 +152,12 @@ class EditorInstance {
async insertAnnotations(annotations) { async insertAnnotations(annotations) {
let html = await this._digestAnnotations(annotations); let html = await this._digestAnnotations(annotations);
if (html) { if (html) {
this._postMessage({ action: 'insertHtml', pos: -1, html }); this._postMessage({ action: 'insertHTML', pos: -1, html });
} }
} }
_postMessage(message) { _postMessage(message) {
this._iframeWindow.postMessage({ instanceId: this.instanceID, message }, '*'); this._iframeWindow.postMessage({ instanceID: this.instanceID, message }, '*');
} }
_getFont() { _getFont() {
@ -177,7 +177,7 @@ class EditorInstance {
async _digestAnnotations(annotations) { async _digestAnnotations(annotations) {
let html = ''; let html = '';
for (let annotation of annotations) { for (let annotation of annotations) {
let attachmentItem = await Zotero.Items.getAsync(annotation.attachmentItemId); let attachmentItem = await Zotero.Items.getAsync(annotation.attachmentItemID);
if (!attachmentItem) { if (!attachmentItem) {
continue; continue;
} }
@ -289,7 +289,7 @@ class EditorInstance {
} }
_messageHandler = async (e) => { _messageHandler = async (e) => {
if (e.data.instanceId !== this.instanceID) { if (e.data.instanceID !== this.instanceID) {
return; return;
} }
let message = e.data.message; let message = e.data.message;
@ -310,7 +310,7 @@ class EditorInstance {
html = await this._digestAnnotations(annotations); html = await this._digestAnnotations(annotations);
} }
if (html) { if (html) {
this._postMessage({ action: 'insertHtml', pos, html }); this._postMessage({ action: 'insertHTML', pos, html });
} }
return; return;
} }
@ -344,7 +344,7 @@ class EditorInstance {
} }
return; return;
} }
case 'openUrl': { case 'openURL': {
let { url } = message; let { url } = message;
let zp = Zotero.getActiveZoteroPane(); let zp = Zotero.getActiveZoteroPane();
if (zp) { if (zp) {
@ -389,7 +389,7 @@ class EditorInstance {
let { citation, pos } = message; let { citation, pos } = message;
let formatted = (await this._getFormattedCitationParts(citation)).join(';'); let formatted = (await this._getFormattedCitationParts(citation)).join(';');
let html = `<span class="citation" data-citation="${encodeURIComponent(JSON.stringify(citation))}">(${formatted})</span>`; let html = `<span class="citation" data-citation="${encodeURIComponent(JSON.stringify(citation))}">(${formatted})</span>`;
this._postMessage({ action: 'insertHtml', pos, html }); this._postMessage({ action: 'insertHTML', pos, html });
return; return;
} }
case 'subscribeProvider': { case 'subscribeProvider': {
@ -404,7 +404,7 @@ class EditorInstance {
return; return;
} }
case 'openCitationPopup': { case 'openCitationPopup': {
let { nodeId, citation } = message; let { nodeID, citation } = message;
if (this._readOnly) { if (this._readOnly) {
return; return;
} }
@ -418,7 +418,7 @@ class EditorInstance {
} }
citation.citationItems = availableCitationItems; citation.citationItems = availableCitationItems;
let libraryID = this._item.libraryID; let libraryID = this._item.libraryID;
this._openQuickFormatDialog(nodeId, citation, [libraryID]); this._openQuickFormatDialog(nodeID, citation, [libraryID]);
return; return;
} }
case 'importImages': { case 'importImages': {
@ -430,11 +430,11 @@ class EditorInstance {
return; return;
} }
for (let image of images) { for (let image of images) {
let { nodeId, src } = image; let { nodeID, src } = image;
let attachmentKey = await this._importImage(src, true); let attachmentKey = await this._importImage(src, true);
// TODO: Inform editor about the failed to import images // TODO: Inform editor about the failed to import images
if (attachmentKey) { if (attachmentKey) {
this._postMessage({ action: 'attachImportedImage', nodeId, attachmentKey }); this._postMessage({ action: 'attachImportedImage', nodeID, attachmentKey });
} }
} }
return; return;
@ -470,7 +470,7 @@ class EditorInstance {
} }
async _feedSubscription(subscription) { async _feedSubscription(subscription) {
let { id, type, nodeId, data } = subscription; let { id, type, nodeID, data } = subscription;
if (type === 'citation') { if (type === 'citation') {
let parts = await this._getFormattedCitationParts(data.citation); let parts = await this._getFormattedCitationParts(data.citation);
this._postMessage({ action: 'notifyProvider', id, type, data: { formattedCitation: parts.join(';') } }); this._postMessage({ action: 'notifyProvider', id, type, data: { formattedCitation: parts.join(';') } });
@ -489,7 +489,7 @@ class EditorInstance {
// new image copy in memory // new image copy in memory
let newAttachmentKey = await this._importImage(dataURL); let newAttachmentKey = await this._importImage(dataURL);
// TODO: Inform editor about the failed to import images // TODO: Inform editor about the failed to import images
this._postMessage({ action: 'attachImportedImage', nodeId, attachmentKey: newAttachmentKey }); this._postMessage({ action: 'attachImportedImage', nodeID, attachmentKey: newAttachmentKey });
} }
} }
// Make sure attachment key belongs to the actual parent note, // Make sure attachment key belongs to the actual parent note,
@ -771,7 +771,7 @@ class EditorInstance {
return 'data:' + item.attachmentContentType + ';base64,' + this._arrayBufferToBase64(buf); return 'data:' + item.attachmentContentType + ';base64,' + this._arrayBufferToBase64(buf);
} }
async _openQuickFormatDialog(nodeId, citationData, filterLibraryIDs) { async _openQuickFormatDialog(nodeID, citationData, filterLibraryIDs) {
await Zotero.Styles.init(); await Zotero.Styles.init();
let that = this; let that = this;
let win; let win;
@ -830,7 +830,7 @@ class EditorInstance {
let formattedCitation = (await that._getFormattedCitationParts(citation)).join(';'); let formattedCitation = (await that._getFormattedCitationParts(citation)).join(';');
if (progressCallback || !citationData.citationItems.length) { if (progressCallback || !citationData.citationItems.length) {
that._postMessage({ action: 'setCitation', nodeId, citation, formattedCitation }); that._postMessage({ action: 'setCitation', nodeID, citation, formattedCitation });
} }
}, },
@ -942,7 +942,7 @@ class EditorInstance {
let jsonAnnotations = []; let jsonAnnotations = [];
for (let annotation of annotations) { for (let annotation of annotations) {
let jsonAnnotation = await Zotero.Annotations.toJSON(annotation); let jsonAnnotation = await Zotero.Annotations.toJSON(annotation);
jsonAnnotation.itemId = attachmentItem.id; jsonAnnotation.itemID = attachmentItem.id;
jsonAnnotations.push(jsonAnnotation); jsonAnnotations.push(jsonAnnotation);
} }
let html = `<p>(${(new Date()).toLocaleString()})</p>\n`; let html = `<p>(${(new Date()).toLocaleString()})</p>\n`;

View file

@ -83,9 +83,9 @@ class PDFWorker {
this._worker.addEventListener('message', async (event) => { this._worker.addEventListener('message', async (event) => {
let message = event.data; let message = event.data;
// console.log(event.data) // console.log(event.data)
if (message.responseId) { if (message.responseID) {
let { resolve, reject } = this._waitingPromises[message.responseId]; let { resolve, reject } = this._waitingPromises[message.responseID];
delete this._waitingPromises[message.responseId]; delete this._waitingPromises[message.responseID];
if (message.data) { if (message.data) {
resolve(message.data); resolve(message.data);
} }
@ -113,7 +113,7 @@ class PDFWorker {
Zotero.debug('Failed to fetch CMap data:'); Zotero.debug('Failed to fetch CMap data:');
Zotero.debug(e); Zotero.debug(e);
} }
this._worker.postMessage({ responseId: event.data.id, data: respData }); this._worker.postMessage({ responseID: event.data.id, data: respData });
} }
}); });
this._worker.addEventListener('error', (event) => { this._worker.addEventListener('error', (event) => {
@ -380,9 +380,9 @@ class PDFRenderer {
let _handleMessage = async (event) => { let _handleMessage = async (event) => {
let message = event.data; let message = event.data;
if (message.responseId) { if (message.responseID) {
let { resolve, reject } = this._waitingPromises[message.responseId]; let { resolve, reject } = this._waitingPromises[message.responseID];
delete this._waitingPromises[message.responseId]; delete this._waitingPromises[message.responseID];
if (message.data) { if (message.data) {
resolve(message.data); resolve(message.data);
} }

View file

@ -190,7 +190,7 @@ class ReaderInstance {
tagsbox.item = item; tagsbox.item = item;
} }
_openAnnotationPopup(x, y, annotationId, colors, selectedColor) { _openAnnotationPopup(x, y, annotationID, colors, selectedColor) {
let popup = this._window.document.createElement('menupopup'); let popup = this._window.document.createElement('menupopup');
this._popupset.appendChild(popup); this._popupset.appendChild(popup);
popup.addEventListener('popuphidden', function () { popup.addEventListener('popuphidden', function () {
@ -205,7 +205,7 @@ class ReaderInstance {
let data = { let data = {
action: 'popupCmd', action: 'popupCmd',
cmd: 'addToNote', cmd: 'addToNote',
id: annotationId id: annotationID
}; };
this._postMessage(data); this._postMessage(data);
}); });
@ -223,7 +223,7 @@ class ReaderInstance {
let data = { let data = {
action: 'popupCmd', action: 'popupCmd',
cmd: 'setAnnotationColor', cmd: 'setAnnotationColor',
id: annotationId, id: annotationID,
color: color[1] color: color[1]
}; };
this._postMessage(data); this._postMessage(data);
@ -239,7 +239,7 @@ class ReaderInstance {
let data = { let data = {
action: 'popupCmd', action: 'popupCmd',
cmd: 'deleteAnnotation', cmd: 'deleteAnnotation',
id: annotationId id: annotationID
}; };
this._postMessage(data); this._postMessage(data);
}); });
@ -274,7 +274,7 @@ class ReaderInstance {
async _postMessage(message, transfer) { async _postMessage(message, transfer) {
await this._waitForReader(); await this._waitForReader();
this._iframeWindow.postMessage({ itemId: this._itemID, message }, this._iframeWindow.origin, transfer); this._iframeWindow.postMessage({ itemID: this._itemID, message }, this._iframeWindow.origin, transfer);
} }
_handleMessage = async (event) => { _handleMessage = async (event) => {
@ -287,7 +287,7 @@ class ReaderInstance {
let data = JSON.parse(JSON.stringify(event.data)); let data = JSON.parse(JSON.stringify(event.data));
// Filter messages coming from previous reader instances, // Filter messages coming from previous reader instances,
// except for `setAnnotation` to still allow saving it // except for `setAnnotation` to still allow saving it
if (data.itemId !== this._itemID && data.message.action !== 'setAnnotation') { if (data.itemID !== this._itemID && data.message.action !== 'setAnnotation') {
return; return;
} }
message = data.message; message = data.message;
@ -297,7 +297,7 @@ class ReaderInstance {
return; return;
} }
case 'setAnnotation': { case 'setAnnotation': {
let attachment = Zotero.Items.get(data.itemId); let attachment = Zotero.Items.get(data.itemID);
let { annotation } = message; let { annotation } = message;
annotation.key = annotation.id; annotation.key = annotation.id;
let saveOptions = { let saveOptions = {
@ -353,7 +353,7 @@ class ReaderInstance {
this._openColorPopup(x, y, colors, selectedColor); this._openColorPopup(x, y, colors, selectedColor);
return; return;
} }
case 'openUrl': { case 'openURL': {
let { url } = message; let { url } = message;
let win = Services.wm.getMostRecentWindow('navigator:browser'); let win = Services.wm.getMostRecentWindow('navigator:browser');
if (win) { if (win) {
@ -685,9 +685,9 @@ class Reader {
// Listen for the parent item, PDF attachment and its annotations updates // Listen for the parent item, PDF attachment and its annotations updates
for (let reader of this._readers) { for (let reader of this._readers) {
if (event === 'delete') { if (event === 'delete') {
let disappearedIds = reader.annotationItemIDs.filter(x => ids.includes(x)); let disappearedIDs = reader.annotationItemIDs.filter(x => ids.includes(x));
if (disappearedIds.length) { if (disappearedIDs.length) {
let keys = disappearedIds.map(id => extraData[id].key); let keys = disappearedIDs.map(id => extraData[id].key);
reader.unsetAnnotations(keys); reader.unsetAnnotations(keys);
} }
if (ids.includes(reader._itemID)) { if (ids.includes(reader._itemID)) {

View file

@ -101,12 +101,12 @@ window.addEventListener('message', async (event) => {
parent.postMessage({ action: 'renderedAnnotation', data: { annotation } }, parent.origin, [annotation.image]); parent.postMessage({ action: 'renderedAnnotation', data: { annotation } }, parent.origin, [annotation.image]);
} }
); );
parent.postMessage({ responseId: message.id, data: num }, parent.origin); parent.postMessage({ responseID: message.id, data: num }, parent.origin);
} }
catch (e) { catch (e) {
console.log(e); console.log(e);
parent.postMessage({ parent.postMessage({
responseId: message.id, responseID: message.id,
error: errObject(e) error: errObject(e)
}, parent.origin); }, parent.origin);
} }