16
sdkjs-plugins/content/zotero/3rd-party.txt
Normal file
@ -0,0 +1,16 @@
|
||||
Zotero ONLYOFFICE integration plugin uses code from the following 3rd party projects:
|
||||
|
||||
\vendor\thirdparty\fetch.umd.js
|
||||
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)
|
||||
License: MIT
|
||||
License File: fetch-polyfill.license
|
||||
|
||||
\vendor\thirdparty\promise-polyfill.min.js
|
||||
promise-polyfill - Lightweight ES6 Promise polyfill for the browser and node. (https://github.com/taylorhakes/promise-polyfill)
|
||||
License: MIT
|
||||
License File: promise-polyfill.license
|
||||
|
||||
\vendor\thirdparty\url-polyfill.min.js
|
||||
url-polyfill - Polyfill URL and URLSearchParams to match last WHATWG specifications. (https://github.com/lifaon74/url-polyfill)
|
||||
License: MIT
|
||||
License File: url-polyfill.license
|
||||
4
sdkjs-plugins/content/zotero/AUTHORS.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Authors
|
||||
|
||||
* Ascensio System SIA: <integration@onlyoffice.com>
|
||||
|
||||
4
sdkjs-plugins/content/zotero/CHANGELOG.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Change Log
|
||||
|
||||
## 1.0.0
|
||||
- Initial release
|
||||
90
sdkjs-plugins/content/zotero/README.md
Normal file
@ -0,0 +1,90 @@
|
||||
# ONLYOFFICE Zotero plugin
|
||||
|
||||
Zotero plugin allows users to create bibliographies in ONLYOFFICE editors using Zotero service.
|
||||
|
||||
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.
|
||||
|
||||
## How to use
|
||||
|
||||
1. Search references by author, title or year.
|
||||
|
||||
2. Among search results, choose ones you want to add to your document.
|
||||
|
||||
3. Choose style (e.g. Chicago Manual, American Psychological Association) and language.
|
||||
|
||||
4. Press `Insert citation`.
|
||||
|
||||
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.
|
||||
|
||||
## How to install to server
|
||||
|
||||
Two installation ways are available:
|
||||
|
||||
1. Put the folder with the plugin code to ONLYOFFICE Document Server folder depending on the operating system:
|
||||
|
||||
For Linux - `/var/www/onlyoffice/documentserver/sdkjs-plugins/`.
|
||||
|
||||
For Windows - `%ProgramFiles%\ONLYOFFICE\DocumentServer\sdkjs-plugins\`.
|
||||
|
||||
The plugins will be available to all the users users of ONLYOFFICE Document Server.
|
||||
No service restart is required.
|
||||
|
||||
2. Edit the Document Server config to add the following lines:
|
||||
|
||||
```
|
||||
var docEditor = new DocsAPI.DocEditor("placeholder", {
|
||||
"editorConfig": {
|
||||
"plugins": {
|
||||
"autostart": [
|
||||
"asc.{BFC5D5C6-89DE-4168-9565-ABD8D1E48711}",
|
||||
...
|
||||
],
|
||||
"pluginsData": [
|
||||
"https://example.com/path/to/zotero/config.json",
|
||||
...
|
||||
]
|
||||
},
|
||||
...
|
||||
},
|
||||
...
|
||||
});
|
||||
```
|
||||
**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.
|
||||
|
||||
## How to install to desktop
|
||||
|
||||
* Archive the plugin files (the archive must contain config.json, index.html, and pluginCode.js).
|
||||
* Change the file extension to .plugin.
|
||||
* Go to the Plugins tab, click Manage Plugins >> Add plugin, browse for the .plugin file.
|
||||
|
||||
## Configuration
|
||||
|
||||
1. Find Zotero plugin in `Plugins` tab of the ONLYOFFICE Document Editor and click it.
|
||||
|
||||
2. Log in to your Zotero account.
|
||||
|
||||
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).
|
||||
|
||||
4. Press `Create new private key`.
|
||||
|
||||
5. Fill in `Key Description`, make sure `Allow library access` box is checked and press `Save Key`.
|
||||
|
||||
5. Copy the newly created key and paste to `API Key` field in the plugin’s interface and save it.
|
||||
|
||||
## Known issues
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
sudo restorecon -Rv /var/www/onlyoffice/documentserver/sdkjs-plugins/
|
||||
```
|
||||
|
||||
After that restart the services:
|
||||
|
||||
```
|
||||
sudo supervisorctl restart ds:docservice
|
||||
```
|
||||
|
||||
## User feedback and support
|
||||
|
||||
To ask questions and share feedback, use Issues in this repository.
|
||||
62
sdkjs-plugins/content/zotero/config.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"name" : "Zotero",
|
||||
"guid" : "asc.{BFC5D5C6-89DE-4168-9565-ABD8D1E48711}",
|
||||
"version": "1.0.0",
|
||||
|
||||
"variations" : [
|
||||
{
|
||||
"description": "Zotero",
|
||||
"url": "index.html",
|
||||
"icons": [ "resources/light/icon.png", "resources/light/icon@2x.png" ],
|
||||
"icons2": [
|
||||
{
|
||||
"style" : "light",
|
||||
|
||||
"100%": {
|
||||
"normal": "resources/light/icon.png"
|
||||
},
|
||||
"125%": {
|
||||
"normal": "resources/light/icon@1.25x.png"
|
||||
},
|
||||
"150%": {
|
||||
"normal": "resources/light/icon@1.5x.png"
|
||||
},
|
||||
"175%": {
|
||||
"normal": "resources/light/icon@1.75x.png"
|
||||
},
|
||||
"200%": {
|
||||
"normal": "resources/light/icon@2x.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"style" : "dark",
|
||||
|
||||
"100%": {
|
||||
"normal": "resources/dark/icon.png"
|
||||
},
|
||||
"125%": {
|
||||
"normal": "resources/dark/icon@1.25x.png"
|
||||
},
|
||||
"150%": {
|
||||
"normal": "resources/dark/icon@1.5x.png"
|
||||
},
|
||||
"175%": {
|
||||
"normal": "resources/dark/icon@1.75x.png"
|
||||
},
|
||||
"200%": {
|
||||
"normal": "resources/dark/icon@2x.png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isViewer": false,
|
||||
"EditorsSupport": [ "word" ],
|
||||
"initDataType": "text",
|
||||
"initData": "",
|
||||
"isVisual": true,
|
||||
"isModal": false,
|
||||
"isInsideMode": true,
|
||||
"isUpdateOleOnResize": false,
|
||||
"initOnSelectionChanged": false
|
||||
}
|
||||
]
|
||||
}
|
||||
158
sdkjs-plugins/content/zotero/index.html
Normal file
@ -0,0 +1,158 @@
|
||||
<!--
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Zotero</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
<link rel="stylesheet" href="resources/css/plugin_style.css">
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
|
||||
<script src="scripts/thirdparty/fetch.umd.js"></script>
|
||||
<script src="scripts/thirdparty/promise-polyfill.min.js"></script>
|
||||
<script src="scripts/thirdparty/url-polyfill.min.js"></script>
|
||||
</head>
|
||||
<body id="body" spellcheck="false" class="noselect">
|
||||
<div id="errorWrapper" class="errorMsg display-none"></div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="mainCont" class="flexCol">
|
||||
|
||||
<div id="configState" class="display-none">
|
||||
<div><span class="i18n">To use Zotero you should get an API key.</span> <span class="i18n">Navigate to</span> <a class="i18n" target="_blank" href="https://www.zotero.org/settings/keys">Zotero API settings</a>. <span class="i18n">Create and copy API key into the field below.</span></div>
|
||||
<div class="mrtop label">
|
||||
<span class="i18n">API Key</span>
|
||||
<input id="apiKeyField" class="form-control" type="text" placeholder="API Key" style="width: 100%;"/>
|
||||
</div>
|
||||
<button id="saveConfigBtn" class="btn-text-default i18n" style="margin-top: 16px; width: 100%;">Save</button>
|
||||
</div>
|
||||
|
||||
<div id="mainState" class="flexCol flexSize display-none">
|
||||
<div id="selectedWrapper">
|
||||
<div class="flexCol flexSize flexCenter">
|
||||
<div id="selectedHolder"></div>
|
||||
</div>
|
||||
<div id="selectedThumb" class="scrollThumb display-none"></div>
|
||||
</div>
|
||||
<label id="searchLabel">
|
||||
<input id="searchField" autocomplete="off" class="form-control i18n" type="text" placeholder="Search references by author, title or year" style="width: 100%;"/>
|
||||
<span id="searchClear" class="display-none">×</span>
|
||||
</label>
|
||||
<div id="docsWrapper" class="flexSize">
|
||||
<div class="flexCol flexSize">
|
||||
<div id="docsHolder" class="flexCol"></div>
|
||||
<div class="flex flexCenter">
|
||||
<div id="libLoader" class="cssload-loading display-none"><i></i><i></i><i></i><i></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="docsThumb" class="scrollThumb display-none"></div>
|
||||
</div>
|
||||
<div id="controlsHolder" class="flexCol">
|
||||
<div id="buttonsWrapper" class="flex display-none" style="justify-content: space-between;">
|
||||
<div id="insertBibBtn" class="btn-text-default i18n" style="width: 45%">Insert Bibliography</div>
|
||||
<div id="cancelBtn" class="btn-text-default i18n" style="width: 45%">Cancel</div>
|
||||
</div>
|
||||
<div id="styleWrapper">
|
||||
<div class="label">
|
||||
<span class="i18n">Style</span>
|
||||
<div class="selectHolder">
|
||||
<input id="styleSelect" class="control select text i18n" type="text" placeholder="Enter style name">
|
||||
<div id="styleSelectList" class="selectList display-none">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="label">
|
||||
<span class="i18n">Language</span>
|
||||
<div class="selectHolder">
|
||||
<input id="styleLang" readonly class="control select" type="text">
|
||||
<div id="styleLangList" class="selectList display-none">
|
||||
<span data-value="af-ZA">Afrikaans</span>
|
||||
<span data-value="ar">Arabic</span>
|
||||
<span data-value="bg-BG">Bulgarian</span>
|
||||
<span data-value="ca-AD">Catalan</span>
|
||||
<span data-value="cs-CZ">Czech</span>
|
||||
<span data-value="cy-GB">Welsh</span>
|
||||
<span data-value="da-DK">Danish</span>
|
||||
<span data-value="de-AT">German (Austria)</span>
|
||||
<span data-value="de-CH">German (Switzerland)</span>
|
||||
<span data-value="de-DE">German (Germany)</span>
|
||||
<span data-value="el-GR">Greek</span>
|
||||
<span data-value="en-GB">English (UK)</span>
|
||||
<span selected data-value="en-US">English (US)</span>
|
||||
<span data-value="es-CL">Spanish (Chile)</span>
|
||||
<span data-value="es-ES">Spanish (Spain)</span>
|
||||
<span data-value="es-MX">Spanish (Mexico)</span>
|
||||
<span data-value="et-EE">Estonian</span>
|
||||
<span data-value="eu">Basque</span>
|
||||
<span data-value="fa-IR">Persian</span>
|
||||
<span data-value="fi-FI">Finnish</span>
|
||||
<span data-value="fr-CA">French (Canada)</span>
|
||||
<span data-value="fr-FR">French (France)</span>
|
||||
<span data-value="he-IL">Hebrew</span>
|
||||
<span data-value="hr-HR">Croatian</span>
|
||||
<span data-value="hu-HU">Hungarian</span>
|
||||
<span data-value="id-ID">Indonesian</span>
|
||||
<span data-value="is-IS">Icelandic</span>
|
||||
<span data-value="it-IT">Italian</span>
|
||||
<span data-value="ja-JP">Japanese</span>
|
||||
<span data-value="km-KH">Khmer</span>
|
||||
<span data-value="ko-KR">Korean</span>
|
||||
<span data-value="la">Latin</span>
|
||||
<span data-value="lt-LT">Lithuanian</span>
|
||||
<span data-value="lv-LV">Latvian</span>
|
||||
<span data-value="mn-MN">Mongolian</span>
|
||||
<span data-value="nb-NO">Norwegian (Bokmål)</span>
|
||||
<span data-value="nl-NL">Dutch</span>
|
||||
<span data-value="nn-NO">Norwegian (Nynorsk)</span>
|
||||
<span data-value="pl-PL">Polish</span>
|
||||
<span data-value="pt-BR">Portuguese (Brazil)</span>
|
||||
<span data-value="pt-PT">Portuguese (Portugal)</span>
|
||||
<span data-value="ro-RO">Romanian</span>
|
||||
<span data-value="ru-RU">Russian</span>
|
||||
<span data-value="sk-SK">Slovak</span>
|
||||
<span data-value="sl-SI">Slovenian</span>
|
||||
<span data-value="sr-RS">Serbian</span>
|
||||
<span data-value="sv-SE">Swedish</span>
|
||||
<span data-value="th-TH">Thai</span>
|
||||
<span data-value="tr-TR">Turkish</span>
|
||||
<span data-value="uk-UA">Ukrainian</span>
|
||||
<span data-value="vi-VN">Vietnamese</span>
|
||||
<span data-value="zh-CN">Chinese (PRC)</span>
|
||||
<span data-value="zh-TW">Chinese (Taiwan)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="footerCont">
|
||||
<span><a href="https://www.zotero.org/" target="_blank" id="zotero-link" class="link i18n">Open Zotero website</a></span>
|
||||
<span id="logoutLink" class="link display-none i18n">Reconfigure</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="scripts/zotero.js"></script>
|
||||
<script src="scripts/code.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
20
sdkjs-plugins/content/zotero/licenses/fetch-polyfill.license
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014-2016 GitHub, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014 Taylor Hakes
|
||||
Copyright (c) 2014 Forbes Lindesay
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
21
sdkjs-plugins/content/zotero/licenses/url-polyfill.license
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2017 Valentin Richard
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
564
sdkjs-plugins/content/zotero/resources/css/plugin_style.css
Normal file
@ -0,0 +1,564 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
flex-flow: column;
|
||||
display: flex;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
input::selection {
|
||||
background: #D8DADC; /* WebKit/Blink Browsers */
|
||||
}
|
||||
|
||||
input::-moz-selection {
|
||||
background: #D8DADC; /* Gecko Browsers */
|
||||
}
|
||||
|
||||
div::selection {
|
||||
background: #D8DADC; /* WebKit/Blink Browsers */
|
||||
}
|
||||
|
||||
div::-moz-selection {
|
||||
background: #D8DADC; /* Gecko Browsers */
|
||||
}
|
||||
|
||||
textarea:focus, input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
background: #fff;
|
||||
outline: none;
|
||||
font-size: 12px;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
margin: 15px 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 5px 18px;
|
||||
}
|
||||
|
||||
.button.wide {
|
||||
padding: 7px 13px;
|
||||
margin: 15px 0px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.blur {
|
||||
filter: blur(3px);
|
||||
}
|
||||
|
||||
.link {
|
||||
text-decoration: underline dotted;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flexSize {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flexCenter {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flexCol {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.mrtop {
|
||||
margin-top: 8px
|
||||
}
|
||||
|
||||
.control {
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #cfcfcf;
|
||||
border-radius: 2px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.control.select {
|
||||
cursor: pointer;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.control.text {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.control.text.wide {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
padding: 2px;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
#content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow-y: hidden;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
#searchField {
|
||||
width: 100%;
|
||||
padding-right: 18px;
|
||||
}
|
||||
|
||||
#searchLabel {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#searchClear {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 4px;
|
||||
font-family: Arial;
|
||||
font-size: 22px;
|
||||
line-height: 0;
|
||||
color: #BDBDBD;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mainCont {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#errorWrapper {
|
||||
background-color: #ffffff;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
#docsWrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 15px;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
#docsHolder {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#selectedWrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
overflow-y: hidden;
|
||||
max-height: 60px;
|
||||
}
|
||||
|
||||
#selectedHolder {
|
||||
width: 100%;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
#selectedHolder > div:last-of-type {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
#controlsHolder {
|
||||
border-top: 1px solid #cfcfcf;
|
||||
padding-top: 15px;
|
||||
overflow-y: visible;
|
||||
}
|
||||
|
||||
#buttonsWrapper {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
#buttonsWrapper > .button {
|
||||
margin: 0px 0px 15px 8px;
|
||||
}
|
||||
|
||||
#styleWrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#styleWrapper .label {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#styleWrapper .label:first-of-type {
|
||||
flex: 5;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#styleWrapper .label:last-of-type {
|
||||
flex: 4;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
#styleWrapper .label > span {
|
||||
color: #444444;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#styleWrapper .label input {
|
||||
width: 100%;
|
||||
padding-right: 18px;
|
||||
}
|
||||
|
||||
.selectHolder {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.selectArrow {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.selectArrow > span {
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 0.5px;
|
||||
margin: -1px;
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
.selectArrow > span:first-of-type {
|
||||
transform: rotateZ(45deg);
|
||||
}
|
||||
|
||||
.selectArrow > span:last-of-type {
|
||||
transform: rotateZ(-45deg);
|
||||
}
|
||||
|
||||
|
||||
#styleLangList {
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.selectList {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: absolute;
|
||||
border: 1px solid rgba(0,0,0,.15);
|
||||
border-radius: 4px;
|
||||
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
|
||||
box-shadow: 0 6px 12px rgba(0,0,0,.175);
|
||||
background: #ffffff;
|
||||
bottom: 22px;
|
||||
max-height: 158px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.selectList > span {
|
||||
padding: 5px 20px;
|
||||
cursor: pointer;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.selectList > span:hover {
|
||||
background-color: #d8dadc;
|
||||
color: #373737;
|
||||
}
|
||||
|
||||
.selectList > span[selected=""] {
|
||||
background-color: #7d858c;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.scrollThumb {
|
||||
width: 9px;
|
||||
background-color: rgb(241, 241, 241);
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAANCAQAAAAz1Zf0AAAAIUlEQVR42mNgAILz/0GQAQo+/gdBBqLAqE5ydH5k+sgEANHgUH2JtDRHAAAAAElFTkSuQmCC);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 center;
|
||||
border: 1px solid #cfcfcf;
|
||||
}
|
||||
|
||||
.scrollThumb.scrolling {
|
||||
background-color: #adadad;
|
||||
border-color: #adadad;
|
||||
}
|
||||
|
||||
.errorMsg {
|
||||
color: #D9534F;
|
||||
}
|
||||
|
||||
.searchDivider {
|
||||
color: #666666;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.doc {
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.docInfo {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.doc > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.secondary-text {
|
||||
font-size: 11px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.truncate-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#footerCont {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#footerCont > span:first-of-type {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* checkbox */
|
||||
|
||||
.checkbox {
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #CFCFCF;
|
||||
box-sizing: border-box;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.checkbox > input {
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.checkbox > span {
|
||||
background: url('../img/checkmark.png') no-repeat;
|
||||
display: none;
|
||||
width: 11px;
|
||||
height: 10px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
.checkbox > input:checked ~ span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn-text-default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.selDoc {
|
||||
display: inline-block;
|
||||
margin-bottom: 5px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.selDoc > span {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.selDoc > span:first-of-type {
|
||||
max-width: 52px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selDoc > span:last-of-type {
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* loader */
|
||||
.cssload-container {
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cssload-loading i {
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
display: inline-block;
|
||||
border-radius: 50%;
|
||||
background: rgb(68,68,68);
|
||||
}
|
||||
|
||||
.cssload-loading i:first-child {
|
||||
opacity: 0;
|
||||
animation: cssload-loading-ani2 0.58s linear infinite;
|
||||
-o-animation: cssload-loading-ani2 0.58s linear infinite;
|
||||
-ms-animation: cssload-loading-ani2 0.58s linear infinite;
|
||||
-webkit-animation: cssload-loading-ani2 0.58s linear infinite;
|
||||
-moz-animation: cssload-loading-ani2 0.58s linear infinite;
|
||||
transform: translate(-19px);
|
||||
-o-transform: translate(-19px);
|
||||
-ms-transform: translate(-19px);
|
||||
-webkit-transform: translate(-19px);
|
||||
-moz-transform: translate(-19px);
|
||||
}
|
||||
|
||||
.cssload-loading i:nth-child(2),
|
||||
.cssload-loading i:nth-child(3) {
|
||||
animation: cssload-loading-ani3 0.58s linear infinite;
|
||||
-o-animation: cssload-loading-ani3 0.58s linear infinite;
|
||||
-ms-animation: cssload-loading-ani3 0.58s linear infinite;
|
||||
-webkit-animation: cssload-loading-ani3 0.58s linear infinite;
|
||||
-moz-animation: cssload-loading-ani3 0.58s linear infinite;
|
||||
}
|
||||
|
||||
.cssload-loading i:last-child {
|
||||
animation: cssload-loading-ani1 0.58s linear infinite;
|
||||
-o-animation: cssload-loading-ani1 0.58s linear infinite;
|
||||
-ms-animation: cssload-loading-ani1 0.58s linear infinite;
|
||||
-webkit-animation: cssload-loading-ani1 0.58s linear infinite;
|
||||
-moz-animation: cssload-loading-ani1 0.58s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes cssload-loading-ani1 {
|
||||
100% {
|
||||
transform: translate(39px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-o-keyframes cssload-loading-ani1 {
|
||||
100% {
|
||||
-o-transform: translate(39px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-ms-keyframes cssload-loading-ani1 {
|
||||
100% {
|
||||
-ms-transform: translate(39px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes cssload-loading-ani1 {
|
||||
100% {
|
||||
-webkit-transform: translate(39px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes cssload-loading-ani1 {
|
||||
100% {
|
||||
-moz-transform: translate(39px);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes cssload-loading-ani2 {
|
||||
100% {
|
||||
transform: translate(19px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-o-keyframes cssload-loading-ani2 {
|
||||
100% {
|
||||
-o-transform: translate(19px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-ms-keyframes cssload-loading-ani2 {
|
||||
100% {
|
||||
-ms-transform: translate(19px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes cssload-loading-ani2 {
|
||||
100% {
|
||||
-webkit-transform: translate(19px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes cssload-loading-ani2 {
|
||||
100% {
|
||||
-moz-transform: translate(19px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes cssload-loading-ani3 {
|
||||
100% {
|
||||
transform: translate(19px);
|
||||
}
|
||||
}
|
||||
|
||||
@-o-keyframes cssload-loading-ani3 {
|
||||
100% {
|
||||
-o-transform: translate(19px);
|
||||
}
|
||||
}
|
||||
|
||||
@-ms-keyframes cssload-loading-ani3 {
|
||||
100% {
|
||||
-ms-transform: translate(19px);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes cssload-loading-ani3 {
|
||||
100% {
|
||||
-webkit-transform: translate(19px);
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes cssload-loading-ani3 {
|
||||
100% {
|
||||
-moz-transform: translate(19px);
|
||||
}
|
||||
}
|
||||
/* end loader */
|
||||
|
||||
.display-none {
|
||||
display: none;
|
||||
}
|
||||
BIN
sdkjs-plugins/content/zotero/resources/dark/icon.png
Normal file
|
After Width: | Height: | Size: 351 B |
BIN
sdkjs-plugins/content/zotero/resources/dark/icon@1.25x.png
Normal file
|
After Width: | Height: | Size: 404 B |
BIN
sdkjs-plugins/content/zotero/resources/dark/icon@1.5x.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
sdkjs-plugins/content/zotero/resources/dark/icon@1.75x.png
Normal file
|
After Width: | Height: | Size: 476 B |
BIN
sdkjs-plugins/content/zotero/resources/dark/icon@2x.png
Normal file
|
After Width: | Height: | Size: 521 B |
BIN
sdkjs-plugins/content/zotero/resources/img/checkmark.png
Normal file
|
After Width: | Height: | Size: 282 B |
BIN
sdkjs-plugins/content/zotero/resources/img/x.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
sdkjs-plugins/content/zotero/resources/light/icon.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
sdkjs-plugins/content/zotero/resources/light/icon@1.25x.png
Normal file
|
After Width: | Height: | Size: 438 B |
BIN
sdkjs-plugins/content/zotero/resources/light/icon@1.5x.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
sdkjs-plugins/content/zotero/resources/light/icon@1.75x.png
Normal file
|
After Width: | Height: | Size: 513 B |
BIN
sdkjs-plugins/content/zotero/resources/light/icon@2x.png
Normal file
|
After Width: | Height: | Size: 564 B |
774
sdkjs-plugins/content/zotero/scripts/code.js
Normal file
@ -0,0 +1,774 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
(function () {
|
||||
var displayNoneClass = "display-none";
|
||||
var blurClass = "blur";
|
||||
var waitForLoad = false;
|
||||
|
||||
var selected = {
|
||||
items: {},
|
||||
html: {},
|
||||
checks: {},
|
||||
count: function () {
|
||||
var k = 0;
|
||||
for (var i in selected.items) k++;
|
||||
return k;
|
||||
}
|
||||
};
|
||||
|
||||
var selectedLocale;
|
||||
var selectedStyle;
|
||||
|
||||
var sdk = null;
|
||||
|
||||
var lastSearch = {
|
||||
text: "",
|
||||
obj: null,
|
||||
groups: []
|
||||
};
|
||||
var elements = {
|
||||
libLoader: document.getElementById("libLoader"),
|
||||
error: document.getElementById("errorWrapper"),
|
||||
|
||||
contentHolder: document.getElementById("content"),
|
||||
docsHolder: document.getElementById("docsHolder"),
|
||||
docsThumb: document.getElementById("docsThumb"),
|
||||
|
||||
configState: document.getElementById("configState"),
|
||||
apiKeyConfigField: document.getElementById("apiKeyField"),
|
||||
saveConfigBtn: document.getElementById("saveConfigBtn"),
|
||||
|
||||
mainState: document.getElementById("mainState"),
|
||||
logoutLink: document.getElementById("logoutLink"),
|
||||
|
||||
selectedWrapper: document.getElementById("selectedWrapper"),
|
||||
selectedHolder: document.getElementById("selectedHolder"),
|
||||
selectedThumb: document.getElementById("selectedThumb"),
|
||||
buttonsWrapper: document.getElementById("buttonsWrapper"),
|
||||
|
||||
searchLabel: document.getElementById("searchLabel"),
|
||||
searchClear: document.getElementById("searchClear"),
|
||||
searchField: document.getElementById("searchField"),
|
||||
|
||||
styleWrapper: document.getElementById("styleWrapper"),
|
||||
styleSelectList: document.getElementById("styleSelectList"),
|
||||
styleSelect: document.getElementById("styleSelect"),
|
||||
styleLang: document.getElementById("styleLang"),
|
||||
|
||||
insertBibBtn: document.getElementById("insertBibBtn"),
|
||||
cancelBtn: document.getElementById("cancelBtn"),
|
||||
};
|
||||
|
||||
var selectedScroller;
|
||||
var docsScroller;
|
||||
|
||||
window.Asc.plugin.init = function () {
|
||||
sdk = window.Asc.plugin.zotero.api({});
|
||||
|
||||
window.Asc.plugin.onTranslate = applyTranslations;
|
||||
|
||||
elements.logoutLink.onclick = function (e) {
|
||||
sdk.clearSettings();
|
||||
switchAuthState('config');
|
||||
return true;
|
||||
};
|
||||
|
||||
function searchFor(text) {
|
||||
if (elements.mainState.classList.contains(displayNoneClass)) return;
|
||||
text = text.trim();
|
||||
if (!text) return;
|
||||
if (text == lastSearch.text) return;
|
||||
lastSearch.text = text;
|
||||
lastSearch.catObj = null;
|
||||
lastSearch.ownObj = null;
|
||||
|
||||
clearLibrary();
|
||||
|
||||
loadLibrary(sdk.items(text), true, true, false);
|
||||
var groups = sdk.getUserGropus();
|
||||
if (groups.length) {
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
loadLibrary(sdk.groups(lastSearch.text, groups[i]), true, false, (i == groups.length -1), true );
|
||||
}
|
||||
}
|
||||
};
|
||||
elements.searchField.onkeypress = function (e) {
|
||||
if (e.keyCode == 13) searchFor(e.target.value);
|
||||
};
|
||||
elements.searchField.onblur = function (e) {
|
||||
setTimeout(function () { searchFor(e.target.value); }, 500);
|
||||
};
|
||||
|
||||
elements.searchField.onkeyup = function (e) {
|
||||
switchClass(elements.searchClear, displayNoneClass, !e.target.value);
|
||||
};
|
||||
elements.searchClear.onclick = function (e) {
|
||||
if (e.target.classList.contains(displayNoneClass)) return true;
|
||||
switchClass(elements.searchClear, displayNoneClass, true);
|
||||
elements.searchField.value = "";
|
||||
lastSearch.text = "";
|
||||
clearLibrary();
|
||||
return true;
|
||||
};
|
||||
|
||||
elements.cancelBtn.onclick = function (e) {
|
||||
var ids = [];
|
||||
for (var id in selected.items) {
|
||||
ids.push(id);
|
||||
}
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
removeSelected(ids[i]);
|
||||
}
|
||||
};
|
||||
|
||||
elements.saveConfigBtn.onclick = function (e) {
|
||||
var apikey = elements.apiKeyConfigField.value.trim();
|
||||
if (apikey) {
|
||||
sdk.setApiKey(apikey)
|
||||
.then(function () {
|
||||
switchAuthState("main");
|
||||
}).catch(function () {
|
||||
showError(getMessage("Invalid API key"));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
elements.insertBibBtn.onclick = formatInsertBibliography;
|
||||
|
||||
selectedScroller = initScrollBox(elements.selectedHolder, elements.selectedThumb);
|
||||
docsScroller = initScrollBox(elements.docsHolder, elements.docsThumb, checkDocsScroll);
|
||||
|
||||
fetch("https://www.zotero.org/styles-files/styles.json")
|
||||
.then(function (resp) { return resp.json(); })
|
||||
.then(function (json) {
|
||||
var lastStyle = getLastUsedStyle();
|
||||
var found = false;
|
||||
|
||||
var onStyleSelect = function (f) {
|
||||
return function (ev) {
|
||||
var sel = ev.target.getAttribute("data-value");
|
||||
saveLastUsedStyle(sel);
|
||||
f(ev);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
if (json[i].dependent != 0) continue;
|
||||
|
||||
var el = document.createElement("span");
|
||||
el.setAttribute("data-value", json[i].name);
|
||||
el.textContent = json[i].title;
|
||||
elements.styleSelectList.appendChild(el);
|
||||
el.onclick = onStyleSelect(onClickListElement(elements.styleSelectList, elements.styleSelect));
|
||||
if (json[i].name == lastStyle) {
|
||||
el.setAttribute("selected", "");
|
||||
selectInput(elements.styleSelect, el, elements.styleSelectList);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
var first = elements.styleSelectList.children[0];
|
||||
first.setAttribute("selected", "");
|
||||
selectInput(elements.styleSelect, first, elements.styleSelectList);
|
||||
}
|
||||
})
|
||||
.catch(function (err) { });
|
||||
|
||||
elements.styleSelect.onkeyup = function () {
|
||||
var input = elements.styleSelect;
|
||||
var filter = input.value.toLowerCase();
|
||||
var list = elements.styleSelectList;
|
||||
|
||||
for (var i = 0; i < list.children.length; i++) {
|
||||
var text = list.children[i].textContent || list.children[i].innerText;
|
||||
var hide = true;
|
||||
if (!filter || text.toLowerCase().indexOf(filter) > -1) {
|
||||
hide = false;
|
||||
}
|
||||
switchClass(list.children[i], displayNoneClass, hide);
|
||||
}
|
||||
}
|
||||
|
||||
elements.styleSelect.onselectchange = function (inp, val) {
|
||||
selectedStyle = val;
|
||||
};
|
||||
elements.styleLang.onselectchange = function (inp, val) {
|
||||
selectedLocale = val;
|
||||
};
|
||||
|
||||
initSelectBoxes();
|
||||
elements.styleSelectList.onopen = function () {
|
||||
elements.styleSelectList.style.width = (elements.styleWrapper.clientWidth - 2) + "px";
|
||||
}
|
||||
|
||||
if (sdk.hasSettings()) {
|
||||
switchAuthState('main');
|
||||
} else {
|
||||
switchAuthState('config');
|
||||
}
|
||||
};
|
||||
window.Asc.plugin.onThemeChanged = function(theme)
|
||||
{
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
var rules = '.selectArrow > span { background-color: ' + window.Asc.plugin.theme['text-normal'] + '}\n';
|
||||
rules += '.link { color : ' + window.Asc.plugin.theme['text-normal'] + ';}\n';
|
||||
rules += '.control.select { background-color : ' + window.Asc.plugin.theme['background-normal'] + ';}\n';
|
||||
rules += '.control { color : ' + window.Asc.plugin.theme['text-normal'] + '; border-color : ' + window.Asc.plugin.theme['border-regular-control'] + '}\n';
|
||||
rules += '.selectList > span { background-color: ' + window.Asc.plugin.theme['background-normal'] + '; ';
|
||||
rules += 'color : ' + window.Asc.plugin.theme['text-normal'] + '; }\n';
|
||||
rules += '.selectList > span:hover { background-color : ' + window.Asc.plugin.theme['highlight-button-hover'] + '; color : ' + window.Asc.plugin.theme['text-normal'] + '}\n';
|
||||
rules += '.selectList > span[selected=""] { background-color : ' + window.Asc.plugin.theme['highlight-button-pressed'] + ';' + '; color : ' + window.Asc.plugin.theme['text-normal'] + '}';
|
||||
var styleTheme = document.createElement('style');
|
||||
styleTheme.type = 'text/css';
|
||||
styleTheme.innerHTML = rules;
|
||||
document.getElementsByTagName('head')[0].appendChild(styleTheme);
|
||||
};
|
||||
var scrollBoxes = [];
|
||||
function initScrollBox(holder, thumb, onscroll) {
|
||||
var scroller = {};
|
||||
scroller.onscroll = checkScroll(holder, thumb, onscroll);
|
||||
|
||||
holder.onwheel = function (e) {
|
||||
holder.scrollTop += (e.deltaY > 10 || e.deltaY < -10) ? e.deltaY : e.deltaY * 20;
|
||||
scroller.onscroll();
|
||||
};
|
||||
|
||||
thumb.onmousedown = function (e) {
|
||||
switchClass(thumb, "scrolling", true);
|
||||
var y = e.clientY;
|
||||
var initialPos = holder.scrollTop;
|
||||
|
||||
window.onmouseup = function (e) {
|
||||
switchClass(thumb, "scrolling", false);
|
||||
window.onmouseup = null;
|
||||
window.onmousemove = null;
|
||||
}
|
||||
window.onmousemove = function (e) {
|
||||
var delta = e.clientY - y;
|
||||
|
||||
var percMoved = delta / holder.clientHeight;
|
||||
var deltaScroll = holder.scrollHeight * percMoved;
|
||||
holder.scrollTop = initialPos + deltaScroll;
|
||||
|
||||
scroller.onscroll();
|
||||
}
|
||||
}
|
||||
|
||||
scrollBoxes.push(scroller);
|
||||
|
||||
document.body.onresize = function () {
|
||||
for (var i = 0; i < scrollBoxes.length; i++) {
|
||||
scrollBoxes[i].onscroll();
|
||||
}
|
||||
}
|
||||
|
||||
return scroller;
|
||||
}
|
||||
|
||||
var selectLists = [];
|
||||
function initSelectBoxes() {
|
||||
var select = document.getElementsByClassName("control select");
|
||||
for (var i = 0; i < select.length; i++) {
|
||||
var input = select[i];
|
||||
var holder = input.parentElement;
|
||||
var arrow = document.createElement("span");
|
||||
arrow.classList.add("selectArrow");
|
||||
arrow.appendChild(document.createElement("span"));
|
||||
arrow.appendChild(document.createElement("span"));
|
||||
holder.appendChild(arrow);
|
||||
|
||||
var list = holder.getElementsByClassName("selectList")[0];
|
||||
if (list.children.length > 0) {
|
||||
var def = false;
|
||||
for (var j = 0; j < list.children.length; j++) {
|
||||
if (list.children[j].hasAttribute("selected")) {
|
||||
selectInput(input, list.children[j], list);
|
||||
def = true;
|
||||
}
|
||||
|
||||
list.children[j].onclick = onClickListElement(list, input);
|
||||
}
|
||||
if (!def) {
|
||||
selectInput(input, list.children[0], list);
|
||||
}
|
||||
}
|
||||
|
||||
var f = function (list, input) {
|
||||
return function (ev) {
|
||||
ev.stopPropagation();
|
||||
if (list.onopen) {
|
||||
list.onopen();
|
||||
}
|
||||
if (!input.hasAttribute("readonly")) {
|
||||
input.select();
|
||||
}
|
||||
openList(list);
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
input.onclick = f(list, input);
|
||||
arrow.onclick = f(list, input);
|
||||
selectLists.push(list);
|
||||
}
|
||||
|
||||
window.onclick = function () {
|
||||
openList(null);
|
||||
}
|
||||
}
|
||||
|
||||
function openList(el) {
|
||||
for (var i = 0; i < selectLists.length; i++) {
|
||||
var close = true;
|
||||
if (selectLists[i] === el) {
|
||||
close = false;
|
||||
}
|
||||
switchClass(selectLists[i], displayNoneClass, close);
|
||||
}
|
||||
}
|
||||
|
||||
function selectInput(input, el, list) {
|
||||
input.value = el.textContent;
|
||||
var val = el.getAttribute("data-value");
|
||||
input.setAttribute("data-value", val);
|
||||
input.setAttribute("title", el.textContent);
|
||||
if (input.onselectchange) {
|
||||
input.onselectchange(input, val);
|
||||
}
|
||||
switchClass(list, displayNoneClass, true);
|
||||
};
|
||||
|
||||
function onClickListElement(list, input) {
|
||||
return function (ev) {
|
||||
var sel = ev.target.getAttribute("data-value");
|
||||
for (var i = 0; i < list.children.length; i++) {
|
||||
if (list.children[i].getAttribute("data-value") == sel) {
|
||||
list.children[i].setAttribute("selected", "");
|
||||
selectInput(input, list.children[i], list);
|
||||
} else {
|
||||
if (list.children[i].hasAttribute("selected")) {
|
||||
list.children[i].attributes.removeNamedItem("selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function applyTranslations() {
|
||||
var elements = document.getElementsByClassName("i18n");
|
||||
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var el = elements[i];
|
||||
if (el.attributes["placeholder"]) el.attributes["placeholder"].value = getMessage(el.attributes["placeholder"].value);
|
||||
if (el.innerText) el.innerText = getMessage(el.innerText);
|
||||
}
|
||||
}
|
||||
|
||||
function getMessage(key) {
|
||||
return window.Asc.plugin.tr(key);
|
||||
}
|
||||
|
||||
function saveLastUsedStyle(id) {
|
||||
localStorage.setItem("zoteroStyleId", id);
|
||||
}
|
||||
|
||||
function getLastUsedStyle() {
|
||||
return localStorage.getItem("zoteroStyleId");
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
if (message) {
|
||||
switchClass(elements.error, displayNoneClass, false);
|
||||
elements.error.textContent = message;
|
||||
setTimeout(function () { window.onclick = function () { showError(); }; }, 100);
|
||||
} else {
|
||||
switchClass(elements.error, displayNoneClass, true);
|
||||
elements.error.textContent = "";
|
||||
window.onclick = null;
|
||||
}
|
||||
}
|
||||
|
||||
function showLibLoader(show) {
|
||||
switchClass(elements.libLoader, displayNoneClass, !show);
|
||||
}
|
||||
|
||||
function switchClass(el, className, add) {
|
||||
if (add) {
|
||||
el.classList.add(className);
|
||||
} else {
|
||||
el.classList.remove(className);
|
||||
}
|
||||
}
|
||||
|
||||
function configState(hide) {
|
||||
switchClass(elements.configState, displayNoneClass, hide);
|
||||
}
|
||||
|
||||
function mainState(hide) {
|
||||
switchClass(elements.mainState, displayNoneClass, hide);
|
||||
switchClass(elements.logoutLink, displayNoneClass, hide);
|
||||
}
|
||||
|
||||
var currentAuthState;
|
||||
function switchAuthState(state) {
|
||||
currentAuthState = state;
|
||||
configState(true);
|
||||
mainState(true);
|
||||
switch (state) {
|
||||
case 'config':
|
||||
configState(false);
|
||||
break;
|
||||
case 'main':
|
||||
mainState(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function checkScroll(holder, thumb, func) {
|
||||
return function () {
|
||||
if (holder.scrollHeight <= holder.clientHeight) {
|
||||
switchClass(thumb, displayNoneClass, true);
|
||||
} else {
|
||||
switchClass(thumb, displayNoneClass, false);
|
||||
var height = holder.clientHeight / holder.scrollHeight * holder.clientHeight;
|
||||
height = height < 40 ? 40 : height;
|
||||
thumb.style.height = height + "px";
|
||||
|
||||
var scroll = holder.scrollHeight - holder.clientHeight;
|
||||
var percScrolled = holder.scrollTop / scroll;
|
||||
|
||||
var margin = percScrolled * (holder.clientHeight - height);
|
||||
thumb.style.marginTop = margin + "px";
|
||||
}
|
||||
|
||||
if (func) func(holder, thumb);
|
||||
}
|
||||
}
|
||||
|
||||
var loadTimeout = null;
|
||||
function checkDocsScroll(holder) {
|
||||
if (shouldLoadMore(holder)) {
|
||||
|
||||
if (loadTimeout) {
|
||||
clearTimeout(loadTimeout);
|
||||
}
|
||||
|
||||
if (!lastSearch.obj && !lastSearch.text.trim() && !lastSearch.groups.length) return;
|
||||
|
||||
waitForLoad = true;
|
||||
loadTimeout = setTimeout(function () {
|
||||
if (shouldLoadMore(holder)) {
|
||||
loadLibrary(lastSearch.obj.next(), true, true, lastSearch.groups.length);
|
||||
for (var i = 0; (i < lastSearch.groups.length && lastSearch.groups[i].next); i++) {
|
||||
loadLibrary(sdk.groups(lastSearch.groups[i].next()), true, false, (i == lastSearch.groups.length -1), true );
|
||||
}
|
||||
} else {
|
||||
waitForLoad = false;
|
||||
}
|
||||
}, 500);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function shouldLoadMore(holder) {
|
||||
if (currentAuthState != "main") return false;
|
||||
if (holder.scrollTop + holder.clientHeight < holder.scrollHeight) return false;
|
||||
var flag = true;
|
||||
lastSearch.groups.forEach(function(el) {
|
||||
if (el.next) flag = false;
|
||||
});
|
||||
if (!lastSearch.obj || !lastSearch.obj.next || !flag) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function clearLibrary() {
|
||||
var holder = elements.docsHolder;
|
||||
while (holder.lastChild) {
|
||||
holder.removeChild(holder.lastChild);
|
||||
}
|
||||
holder.scrollTop = 0;
|
||||
lastSearch.catObj = null;
|
||||
lastSearch.ownObj = null;
|
||||
docsScroller.onscroll();
|
||||
}
|
||||
|
||||
function loadLibrary(promise, append, showLoader, hideLoader, isGroup) {
|
||||
if (showLoader) showLibLoader(true);
|
||||
promise
|
||||
.then(function (res) {
|
||||
displaySearchItems(append, res, null, hideLoader, isGroup);
|
||||
})
|
||||
.catch(function (err) {
|
||||
displaySearchItems(append, null, err.message, hideLoader, isGroup);
|
||||
})
|
||||
.finally(function () {
|
||||
if (hideLoader) {
|
||||
showLibLoader(false);
|
||||
waitForLoad = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function displaySearchItems(append, res, err, showNotFound, isGroup) {
|
||||
var holder = elements.docsHolder;
|
||||
|
||||
if (!append) {
|
||||
clearLibrary();
|
||||
}
|
||||
|
||||
var first = false;
|
||||
if (!lastSearch.obj && (res.items && !res.items.length) ) first = true;
|
||||
if (err) {
|
||||
if (first) {
|
||||
lastSearch.obj = {};
|
||||
lastSearch.groups = [];
|
||||
}
|
||||
lastSearch.obj.next = null;
|
||||
} else {
|
||||
if (isGroup)
|
||||
lastSearch.groups.push(res);
|
||||
else
|
||||
lastSearch.obj = res;
|
||||
}
|
||||
|
||||
var page = document.createElement("div");
|
||||
page.classList.add("page" + holder.children.length);
|
||||
if (res && res.items.length > 0) {
|
||||
for (var i in res.items) {
|
||||
page.appendChild(buildDocElement(res.items[i]));
|
||||
}
|
||||
} else if (err || first) {
|
||||
if (err) {
|
||||
showError(err);
|
||||
} else if (showNotFound) {
|
||||
var notFound = document.createElement("div");
|
||||
notFound.textContent = getMessage("Nothing found");
|
||||
notFound.classList.add("searchInfo");
|
||||
page.appendChild(notFound);
|
||||
}
|
||||
}
|
||||
holder.appendChild(page);
|
||||
|
||||
docsScroller.onscroll();
|
||||
}
|
||||
|
||||
function buildDocElement(item) {
|
||||
var root = document.createElement("div");
|
||||
root.classList.add("doc");
|
||||
|
||||
var checkHolder = document.createElement("div");
|
||||
var checkWrapper = document.createElement("div");
|
||||
checkWrapper.classList.add("checkbox");
|
||||
var check = document.createElement("input");
|
||||
check.setAttribute("type", "checkbox");
|
||||
if (selected.items[item.key]) {
|
||||
check.checked = true;
|
||||
selected.checks[item.key] = check;
|
||||
}
|
||||
checkWrapper.appendChild(check);
|
||||
checkWrapper.appendChild(document.createElement("span"));
|
||||
checkHolder.appendChild(checkWrapper);
|
||||
|
||||
var docInfo = document.createElement("div");
|
||||
docInfo.classList.add("docInfo");
|
||||
|
||||
var title = document.createElement("div");
|
||||
title.textContent = item.data.title;
|
||||
title.classList.add("truncate-text");
|
||||
docInfo.appendChild(title);
|
||||
|
||||
if (item.data.creators && item.data.creators.length > 0) {
|
||||
var authors = document.createElement("div");
|
||||
authors.textContent = item.data.creators
|
||||
.map(function (a) {
|
||||
if (a.name) return a.name;
|
||||
return a.lastName + ", " + a.firstName;
|
||||
})
|
||||
.join("; ");
|
||||
authors.setAttribute("title", authors.textContent);
|
||||
authors.classList.add("secondary-text");
|
||||
authors.classList.add("truncate-text");
|
||||
authors.classList.add("nowrap");
|
||||
docInfo.appendChild(authors);
|
||||
}
|
||||
|
||||
var source = document.createElement("div");
|
||||
if (item.data.publisher || item.data.place) {
|
||||
source.textContent = item.data.publisher || item.data.place;
|
||||
}
|
||||
if (item.data.date) {
|
||||
if (source.textContent) {
|
||||
source.textContent += " (" + item.data.date + ")";
|
||||
} else {
|
||||
source.textContent = item.data.date;
|
||||
}
|
||||
}
|
||||
source.setAttribute("title", source.textContent);
|
||||
source.classList.add("secondary-text");
|
||||
source.classList.add("truncate-text");
|
||||
source.classList.add("nowrap");
|
||||
docInfo.appendChild(source);
|
||||
|
||||
root.appendChild(checkHolder);
|
||||
root.appendChild(docInfo);
|
||||
|
||||
function selectItem(input, item) {
|
||||
return function (e) {
|
||||
input.checked = !input.checked;
|
||||
if (input.checked) {
|
||||
addSelected(item, input);
|
||||
} else {
|
||||
removeSelected(item.key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var f = selectItem(check, item);
|
||||
checkWrapper.onclick = f;
|
||||
docInfo.onclick = f;
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
function addSelected(item, input) {
|
||||
var el = buildSelectedElement(item);
|
||||
selected.items[item.key] = item;
|
||||
selected.html[item.key] = el;
|
||||
selected.checks[item.key] = input;
|
||||
elements.selectedHolder.appendChild(el);
|
||||
docsScroller.onscroll();
|
||||
selectedScroller.onscroll();
|
||||
checkSelected();
|
||||
}
|
||||
|
||||
function removeSelected(key) {
|
||||
var el = selected.html[key];
|
||||
delete selected.items[key];
|
||||
delete selected.html[key];
|
||||
if (selected.checks[key]) {
|
||||
selected.checks[key].checked = false;
|
||||
delete selected.checks[key];
|
||||
}
|
||||
elements.selectedHolder.removeChild(el);
|
||||
docsScroller.onscroll();
|
||||
selectedScroller.onscroll();
|
||||
checkSelected();
|
||||
}
|
||||
|
||||
function buildSelectedElement(item) {
|
||||
var root = document.createElement("div");
|
||||
root.classList.add("selDoc");
|
||||
|
||||
var name = document.createElement("span");
|
||||
name.textContent = item.data.title;
|
||||
name.setAttribute("title", item.data.title);
|
||||
|
||||
var year = document.createElement("span");
|
||||
if (item.data.date) {
|
||||
year.textContent = item.data.date;
|
||||
}
|
||||
|
||||
var remove = document.createElement("span");
|
||||
remove.onclick = function () {
|
||||
removeSelected(item.key);
|
||||
};
|
||||
remove.textContent = '×';
|
||||
|
||||
root.appendChild(name);
|
||||
root.appendChild(year);
|
||||
root.appendChild(remove);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
function checkSelected() {
|
||||
switchClass(elements.buttonsWrapper, displayNoneClass, selected.count() <= 0);
|
||||
}
|
||||
|
||||
function formatInsertBibliography() {
|
||||
if (!selectedStyle) {
|
||||
showError(getMessage("Style is not selected"));
|
||||
return;
|
||||
}
|
||||
if (!selectedLocale) {
|
||||
showError(getMessage("Language is not selected"));
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = {
|
||||
users: {
|
||||
keys : [],
|
||||
},
|
||||
groups: {}
|
||||
};
|
||||
for (const key in selected.items) {
|
||||
if (Object.hasOwnProperty.call(selected.items, key)) {
|
||||
const el = selected.items[key];
|
||||
if (el.library.type == "user") {
|
||||
obj.users.keys.push(key);
|
||||
} else if (el.library.type == "group") {
|
||||
if (obj.groups[el.library.id]) {
|
||||
obj.groups[el.library.id].keys.push(key);
|
||||
} else {
|
||||
obj.groups[el.library.id] = {
|
||||
keys: [key]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.users.keys.length) {
|
||||
sdk.format(obj.users.keys, null, selectedStyle, selectedLocale)
|
||||
.then(function (res) {
|
||||
insertInDocument(res);
|
||||
})
|
||||
.catch(function (err) {
|
||||
showError(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.keys(obj.groups).length != 0) {
|
||||
for (const key in obj.groups) {
|
||||
if (Object.hasOwnProperty.call(obj.groups, key)) {
|
||||
const element = obj.groups[key];
|
||||
sdk.format(element.keys, key, selectedStyle, selectedLocale)
|
||||
.then(function (res) {
|
||||
insertInDocument(res);
|
||||
})
|
||||
.catch(function (err) {
|
||||
showError(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function insertInDocument(html) {
|
||||
if (html) {
|
||||
window.Asc.plugin.executeMethod("PasteHtml", [html]);
|
||||
} else {
|
||||
showError(getMessage("Bibliography cannot be created with selected style"));
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
612
sdkjs-plugins/content/zotero/scripts/thirdparty/fetch.umd.js
vendored
Normal file
@ -0,0 +1,612 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.WHATWGFetch = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var global =
|
||||
(typeof globalThis !== 'undefined' && globalThis) ||
|
||||
(typeof self !== 'undefined' && self) ||
|
||||
(typeof global !== 'undefined' && global);
|
||||
|
||||
var support = {
|
||||
searchParams: 'URLSearchParams' in global,
|
||||
iterable: 'Symbol' in global && 'iterator' in Symbol,
|
||||
blob:
|
||||
'FileReader' in global &&
|
||||
'Blob' in global &&
|
||||
(function() {
|
||||
try {
|
||||
new Blob();
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
})(),
|
||||
formData: 'FormData' in global,
|
||||
arrayBuffer: 'ArrayBuffer' in global
|
||||
};
|
||||
|
||||
function isDataView(obj) {
|
||||
return obj && DataView.prototype.isPrototypeOf(obj)
|
||||
}
|
||||
|
||||
if (support.arrayBuffer) {
|
||||
var viewClasses = [
|
||||
'[object Int8Array]',
|
||||
'[object Uint8Array]',
|
||||
'[object Uint8ClampedArray]',
|
||||
'[object Int16Array]',
|
||||
'[object Uint16Array]',
|
||||
'[object Int32Array]',
|
||||
'[object Uint32Array]',
|
||||
'[object Float32Array]',
|
||||
'[object Float64Array]'
|
||||
];
|
||||
|
||||
var isArrayBufferView =
|
||||
ArrayBuffer.isView ||
|
||||
function(obj) {
|
||||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeName(name) {
|
||||
if (typeof name !== 'string') {
|
||||
name = String(name);
|
||||
}
|
||||
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
|
||||
throw new TypeError('Invalid character in header field name')
|
||||
}
|
||||
return name.toLowerCase()
|
||||
}
|
||||
|
||||
function normalizeValue(value) {
|
||||
if (typeof value !== 'string') {
|
||||
value = String(value);
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// Build a destructive iterator for the value list
|
||||
function iteratorFor(items) {
|
||||
var iterator = {
|
||||
next: function() {
|
||||
var value = items.shift();
|
||||
return {done: value === undefined, value: value}
|
||||
}
|
||||
};
|
||||
|
||||
if (support.iterable) {
|
||||
iterator[Symbol.iterator] = function() {
|
||||
return iterator
|
||||
};
|
||||
}
|
||||
|
||||
return iterator
|
||||
}
|
||||
|
||||
function Headers(headers) {
|
||||
this.map = {};
|
||||
|
||||
if (headers instanceof Headers) {
|
||||
headers.forEach(function(value, name) {
|
||||
this.append(name, value);
|
||||
}, this);
|
||||
} else if (Array.isArray(headers)) {
|
||||
headers.forEach(function(header) {
|
||||
this.append(header[0], header[1]);
|
||||
}, this);
|
||||
} else if (headers) {
|
||||
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
||||
this.append(name, headers[name]);
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
Headers.prototype.append = function(name, value) {
|
||||
name = normalizeName(name);
|
||||
value = normalizeValue(value);
|
||||
var oldValue = this.map[name];
|
||||
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
||||
};
|
||||
|
||||
Headers.prototype['delete'] = function(name) {
|
||||
delete this.map[normalizeName(name)];
|
||||
};
|
||||
|
||||
Headers.prototype.get = function(name) {
|
||||
name = normalizeName(name);
|
||||
return this.has(name) ? this.map[name] : null
|
||||
};
|
||||
|
||||
Headers.prototype.has = function(name) {
|
||||
return this.map.hasOwnProperty(normalizeName(name))
|
||||
};
|
||||
|
||||
Headers.prototype.set = function(name, value) {
|
||||
this.map[normalizeName(name)] = normalizeValue(value);
|
||||
};
|
||||
|
||||
Headers.prototype.forEach = function(callback, thisArg) {
|
||||
for (var name in this.map) {
|
||||
if (this.map.hasOwnProperty(name)) {
|
||||
callback.call(thisArg, this.map[name], name, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Headers.prototype.keys = function() {
|
||||
var items = [];
|
||||
this.forEach(function(value, name) {
|
||||
items.push(name);
|
||||
});
|
||||
return iteratorFor(items)
|
||||
};
|
||||
|
||||
Headers.prototype.values = function() {
|
||||
var items = [];
|
||||
this.forEach(function(value) {
|
||||
items.push(value);
|
||||
});
|
||||
return iteratorFor(items)
|
||||
};
|
||||
|
||||
Headers.prototype.entries = function() {
|
||||
var items = [];
|
||||
this.forEach(function(value, name) {
|
||||
items.push([name, value]);
|
||||
});
|
||||
return iteratorFor(items)
|
||||
};
|
||||
|
||||
if (support.iterable) {
|
||||
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
||||
}
|
||||
|
||||
function consumed(body) {
|
||||
if (body.bodyUsed) {
|
||||
return Promise.reject(new TypeError('Already read'))
|
||||
}
|
||||
body.bodyUsed = true;
|
||||
}
|
||||
|
||||
function fileReaderReady(reader) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
reader.onload = function() {
|
||||
resolve(reader.result);
|
||||
};
|
||||
reader.onerror = function() {
|
||||
reject(reader.error);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
function readBlobAsArrayBuffer(blob) {
|
||||
var reader = new FileReader();
|
||||
var promise = fileReaderReady(reader);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
return promise
|
||||
}
|
||||
|
||||
function readBlobAsText(blob) {
|
||||
var reader = new FileReader();
|
||||
var promise = fileReaderReady(reader);
|
||||
reader.readAsText(blob);
|
||||
return promise
|
||||
}
|
||||
|
||||
function readArrayBufferAsText(buf) {
|
||||
var view = new Uint8Array(buf);
|
||||
var chars = new Array(view.length);
|
||||
|
||||
for (var i = 0; i < view.length; i++) {
|
||||
chars[i] = String.fromCharCode(view[i]);
|
||||
}
|
||||
return chars.join('')
|
||||
}
|
||||
|
||||
function bufferClone(buf) {
|
||||
if (buf.slice) {
|
||||
return buf.slice(0)
|
||||
} else {
|
||||
var view = new Uint8Array(buf.byteLength);
|
||||
view.set(new Uint8Array(buf));
|
||||
return view.buffer
|
||||
}
|
||||
}
|
||||
|
||||
function Body() {
|
||||
this.bodyUsed = false;
|
||||
|
||||
this._initBody = function(body) {
|
||||
/*
|
||||
fetch-mock wraps the Response object in an ES6 Proxy to
|
||||
provide useful test harness features such as flush. However, on
|
||||
ES5 browsers without fetch or Proxy support pollyfills must be used;
|
||||
the proxy-pollyfill is unable to proxy an attribute unless it exists
|
||||
on the object before the Proxy is created. This change ensures
|
||||
Response.bodyUsed exists on the instance, while maintaining the
|
||||
semantic of setting Request.bodyUsed in the constructor before
|
||||
_initBody is called.
|
||||
*/
|
||||
this.bodyUsed = this.bodyUsed;
|
||||
this._bodyInit = body;
|
||||
if (!body) {
|
||||
this._bodyText = '';
|
||||
} else if (typeof body === 'string') {
|
||||
this._bodyText = body;
|
||||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
||||
this._bodyBlob = body;
|
||||
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
||||
this._bodyFormData = body;
|
||||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
||||
this._bodyText = body.toString();
|
||||
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
||||
this._bodyArrayBuffer = bufferClone(body.buffer);
|
||||
// IE 10-11 can't handle a DataView body.
|
||||
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
||||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
||||
this._bodyArrayBuffer = bufferClone(body);
|
||||
} else {
|
||||
this._bodyText = body = Object.prototype.toString.call(body);
|
||||
}
|
||||
|
||||
if (!this.headers.get('content-type')) {
|
||||
if (typeof body === 'string') {
|
||||
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
||||
} else if (this._bodyBlob && this._bodyBlob.type) {
|
||||
this.headers.set('content-type', this._bodyBlob.type);
|
||||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
||||
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (support.blob) {
|
||||
this.blob = function() {
|
||||
var rejected = consumed(this);
|
||||
if (rejected) {
|
||||
return rejected
|
||||
}
|
||||
|
||||
if (this._bodyBlob) {
|
||||
return Promise.resolve(this._bodyBlob)
|
||||
} else if (this._bodyArrayBuffer) {
|
||||
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
||||
} else if (this._bodyFormData) {
|
||||
throw new Error('could not read FormData body as blob')
|
||||
} else {
|
||||
return Promise.resolve(new Blob([this._bodyText]))
|
||||
}
|
||||
};
|
||||
|
||||
this.arrayBuffer = function() {
|
||||
if (this._bodyArrayBuffer) {
|
||||
var isConsumed = consumed(this);
|
||||
if (isConsumed) {
|
||||
return isConsumed
|
||||
}
|
||||
if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
||||
return Promise.resolve(
|
||||
this._bodyArrayBuffer.buffer.slice(
|
||||
this._bodyArrayBuffer.byteOffset,
|
||||
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
||||
)
|
||||
)
|
||||
} else {
|
||||
return Promise.resolve(this._bodyArrayBuffer)
|
||||
}
|
||||
} else {
|
||||
return this.blob().then(readBlobAsArrayBuffer)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.text = function() {
|
||||
var rejected = consumed(this);
|
||||
if (rejected) {
|
||||
return rejected
|
||||
}
|
||||
|
||||
if (this._bodyBlob) {
|
||||
return readBlobAsText(this._bodyBlob)
|
||||
} else if (this._bodyArrayBuffer) {
|
||||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
||||
} else if (this._bodyFormData) {
|
||||
throw new Error('could not read FormData body as text')
|
||||
} else {
|
||||
return Promise.resolve(this._bodyText)
|
||||
}
|
||||
};
|
||||
|
||||
if (support.formData) {
|
||||
this.formData = function() {
|
||||
return this.text().then(decode)
|
||||
};
|
||||
}
|
||||
|
||||
this.json = function() {
|
||||
return this.text().then(JSON.parse)
|
||||
};
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
// HTTP methods whose capitalization should be normalized
|
||||
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
||||
|
||||
function normalizeMethod(method) {
|
||||
var upcased = method.toUpperCase();
|
||||
return methods.indexOf(upcased) > -1 ? upcased : method
|
||||
}
|
||||
|
||||
function Request(input, options) {
|
||||
if (!(this instanceof Request)) {
|
||||
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
var body = options.body;
|
||||
|
||||
if (input instanceof Request) {
|
||||
if (input.bodyUsed) {
|
||||
throw new TypeError('Already read')
|
||||
}
|
||||
this.url = input.url;
|
||||
this.credentials = input.credentials;
|
||||
if (!options.headers) {
|
||||
this.headers = new Headers(input.headers);
|
||||
}
|
||||
this.method = input.method;
|
||||
this.mode = input.mode;
|
||||
this.signal = input.signal;
|
||||
if (!body && input._bodyInit != null) {
|
||||
body = input._bodyInit;
|
||||
input.bodyUsed = true;
|
||||
}
|
||||
} else {
|
||||
this.url = String(input);
|
||||
}
|
||||
|
||||
this.credentials = options.credentials || this.credentials || 'same-origin';
|
||||
if (options.headers || !this.headers) {
|
||||
this.headers = new Headers(options.headers);
|
||||
}
|
||||
this.method = normalizeMethod(options.method || this.method || 'GET');
|
||||
this.mode = options.mode || this.mode || null;
|
||||
this.signal = options.signal || this.signal;
|
||||
this.referrer = null;
|
||||
|
||||
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
||||
throw new TypeError('Body not allowed for GET or HEAD requests')
|
||||
}
|
||||
this._initBody(body);
|
||||
|
||||
if (this.method === 'GET' || this.method === 'HEAD') {
|
||||
if (options.cache === 'no-store' || options.cache === 'no-cache') {
|
||||
// Search for a '_' parameter in the query string
|
||||
var reParamSearch = /([?&])_=[^&]*/;
|
||||
if (reParamSearch.test(this.url)) {
|
||||
// If it already exists then set the value with the current time
|
||||
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
|
||||
} else {
|
||||
// Otherwise add a new '_' parameter to the end with the current time
|
||||
var reQueryString = /\?/;
|
||||
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Request.prototype.clone = function() {
|
||||
return new Request(this, {body: this._bodyInit})
|
||||
};
|
||||
|
||||
function decode(body) {
|
||||
var form = new FormData();
|
||||
body
|
||||
.trim()
|
||||
.split('&')
|
||||
.forEach(function(bytes) {
|
||||
if (bytes) {
|
||||
var split = bytes.split('=');
|
||||
var name = split.shift().replace(/\+/g, ' ');
|
||||
var value = split.join('=').replace(/\+/g, ' ');
|
||||
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
||||
}
|
||||
});
|
||||
return form
|
||||
}
|
||||
|
||||
function parseHeaders(rawHeaders) {
|
||||
var headers = new Headers();
|
||||
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
||||
// https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
||||
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
||||
var parts = line.split(':');
|
||||
var key = parts.shift().trim();
|
||||
if (key) {
|
||||
var value = parts.join(':').trim();
|
||||
headers.append(key, value);
|
||||
}
|
||||
});
|
||||
return headers
|
||||
}
|
||||
|
||||
Body.call(Request.prototype);
|
||||
|
||||
function Response(bodyInit, options) {
|
||||
if (!(this instanceof Response)) {
|
||||
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.type = 'default';
|
||||
this.status = options.status === undefined ? 200 : options.status;
|
||||
this.ok = this.status >= 200 && this.status < 300;
|
||||
this.statusText = 'statusText' in options ? options.statusText : '';
|
||||
this.headers = new Headers(options.headers);
|
||||
this.url = options.url || '';
|
||||
this._initBody(bodyInit);
|
||||
}
|
||||
|
||||
Body.call(Response.prototype);
|
||||
|
||||
Response.prototype.clone = function() {
|
||||
return new Response(this._bodyInit, {
|
||||
status: this.status,
|
||||
statusText: this.statusText,
|
||||
headers: new Headers(this.headers),
|
||||
url: this.url
|
||||
})
|
||||
};
|
||||
|
||||
Response.error = function() {
|
||||
var response = new Response(null, {status: 0, statusText: ''});
|
||||
response.type = 'error';
|
||||
return response
|
||||
};
|
||||
|
||||
var redirectStatuses = [301, 302, 303, 307, 308];
|
||||
|
||||
Response.redirect = function(url, status) {
|
||||
if (redirectStatuses.indexOf(status) === -1) {
|
||||
throw new RangeError('Invalid status code')
|
||||
}
|
||||
|
||||
return new Response(null, {status: status, headers: {location: url}})
|
||||
};
|
||||
|
||||
exports.DOMException = global.DOMException;
|
||||
try {
|
||||
new exports.DOMException();
|
||||
} catch (err) {
|
||||
exports.DOMException = function(message, name) {
|
||||
this.message = message;
|
||||
this.name = name;
|
||||
var error = Error(message);
|
||||
this.stack = error.stack;
|
||||
};
|
||||
exports.DOMException.prototype = Object.create(Error.prototype);
|
||||
exports.DOMException.prototype.constructor = exports.DOMException;
|
||||
}
|
||||
|
||||
function fetch(input, init) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var request = new Request(input, init);
|
||||
|
||||
if (request.signal && request.signal.aborted) {
|
||||
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
function abortXhr() {
|
||||
xhr.abort();
|
||||
}
|
||||
|
||||
xhr.onload = function() {
|
||||
var options = {
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText,
|
||||
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
||||
};
|
||||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
||||
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
||||
setTimeout(function() {
|
||||
resolve(new Response(body, options));
|
||||
}, 0);
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
setTimeout(function() {
|
||||
reject(new TypeError('Network request failed'));
|
||||
}, 0);
|
||||
};
|
||||
|
||||
xhr.ontimeout = function() {
|
||||
setTimeout(function() {
|
||||
reject(new TypeError('Network request failed'));
|
||||
}, 0);
|
||||
};
|
||||
|
||||
xhr.onabort = function() {
|
||||
setTimeout(function() {
|
||||
reject(new exports.DOMException('Aborted', 'AbortError'));
|
||||
}, 0);
|
||||
};
|
||||
|
||||
function fixUrl(url) {
|
||||
try {
|
||||
return url === '' && global.location.href ? global.location.href : url
|
||||
} catch (e) {
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
xhr.open(request.method, fixUrl(request.url), true);
|
||||
|
||||
if (request.credentials === 'include') {
|
||||
xhr.withCredentials = true;
|
||||
} else if (request.credentials === 'omit') {
|
||||
xhr.withCredentials = false;
|
||||
}
|
||||
|
||||
if ('responseType' in xhr) {
|
||||
if (support.blob) {
|
||||
xhr.responseType = 'blob';
|
||||
} else if (
|
||||
support.arrayBuffer &&
|
||||
request.headers.get('Content-Type') &&
|
||||
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
||||
) {
|
||||
xhr.responseType = 'arraybuffer';
|
||||
}
|
||||
}
|
||||
|
||||
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
||||
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
||||
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
||||
});
|
||||
} else {
|
||||
request.headers.forEach(function(value, name) {
|
||||
xhr.setRequestHeader(name, value);
|
||||
});
|
||||
}
|
||||
|
||||
if (request.signal) {
|
||||
request.signal.addEventListener('abort', abortXhr);
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
// DONE (success or failure)
|
||||
if (xhr.readyState === 4) {
|
||||
request.signal.removeEventListener('abort', abortXhr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
||||
})
|
||||
}
|
||||
|
||||
fetch.polyfill = true;
|
||||
|
||||
if (!global.fetch) {
|
||||
global.fetch = fetch;
|
||||
global.Headers = Headers;
|
||||
global.Request = Request;
|
||||
global.Response = Response;
|
||||
}
|
||||
|
||||
exports.Headers = Headers;
|
||||
exports.Request = Request;
|
||||
exports.Response = Response;
|
||||
exports.fetch = fetch;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
1
sdkjs-plugins/content/zotero/scripts/thirdparty/promise-polyfill.min.js
vendored
Normal file
@ -0,0 +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});
|
||||
1
sdkjs-plugins/content/zotero/scripts/thirdparty/url-polyfill.min.js
vendored
Normal file
198
sdkjs-plugins/content/zotero/scripts/zotero.js
Normal file
@ -0,0 +1,198 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
(function () {
|
||||
if (!window.Asc.plugin.zotero) window.Asc.plugin.zotero = {};
|
||||
window.Asc.plugin.zotero.api = function (cfg) {
|
||||
var apiKey;
|
||||
var userId;
|
||||
var userGroups = [];
|
||||
var baseUrl = cfg.baseUrl || "https://api.zotero.org/";
|
||||
|
||||
function getRequest(url) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var headers = {
|
||||
"Zotero-API-Version": "3"
|
||||
};
|
||||
if (apiKey) headers["Zotero-API-Key"] = apiKey;
|
||||
fetch(url, {
|
||||
headers: headers
|
||||
}).then(function (res) {
|
||||
if (!res.ok) throw new Error(res.status + " " + res.statusText);
|
||||
resolve(res);
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function buildGetRequest(path, query) {
|
||||
var url = new URL(path, baseUrl);
|
||||
for (var key in query) url.searchParams.append(key, query[key]);
|
||||
return getRequest(url);
|
||||
}
|
||||
|
||||
function items(search) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
parseItemsResponse(buildGetRequest("users/" + userId + "/items", {
|
||||
q: search
|
||||
}), resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
function groups(search, groupId) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
parseItemsResponse(buildGetRequest("groups/" + groupId + "/items", {
|
||||
q: search
|
||||
}), resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
function getUserGropus() {
|
||||
return userGroups;
|
||||
}
|
||||
|
||||
function format(ids, key, style, locale) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var request;
|
||||
if (key) {
|
||||
request = buildGetRequest("groups/" + key + "/items", {
|
||||
format: "bib",
|
||||
style: style,
|
||||
locale: locale,
|
||||
itemKey: ids.join(",")
|
||||
})
|
||||
} else {
|
||||
request = buildGetRequest("users/" + userId + "/items", {
|
||||
format: "bib",
|
||||
style: style,
|
||||
locale: locale,
|
||||
itemKey: ids.join(",")
|
||||
})
|
||||
}
|
||||
request.then(function (res) {
|
||||
resolve(res.text());
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getUserId(key) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
buildGetRequest("keys/" + key)
|
||||
.then(function (res) {
|
||||
if (!res.ok) throw new Error(res.status + " " + res.statusText);
|
||||
return res.json();
|
||||
}).then(function (res) {
|
||||
saveSettings(res.userID, key);
|
||||
resolve(true);
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function applySettings(id, key) {
|
||||
userId = id;
|
||||
apiKey = key;
|
||||
}
|
||||
|
||||
function saveSettings(id, key) {
|
||||
applySettings(id, key);
|
||||
localStorage.setItem("zoteroUserId", id);
|
||||
localStorage.setItem("zoteroApiKey", key);
|
||||
buildGetRequest("users/" + id + "/groups")
|
||||
.then(function (res) {
|
||||
if (!res.ok) throw new Error(res.status + " " + res.statusText);
|
||||
return res.json();
|
||||
}).then(function (res) {
|
||||
res.forEach(function(el) {
|
||||
userGroups.push(el.id);
|
||||
});
|
||||
localStorage.setItem("zoteroUserGroups", userGroups.join(';'));
|
||||
}).catch(function (err) {
|
||||
throw new Error(err)
|
||||
});
|
||||
}
|
||||
|
||||
function getSettings() {
|
||||
var uid = localStorage.getItem("zoteroUserId");
|
||||
var key = localStorage.getItem("zoteroApiKey");
|
||||
var groups = localStorage.getItem("zoteroUserGroups");
|
||||
if (groups)
|
||||
userGroups = groups.split(';');
|
||||
|
||||
var configured = !(!uid || !key);
|
||||
if (configured) applySettings(uid, key);
|
||||
return configured;
|
||||
}
|
||||
|
||||
function clearSettings() {
|
||||
localStorage.removeItem("zoteroUserId");
|
||||
localStorage.removeItem("zoteroApiKey");
|
||||
localStorage.removeItem("zoteroUserGroups");
|
||||
userGroups = [];
|
||||
}
|
||||
|
||||
function parseItemsResponse(promise, resolve, reject) {
|
||||
promise.then(function (res) {
|
||||
res.json().then(function (json) {
|
||||
var links = parseLinkHeader(res.headers.get("Link"));
|
||||
var obj = {
|
||||
items: json
|
||||
};
|
||||
if (links.next) {
|
||||
obj.next = function () {
|
||||
return new Promise(function (rs, rj) {
|
||||
parseItemsResponse(getRequest(links.next), rs, rj);
|
||||
});
|
||||
}
|
||||
}
|
||||
resolve(obj);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
var linkHeaderRegex = /<(.*?)>; rel="(.*?)"/g;
|
||||
function parseLinkHeader(headerValue) {
|
||||
var links = {};
|
||||
if (!headerValue) return links;
|
||||
headerValue = headerValue.trim();
|
||||
if (!headerValue) return links;
|
||||
|
||||
var match;
|
||||
while ((match = linkHeaderRegex.exec(headerValue)) !== null) {
|
||||
links[match[2]] = match[1];
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
return {
|
||||
items: items,
|
||||
groups: groups,
|
||||
getUserGropus: getUserGropus,
|
||||
format: format,
|
||||
hasSettings: getSettings,
|
||||
clearSettings: clearSettings,
|
||||
setApiKey: getUserId
|
||||
}
|
||||
}
|
||||
})();
|
||||
21
sdkjs-plugins/content/zotero/translations/cs-CS.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Pro použití Zotera byste měli využít klíč API.",
|
||||
"Navigate to": "Přejít na",
|
||||
"Zotero API settings": "Nastavení API Zotero",
|
||||
"Create and copy API key into the field below.": "Vytvořte a zkopírujte klíč API do pole níže.",
|
||||
"Open Zotero website": "Otevřít webové stránky Zotero",
|
||||
"Invalid API key": "Neplatný klíč API",
|
||||
"API Key": "Klíč API",
|
||||
"Nothing found": "Nic nebylo nalezeno",
|
||||
"Style is not selected": "Nebyl vybrán styl",
|
||||
"Language is not selected": "Nebyl vybrán jazyk",
|
||||
"Search references by author, title or year": "Vyhledávat odkazy podle autora, názvu nebo roku",
|
||||
"Cancel": "Storno",
|
||||
"Insert Bibliography": "Vložit bibliografii",
|
||||
"Style": "Styl",
|
||||
"Enter style name": "Zadejte název stylu",
|
||||
"Language": "Jazyk",
|
||||
"Reconfigure": "Přenastavit",
|
||||
"Learn more here.": "Více informací se dozvíte zde.",
|
||||
"Save": "Uložit"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/de-DE.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Sie brauchen einen API-Schlüssel, um Zotero zu nutzen.",
|
||||
"Navigate to": "Navigieren zu",
|
||||
"Zotero API settings": "API-Einstellungen für Zotero",
|
||||
"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.",
|
||||
"Open Zotero website": "Webseite von Zotero öffnen",
|
||||
"Invalid API key": "Ungültiger API-Schlüssel",
|
||||
"API Key": "API-Schlüssel",
|
||||
"Nothing found": "Keine Suchergebnisse",
|
||||
"Style is not selected": "Stil nicht ausgewählt",
|
||||
"Language is not selected": "Sprache nicht ausgewählt",
|
||||
"Search references by author, title or year": "Durchsuchen Sie Referenzen nach Autor, Titel oder Jahr",
|
||||
"Cancel": "Abbrechen",
|
||||
"Insert Bibliography": "Bibliografie einfügen",
|
||||
"Style": "Stil",
|
||||
"Enter style name": "Stilname eingeben",
|
||||
"Language": "Sprache",
|
||||
"Reconfigure": "Neu konfigurieren",
|
||||
"Learn more here.": "Erfahren Sie mehr hier.",
|
||||
"Save": "Speichern"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/es-ES.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Para usar Zotero debe obtener una clave de API.",
|
||||
"Navigate to": "Navegue a",
|
||||
"Zotero API settings": "Configuración de la API Zotero",
|
||||
"Create and copy API key into the field below.": "Cree y copie la clave de API en el campo de abajo.",
|
||||
"Open Zotero website": "Abra el sitio web de Zotero",
|
||||
"Invalid API key": "Clave de API inválida",
|
||||
"API Key": "Clave de API",
|
||||
"Nothing found": "No encontrado",
|
||||
"Style is not selected": "Estilo no está seleccionado",
|
||||
"Language is not selected": "Idioma no está seleccionado",
|
||||
"Search references by author, title or year": "Busque referencias por autor, título o año",
|
||||
"Cancel": "Cancelar",
|
||||
"Insert Bibliography": "Inserte Bibliografía",
|
||||
"Style": "Estilo",
|
||||
"Enter style name": "Introduzca el nombre del estilo",
|
||||
"Language": "Idioma",
|
||||
"Reconfigure": "Reconfigurar",
|
||||
"Learn more here.": "Aprenda más aquí.",
|
||||
"Save": "Salvar"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/fr-FR.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Pour utiliser Zotero, vous devez obtenir une clé API.",
|
||||
"Navigate to": "Accéder à",
|
||||
"Zotero API settings": "Paramètres de l'API Zotero",
|
||||
"Create and copy API key into the field below.": "Créez et copiez la clé API dans le champs ci-dessous.",
|
||||
"Open Zotero website": "Passer au site web de Zotero",
|
||||
"Invalid API key": "La clé API n'est pas valide",
|
||||
"API Key": "Сlé API",
|
||||
"Nothing found": "Rien n'a été trouvé",
|
||||
"Style is not selected": "Le style n'est pas sélectionné",
|
||||
"Language is not selected": "La langue n'est pas sélectionnée",
|
||||
"Search references by author, title or year": "Rechercher les références par auteur, titre ou année",
|
||||
"Cancel": "Annuler",
|
||||
"Insert Bibliography": "Insérer une bibliographie",
|
||||
"Style": "Style",
|
||||
"Enter style name": "Entrer le nom du style",
|
||||
"Language": "Langue",
|
||||
"Reconfigure": "Reconfigurer",
|
||||
"Learn more here.": "En savoir plus ici.",
|
||||
"Save": "Sauvegarder"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/it-IT.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Per usare Zotero è necessaria una chiave API.",
|
||||
"Navigate to": "Naviga verso",
|
||||
"Zotero API settings": "Impostazioni API Zotero",
|
||||
"Create and copy API key into the field below.": "Crea e copia la chiave API nel campo sottostante.",
|
||||
"Open Zotero website": "Apri il sito web Zotero",
|
||||
"Invalid API key": "Chiave API non valida",
|
||||
"API Key": "Chiave API",
|
||||
"Search in all literature:": "Cerca in tutta la letteratura",
|
||||
"Style is not selected": "Lo stile non ? selezionato",
|
||||
"Language is not selected": "Il linguaggio non ? selezionato",
|
||||
"Search references by author, title or year": "Cerca riferimenti per autore, titolo o anno",
|
||||
"Cancel": "Annulla",
|
||||
"Insert Bibliography": "Inserisci Bibliografia",
|
||||
"Style": "Stile",
|
||||
"Enter style name": "Inserisci nome dello stile",
|
||||
"Language": "Lingua",
|
||||
"Reconfigure": "Riconfigura",
|
||||
"Learn more here.": "Ulteriori informazioni qui.",
|
||||
"Save": "Salva"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/ja-JA.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Zoteroを使用するようにAPIキーを取得のが必要です。",
|
||||
"Navigate to": "(noun)に移動する",
|
||||
"Zotero API settings": "ZoteroのAPI設定",
|
||||
"Create and copy API key into the field below.": "キーを作成し、以下のフィールドにコピーしてください。",
|
||||
"Open Zotero website": "Zoteroウェブサイトを開く",
|
||||
"Invalid API key": "無効なAPIキー",
|
||||
"API Key": "APIキー",
|
||||
"Nothing found": "未找到任何东西",
|
||||
"Style is not selected": "未选择样式",
|
||||
"Language is not selected": "未选择语言",
|
||||
"Search references by author, title or year": "作者、标题或年份搜索引用",
|
||||
"Cancel": "取消",
|
||||
"Insert Bibliography": "插入参考文献",
|
||||
"Style": "样式",
|
||||
"Enter style name": "输入样式名称",
|
||||
"Language": "语言",
|
||||
"Reconfigure": "重新配置",
|
||||
"Learn more here.": "もっとここで知る。",
|
||||
"Save": "セーブ"
|
||||
}
|
||||
12
sdkjs-plugins/content/zotero/translations/langs.json
Normal file
@ -0,0 +1,12 @@
|
||||
[
|
||||
"cs-CS",
|
||||
"de-DE",
|
||||
"es-ES",
|
||||
"fr-FR",
|
||||
"it-IT",
|
||||
"ja-JA",
|
||||
"nl-NL",
|
||||
"pt-PT",
|
||||
"ru-RU",
|
||||
"zh-ZH"
|
||||
]
|
||||
21
sdkjs-plugins/content/zotero/translations/nl-NL.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Om Zotero te gebruiken moet u een API key hebben.",
|
||||
"Navigate to": "Navigeren naar",
|
||||
"Zotero API settings": "Zotero API instellingen",
|
||||
"Create and copy API key into the field below.": "Maak en kopieer API key in het onderstaande veld.",
|
||||
"Open Zotero website": "Open Zotero website",
|
||||
"Invalid API key": "Ongeldige API key",
|
||||
"API Key": "API Key",
|
||||
"Nothing found": "Niks gevonden",
|
||||
"Style is not selected": "Stijl is niet geselecteerd",
|
||||
"Language is not selected": "Taal is niet geselecteerd",
|
||||
"Search references by author, title or year": "Zoek referenties op auteur, titel of jaartal",
|
||||
"Cancel": "Annuleren",
|
||||
"Insert Bibliography": "Bibliografie Invoegen",
|
||||
"Style": "Stijl",
|
||||
"Enter style name": "Stijl naam invoeren",
|
||||
"Language": "Taal",
|
||||
"Reconfigure": "Opnieuw instellen",
|
||||
"Learn more here.": "Lees hier meer.",
|
||||
"Save": "Opslaan"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/pt-PT.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Para usar Zotero, obtenha uma chave de API.",
|
||||
"Navigate to": "Navegar para",
|
||||
"Zotero API settings": "Configurações de API do Zotero",
|
||||
"Create and copy API key into the field below.": "Crie e copie a chave de API no campo abaixo.",
|
||||
"Open Zotero website": "Abrir site do Zotero",
|
||||
"Invalid API key": "Chave de API inválida",
|
||||
"API Key": "Chave de API",
|
||||
"Nothing found": "Nada encontrado",
|
||||
"Style is not selected": "O estilo não está selecionado",
|
||||
"Language is not selected": "O idioma não está selecionado",
|
||||
"Search references by author, title or year": "Pesquise referências por autor, título ou ano",
|
||||
"Cancel": "Cancelar",
|
||||
"Insert Bibliography": "Inserir bibliografia",
|
||||
"Style": "Estilo",
|
||||
"Enter style name": "Digite o nome do estilo",
|
||||
"Language": "Idioma",
|
||||
"Reconfigure": "Reconfigurar",
|
||||
"Learn more here.": "Saiba mais aqui.",
|
||||
"Save": "Salve"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/ru-RU.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "Для использования Zotero необходимо получить ключ API.",
|
||||
"Navigate to": "Перейти к",
|
||||
"Zotero API settings": "Параметрам API Zotero",
|
||||
"Create and copy API key into the field below.": "Создайте ключ API и скопируйте его в поле ниже.",
|
||||
"Open Zotero website": "Сайт Zotero",
|
||||
"Invalid API key": "Недопустимый ключ API",
|
||||
"API Key": "Ключ API",
|
||||
"Nothing found": "Ничего не найдено",
|
||||
"Style is not selected": "Стиль не выбран",
|
||||
"Language is not selected": "Язык не выбран",
|
||||
"Search references by author, title or year": "Поиск по автору, названию или году издания",
|
||||
"Cancel": "Отмена",
|
||||
"Insert Bibliography": "Вставить библиографию",
|
||||
"Style": "Стиль",
|
||||
"Enter style name": "Введите имя стиля",
|
||||
"Language": "Язык",
|
||||
"Reconfigure": "Перенастроить",
|
||||
"Learn more here.": "Подробности здесь.",
|
||||
"Save": "Сохранить"
|
||||
}
|
||||
21
sdkjs-plugins/content/zotero/translations/zh-ZH.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"To use Zotero you should get an API key.": "要使用Zotero,您应该获得一个API密钥。",
|
||||
"Navigate to": "导航到",
|
||||
"Zotero API settings": "Zotero API设置",
|
||||
"Create and copy API key into the field below.": "创建API密钥并将其复制到下面的字段中。",
|
||||
"Open Zotero website": "Zotero网站",
|
||||
"Invalid API key": "无效的API密钥",
|
||||
"API Key": "API密钥",
|
||||
"Nothing found": "未找到任何东西",
|
||||
"Style is not selected": "未选择样式",
|
||||
"Language is not selected": "未选择语言",
|
||||
"Search references by author, title or year": "作者、标题或年份搜索引用",
|
||||
"Cancel": "取消",
|
||||
"Insert Bibliography": "插入参考文献",
|
||||
"Style": "样式",
|
||||
"Enter style name": "输入样式名称",
|
||||
"Language": "语言",
|
||||
"Reconfigure": "重新配置",
|
||||
"Learn more here.": "もっとここで知る。",
|
||||
"Save": "セーブ"
|
||||
}
|
||||