├── CHANGELOG.md ├── AUTHORS.md ├── resources ├── img │ ├── x.png │ └── checkmark.png ├── dark │ ├── icon.png │ ├── icon@2x.png │ ├── icon@1.25x.png │ ├── icon@1.5x.png │ └── icon@1.75x.png ├── light │ ├── icon.png │ ├── icon@1.5x.png │ ├── icon@2x.png │ ├── icon@1.25x.png │ └── icon@1.75x.png └── css │ └── plugin_style.css ├── translations ├── langs.json ├── zh-ZH.json ├── ja-JA.json ├── ru-RU.json ├── cs-CS.json ├── nl-NL.json ├── pt-PT.json ├── es-ES.json ├── it-IT.json ├── fr-FR.json └── de-DE.json ├── .github └── workflows │ └── release.yml ├── 3rd-party.txt ├── licenses ├── fetch-polyfill.license ├── url-polyfill.license └── promise-polyfill.license ├── config.json ├── scripts ├── thirdparty │ ├── promise-polyfill.min.js │ ├── url-polyfill.min.js │ └── fetch.umd.js ├── zotero.js └── code.js ├── README.md ├── index.html └── LICENSE /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 1.0.0 4 | - Initial release -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | * Ascensio System SIA: 4 | 5 | -------------------------------------------------------------------------------- /resources/img/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/img/x.png -------------------------------------------------------------------------------- /resources/dark/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/dark/icon.png -------------------------------------------------------------------------------- /resources/light/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/light/icon.png -------------------------------------------------------------------------------- /resources/dark/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/dark/icon@2x.png -------------------------------------------------------------------------------- /resources/dark/icon@1.25x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/dark/icon@1.25x.png -------------------------------------------------------------------------------- /resources/dark/icon@1.5x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/dark/icon@1.5x.png -------------------------------------------------------------------------------- /resources/dark/icon@1.75x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/dark/icon@1.75x.png -------------------------------------------------------------------------------- /resources/img/checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/img/checkmark.png -------------------------------------------------------------------------------- /resources/light/icon@1.5x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/light/icon@1.5x.png -------------------------------------------------------------------------------- /resources/light/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/light/icon@2x.png -------------------------------------------------------------------------------- /resources/light/icon@1.25x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/light/icon@1.25x.png -------------------------------------------------------------------------------- /resources/light/icon@1.75x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ONLYOFFICE/plugin-zotero/HEAD/resources/light/icon@1.75x.png -------------------------------------------------------------------------------- /translations/langs.json: -------------------------------------------------------------------------------- 1 | [ 2 | "cs-CS", 3 | "de-DE", 4 | "es-ES", 5 | "fr-FR", 6 | "it-IT", 7 | "ja-JA", 8 | "nl-NL", 9 | "pt-PT", 10 | "ru-RU", 11 | "zh-ZH" 12 | ] -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | tags: 7 | - "v*" 8 | 9 | jobs: 10 | release: 11 | uses: ONLYOFFICE/onlyoffice.github.io/.github/workflows/release.yml@master 12 | -------------------------------------------------------------------------------- /translations/zh-ZH.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "要使用Zotero,您应该获得一个API密钥。", 3 | "Navigate to": "导航到", 4 | "Zotero API settings": "Zotero API设置", 5 | "Create and copy API key into the field below.": "创建API密钥并将其复制到下面的字段中。", 6 | "Open Zotero website": "Zotero网站", 7 | "Invalid API key": "无效的API密钥", 8 | "API Key": "API密钥", 9 | "Nothing found": "未找到任何东西", 10 | "Style is not selected": "未选择样式", 11 | "Language is not selected": "未选择语言", 12 | "Search references by author, title or year": "作者、标题或年份搜索引用", 13 | "Cancel": "取消", 14 | "Insert Bibliography": "插入参考文献", 15 | "Style": "样式", 16 | "Enter style name": "输入样式名称", 17 | "Language": "语言", 18 | "Reconfigure": "重新配置", 19 | "Learn more here.": "もっとここで知る。", 20 | "Save": "セーブ" 21 | } -------------------------------------------------------------------------------- /translations/ja-JA.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Zoteroを使用するようにAPIキーを取得のが必要です。", 3 | "Navigate to": "(noun)に移動する", 4 | "Zotero API settings": "ZoteroのAPI設定", 5 | "Create and copy API key into the field below.": "キーを作成し、以下のフィールドにコピーしてください。", 6 | "Open Zotero website": "Zoteroウェブサイトを開く", 7 | "Invalid API key": "無効なAPIキー", 8 | "API Key": "APIキー", 9 | "Nothing found": "未找到任何东西", 10 | "Style is not selected": "未选择样式", 11 | "Language is not selected": "未选择语言", 12 | "Search references by author, title or year": "作者、标题或年份搜索引用", 13 | "Cancel": "取消", 14 | "Insert Bibliography": "插入参考文献", 15 | "Style": "样式", 16 | "Enter style name": "输入样式名称", 17 | "Language": "语言", 18 | "Reconfigure": "重新配置", 19 | "Learn more here.": "もっとここで知る。", 20 | "Save": "セーブ" 21 | } -------------------------------------------------------------------------------- /3rd-party.txt: -------------------------------------------------------------------------------- 1 | Zotero ONLYOFFICE integration plugin uses code from the following 3rd party projects: 2 | 3 | \vendor\thirdparty\fetch.umd.js 4 | fetch-polyfill - This project is a polyfill that implements a subset of the standard Fetch specification, enough to make fetch a viable replacement for most uses of XMLHttpRequest in traditional web applications. (https://github.com/github/fetch) 5 | License: MIT 6 | License File: fetch-polyfill.license 7 | 8 | \vendor\thirdparty\promise-polyfill.min.js 9 | promise-polyfill - Lightweight ES6 Promise polyfill for the browser and node. (https://github.com/taylorhakes/promise-polyfill) 10 | License: MIT 11 | License File: promise-polyfill.license 12 | 13 | \vendor\thirdparty\url-polyfill.min.js 14 | url-polyfill - Polyfill URL and URLSearchParams to match last WHATWG specifications. (https://github.com/lifaon74/url-polyfill) 15 | License: MIT 16 | License File: url-polyfill.license -------------------------------------------------------------------------------- /translations/ru-RU.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Для использования Zotero необходимо получить ключ API.", 3 | "Navigate to": "Перейти к", 4 | "Zotero API settings": "Параметрам API Zotero", 5 | "Create and copy API key into the field below.": "Создайте ключ API и скопируйте его в поле ниже.", 6 | "Open Zotero website": "Сайт Zotero", 7 | "Invalid API key": "Недопустимый ключ API", 8 | "API Key": "Ключ API", 9 | "Nothing found": "Ничего не найдено", 10 | "Style is not selected": "Стиль не выбран", 11 | "Language is not selected": "Язык не выбран", 12 | "Search references by author, title or year": "Поиск по автору, названию или году издания", 13 | "Cancel": "Отмена", 14 | "Insert Bibliography": "Вставить библиографию", 15 | "Style": "Стиль", 16 | "Enter style name": "Введите имя стиля", 17 | "Language": "Язык", 18 | "Reconfigure": "Перенастроить", 19 | "Learn more here.": "Подробности здесь.", 20 | "Save": "Сохранить" 21 | } -------------------------------------------------------------------------------- /translations/cs-CS.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Pro použití Zotera byste měli využít klíč API.", 3 | "Navigate to": "Přejít na", 4 | "Zotero API settings": "Nastavení API Zotero", 5 | "Create and copy API key into the field below.": "Vytvořte a zkopírujte klíč API do pole níže.", 6 | "Open Zotero website": "Otevřít webové stránky Zotero", 7 | "Invalid API key": "Neplatný klíč API", 8 | "API Key": "Klíč API", 9 | "Nothing found": "Nic nebylo nalezeno", 10 | "Style is not selected": "Nebyl vybrán styl", 11 | "Language is not selected": "Nebyl vybrán jazyk", 12 | "Search references by author, title or year": "Vyhledávat odkazy podle autora, názvu nebo roku", 13 | "Cancel": "Storno", 14 | "Insert Bibliography": "Vložit bibliografii", 15 | "Style": "Styl", 16 | "Enter style name": "Zadejte název stylu", 17 | "Language": "Jazyk", 18 | "Reconfigure": "Přenastavit", 19 | "Learn more here.": "Více informací se dozvíte zde.", 20 | "Save": "Uložit" 21 | } -------------------------------------------------------------------------------- /translations/nl-NL.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Om Zotero te gebruiken moet u een API key hebben.", 3 | "Navigate to": "Navigeren naar", 4 | "Zotero API settings": "Zotero API instellingen", 5 | "Create and copy API key into the field below.": "Maak en kopieer API key in het onderstaande veld.", 6 | "Open Zotero website": "Open Zotero website", 7 | "Invalid API key": "Ongeldige API key", 8 | "API Key": "API Key", 9 | "Nothing found": "Niks gevonden", 10 | "Style is not selected": "Stijl is niet geselecteerd", 11 | "Language is not selected": "Taal is niet geselecteerd", 12 | "Search references by author, title or year": "Zoek referenties op auteur, titel of jaartal", 13 | "Cancel": "Annuleren", 14 | "Insert Bibliography": "Bibliografie Invoegen", 15 | "Style": "Stijl", 16 | "Enter style name": "Stijl naam invoeren", 17 | "Language": "Taal", 18 | "Reconfigure": "Opnieuw instellen", 19 | "Learn more here.": "Lees hier meer.", 20 | "Save": "Opslaan" 21 | } -------------------------------------------------------------------------------- /translations/pt-PT.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Para usar Zotero, obtenha uma chave de API.", 3 | "Navigate to": "Navegar para", 4 | "Zotero API settings": "Configurações de API do Zotero", 5 | "Create and copy API key into the field below.": "Crie e copie a chave de API no campo abaixo.", 6 | "Open Zotero website": "Abrir site do Zotero", 7 | "Invalid API key": "Chave de API inválida", 8 | "API Key": "Chave de API", 9 | "Nothing found": "Nada encontrado", 10 | "Style is not selected": "O estilo não está selecionado", 11 | "Language is not selected": "O idioma não está selecionado", 12 | "Search references by author, title or year": "Pesquise referências por autor, título ou ano", 13 | "Cancel": "Cancelar", 14 | "Insert Bibliography": "Inserir bibliografia", 15 | "Style": "Estilo", 16 | "Enter style name": "Digite o nome do estilo", 17 | "Language": "Idioma", 18 | "Reconfigure": "Reconfigurar", 19 | "Learn more here.": "Saiba mais aqui.", 20 | "Save": "Salve" 21 | } -------------------------------------------------------------------------------- /translations/es-ES.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Para usar Zotero debe obtener una clave de API.", 3 | "Navigate to": "Navegue a", 4 | "Zotero API settings": "Configuración de la API Zotero", 5 | "Create and copy API key into the field below.": "Cree y copie la clave de API en el campo de abajo.", 6 | "Open Zotero website": "Abra el sitio web de Zotero", 7 | "Invalid API key": "Clave de API inválida", 8 | "API Key": "Clave de API", 9 | "Nothing found": "No encontrado", 10 | "Style is not selected": "Estilo no está seleccionado", 11 | "Language is not selected": "Idioma no está seleccionado", 12 | "Search references by author, title or year": "Busque referencias por autor, título o año", 13 | "Cancel": "Cancelar", 14 | "Insert Bibliography": "Inserte Bibliografía", 15 | "Style": "Estilo", 16 | "Enter style name": "Introduzca el nombre del estilo", 17 | "Language": "Idioma", 18 | "Reconfigure": "Reconfigurar", 19 | "Learn more here.": "Aprenda más aquí.", 20 | "Save": "Salvar" 21 | } -------------------------------------------------------------------------------- /translations/it-IT.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Per usare Zotero è necessaria una chiave API.", 3 | "Navigate to": "Naviga verso", 4 | "Zotero API settings": "Impostazioni API Zotero", 5 | "Create and copy API key into the field below.": "Crea e copia la chiave API nel campo sottostante.", 6 | "Open Zotero website": "Apri il sito web Zotero", 7 | "Invalid API key": "Chiave API non valida", 8 | "API Key": "Chiave API", 9 | "Search in all literature:": "Cerca in tutta la letteratura", 10 | "Style is not selected": "Lo stile non ? selezionato", 11 | "Language is not selected": "Il linguaggio non ? selezionato", 12 | "Search references by author, title or year": "Cerca riferimenti per autore, titolo o anno", 13 | "Cancel": "Annulla", 14 | "Insert Bibliography": "Inserisci Bibliografia", 15 | "Style": "Stile", 16 | "Enter style name": "Inserisci nome dello stile", 17 | "Language": "Lingua", 18 | "Reconfigure": "Riconfigura", 19 | "Learn more here.": "Ulteriori informazioni qui.", 20 | "Save": "Salva" 21 | } -------------------------------------------------------------------------------- /translations/fr-FR.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Pour utiliser Zotero, vous devez obtenir une clé API.", 3 | "Navigate to": "Accéder à", 4 | "Zotero API settings": "Paramètres de l'API Zotero", 5 | "Create and copy API key into the field below.": "Créez et copiez la clé API dans le champs ci-dessous.", 6 | "Open Zotero website": "Passer au site web de Zotero", 7 | "Invalid API key": "La clé API n'est pas valide", 8 | "API Key": "Сlé API", 9 | "Nothing found": "Rien n'a été trouvé", 10 | "Style is not selected": "Le style n'est pas sélectionné", 11 | "Language is not selected": "La langue n'est pas sélectionnée", 12 | "Search references by author, title or year": "Rechercher les références par auteur, titre ou année", 13 | "Cancel": "Annuler", 14 | "Insert Bibliography": "Insérer une bibliographie", 15 | "Style": "Style", 16 | "Enter style name": "Entrer le nom du style", 17 | "Language": "Langue", 18 | "Reconfigure": "Reconfigurer", 19 | "Learn more here.": "En savoir plus ici.", 20 | "Save": "Sauvegarder" 21 | } -------------------------------------------------------------------------------- /translations/de-DE.json: -------------------------------------------------------------------------------- 1 | { 2 | "To use Zotero you should get an API key.": "Sie brauchen einen API-Schlüssel, um Zotero zu nutzen.", 3 | "Navigate to": "Navigieren zu", 4 | "Zotero API settings": "API-Einstellungen für Zotero", 5 | "Create and copy API key into the field below.": "Erstellen Sie einen API-Schlüssel und fügen Sie diesen in einen Feld unten ein.", 6 | "Open Zotero website": "Webseite von Zotero öffnen", 7 | "Invalid API key": "Ungültiger API-Schlüssel", 8 | "API Key": "API-Schlüssel", 9 | "Nothing found": "Keine Suchergebnisse", 10 | "Style is not selected": "Stil nicht ausgewählt", 11 | "Language is not selected": "Sprache nicht ausgewählt", 12 | "Search references by author, title or year": "Durchsuchen Sie Referenzen nach Autor, Titel oder Jahr", 13 | "Cancel": "Abbrechen", 14 | "Insert Bibliography": "Bibliografie einfügen", 15 | "Style": "Stil", 16 | "Enter style name": "Stilname eingeben", 17 | "Language": "Sprache", 18 | "Reconfigure": "Neu konfigurieren", 19 | "Learn more here.": "Erfahren Sie mehr hier.", 20 | "Save": "Speichern" 21 | } -------------------------------------------------------------------------------- /licenses/fetch-polyfill.license: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2016 GitHub, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /licenses/url-polyfill.license: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2017 Valentin Richard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /licenses/promise-polyfill.license: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Taylor Hakes 2 | Copyright (c) 2014 Forbes Lindesay 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Zotero", 3 | "guid" : "asc.{BFC5D5C6-89DE-4168-9565-ABD8D1E48711}", 4 | "version": "1.0.0", 5 | 6 | "variations" : [ 7 | { 8 | "description": "Zotero", 9 | "url": "index.html", 10 | "icons": [ "resources/light/icon.png", "resources/light/icon@2x.png" ], 11 | "icons2": [ 12 | { 13 | "style" : "light", 14 | 15 | "100%": { 16 | "normal": "resources/light/icon.png" 17 | }, 18 | "125%": { 19 | "normal": "resources/light/icon@1.25x.png" 20 | }, 21 | "150%": { 22 | "normal": "resources/light/icon@1.5x.png" 23 | }, 24 | "175%": { 25 | "normal": "resources/light/icon@1.75x.png" 26 | }, 27 | "200%": { 28 | "normal": "resources/light/icon@2x.png" 29 | } 30 | }, 31 | { 32 | "style" : "dark", 33 | 34 | "100%": { 35 | "normal": "resources/dark/icon.png" 36 | }, 37 | "125%": { 38 | "normal": "resources/dark/icon@1.25x.png" 39 | }, 40 | "150%": { 41 | "normal": "resources/dark/icon@1.5x.png" 42 | }, 43 | "175%": { 44 | "normal": "resources/dark/icon@1.75x.png" 45 | }, 46 | "200%": { 47 | "normal": "resources/dark/icon@2x.png" 48 | } 49 | } 50 | ], 51 | "isViewer": false, 52 | "EditorsSupport": [ "word" ], 53 | "initDataType": "text", 54 | "initData": "", 55 | "isVisual": true, 56 | "isModal": false, 57 | "isInsideMode": true, 58 | "isUpdateOleOnResize": false, 59 | "initOnSelectionChanged": false 60 | } 61 | ] 62 | } -------------------------------------------------------------------------------- /scripts/thirdparty/promise-polyfill.min.js: -------------------------------------------------------------------------------- 1 | !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(e){return!(!e||"undefined"==typeof e.length)}function t(){}function o(e){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],c(e,this)}function r(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(r){return void f(n.promise,r)}i(n.promise,o)}else(1===e._state?i:f)(n.promise,e._value)})):e._deferreds.push(n)}function i(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof t)return void c(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,u(e)}catch(r){f(e,r)}}function f(e,n){e._state=2,e._value=n,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;t>n;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e(function(e){t||(t=!0,i(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype["finally"]=e,o.all=function(e){return new o(function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,function(n){r(e,n)},o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=o}); 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Information 2 | 3 | This repository is an archive of plugin-zotero. Now it moved to the marketplace repository [onlyoffice.github.io](https://github.com/ONLYOFFICE/onlyoffice.github.io/tree/master/sdkjs-plugins/content). 4 | 5 | # ONLYOFFICE Zotero plugin 6 | 7 | Zotero plugin allows users to create bibliographies in ONLYOFFICE editors using Zotero service. 8 | 9 | The plugin is pre-installed in ONLYOFFICE Workspace (both Enterprise and Community Edition), ONLYOFFICE cloud service, and ONLYOFFICE Personal. It can also be installed to Document Server and desktop editors manually. 10 | 11 | ## How to use 12 | 13 | 1. Search references by author, title or year. 14 | 15 | 2. Among search results, choose ones you want to add to your document. 16 | 17 | 3. Choose style (e.g. Chicago Manual, American Psychological Association) and language. 18 | 19 | 4. Press `Insert citation`. 20 | 21 | Please note that Zotero works only with user’s personal library associated with the your account. The desired sources must be added to your library in Zotero before you can search and add them to your bibliography via plugin. 22 | 23 | ## How to install to server 24 | 25 | Two installation ways are available: 26 | 27 | 1. Put the folder with the plugin code to ONLYOFFICE Document Server folder depending on the operating system: 28 | 29 | For Linux - `/var/www/onlyoffice/documentserver/sdkjs-plugins/`. 30 | 31 | For Windows - `%ProgramFiles%\ONLYOFFICE\DocumentServer\sdkjs-plugins\`. 32 | 33 | The plugins will be available to all the users users of ONLYOFFICE Document Server. 34 | No service restart is required. 35 | 36 | 2. Edit the Document Server config to add the following lines: 37 | 38 | ``` 39 | var docEditor = new DocsAPI.DocEditor("placeholder", { 40 | "editorConfig": { 41 | "plugins": { 42 | "autostart": [ 43 | "asc.{BFC5D5C6-89DE-4168-9565-ABD8D1E48711}", 44 | ... 45 | ], 46 | "pluginsData": [ 47 | "https://example.com/path/to/zotero/config.json", 48 | ... 49 | ] 50 | }, 51 | ... 52 | }, 53 | ... 54 | }); 55 | ``` 56 | **Important**: when you integrate ONLYOFFICE Document Server with a 3rd-party storage, you need to use special connectors (integration apps). If you compile a connector from source code or create a new one, you can add plugins using Document Server config. If you use ready connectors (e.g. from ownCloud/Nextcloud marketplaces) adding plugins via config is not applicable. 57 | 58 | ## How to install to desktop 59 | 60 | * Archive the plugin files (the archive must contain config.json, index.html, and pluginCode.js). 61 | * Change the file extension to .plugin. 62 | * Go to the Plugins tab, click Manage Plugins >> Add plugin, browse for the .plugin file. 63 | 64 | ## Configuration 65 | 66 | 1. Find Zotero plugin in `Plugins` tab of the ONLYOFFICE Document Editor and click it. 67 | 68 | 2. Log in to your Zotero account. 69 | 70 | 3. Follow `Zotero API settings` link from the plugin’s window. If you are logged in, you'll be able to proceed. If you are not logged in, you'll see an error message. In this case, click `Log in` (top right corner of your screen). 71 | 72 | 4. Press `Create new private key`. 73 | 74 | 5. Fill in `Key Description`, make sure `Allow library access` box is checked and press `Save Key`. 75 | 76 | 5. Copy the newly created key and paste to `API Key` field in the plugin’s interface and save it. 77 | 78 | ## Known issues 79 | 80 | For CentOS users with SELinx enabled, after copying the src folder to sdkjs-plugins, plugins may not work due to the variable file security context. To restore the rights, use the following command: 81 | 82 | ``` 83 | sudo restorecon -Rv /var/www/onlyoffice/documentserver/sdkjs-plugins/ 84 | ``` 85 | 86 | After that restart the services: 87 | 88 | ``` 89 | sudo supervisorctl restart ds:docservice 90 | ``` 91 | 92 | ## User feedback and support 93 | 94 | To ask questions and share feedback, use Issues in this repository. 95 | -------------------------------------------------------------------------------- /scripts/thirdparty/url-polyfill.min.js: -------------------------------------------------------------------------------- 1 | (function(t){var e=function(){try{return!!Symbol.iterator}catch(e){return false}};var r=e();var n=function(t){var e={next:function(){var e=t.shift();return{done:e===void 0,value:e}}};if(r){e[Symbol.iterator]=function(){return e}}return e};var i=function(e){return encodeURIComponent(e).replace(/%20/g,"+")};var o=function(e){return decodeURIComponent(String(e).replace(/\+/g," "))};var a=function(){var a=function(e){Object.defineProperty(this,"_entries",{writable:true,value:{}});var t=typeof e;if(t==="undefined"){}else if(t==="string"){if(e!==""){this._fromString(e)}}else if(e instanceof a){var r=this;e.forEach(function(e,t){r.append(t,e)})}else if(e!==null&&t==="object"){if(Object.prototype.toString.call(e)==="[object Array]"){for(var n=0;nt[0]){return+1}else{return 0}});if(r._entries){r._entries={}}for(var e=0;e1?o(i[1]):"")}}})}})(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:this);(function(u){var e=function(){try{var e=new u.URL("b","http://a");e.pathname="c d";return e.href==="http://a/c%20d"&&e.searchParams}catch(e){return false}};var t=function(){var t=u.URL;var e=function(e,t){if(typeof e!=="string")e=String(e);var r=document,n;if(t&&(u.location===void 0||t!==u.location.href)){r=document.implementation.createHTMLDocument("");n=r.createElement("base");n.href=t;r.head.appendChild(n);try{if(n.href.indexOf(t)!==0)throw new Error(n.href)}catch(e){throw new Error("URL unable to set base "+t+" due to "+e)}}var i=r.createElement("a");i.href=e;if(n){r.body.appendChild(i);i.href=i.href}var o=r.createElement("input");o.type="url";o.value=e;if(i.protocol===":"||!/:/.test(i.href)||!o.checkValidity()&&!t){throw new TypeError("Invalid URL")}Object.defineProperty(this,"_anchorElement",{value:i});var a=new u.URLSearchParams(this.search);var s=true;var c=true;var f=this;["append","delete","set"].forEach(function(e){var t=a[e];a[e]=function(){t.apply(a,arguments);if(s){c=false;f.search=a.toString();c=true}}});Object.defineProperty(this,"searchParams",{value:a,enumerable:true});var h=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:false,configurable:false,writable:false,value:function(){if(this.search!==h){h=this.search;if(c){s=false;this.searchParams._fromString(this.search);s=true}}}})};var r=e.prototype;var n=function(t){Object.defineProperty(r,t,{get:function(){return this._anchorElement[t]},set:function(e){this._anchorElement[t]=e},enumerable:true})};["hash","host","hostname","port","protocol"].forEach(function(e){n(e)});Object.defineProperty(r,"search",{get:function(){return this._anchorElement["search"]},set:function(e){this._anchorElement["search"]=e;this._updateSearchParams()},enumerable:true});Object.defineProperties(r,{toString:{get:function(){var e=this;return function(){return e.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(e){this._anchorElement.href=e;this._updateSearchParams()},enumerable:true},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(e){this._anchorElement.pathname=e},enumerable:true},origin:{get:function(){var e={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol];var t=this._anchorElement.port!=e&&this._anchorElement.port!=="";return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(t?":"+this._anchorElement.port:"")},enumerable:true},password:{get:function(){return""},set:function(e){},enumerable:true},username:{get:function(){return""},set:function(e){},enumerable:true}});e.createObjectURL=function(e){return t.createObjectURL.apply(t,arguments)};e.revokeObjectURL=function(e){return t.revokeObjectURL.apply(t,arguments)};u.URL=e};if(!e()){t()}if(u.location!==void 0&&!("origin"in u.location)){var r=function(){return u.location.protocol+"//"+u.location.hostname+(u.location.port?":"+u.location.port:"")};try{Object.defineProperty(u.location,"origin",{get:r,enumerable:true})}catch(e){setInterval(function(){u.location.origin=r()},100)}}})(typeof global!=="undefined"?global:typeof window!=="undefined"?window:typeof self!=="undefined"?self:this); -------------------------------------------------------------------------------- /scripts/zotero.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * (c) Copyright Ascensio System SIA 2020 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | (function () { 19 | if (!window.Asc.plugin.zotero) window.Asc.plugin.zotero = {}; 20 | window.Asc.plugin.zotero.api = function (cfg) { 21 | var apiKey; 22 | var userId; 23 | var userGroups = []; 24 | var baseUrl = cfg.baseUrl || "https://api.zotero.org/"; 25 | 26 | function getRequest(url) { 27 | return new Promise(function (resolve, reject) { 28 | var headers = { 29 | "Zotero-API-Version": "3" 30 | }; 31 | if (apiKey) headers["Zotero-API-Key"] = apiKey; 32 | fetch(url, { 33 | headers: headers 34 | }).then(function (res) { 35 | if (!res.ok) throw new Error(res.status + " " + res.statusText); 36 | resolve(res); 37 | }).catch(function (err) { 38 | reject(err); 39 | }); 40 | }); 41 | } 42 | 43 | function buildGetRequest(path, query) { 44 | var url = new URL(path, baseUrl); 45 | for (var key in query) url.searchParams.append(key, query[key]); 46 | return getRequest(url); 47 | } 48 | 49 | function items(search) { 50 | return new Promise(function (resolve, reject) { 51 | parseItemsResponse(buildGetRequest("users/" + userId + "/items", { 52 | q: search 53 | }), resolve, reject); 54 | }); 55 | } 56 | 57 | function groups(search, groupId) { 58 | return new Promise(function (resolve, reject) { 59 | parseItemsResponse(buildGetRequest("groups/" + groupId + "/items", { 60 | q: search 61 | }), resolve, reject); 62 | }); 63 | } 64 | 65 | function getUserGropus() { 66 | return userGroups; 67 | } 68 | 69 | function format(ids, key, style, locale) { 70 | return new Promise(function (resolve, reject) { 71 | var request; 72 | if (key) { 73 | request = buildGetRequest("groups/" + key + "/items", { 74 | format: "bib", 75 | style: style, 76 | locale: locale, 77 | itemKey: ids.join(",") 78 | }) 79 | } else { 80 | request = buildGetRequest("users/" + userId + "/items", { 81 | format: "bib", 82 | style: style, 83 | locale: locale, 84 | itemKey: ids.join(",") 85 | }) 86 | } 87 | request.then(function (res) { 88 | resolve(res.text()); 89 | }).catch(function (err) { 90 | reject(err); 91 | }); 92 | }); 93 | } 94 | 95 | function getUserId(key) { 96 | return new Promise(function (resolve, reject) { 97 | buildGetRequest("keys/" + key) 98 | .then(function (res) { 99 | if (!res.ok) throw new Error(res.status + " " + res.statusText); 100 | return res.json(); 101 | }).then(function (res) { 102 | saveSettings(res.userID, key); 103 | resolve(true); 104 | }).catch(function (err) { 105 | reject(err); 106 | }); 107 | }); 108 | } 109 | 110 | function applySettings(id, key) { 111 | userId = id; 112 | apiKey = key; 113 | } 114 | 115 | function saveSettings(id, key) { 116 | applySettings(id, key); 117 | localStorage.setItem("zoteroUserId", id); 118 | localStorage.setItem("zoteroApiKey", key); 119 | buildGetRequest("users/" + id + "/groups") 120 | .then(function (res) { 121 | if (!res.ok) throw new Error(res.status + " " + res.statusText); 122 | return res.json(); 123 | }).then(function (res) { 124 | res.forEach(function(el) { 125 | userGroups.push(el.id); 126 | }); 127 | localStorage.setItem("zoteroUserGroups", userGroups.join(';')); 128 | }).catch(function (err) { 129 | throw new Error(err) 130 | }); 131 | } 132 | 133 | function getSettings() { 134 | var uid = localStorage.getItem("zoteroUserId"); 135 | var key = localStorage.getItem("zoteroApiKey"); 136 | var groups = localStorage.getItem("zoteroUserGroups"); 137 | if (groups) 138 | userGroups = groups.split(';'); 139 | 140 | var configured = !(!uid || !key); 141 | if (configured) applySettings(uid, key); 142 | return configured; 143 | } 144 | 145 | function clearSettings() { 146 | localStorage.removeItem("zoteroUserId"); 147 | localStorage.removeItem("zoteroApiKey"); 148 | localStorage.removeItem("zoteroUserGroups"); 149 | userGroups = []; 150 | } 151 | 152 | function parseItemsResponse(promise, resolve, reject) { 153 | promise.then(function (res) { 154 | res.json().then(function (json) { 155 | var links = parseLinkHeader(res.headers.get("Link")); 156 | var obj = { 157 | items: json 158 | }; 159 | if (links.next) { 160 | obj.next = function () { 161 | return new Promise(function (rs, rj) { 162 | parseItemsResponse(getRequest(links.next), rs, rj); 163 | }); 164 | } 165 | } 166 | resolve(obj); 167 | }); 168 | }).catch(function (err) { 169 | reject(err); 170 | }); 171 | } 172 | 173 | var linkHeaderRegex = /<(.*?)>; rel="(.*?)"/g; 174 | function parseLinkHeader(headerValue) { 175 | var links = {}; 176 | if (!headerValue) return links; 177 | headerValue = headerValue.trim(); 178 | if (!headerValue) return links; 179 | 180 | var match; 181 | while ((match = linkHeaderRegex.exec(headerValue)) !== null) { 182 | links[match[2]] = match[1]; 183 | } 184 | 185 | return links; 186 | } 187 | 188 | return { 189 | items: items, 190 | groups: groups, 191 | getUserGropus: getUserGropus, 192 | format: format, 193 | hasSettings: getSettings, 194 | clearSettings: clearSettings, 195 | setApiKey: getUserId 196 | } 197 | } 198 | })(); 199 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | Zotero 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | 36 |
37 | 38 | 46 | 47 | 145 | 146 |
147 | 148 |
149 | Open Zotero website 150 | 151 |
152 | 153 |
154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /resources/css/plugin_style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | width: 100%; 4 | margin: 0; 5 | box-sizing: border-box; 6 | } 7 | 8 | body { 9 | flex-flow: column; 10 | display: flex; 11 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 12 | font-size: 11px; 13 | } 14 | 15 | input::selection { 16 | background: #D8DADC; /* WebKit/Blink Browsers */ 17 | } 18 | 19 | input::-moz-selection { 20 | background: #D8DADC; /* Gecko Browsers */ 21 | } 22 | 23 | div::selection { 24 | background: #D8DADC; /* WebKit/Blink Browsers */ 25 | } 26 | 27 | div::-moz-selection { 28 | background: #D8DADC; /* Gecko Browsers */ 29 | } 30 | 31 | textarea:focus, input:focus { 32 | outline: none; 33 | } 34 | 35 | .button { 36 | background: #fff; 37 | outline: none; 38 | font-size: 12px; 39 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 40 | cursor: pointer; 41 | text-align: center; 42 | margin: 15px 4px; 43 | display: flex; 44 | align-items: center; 45 | justify-content: center; 46 | padding: 5px 18px; 47 | } 48 | 49 | .button.wide { 50 | padding: 7px 13px; 51 | margin: 15px 0px; 52 | width: 100%; 53 | } 54 | 55 | .blur { 56 | filter: blur(3px); 57 | } 58 | 59 | .link { 60 | text-decoration: underline dotted; 61 | cursor: pointer; 62 | } 63 | 64 | .flex { 65 | display: flex; 66 | } 67 | 68 | .flexSize { 69 | flex: 1; 70 | } 71 | 72 | .flexCenter { 73 | align-items: center; 74 | justify-content: center; 75 | } 76 | 77 | .flexCol { 78 | display: flex; 79 | flex-direction: column; 80 | overflow-y: hidden; 81 | } 82 | 83 | .mrtop { 84 | margin-top: 8px 85 | } 86 | 87 | .control { 88 | box-sizing: border-box; 89 | border: 1px solid #cfcfcf; 90 | border-radius: 2px; 91 | color: #333333; 92 | } 93 | 94 | .control.select { 95 | cursor: pointer; 96 | background-color: #ffffff; 97 | } 98 | 99 | .control.text { 100 | cursor: text; 101 | } 102 | 103 | .control.text.wide { 104 | width: 100%; 105 | } 106 | 107 | input[type="text"] { 108 | padding: 2px; 109 | cursor: text; 110 | } 111 | 112 | #content { 113 | display: flex; 114 | flex-direction: column; 115 | flex: 1; 116 | overflow-y: hidden; 117 | padding: 10px 12px; 118 | } 119 | 120 | #searchField { 121 | width: 100%; 122 | padding-right: 18px; 123 | } 124 | 125 | #searchLabel { 126 | position: relative; 127 | } 128 | 129 | #searchClear { 130 | position: absolute; 131 | top: 11px; 132 | right: 4px; 133 | font-family: Arial; 134 | font-size: 22px; 135 | line-height: 0; 136 | color: #BDBDBD; 137 | cursor: pointer; 138 | } 139 | 140 | #mainCont { 141 | flex: 1; 142 | } 143 | 144 | #errorWrapper { 145 | background-color: #ffffff; 146 | padding: 10px 12px; 147 | } 148 | 149 | #docsWrapper { 150 | display: flex; 151 | flex-direction: row; 152 | margin-top: 15px; 153 | overflow-y: hidden; 154 | } 155 | 156 | #docsHolder { 157 | width: 100%; 158 | } 159 | 160 | #selectedWrapper { 161 | display: flex; 162 | flex-direction: row; 163 | overflow-y: hidden; 164 | max-height: 60px; 165 | } 166 | 167 | #selectedHolder { 168 | width: 100%; 169 | overflow-y: hidden; 170 | } 171 | 172 | #selectedHolder > div:last-of-type { 173 | margin-bottom: 14px; 174 | } 175 | 176 | #controlsHolder { 177 | border-top: 1px solid #cfcfcf; 178 | padding-top: 15px; 179 | overflow-y: visible; 180 | } 181 | 182 | #buttonsWrapper { 183 | flex-direction: row-reverse; 184 | } 185 | 186 | #buttonsWrapper > .button { 187 | margin: 0px 0px 15px 8px; 188 | } 189 | 190 | #styleWrapper { 191 | display: flex; 192 | flex-direction: row; 193 | width: 100%; 194 | } 195 | 196 | #styleWrapper .label { 197 | margin-bottom: 15px; 198 | } 199 | 200 | #styleWrapper .label:first-of-type { 201 | flex: 5; 202 | margin-right: 4px; 203 | } 204 | 205 | #styleWrapper .label:last-of-type { 206 | flex: 4; 207 | margin-left: 4px; 208 | } 209 | 210 | #styleWrapper .label > span { 211 | color: #444444; 212 | display: block; 213 | } 214 | 215 | #styleWrapper .label input { 216 | width: 100%; 217 | padding-right: 18px; 218 | } 219 | 220 | .selectHolder { 221 | position: relative; 222 | } 223 | 224 | .selectArrow { 225 | cursor: pointer; 226 | position: absolute; 227 | top: -1px; 228 | right: 8px; 229 | } 230 | 231 | .selectArrow > span { 232 | display: inline-block; 233 | width: 4px; 234 | height: 0.5px; 235 | margin: -1px; 236 | background-color: #000000; 237 | } 238 | 239 | .selectArrow > span:first-of-type { 240 | transform: rotateZ(45deg); 241 | } 242 | 243 | .selectArrow > span:last-of-type { 244 | transform: rotateZ(-45deg); 245 | } 246 | 247 | 248 | #styleLangList { 249 | right: 0px; 250 | } 251 | 252 | .selectList { 253 | display: flex; 254 | flex-direction: column; 255 | position: absolute; 256 | border: 1px solid rgba(0,0,0,.15); 257 | border-radius: 4px; 258 | -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); 259 | box-shadow: 0 6px 12px rgba(0,0,0,.175); 260 | background: #ffffff; 261 | bottom: 22px; 262 | max-height: 158px; 263 | overflow-x: hidden; 264 | overflow-y: auto; 265 | } 266 | 267 | .selectList > span { 268 | padding: 5px 20px; 269 | cursor: pointer; 270 | color: #444444; 271 | } 272 | 273 | .selectList > span:hover { 274 | background-color: #d8dadc; 275 | color: #373737; 276 | } 277 | 278 | .selectList > span[selected=""] { 279 | background-color: #7d858c; 280 | color: #ffffff; 281 | } 282 | 283 | .scrollThumb { 284 | width: 9px; 285 | background-color: rgb(241, 241, 241); 286 | border-radius: 2px; 287 | box-sizing: border-box; 288 | background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAANCAQAAAAz1Zf0AAAAIUlEQVR42mNgAILz/0GQAQo+/gdBBqLAqE5ydH5k+sgEANHgUH2JtDRHAAAAAElFTkSuQmCC); 289 | background-repeat: no-repeat; 290 | background-position: 0 center; 291 | border: 1px solid #cfcfcf; 292 | } 293 | 294 | .scrollThumb.scrolling { 295 | background-color: #adadad; 296 | border-color: #adadad; 297 | } 298 | 299 | .errorMsg { 300 | color: #D9534F; 301 | } 302 | 303 | .searchDivider { 304 | color: #666666; 305 | margin: 12px 0; 306 | } 307 | 308 | .doc { 309 | margin-bottom: 10px; 310 | display: flex; 311 | flex-direction: row; 312 | } 313 | 314 | .docInfo { 315 | min-width: 0; 316 | } 317 | 318 | .doc > div { 319 | display: flex; 320 | flex-direction: column; 321 | } 322 | 323 | .secondary-text { 324 | font-size: 11px; 325 | color: #999999; 326 | } 327 | 328 | .truncate-text { 329 | overflow: hidden; 330 | text-overflow: ellipsis; 331 | } 332 | 333 | .nowrap { 334 | white-space: nowrap; 335 | } 336 | 337 | #footerCont { 338 | display: flex; 339 | flex-direction: row; 340 | } 341 | 342 | #footerCont > span:first-of-type { 343 | flex: 1; 344 | } 345 | 346 | /* checkbox */ 347 | 348 | .checkbox { 349 | background: #FFFFFF; 350 | border: 1px solid #CFCFCF; 351 | box-sizing: border-box; 352 | width: 13px; 353 | height: 13px; 354 | margin-right: 8px; 355 | } 356 | 357 | .checkbox > input { 358 | width: 0; 359 | height: 0; 360 | position: absolute; 361 | visibility: hidden; 362 | } 363 | 364 | .checkbox > span { 365 | background: url('../img/checkmark.png') no-repeat; 366 | display: none; 367 | width: 11px; 368 | height: 10px; 369 | position: relative; 370 | top: -1px; 371 | left: 2px; 372 | } 373 | 374 | .checkbox > input:checked ~ span { 375 | display: inline-block; 376 | } 377 | 378 | .btn-text-default { 379 | display: flex; 380 | align-items: center; 381 | justify-content: center; 382 | } 383 | 384 | .selDoc { 385 | display: inline-block; 386 | margin-bottom: 5px; 387 | margin-right: 6px; 388 | } 389 | 390 | .selDoc > span { 391 | display: inline-block; 392 | margin-right: 5px; 393 | vertical-align: middle; 394 | } 395 | 396 | .selDoc > span:first-of-type { 397 | max-width: 52px; 398 | overflow: hidden; 399 | text-overflow: ellipsis; 400 | white-space: nowrap; 401 | } 402 | 403 | .selDoc > span:last-of-type { 404 | cursor: pointer; 405 | font-size: 18px; 406 | margin-top: 2px; 407 | } 408 | 409 | /* loader */ 410 | .cssload-container { 411 | z-index: 1; 412 | display: flex; 413 | position: absolute; 414 | top: 0; 415 | left: 0; 416 | width: 100%; 417 | height: 100%; 418 | align-items: center; 419 | justify-content: center; 420 | } 421 | 422 | .cssload-loading i { 423 | width: 19px; 424 | height: 19px; 425 | display: inline-block; 426 | border-radius: 50%; 427 | background: rgb(68,68,68); 428 | } 429 | 430 | .cssload-loading i:first-child { 431 | opacity: 0; 432 | animation: cssload-loading-ani2 0.58s linear infinite; 433 | -o-animation: cssload-loading-ani2 0.58s linear infinite; 434 | -ms-animation: cssload-loading-ani2 0.58s linear infinite; 435 | -webkit-animation: cssload-loading-ani2 0.58s linear infinite; 436 | -moz-animation: cssload-loading-ani2 0.58s linear infinite; 437 | transform: translate(-19px); 438 | -o-transform: translate(-19px); 439 | -ms-transform: translate(-19px); 440 | -webkit-transform: translate(-19px); 441 | -moz-transform: translate(-19px); 442 | } 443 | 444 | .cssload-loading i:nth-child(2), 445 | .cssload-loading i:nth-child(3) { 446 | animation: cssload-loading-ani3 0.58s linear infinite; 447 | -o-animation: cssload-loading-ani3 0.58s linear infinite; 448 | -ms-animation: cssload-loading-ani3 0.58s linear infinite; 449 | -webkit-animation: cssload-loading-ani3 0.58s linear infinite; 450 | -moz-animation: cssload-loading-ani3 0.58s linear infinite; 451 | } 452 | 453 | .cssload-loading i:last-child { 454 | animation: cssload-loading-ani1 0.58s linear infinite; 455 | -o-animation: cssload-loading-ani1 0.58s linear infinite; 456 | -ms-animation: cssload-loading-ani1 0.58s linear infinite; 457 | -webkit-animation: cssload-loading-ani1 0.58s linear infinite; 458 | -moz-animation: cssload-loading-ani1 0.58s linear infinite; 459 | } 460 | 461 | @keyframes cssload-loading-ani1 { 462 | 100% { 463 | transform: translate(39px); 464 | opacity: 0; 465 | } 466 | } 467 | 468 | @-o-keyframes cssload-loading-ani1 { 469 | 100% { 470 | -o-transform: translate(39px); 471 | opacity: 0; 472 | } 473 | } 474 | 475 | @-ms-keyframes cssload-loading-ani1 { 476 | 100% { 477 | -ms-transform: translate(39px); 478 | opacity: 0; 479 | } 480 | } 481 | 482 | @-webkit-keyframes cssload-loading-ani1 { 483 | 100% { 484 | -webkit-transform: translate(39px); 485 | opacity: 0; 486 | } 487 | } 488 | 489 | @-moz-keyframes cssload-loading-ani1 { 490 | 100% { 491 | -moz-transform: translate(39px); 492 | opacity: 0; 493 | } 494 | } 495 | 496 | @keyframes cssload-loading-ani2 { 497 | 100% { 498 | transform: translate(19px); 499 | opacity: 1; 500 | } 501 | } 502 | 503 | @-o-keyframes cssload-loading-ani2 { 504 | 100% { 505 | -o-transform: translate(19px); 506 | opacity: 1; 507 | } 508 | } 509 | 510 | @-ms-keyframes cssload-loading-ani2 { 511 | 100% { 512 | -ms-transform: translate(19px); 513 | opacity: 1; 514 | } 515 | } 516 | 517 | @-webkit-keyframes cssload-loading-ani2 { 518 | 100% { 519 | -webkit-transform: translate(19px); 520 | opacity: 1; 521 | } 522 | } 523 | 524 | @-moz-keyframes cssload-loading-ani2 { 525 | 100% { 526 | -moz-transform: translate(19px); 527 | opacity: 1; 528 | } 529 | } 530 | 531 | @keyframes cssload-loading-ani3 { 532 | 100% { 533 | transform: translate(19px); 534 | } 535 | } 536 | 537 | @-o-keyframes cssload-loading-ani3 { 538 | 100% { 539 | -o-transform: translate(19px); 540 | } 541 | } 542 | 543 | @-ms-keyframes cssload-loading-ani3 { 544 | 100% { 545 | -ms-transform: translate(19px); 546 | } 547 | } 548 | 549 | @-webkit-keyframes cssload-loading-ani3 { 550 | 100% { 551 | -webkit-transform: translate(19px); 552 | } 553 | } 554 | 555 | @-moz-keyframes cssload-loading-ani3 { 556 | 100% { 557 | -moz-transform: translate(19px); 558 | } 559 | } 560 | /* end loader */ 561 | 562 | .display-none { 563 | display: none; 564 | } 565 | -------------------------------------------------------------------------------- /scripts/thirdparty/fetch.umd.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 3 | typeof define === 'function' && define.amd ? define(['exports'], factory) : 4 | (factory((global.WHATWGFetch = {}))); 5 | }(this, (function (exports) { 'use strict'; 6 | 7 | var global = 8 | (typeof globalThis !== 'undefined' && globalThis) || 9 | (typeof self !== 'undefined' && self) || 10 | (typeof global !== 'undefined' && global); 11 | 12 | var support = { 13 | searchParams: 'URLSearchParams' in global, 14 | iterable: 'Symbol' in global && 'iterator' in Symbol, 15 | blob: 16 | 'FileReader' in global && 17 | 'Blob' in global && 18 | (function() { 19 | try { 20 | new Blob(); 21 | return true 22 | } catch (e) { 23 | return false 24 | } 25 | })(), 26 | formData: 'FormData' in global, 27 | arrayBuffer: 'ArrayBuffer' in global 28 | }; 29 | 30 | function isDataView(obj) { 31 | return obj && DataView.prototype.isPrototypeOf(obj) 32 | } 33 | 34 | if (support.arrayBuffer) { 35 | var viewClasses = [ 36 | '[object Int8Array]', 37 | '[object Uint8Array]', 38 | '[object Uint8ClampedArray]', 39 | '[object Int16Array]', 40 | '[object Uint16Array]', 41 | '[object Int32Array]', 42 | '[object Uint32Array]', 43 | '[object Float32Array]', 44 | '[object Float64Array]' 45 | ]; 46 | 47 | var isArrayBufferView = 48 | ArrayBuffer.isView || 49 | function(obj) { 50 | return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 51 | }; 52 | } 53 | 54 | function normalizeName(name) { 55 | if (typeof name !== 'string') { 56 | name = String(name); 57 | } 58 | if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { 59 | throw new TypeError('Invalid character in header field name') 60 | } 61 | return name.toLowerCase() 62 | } 63 | 64 | function normalizeValue(value) { 65 | if (typeof value !== 'string') { 66 | value = String(value); 67 | } 68 | return value 69 | } 70 | 71 | // Build a destructive iterator for the value list 72 | function iteratorFor(items) { 73 | var iterator = { 74 | next: function() { 75 | var value = items.shift(); 76 | return {done: value === undefined, value: value} 77 | } 78 | }; 79 | 80 | if (support.iterable) { 81 | iterator[Symbol.iterator] = function() { 82 | return iterator 83 | }; 84 | } 85 | 86 | return iterator 87 | } 88 | 89 | function Headers(headers) { 90 | this.map = {}; 91 | 92 | if (headers instanceof Headers) { 93 | headers.forEach(function(value, name) { 94 | this.append(name, value); 95 | }, this); 96 | } else if (Array.isArray(headers)) { 97 | headers.forEach(function(header) { 98 | this.append(header[0], header[1]); 99 | }, this); 100 | } else if (headers) { 101 | Object.getOwnPropertyNames(headers).forEach(function(name) { 102 | this.append(name, headers[name]); 103 | }, this); 104 | } 105 | } 106 | 107 | Headers.prototype.append = function(name, value) { 108 | name = normalizeName(name); 109 | value = normalizeValue(value); 110 | var oldValue = this.map[name]; 111 | this.map[name] = oldValue ? oldValue + ', ' + value : value; 112 | }; 113 | 114 | Headers.prototype['delete'] = function(name) { 115 | delete this.map[normalizeName(name)]; 116 | }; 117 | 118 | Headers.prototype.get = function(name) { 119 | name = normalizeName(name); 120 | return this.has(name) ? this.map[name] : null 121 | }; 122 | 123 | Headers.prototype.has = function(name) { 124 | return this.map.hasOwnProperty(normalizeName(name)) 125 | }; 126 | 127 | Headers.prototype.set = function(name, value) { 128 | this.map[normalizeName(name)] = normalizeValue(value); 129 | }; 130 | 131 | Headers.prototype.forEach = function(callback, thisArg) { 132 | for (var name in this.map) { 133 | if (this.map.hasOwnProperty(name)) { 134 | callback.call(thisArg, this.map[name], name, this); 135 | } 136 | } 137 | }; 138 | 139 | Headers.prototype.keys = function() { 140 | var items = []; 141 | this.forEach(function(value, name) { 142 | items.push(name); 143 | }); 144 | return iteratorFor(items) 145 | }; 146 | 147 | Headers.prototype.values = function() { 148 | var items = []; 149 | this.forEach(function(value) { 150 | items.push(value); 151 | }); 152 | return iteratorFor(items) 153 | }; 154 | 155 | Headers.prototype.entries = function() { 156 | var items = []; 157 | this.forEach(function(value, name) { 158 | items.push([name, value]); 159 | }); 160 | return iteratorFor(items) 161 | }; 162 | 163 | if (support.iterable) { 164 | Headers.prototype[Symbol.iterator] = Headers.prototype.entries; 165 | } 166 | 167 | function consumed(body) { 168 | if (body.bodyUsed) { 169 | return Promise.reject(new TypeError('Already read')) 170 | } 171 | body.bodyUsed = true; 172 | } 173 | 174 | function fileReaderReady(reader) { 175 | return new Promise(function(resolve, reject) { 176 | reader.onload = function() { 177 | resolve(reader.result); 178 | }; 179 | reader.onerror = function() { 180 | reject(reader.error); 181 | }; 182 | }) 183 | } 184 | 185 | function readBlobAsArrayBuffer(blob) { 186 | var reader = new FileReader(); 187 | var promise = fileReaderReady(reader); 188 | reader.readAsArrayBuffer(blob); 189 | return promise 190 | } 191 | 192 | function readBlobAsText(blob) { 193 | var reader = new FileReader(); 194 | var promise = fileReaderReady(reader); 195 | reader.readAsText(blob); 196 | return promise 197 | } 198 | 199 | function readArrayBufferAsText(buf) { 200 | var view = new Uint8Array(buf); 201 | var chars = new Array(view.length); 202 | 203 | for (var i = 0; i < view.length; i++) { 204 | chars[i] = String.fromCharCode(view[i]); 205 | } 206 | return chars.join('') 207 | } 208 | 209 | function bufferClone(buf) { 210 | if (buf.slice) { 211 | return buf.slice(0) 212 | } else { 213 | var view = new Uint8Array(buf.byteLength); 214 | view.set(new Uint8Array(buf)); 215 | return view.buffer 216 | } 217 | } 218 | 219 | function Body() { 220 | this.bodyUsed = false; 221 | 222 | this._initBody = function(body) { 223 | /* 224 | fetch-mock wraps the Response object in an ES6 Proxy to 225 | provide useful test harness features such as flush. However, on 226 | ES5 browsers without fetch or Proxy support pollyfills must be used; 227 | the proxy-pollyfill is unable to proxy an attribute unless it exists 228 | on the object before the Proxy is created. This change ensures 229 | Response.bodyUsed exists on the instance, while maintaining the 230 | semantic of setting Request.bodyUsed in the constructor before 231 | _initBody is called. 232 | */ 233 | this.bodyUsed = this.bodyUsed; 234 | this._bodyInit = body; 235 | if (!body) { 236 | this._bodyText = ''; 237 | } else if (typeof body === 'string') { 238 | this._bodyText = body; 239 | } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { 240 | this._bodyBlob = body; 241 | } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { 242 | this._bodyFormData = body; 243 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 244 | this._bodyText = body.toString(); 245 | } else if (support.arrayBuffer && support.blob && isDataView(body)) { 246 | this._bodyArrayBuffer = bufferClone(body.buffer); 247 | // IE 10-11 can't handle a DataView body. 248 | this._bodyInit = new Blob([this._bodyArrayBuffer]); 249 | } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { 250 | this._bodyArrayBuffer = bufferClone(body); 251 | } else { 252 | this._bodyText = body = Object.prototype.toString.call(body); 253 | } 254 | 255 | if (!this.headers.get('content-type')) { 256 | if (typeof body === 'string') { 257 | this.headers.set('content-type', 'text/plain;charset=UTF-8'); 258 | } else if (this._bodyBlob && this._bodyBlob.type) { 259 | this.headers.set('content-type', this._bodyBlob.type); 260 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 261 | this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); 262 | } 263 | } 264 | }; 265 | 266 | if (support.blob) { 267 | this.blob = function() { 268 | var rejected = consumed(this); 269 | if (rejected) { 270 | return rejected 271 | } 272 | 273 | if (this._bodyBlob) { 274 | return Promise.resolve(this._bodyBlob) 275 | } else if (this._bodyArrayBuffer) { 276 | return Promise.resolve(new Blob([this._bodyArrayBuffer])) 277 | } else if (this._bodyFormData) { 278 | throw new Error('could not read FormData body as blob') 279 | } else { 280 | return Promise.resolve(new Blob([this._bodyText])) 281 | } 282 | }; 283 | 284 | this.arrayBuffer = function() { 285 | if (this._bodyArrayBuffer) { 286 | var isConsumed = consumed(this); 287 | if (isConsumed) { 288 | return isConsumed 289 | } 290 | if (ArrayBuffer.isView(this._bodyArrayBuffer)) { 291 | return Promise.resolve( 292 | this._bodyArrayBuffer.buffer.slice( 293 | this._bodyArrayBuffer.byteOffset, 294 | this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength 295 | ) 296 | ) 297 | } else { 298 | return Promise.resolve(this._bodyArrayBuffer) 299 | } 300 | } else { 301 | return this.blob().then(readBlobAsArrayBuffer) 302 | } 303 | }; 304 | } 305 | 306 | this.text = function() { 307 | var rejected = consumed(this); 308 | if (rejected) { 309 | return rejected 310 | } 311 | 312 | if (this._bodyBlob) { 313 | return readBlobAsText(this._bodyBlob) 314 | } else if (this._bodyArrayBuffer) { 315 | return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) 316 | } else if (this._bodyFormData) { 317 | throw new Error('could not read FormData body as text') 318 | } else { 319 | return Promise.resolve(this._bodyText) 320 | } 321 | }; 322 | 323 | if (support.formData) { 324 | this.formData = function() { 325 | return this.text().then(decode) 326 | }; 327 | } 328 | 329 | this.json = function() { 330 | return this.text().then(JSON.parse) 331 | }; 332 | 333 | return this 334 | } 335 | 336 | // HTTP methods whose capitalization should be normalized 337 | var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; 338 | 339 | function normalizeMethod(method) { 340 | var upcased = method.toUpperCase(); 341 | return methods.indexOf(upcased) > -1 ? upcased : method 342 | } 343 | 344 | function Request(input, options) { 345 | if (!(this instanceof Request)) { 346 | throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') 347 | } 348 | 349 | options = options || {}; 350 | var body = options.body; 351 | 352 | if (input instanceof Request) { 353 | if (input.bodyUsed) { 354 | throw new TypeError('Already read') 355 | } 356 | this.url = input.url; 357 | this.credentials = input.credentials; 358 | if (!options.headers) { 359 | this.headers = new Headers(input.headers); 360 | } 361 | this.method = input.method; 362 | this.mode = input.mode; 363 | this.signal = input.signal; 364 | if (!body && input._bodyInit != null) { 365 | body = input._bodyInit; 366 | input.bodyUsed = true; 367 | } 368 | } else { 369 | this.url = String(input); 370 | } 371 | 372 | this.credentials = options.credentials || this.credentials || 'same-origin'; 373 | if (options.headers || !this.headers) { 374 | this.headers = new Headers(options.headers); 375 | } 376 | this.method = normalizeMethod(options.method || this.method || 'GET'); 377 | this.mode = options.mode || this.mode || null; 378 | this.signal = options.signal || this.signal; 379 | this.referrer = null; 380 | 381 | if ((this.method === 'GET' || this.method === 'HEAD') && body) { 382 | throw new TypeError('Body not allowed for GET or HEAD requests') 383 | } 384 | this._initBody(body); 385 | 386 | if (this.method === 'GET' || this.method === 'HEAD') { 387 | if (options.cache === 'no-store' || options.cache === 'no-cache') { 388 | // Search for a '_' parameter in the query string 389 | var reParamSearch = /([?&])_=[^&]*/; 390 | if (reParamSearch.test(this.url)) { 391 | // If it already exists then set the value with the current time 392 | this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); 393 | } else { 394 | // Otherwise add a new '_' parameter to the end with the current time 395 | var reQueryString = /\?/; 396 | this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); 397 | } 398 | } 399 | } 400 | } 401 | 402 | Request.prototype.clone = function() { 403 | return new Request(this, {body: this._bodyInit}) 404 | }; 405 | 406 | function decode(body) { 407 | var form = new FormData(); 408 | body 409 | .trim() 410 | .split('&') 411 | .forEach(function(bytes) { 412 | if (bytes) { 413 | var split = bytes.split('='); 414 | var name = split.shift().replace(/\+/g, ' '); 415 | var value = split.join('=').replace(/\+/g, ' '); 416 | form.append(decodeURIComponent(name), decodeURIComponent(value)); 417 | } 418 | }); 419 | return form 420 | } 421 | 422 | function parseHeaders(rawHeaders) { 423 | var headers = new Headers(); 424 | // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space 425 | // https://tools.ietf.org/html/rfc7230#section-3.2 426 | var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); 427 | preProcessedHeaders.split(/\r?\n/).forEach(function(line) { 428 | var parts = line.split(':'); 429 | var key = parts.shift().trim(); 430 | if (key) { 431 | var value = parts.join(':').trim(); 432 | headers.append(key, value); 433 | } 434 | }); 435 | return headers 436 | } 437 | 438 | Body.call(Request.prototype); 439 | 440 | function Response(bodyInit, options) { 441 | if (!(this instanceof Response)) { 442 | throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') 443 | } 444 | if (!options) { 445 | options = {}; 446 | } 447 | 448 | this.type = 'default'; 449 | this.status = options.status === undefined ? 200 : options.status; 450 | this.ok = this.status >= 200 && this.status < 300; 451 | this.statusText = 'statusText' in options ? options.statusText : ''; 452 | this.headers = new Headers(options.headers); 453 | this.url = options.url || ''; 454 | this._initBody(bodyInit); 455 | } 456 | 457 | Body.call(Response.prototype); 458 | 459 | Response.prototype.clone = function() { 460 | return new Response(this._bodyInit, { 461 | status: this.status, 462 | statusText: this.statusText, 463 | headers: new Headers(this.headers), 464 | url: this.url 465 | }) 466 | }; 467 | 468 | Response.error = function() { 469 | var response = new Response(null, {status: 0, statusText: ''}); 470 | response.type = 'error'; 471 | return response 472 | }; 473 | 474 | var redirectStatuses = [301, 302, 303, 307, 308]; 475 | 476 | Response.redirect = function(url, status) { 477 | if (redirectStatuses.indexOf(status) === -1) { 478 | throw new RangeError('Invalid status code') 479 | } 480 | 481 | return new Response(null, {status: status, headers: {location: url}}) 482 | }; 483 | 484 | exports.DOMException = global.DOMException; 485 | try { 486 | new exports.DOMException(); 487 | } catch (err) { 488 | exports.DOMException = function(message, name) { 489 | this.message = message; 490 | this.name = name; 491 | var error = Error(message); 492 | this.stack = error.stack; 493 | }; 494 | exports.DOMException.prototype = Object.create(Error.prototype); 495 | exports.DOMException.prototype.constructor = exports.DOMException; 496 | } 497 | 498 | function fetch(input, init) { 499 | return new Promise(function(resolve, reject) { 500 | var request = new Request(input, init); 501 | 502 | if (request.signal && request.signal.aborted) { 503 | return reject(new exports.DOMException('Aborted', 'AbortError')) 504 | } 505 | 506 | var xhr = new XMLHttpRequest(); 507 | 508 | function abortXhr() { 509 | xhr.abort(); 510 | } 511 | 512 | xhr.onload = function() { 513 | var options = { 514 | status: xhr.status, 515 | statusText: xhr.statusText, 516 | headers: parseHeaders(xhr.getAllResponseHeaders() || '') 517 | }; 518 | options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); 519 | var body = 'response' in xhr ? xhr.response : xhr.responseText; 520 | setTimeout(function() { 521 | resolve(new Response(body, options)); 522 | }, 0); 523 | }; 524 | 525 | xhr.onerror = function() { 526 | setTimeout(function() { 527 | reject(new TypeError('Network request failed')); 528 | }, 0); 529 | }; 530 | 531 | xhr.ontimeout = function() { 532 | setTimeout(function() { 533 | reject(new TypeError('Network request failed')); 534 | }, 0); 535 | }; 536 | 537 | xhr.onabort = function() { 538 | setTimeout(function() { 539 | reject(new exports.DOMException('Aborted', 'AbortError')); 540 | }, 0); 541 | }; 542 | 543 | function fixUrl(url) { 544 | try { 545 | return url === '' && global.location.href ? global.location.href : url 546 | } catch (e) { 547 | return url 548 | } 549 | } 550 | 551 | xhr.open(request.method, fixUrl(request.url), true); 552 | 553 | if (request.credentials === 'include') { 554 | xhr.withCredentials = true; 555 | } else if (request.credentials === 'omit') { 556 | xhr.withCredentials = false; 557 | } 558 | 559 | if ('responseType' in xhr) { 560 | if (support.blob) { 561 | xhr.responseType = 'blob'; 562 | } else if ( 563 | support.arrayBuffer && 564 | request.headers.get('Content-Type') && 565 | request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 566 | ) { 567 | xhr.responseType = 'arraybuffer'; 568 | } 569 | } 570 | 571 | if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { 572 | Object.getOwnPropertyNames(init.headers).forEach(function(name) { 573 | xhr.setRequestHeader(name, normalizeValue(init.headers[name])); 574 | }); 575 | } else { 576 | request.headers.forEach(function(value, name) { 577 | xhr.setRequestHeader(name, value); 578 | }); 579 | } 580 | 581 | if (request.signal) { 582 | request.signal.addEventListener('abort', abortXhr); 583 | 584 | xhr.onreadystatechange = function() { 585 | // DONE (success or failure) 586 | if (xhr.readyState === 4) { 587 | request.signal.removeEventListener('abort', abortXhr); 588 | } 589 | }; 590 | } 591 | 592 | xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); 593 | }) 594 | } 595 | 596 | fetch.polyfill = true; 597 | 598 | if (!global.fetch) { 599 | global.fetch = fetch; 600 | global.Headers = Headers; 601 | global.Request = Request; 602 | global.Response = Response; 603 | } 604 | 605 | exports.Headers = Headers; 606 | exports.Request = Request; 607 | exports.Response = Response; 608 | exports.fetch = fetch; 609 | 610 | Object.defineProperty(exports, '__esModule', { value: true }); 611 | 612 | }))); 613 | -------------------------------------------------------------------------------- /scripts/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * (c) Copyright Ascensio System SIA 2020 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | (function () { 19 | var displayNoneClass = "display-none"; 20 | var blurClass = "blur"; 21 | var waitForLoad = false; 22 | 23 | var selected = { 24 | items: {}, 25 | html: {}, 26 | checks: {}, 27 | count: function () { 28 | var k = 0; 29 | for (var i in selected.items) k++; 30 | return k; 31 | } 32 | }; 33 | 34 | var selectedLocale; 35 | var selectedStyle; 36 | 37 | var sdk = null; 38 | 39 | var lastSearch = { 40 | text: "", 41 | obj: null, 42 | groups: [] 43 | }; 44 | var elements = { 45 | libLoader: document.getElementById("libLoader"), 46 | error: document.getElementById("errorWrapper"), 47 | 48 | contentHolder: document.getElementById("content"), 49 | docsHolder: document.getElementById("docsHolder"), 50 | docsThumb: document.getElementById("docsThumb"), 51 | 52 | configState: document.getElementById("configState"), 53 | apiKeyConfigField: document.getElementById("apiKeyField"), 54 | saveConfigBtn: document.getElementById("saveConfigBtn"), 55 | 56 | mainState: document.getElementById("mainState"), 57 | logoutLink: document.getElementById("logoutLink"), 58 | 59 | selectedWrapper: document.getElementById("selectedWrapper"), 60 | selectedHolder: document.getElementById("selectedHolder"), 61 | selectedThumb: document.getElementById("selectedThumb"), 62 | buttonsWrapper: document.getElementById("buttonsWrapper"), 63 | 64 | searchLabel: document.getElementById("searchLabel"), 65 | searchClear: document.getElementById("searchClear"), 66 | searchField: document.getElementById("searchField"), 67 | 68 | styleWrapper: document.getElementById("styleWrapper"), 69 | styleSelectList: document.getElementById("styleSelectList"), 70 | styleSelect: document.getElementById("styleSelect"), 71 | styleLang: document.getElementById("styleLang"), 72 | 73 | insertBibBtn: document.getElementById("insertBibBtn"), 74 | cancelBtn: document.getElementById("cancelBtn"), 75 | }; 76 | 77 | var selectedScroller; 78 | var docsScroller; 79 | 80 | window.Asc.plugin.init = function () { 81 | sdk = window.Asc.plugin.zotero.api({}); 82 | 83 | window.Asc.plugin.onTranslate = applyTranslations; 84 | 85 | elements.logoutLink.onclick = function (e) { 86 | sdk.clearSettings(); 87 | switchAuthState('config'); 88 | return true; 89 | }; 90 | 91 | function searchFor(text) { 92 | if (elements.mainState.classList.contains(displayNoneClass)) return; 93 | text = text.trim(); 94 | if (!text) return; 95 | if (text == lastSearch.text) return; 96 | lastSearch.text = text; 97 | lastSearch.catObj = null; 98 | lastSearch.ownObj = null; 99 | 100 | clearLibrary(); 101 | 102 | loadLibrary(sdk.items(text), true, true, false); 103 | var groups = sdk.getUserGropus(); 104 | if (groups.length) { 105 | for (var i = 0; i < groups.length; i++) { 106 | loadLibrary(sdk.groups(lastSearch.text, groups[i]), true, false, (i == groups.length -1), true ); 107 | } 108 | } 109 | }; 110 | elements.searchField.onkeypress = function (e) { 111 | if (e.keyCode == 13) searchFor(e.target.value); 112 | }; 113 | elements.searchField.onblur = function (e) { 114 | setTimeout(function () { searchFor(e.target.value); }, 500); 115 | }; 116 | 117 | elements.searchField.onkeyup = function (e) { 118 | switchClass(elements.searchClear, displayNoneClass, !e.target.value); 119 | }; 120 | elements.searchClear.onclick = function (e) { 121 | if (e.target.classList.contains(displayNoneClass)) return true; 122 | switchClass(elements.searchClear, displayNoneClass, true); 123 | elements.searchField.value = ""; 124 | lastSearch.text = ""; 125 | clearLibrary(); 126 | return true; 127 | }; 128 | 129 | elements.cancelBtn.onclick = function (e) { 130 | var ids = []; 131 | for (var id in selected.items) { 132 | ids.push(id); 133 | } 134 | for (var i = 0; i < ids.length; i++) { 135 | removeSelected(ids[i]); 136 | } 137 | }; 138 | 139 | elements.saveConfigBtn.onclick = function (e) { 140 | var apikey = elements.apiKeyConfigField.value.trim(); 141 | if (apikey) { 142 | sdk.setApiKey(apikey) 143 | .then(function () { 144 | switchAuthState("main"); 145 | }).catch(function () { 146 | showError(getMessage("Invalid API key")); 147 | }); 148 | } 149 | }; 150 | 151 | elements.insertBibBtn.onclick = formatInsertBibliography; 152 | 153 | selectedScroller = initScrollBox(elements.selectedHolder, elements.selectedThumb); 154 | docsScroller = initScrollBox(elements.docsHolder, elements.docsThumb, checkDocsScroll); 155 | 156 | fetch("https://www.zotero.org/styles-files/styles.json") 157 | .then(function (resp) { return resp.json(); }) 158 | .then(function (json) { 159 | var lastStyle = getLastUsedStyle(); 160 | var found = false; 161 | 162 | var onStyleSelect = function (f) { 163 | return function (ev) { 164 | var sel = ev.target.getAttribute("data-value"); 165 | saveLastUsedStyle(sel); 166 | f(ev); 167 | } 168 | } 169 | 170 | for (var i = 0; i < json.length; i++) { 171 | if (json[i].dependent != 0) continue; 172 | 173 | var el = document.createElement("span"); 174 | el.setAttribute("data-value", json[i].name); 175 | el.textContent = json[i].title; 176 | elements.styleSelectList.appendChild(el); 177 | el.onclick = onStyleSelect(onClickListElement(elements.styleSelectList, elements.styleSelect)); 178 | if (json[i].name == lastStyle) { 179 | el.setAttribute("selected", ""); 180 | selectInput(elements.styleSelect, el, elements.styleSelectList); 181 | found = true; 182 | } 183 | } 184 | 185 | if (!found) { 186 | var first = elements.styleSelectList.children[0]; 187 | first.setAttribute("selected", ""); 188 | selectInput(elements.styleSelect, first, elements.styleSelectList); 189 | } 190 | }) 191 | .catch(function (err) { }); 192 | 193 | elements.styleSelect.onkeyup = function () { 194 | var input = elements.styleSelect; 195 | var filter = input.value.toLowerCase(); 196 | var list = elements.styleSelectList; 197 | 198 | for (var i = 0; i < list.children.length; i++) { 199 | var text = list.children[i].textContent || list.children[i].innerText; 200 | var hide = true; 201 | if (!filter || text.toLowerCase().indexOf(filter) > -1) { 202 | hide = false; 203 | } 204 | switchClass(list.children[i], displayNoneClass, hide); 205 | } 206 | } 207 | 208 | elements.styleSelect.onselectchange = function (inp, val) { 209 | selectedStyle = val; 210 | }; 211 | elements.styleLang.onselectchange = function (inp, val) { 212 | selectedLocale = val; 213 | }; 214 | 215 | initSelectBoxes(); 216 | elements.styleSelectList.onopen = function () { 217 | elements.styleSelectList.style.width = (elements.styleWrapper.clientWidth - 2) + "px"; 218 | } 219 | 220 | if (sdk.hasSettings()) { 221 | switchAuthState('main'); 222 | } else { 223 | switchAuthState('config'); 224 | } 225 | }; 226 | window.Asc.plugin.onThemeChanged = function(theme) 227 | { 228 | window.Asc.plugin.onThemeChangedBase(theme); 229 | var rules = '.selectArrow > span { background-color: ' + window.Asc.plugin.theme['text-normal'] + '}\n'; 230 | rules += '.link { color : ' + window.Asc.plugin.theme['text-normal'] + ';}\n'; 231 | rules += '.control.select { background-color : ' + window.Asc.plugin.theme['background-normal'] + ';}\n'; 232 | rules += '.control { color : ' + window.Asc.plugin.theme['text-normal'] + '; border-color : ' + window.Asc.plugin.theme['border-regular-control'] + '}\n'; 233 | rules += '.selectList > span { background-color: ' + window.Asc.plugin.theme['background-normal'] + '; '; 234 | rules += 'color : ' + window.Asc.plugin.theme['text-normal'] + '; }\n'; 235 | rules += '.selectList > span:hover { background-color : ' + window.Asc.plugin.theme['highlight-button-hover'] + '; color : ' + window.Asc.plugin.theme['text-normal'] + '}\n'; 236 | rules += '.selectList > span[selected=""] { background-color : ' + window.Asc.plugin.theme['highlight-button-pressed'] + ';' + '; color : ' + window.Asc.plugin.theme['text-normal'] + '}'; 237 | var styleTheme = document.createElement('style'); 238 | styleTheme.type = 'text/css'; 239 | styleTheme.innerHTML = rules; 240 | document.getElementsByTagName('head')[0].appendChild(styleTheme); 241 | }; 242 | var scrollBoxes = []; 243 | function initScrollBox(holder, thumb, onscroll) { 244 | var scroller = {}; 245 | scroller.onscroll = checkScroll(holder, thumb, onscroll); 246 | 247 | holder.onwheel = function (e) { 248 | holder.scrollTop += (e.deltaY > 10 || e.deltaY < -10) ? e.deltaY : e.deltaY * 20; 249 | scroller.onscroll(); 250 | }; 251 | 252 | thumb.onmousedown = function (e) { 253 | switchClass(thumb, "scrolling", true); 254 | var y = e.clientY; 255 | var initialPos = holder.scrollTop; 256 | 257 | window.onmouseup = function (e) { 258 | switchClass(thumb, "scrolling", false); 259 | window.onmouseup = null; 260 | window.onmousemove = null; 261 | } 262 | window.onmousemove = function (e) { 263 | var delta = e.clientY - y; 264 | 265 | var percMoved = delta / holder.clientHeight; 266 | var deltaScroll = holder.scrollHeight * percMoved; 267 | holder.scrollTop = initialPos + deltaScroll; 268 | 269 | scroller.onscroll(); 270 | } 271 | } 272 | 273 | scrollBoxes.push(scroller); 274 | 275 | document.body.onresize = function () { 276 | for (var i = 0; i < scrollBoxes.length; i++) { 277 | scrollBoxes[i].onscroll(); 278 | } 279 | } 280 | 281 | return scroller; 282 | } 283 | 284 | var selectLists = []; 285 | function initSelectBoxes() { 286 | var select = document.getElementsByClassName("control select"); 287 | for (var i = 0; i < select.length; i++) { 288 | var input = select[i]; 289 | var holder = input.parentElement; 290 | var arrow = document.createElement("span"); 291 | arrow.classList.add("selectArrow"); 292 | arrow.appendChild(document.createElement("span")); 293 | arrow.appendChild(document.createElement("span")); 294 | holder.appendChild(arrow); 295 | 296 | var list = holder.getElementsByClassName("selectList")[0]; 297 | if (list.children.length > 0) { 298 | var def = false; 299 | for (var j = 0; j < list.children.length; j++) { 300 | if (list.children[j].hasAttribute("selected")) { 301 | selectInput(input, list.children[j], list); 302 | def = true; 303 | } 304 | 305 | list.children[j].onclick = onClickListElement(list, input); 306 | } 307 | if (!def) { 308 | selectInput(input, list.children[0], list); 309 | } 310 | } 311 | 312 | var f = function (list, input) { 313 | return function (ev) { 314 | ev.stopPropagation(); 315 | if (list.onopen) { 316 | list.onopen(); 317 | } 318 | if (!input.hasAttribute("readonly")) { 319 | input.select(); 320 | } 321 | openList(list); 322 | return true; 323 | }; 324 | }; 325 | 326 | input.onclick = f(list, input); 327 | arrow.onclick = f(list, input); 328 | selectLists.push(list); 329 | } 330 | 331 | window.onclick = function () { 332 | openList(null); 333 | } 334 | } 335 | 336 | function openList(el) { 337 | for (var i = 0; i < selectLists.length; i++) { 338 | var close = true; 339 | if (selectLists[i] === el) { 340 | close = false; 341 | } 342 | switchClass(selectLists[i], displayNoneClass, close); 343 | } 344 | } 345 | 346 | function selectInput(input, el, list) { 347 | input.value = el.textContent; 348 | var val = el.getAttribute("data-value"); 349 | input.setAttribute("data-value", val); 350 | input.setAttribute("title", el.textContent); 351 | if (input.onselectchange) { 352 | input.onselectchange(input, val); 353 | } 354 | switchClass(list, displayNoneClass, true); 355 | }; 356 | 357 | function onClickListElement(list, input) { 358 | return function (ev) { 359 | var sel = ev.target.getAttribute("data-value"); 360 | for (var i = 0; i < list.children.length; i++) { 361 | if (list.children[i].getAttribute("data-value") == sel) { 362 | list.children[i].setAttribute("selected", ""); 363 | selectInput(input, list.children[i], list); 364 | } else { 365 | if (list.children[i].hasAttribute("selected")) { 366 | list.children[i].attributes.removeNamedItem("selected"); 367 | } 368 | } 369 | } 370 | }; 371 | }; 372 | 373 | function applyTranslations() { 374 | var elements = document.getElementsByClassName("i18n"); 375 | 376 | for (var i = 0; i < elements.length; i++) { 377 | var el = elements[i]; 378 | if (el.attributes["placeholder"]) el.attributes["placeholder"].value = getMessage(el.attributes["placeholder"].value); 379 | if (el.innerText) el.innerText = getMessage(el.innerText); 380 | } 381 | } 382 | 383 | function getMessage(key) { 384 | return window.Asc.plugin.tr(key); 385 | } 386 | 387 | function saveLastUsedStyle(id) { 388 | localStorage.setItem("zoteroStyleId", id); 389 | } 390 | 391 | function getLastUsedStyle() { 392 | return localStorage.getItem("zoteroStyleId"); 393 | } 394 | 395 | function showError(message) { 396 | if (message) { 397 | switchClass(elements.error, displayNoneClass, false); 398 | elements.error.textContent = message; 399 | setTimeout(function () { window.onclick = function () { showError(); }; }, 100); 400 | } else { 401 | switchClass(elements.error, displayNoneClass, true); 402 | elements.error.textContent = ""; 403 | window.onclick = null; 404 | } 405 | } 406 | 407 | function showLibLoader(show) { 408 | switchClass(elements.libLoader, displayNoneClass, !show); 409 | } 410 | 411 | function switchClass(el, className, add) { 412 | if (add) { 413 | el.classList.add(className); 414 | } else { 415 | el.classList.remove(className); 416 | } 417 | } 418 | 419 | function configState(hide) { 420 | switchClass(elements.configState, displayNoneClass, hide); 421 | } 422 | 423 | function mainState(hide) { 424 | switchClass(elements.mainState, displayNoneClass, hide); 425 | switchClass(elements.logoutLink, displayNoneClass, hide); 426 | } 427 | 428 | var currentAuthState; 429 | function switchAuthState(state) { 430 | currentAuthState = state; 431 | configState(true); 432 | mainState(true); 433 | switch (state) { 434 | case 'config': 435 | configState(false); 436 | break; 437 | case 'main': 438 | mainState(false); 439 | break; 440 | } 441 | } 442 | 443 | function checkScroll(holder, thumb, func) { 444 | return function () { 445 | if (holder.scrollHeight <= holder.clientHeight) { 446 | switchClass(thumb, displayNoneClass, true); 447 | } else { 448 | switchClass(thumb, displayNoneClass, false); 449 | var height = holder.clientHeight / holder.scrollHeight * holder.clientHeight; 450 | height = height < 40 ? 40 : height; 451 | thumb.style.height = height + "px"; 452 | 453 | var scroll = holder.scrollHeight - holder.clientHeight; 454 | var percScrolled = holder.scrollTop / scroll; 455 | 456 | var margin = percScrolled * (holder.clientHeight - height); 457 | thumb.style.marginTop = margin + "px"; 458 | } 459 | 460 | if (func) func(holder, thumb); 461 | } 462 | } 463 | 464 | var loadTimeout = null; 465 | function checkDocsScroll(holder) { 466 | if (shouldLoadMore(holder)) { 467 | 468 | if (loadTimeout) { 469 | clearTimeout(loadTimeout); 470 | } 471 | 472 | if (!lastSearch.obj && !lastSearch.text.trim() && !lastSearch.groups.length) return; 473 | 474 | waitForLoad = true; 475 | loadTimeout = setTimeout(function () { 476 | if (shouldLoadMore(holder)) { 477 | loadLibrary(lastSearch.obj.next(), true, true, lastSearch.groups.length); 478 | for (var i = 0; (i < lastSearch.groups.length && lastSearch.groups[i].next); i++) { 479 | loadLibrary(sdk.groups(lastSearch.groups[i].next()), true, false, (i == lastSearch.groups.length -1), true ); 480 | } 481 | } else { 482 | waitForLoad = false; 483 | } 484 | }, 500); 485 | 486 | } 487 | } 488 | 489 | function shouldLoadMore(holder) { 490 | if (currentAuthState != "main") return false; 491 | if (holder.scrollTop + holder.clientHeight < holder.scrollHeight) return false; 492 | var flag = true; 493 | lastSearch.groups.forEach(function(el) { 494 | if (el.next) flag = false; 495 | }); 496 | if (!lastSearch.obj || !lastSearch.obj.next || !flag) return false; 497 | 498 | return true; 499 | } 500 | 501 | function clearLibrary() { 502 | var holder = elements.docsHolder; 503 | while (holder.lastChild) { 504 | holder.removeChild(holder.lastChild); 505 | } 506 | holder.scrollTop = 0; 507 | lastSearch.catObj = null; 508 | lastSearch.ownObj = null; 509 | docsScroller.onscroll(); 510 | } 511 | 512 | function loadLibrary(promise, append, showLoader, hideLoader, isGroup) { 513 | if (showLoader) showLibLoader(true); 514 | promise 515 | .then(function (res) { 516 | displaySearchItems(append, res, null, hideLoader, isGroup); 517 | }) 518 | .catch(function (err) { 519 | displaySearchItems(append, null, err.message, hideLoader, isGroup); 520 | }) 521 | .finally(function () { 522 | if (hideLoader) { 523 | showLibLoader(false); 524 | waitForLoad = false; 525 | } 526 | }); 527 | } 528 | 529 | function displaySearchItems(append, res, err, showNotFound, isGroup) { 530 | var holder = elements.docsHolder; 531 | 532 | if (!append) { 533 | clearLibrary(); 534 | } 535 | 536 | var first = false; 537 | if (!lastSearch.obj && (res.items && !res.items.length) ) first = true; 538 | if (err) { 539 | if (first) { 540 | lastSearch.obj = {}; 541 | lastSearch.groups = []; 542 | } 543 | lastSearch.obj.next = null; 544 | } else { 545 | if (isGroup) 546 | lastSearch.groups.push(res); 547 | else 548 | lastSearch.obj = res; 549 | } 550 | 551 | var page = document.createElement("div"); 552 | page.classList.add("page" + holder.children.length); 553 | if (res && res.items.length > 0) { 554 | for (var i in res.items) { 555 | page.appendChild(buildDocElement(res.items[i])); 556 | } 557 | } else if (err || first) { 558 | if (err) { 559 | showError(err); 560 | } else if (showNotFound) { 561 | var notFound = document.createElement("div"); 562 | notFound.textContent = getMessage("Nothing found"); 563 | notFound.classList.add("searchInfo"); 564 | page.appendChild(notFound); 565 | } 566 | } 567 | holder.appendChild(page); 568 | 569 | docsScroller.onscroll(); 570 | } 571 | 572 | function buildDocElement(item) { 573 | var root = document.createElement("div"); 574 | root.classList.add("doc"); 575 | 576 | var checkHolder = document.createElement("div"); 577 | var checkWrapper = document.createElement("div"); 578 | checkWrapper.classList.add("checkbox"); 579 | var check = document.createElement("input"); 580 | check.setAttribute("type", "checkbox"); 581 | if (selected.items[item.key]) { 582 | check.checked = true; 583 | selected.checks[item.key] = check; 584 | } 585 | checkWrapper.appendChild(check); 586 | checkWrapper.appendChild(document.createElement("span")); 587 | checkHolder.appendChild(checkWrapper); 588 | 589 | var docInfo = document.createElement("div"); 590 | docInfo.classList.add("docInfo"); 591 | 592 | var title = document.createElement("div"); 593 | title.textContent = item.data.title; 594 | title.classList.add("truncate-text"); 595 | docInfo.appendChild(title); 596 | 597 | if (item.data.creators && item.data.creators.length > 0) { 598 | var authors = document.createElement("div"); 599 | authors.textContent = item.data.creators 600 | .map(function (a) { 601 | if (a.name) return a.name; 602 | return a.lastName + ", " + a.firstName; 603 | }) 604 | .join("; "); 605 | authors.setAttribute("title", authors.textContent); 606 | authors.classList.add("secondary-text"); 607 | authors.classList.add("truncate-text"); 608 | authors.classList.add("nowrap"); 609 | docInfo.appendChild(authors); 610 | } 611 | 612 | var source = document.createElement("div"); 613 | if (item.data.publisher || item.data.place) { 614 | source.textContent = item.data.publisher || item.data.place; 615 | } 616 | if (item.data.date) { 617 | if (source.textContent) { 618 | source.textContent += " (" + item.data.date + ")"; 619 | } else { 620 | source.textContent = item.data.date; 621 | } 622 | } 623 | source.setAttribute("title", source.textContent); 624 | source.classList.add("secondary-text"); 625 | source.classList.add("truncate-text"); 626 | source.classList.add("nowrap"); 627 | docInfo.appendChild(source); 628 | 629 | root.appendChild(checkHolder); 630 | root.appendChild(docInfo); 631 | 632 | function selectItem(input, item) { 633 | return function (e) { 634 | input.checked = !input.checked; 635 | if (input.checked) { 636 | addSelected(item, input); 637 | } else { 638 | removeSelected(item.key); 639 | } 640 | }; 641 | } 642 | 643 | var f = selectItem(check, item); 644 | checkWrapper.onclick = f; 645 | docInfo.onclick = f; 646 | 647 | return root; 648 | } 649 | 650 | function addSelected(item, input) { 651 | var el = buildSelectedElement(item); 652 | selected.items[item.key] = item; 653 | selected.html[item.key] = el; 654 | selected.checks[item.key] = input; 655 | elements.selectedHolder.appendChild(el); 656 | docsScroller.onscroll(); 657 | selectedScroller.onscroll(); 658 | checkSelected(); 659 | } 660 | 661 | function removeSelected(key) { 662 | var el = selected.html[key]; 663 | delete selected.items[key]; 664 | delete selected.html[key]; 665 | if (selected.checks[key]) { 666 | selected.checks[key].checked = false; 667 | delete selected.checks[key]; 668 | } 669 | elements.selectedHolder.removeChild(el); 670 | docsScroller.onscroll(); 671 | selectedScroller.onscroll(); 672 | checkSelected(); 673 | } 674 | 675 | function buildSelectedElement(item) { 676 | var root = document.createElement("div"); 677 | root.classList.add("selDoc"); 678 | 679 | var name = document.createElement("span"); 680 | name.textContent = item.data.title; 681 | name.setAttribute("title", item.data.title); 682 | 683 | var year = document.createElement("span"); 684 | if (item.data.date) { 685 | year.textContent = item.data.date; 686 | } 687 | 688 | var remove = document.createElement("span"); 689 | remove.onclick = function () { 690 | removeSelected(item.key); 691 | }; 692 | remove.textContent = '×'; 693 | 694 | root.appendChild(name); 695 | root.appendChild(year); 696 | root.appendChild(remove); 697 | 698 | return root; 699 | } 700 | 701 | function checkSelected() { 702 | switchClass(elements.buttonsWrapper, displayNoneClass, selected.count() <= 0); 703 | } 704 | 705 | function formatInsertBibliography() { 706 | if (!selectedStyle) { 707 | showError(getMessage("Style is not selected")); 708 | return; 709 | } 710 | if (!selectedLocale) { 711 | showError(getMessage("Language is not selected")); 712 | return; 713 | } 714 | 715 | var obj = { 716 | users: { 717 | keys : [], 718 | }, 719 | groups: {} 720 | }; 721 | for (const key in selected.items) { 722 | if (Object.hasOwnProperty.call(selected.items, key)) { 723 | const el = selected.items[key]; 724 | if (el.library.type == "user") { 725 | obj.users.keys.push(key); 726 | } else if (el.library.type == "group") { 727 | if (obj.groups[el.library.id]) { 728 | obj.groups[el.library.id].keys.push(key); 729 | } else { 730 | obj.groups[el.library.id] = { 731 | keys: [key] 732 | }; 733 | } 734 | } 735 | } 736 | } 737 | 738 | if (obj.users.keys.length) { 739 | sdk.format(obj.users.keys, null, selectedStyle, selectedLocale) 740 | .then(function (res) { 741 | insertInDocument(res); 742 | }) 743 | .catch(function (err) { 744 | showError(err); 745 | }); 746 | } 747 | 748 | if (Object.keys(obj.groups).length != 0) { 749 | for (const key in obj.groups) { 750 | if (Object.hasOwnProperty.call(obj.groups, key)) { 751 | const element = obj.groups[key]; 752 | sdk.format(element.keys, key, selectedStyle, selectedLocale) 753 | .then(function (res) { 754 | insertInDocument(res); 755 | }) 756 | .catch(function (err) { 757 | showError(err); 758 | }); 759 | } 760 | } 761 | } 762 | 763 | 764 | } 765 | 766 | function insertInDocument(html) { 767 | if (html) { 768 | window.Asc.plugin.executeMethod("PasteHtml", [html]); 769 | } else { 770 | showError(getMessage("Bibliography cannot be created with selected style")); 771 | } 772 | }; 773 | 774 | })(); 775 | --------------------------------------------------------------------------------