mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
Merge pull request #334 from AlexeyMatveev686/feature/pixabay
[pixabay] Add default key for plugin.
This commit is contained in:
@ -2,4 +2,8 @@
|
||||
|
||||
## 1.0.0
|
||||
|
||||
* Initial release.
|
||||
* Initial release.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
* Add default key if user don't have their own key.
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Pixabay",
|
||||
"guid": "asc.{1f6b80f3-8b3c-41c7-96a1-4b4386a6bd4c}",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
|
||||
"variations": [
|
||||
{
|
||||
|
||||
Binary file not shown.
@ -187,7 +187,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-container-id" >
|
||||
<div id="api" style="margin-bottom: 16px;">
|
||||
<div id="api" style="margin-bottom: 16px; display: none;">
|
||||
<div style="margin: 12px"><span class="i18n">To use Pixabay, create Pixabay account, then copy the API key and insert it in the specified field.</span> <a id="link-readme" class="i18n" target="_blank" href="https://github.com/ONLYOFFICE/onlyoffice.github.io/tree/master/sdkjs-plugins/content/pixabay#configuration">Learn more here.</a></div>
|
||||
<div style="margin: 16px 0 4px 0; font-weight: normal !important;">
|
||||
<label class="i18n" style="margin-left:12px;">API key</label>
|
||||
@ -195,7 +195,7 @@
|
||||
<input type="text" id="api-value" class="form-control i18n" data-id="pixabay-api-key" placeholder="Enter your Pixabay API key" style="width: calc(100% - 24px); margin: 0 12px 0 12px; text-align: left;">
|
||||
<button id="save" class="btn-text-default i18n">Save</button>
|
||||
</div>
|
||||
<div id="main-search-container-id" style="display:none;">
|
||||
<div id="main-search-container-id" style="display:block;">
|
||||
<input type="text" id="search-phrase" class="form-control i18n" placeholder="Enter search phrase" data-id="search-phrase-id" style="width: calc(100% - 24px); margin: 16px 12px 0 12px; text-align: left;">
|
||||
<button id="button-search-id" class="btn-text-default i18n">Search</button>
|
||||
<div id="hide_show_reconf">
|
||||
|
||||
@ -22,6 +22,7 @@ let Ps1, Ps2;
|
||||
|
||||
const displayNoneClass = "display-none";
|
||||
const borderColor = '#cbcbcb';
|
||||
const OOKey = '52-50-56-53-54-54-48-53-45-50-55-48-50-102-49-49-52-49-97-52-50-101-55-101-50-54-98-48-100-48-53-49-53-98';
|
||||
|
||||
function showLoader(show) {
|
||||
switchClass(elements.loader, displayNoneClass, !show);
|
||||
@ -353,7 +354,7 @@ let Ps1, Ps2;
|
||||
|
||||
$('#save').on('click', function() {
|
||||
const apikey = elements.api_input.value.trim();
|
||||
if (apikey !== '') {
|
||||
if (true || apikey !== '') {
|
||||
loadClipArtPage(1, sLastQuery);
|
||||
} else {
|
||||
$('#preview-images-container-id').empty();
|
||||
@ -382,6 +383,7 @@ let Ps1, Ps2;
|
||||
});
|
||||
|
||||
$('#reconf').on('click', function() {
|
||||
showLoader(false);
|
||||
saved_key = localStorage.getItem($('#api-value').attr('data-id'));
|
||||
localStorage.removeItem ($('#api-value').attr('data-id'));
|
||||
if (saved_key !== null)
|
||||
@ -398,7 +400,7 @@ let Ps1, Ps2;
|
||||
});
|
||||
|
||||
updateScroll();
|
||||
if (elements.api_input.value.trim() !== '')
|
||||
if (true || elements.api_input.value.trim() !== '')
|
||||
loadClipArtPage(1, sLastQuery);
|
||||
};
|
||||
|
||||
@ -477,13 +479,14 @@ let Ps1, Ps2;
|
||||
loadImgs(oResponse.hits[nUrl].largeImageURL);
|
||||
}
|
||||
}).error(function(oError) {
|
||||
$('#reconf').trigger('click');
|
||||
showLoader(false);
|
||||
container = document.getElementById('scrollable-container-id');
|
||||
container.scrollTop = 0;
|
||||
updateScroll();
|
||||
updateNavigation(0, 0);
|
||||
$('#preview-images-container-id').empty();
|
||||
if (elements.api_input.value.trim() !== '') {
|
||||
if (true || elements.api_input.value.trim() !== '') {
|
||||
if (!$('#api-value').hasClass('error_api'))
|
||||
$('#api-value').toggleClass('error_api');
|
||||
|
||||
@ -506,9 +509,19 @@ let Ps1, Ps2;
|
||||
});
|
||||
};
|
||||
|
||||
function getKey() {
|
||||
let arr = OOKey.split('-');
|
||||
let result = '';
|
||||
arr.forEach(function(el) {
|
||||
result += String.fromCharCode(el);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
function CreateRequest(nPageIndex, sQuery) {
|
||||
let sRequest = 'key=';
|
||||
let apikey = elements.api_input.value.trim();
|
||||
if (!apikey) apikey = getKey();
|
||||
let lang = elements.locale.value;
|
||||
let category = elements.category.value;
|
||||
let search_phrase = elements.search_phrase.value.replace(/ /gi, "+") || sQuery.replace(/ /gi, "+");
|
||||
|
||||
Reference in New Issue
Block a user