Merge pull request #33 from ONLYOFFICE/develop

Release 1.0.0
This commit is contained in:
catbasilio
2022-07-19 12:33:19 +03:00
committed by GitHub
12 changed files with 134 additions and 147 deletions

View File

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2020] [Ascensio System SIA]
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -7,7 +7,7 @@
"de": "Thesaurus"
},
"guid": "asc.{BE5CBF95-C0AD-4842-B157-AC40FEDD9840}",
"version": "1.0",
"version": "1.0.0",
"variations": [
{

View File

@ -29,13 +29,13 @@
</head>
<body class='body'>
<div id="synonimresult_id" class = "input-field">
<input type="text" class = "input-synonim input-white form-control" name="q" id = "inp_search" placeholder="Search" autocomplete="off">
<input type="text" class = "input-synonim form-control" name="q" id = "inp_search" placeholder="Search" autocomplete="off" spellcheck="false">
<button class = "btn-text-default" style="max-width: 50px;" id ="btn_search">Lookup</button>
<button class = "btn-text-default" style="max-width: 50px;" id="btn_showApiKey">ApiKey</button>
</div>
<div id="div_ApiKey" style="display: none; padding-top: 10px;">
<div class = "input-field">
<input type="text" class = "input-synonim input-white form-control" title="Enter your ApiKey" name="ApiKey" id = "inp_ApiKey" autocomplete="off">
<input type="text" class = "input-synonim form-control" title="Enter your ApiKey" name="ApiKey" id = "inp_ApiKey" autocomplete="off" spellcheck="false">
<button class = "btn-text-default" id ="btn_enterApiKey">Ok</button>
</div>
</div>

View File

@ -23,28 +23,29 @@ html, body {
div::selection {
background: #a8d1ff;
}
.button {
color: #fff;
button {
/* color: #fff;
background-color: #7d858c;
border: 1px solid #cfcfcf;
border-radius: 2px;
outline: none;
font-size: 11px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
height: 22px;
cursor: pointer;
cursor: pointer; */
height: 22px !important;
}
.input-synonim {
outline-color: #7d858c;
width: calc(100% - 10px);
border: 1px solid #cfcfcf;
}
.input-white::selection {
input::selection {
background: #D8DADC; /* WebKit/Blink Browsers */
color: #444444;
}
.input-white::-moz-selection {
input::-moz-selection {
background: #D8DADC; /* Gecko Browsers */
color: #444444;
}
.input-field {
display: flex;
@ -53,7 +54,12 @@ div::selection {
.not-found {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding-left: 5px;
color: red;
}
.h3-caption {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding-left: 5px;
}
.div-words {
width: 100%;
display: flex;
@ -65,8 +71,7 @@ div::selection {
.label-words {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
margin-left: 10px;
margin-top: 10px;
padding: 5px 5px;
cursor: pointer;
}
.global {

View File

@ -15,9 +15,8 @@
* limitations under the License.
*
*/
(function(window, undefined){
window.oncontextmenu = function(e)
{
(function(window, undefined) {
window.oncontextmenu = function(e) {
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
@ -34,7 +33,7 @@
isInitp = false,
predata = "";
$(document).ready(function () {
$(document).ready(function() {
//event mouseout label
$('body').on('mouseout', '.label-words', function() {
$(this).removeClass('label-selected');
@ -45,17 +44,19 @@
});
//event click label
$('body').on('click', '.label-words', function() {
var _htmlPaste = "<span >" + $(this).text() +" "+ "</span>";
window.Asc.plugin.executeMethod("PasteText", [$(this).text() +" "]);
});
//event button click
button = document.getElementById("btn_search");
button.onclick = function() {
synonim_data = inputSerch.value;
if ((null!=synonim_data) && (predata != synonim_data))
{
btn_search = document.getElementById("btn_search");
btn_search.onclick = function() {
synonim_data = inputSerch.value.trim();
if ('' !== synonim_data && null !== synonim_data) {
if (predata !== synonim_data) {
$('#global').empty(); // cleared global div
synonim();
}
} else {
$('#global').empty(); // cleared global div
synonim();
}
};
inputApiKey = document.getElementById("inp_ApiKey");
@ -79,8 +80,7 @@
});
function synonim() {
if (!isInit)
{
if (!isInit) {
var container = document.getElementById('scrollable-container-id');
Ps = new PerfectScrollbar('#' + container.id, {});
updateScroll();
@ -97,76 +97,61 @@
_url += SynonimFormat;
xhr.open('GET', _url, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 404)
{
$('#global').append("<h3 id = \"not_found\" class = \"not-found\">This word not found</h3>"); //if synonym not found
updateScroll();
updateScroll();
}
if (this.readyState == 4 && this.status == 500) {
$('#global').append("<h3 id = \"not_found\" class = \"not-found\">"+this.statusText+"</h3>"); //if synonym not found
updateScroll();
updateScroll();
}
if (this.readyState == 4 && this.status == 200 && !closed)
{
try
{
var _obj = JSON.parse(this.responseText);
if (_obj.noun) //if noun exist
{
drawWords(_obj.noun,"Noun");
}
if(_obj.adjective) //if andjective exist
{
drawWords(_obj.adjective,"Adjective")
}
if(_obj.verb) //if verb exist
{
drawWords(_obj.verb,"Verb")
}
updateScroll();
updateScroll();
xhr.onreadystatechange = function() {
if (this.readyState === 4) {
switch (this.status) {
case 401:
case 403:
synonim();
break;
case 404:
$('#global').append("<h3 id = \"not_found\" class = \"not-found\">" + window.Asc.plugin.tr("This word not found") + "</h3>"); //if synonym not found
break;
case 500:
$('#global').append("<h3 id = \"not_found\" class = \"not-found\">"+this.statusText+"</h3>"); //if synonym not found
break;
case 200:
if (!closed) {
try {
var _obj = JSON.parse(this.responseText);
if (_obj.noun) //if noun exist
drawWords(_obj.noun,"Noun");
if(_obj.adjective) //if andjective exist
drawWords(_obj.adjective,"Adjective")
if(_obj.verb) //if verb exist
drawWords(_obj.verb,"Verb")
}
catch (err){}
}
}
catch (err)
{}
}else if (401 == this.readyState || 403 == this.status)
synonim();
updateScroll();
updateScroll();
}
};
xhr.send(null);
};
window.Asc.plugin.init = function(text) {
if (!isInitp)
{
synonim_data = text.trim();
if (!isInitp) {
inputSerch = document.getElementById("inp_search");
inputSerch.value = text;
synonim_data = text;
if (null != synonim_data && synonim_data != "")
synonim();
}else{
inputSerch.value = text;
synonim_data = text;
if (predata == synonim_data)
{
return;
}else {
$('#global').empty(); // cleared global div
if (synonim_data == "")
{
predata = "";
return;
}
synonim();
}
isInitp = true;
}
isInitp = true;
$('#global').empty(); // cleared global div
window.Asc.plugin.executeMethod("GetSelectedText", [{Numbering:false, Math: false, TableCellSeparator: '\n', ParaSeparator: '\n', TabSymbol: String.fromCharCode(160)}], function(data) {
var val = (data === undefined) ? "" : (data.trim() == '') ? synonim_data : data.replace(/\r/g, ' ').trim();
inputSerch.value = val;
synonim_data = val;
if (synonim_data && synonim_data !== "" && predata !== synonim_data)
synonim();
predata = val;
});
};
window.Asc.plugin.button = function(id)
{
window.Asc.plugin.button = function() {
this.executeCommand("close", "");
};
@ -185,30 +170,26 @@
//draws the structure of the plugin
function drawWords(response, type) {
$('#global').append("<h3 class = \"not-found\">" + type + "</h3>");
$('#global').append("<h3 class = \"h3-caption\">" + window.Asc.plugin.tr(type) + "</h3>");
$('#global').append("<div id = " + type + " ></div>");
if (response.syn && response.syn.length)
{
if (response.syn && response.syn.length) {
$("#"+type).append("<div id =\""+ type +"-synonims\" class = \"div-words\"></div>");
for (let i=0; i<response.syn.length; i++)
for (let i = 0; i < response.syn.length; i++)
$('#'+ type +'-synonims').append("<label class =\"label-words\">"+ response.syn[i] +"</label>");
}
if(response.ant && response.ant.length)
{
$("#"+type).append("<h4 class = \"not-found\">Antonyms</h4>");
if (response.ant && response.ant.length) {
$("#"+type).append("<h3 class = \"h3-caption\">" + window.Asc.plugin.tr("Antonyms") + "</h3>");
$("#"+type).append("<div id =\""+ type +"-antonyms\" class = \"div-words\"></div>");
for (let i=0; i<response.ant.length; i++)
$('#'+ type +'-antonyms').append("<label class =\"label-words\">"+ response.ant[i] +"</label>");
}
};
function updateScroll()
{
function updateScroll() {
Ps && Ps.update();
};
window.Asc.plugin.onTranslate = function()
{
window.Asc.plugin.onTranslate = function() {
var btn_search = document.getElementById("btn_search");
if (btn_search)
btn_search.innerHTML = window.Asc.plugin.tr("Lookup");
@ -221,19 +202,8 @@
};
window.Asc.plugin.onThemeChanged = function(theme)
{
window.Asc.plugin.onThemeChanged = function(theme) {
window.Asc.plugin.onThemeChangedBase(theme);
if (theme.name !== "theme-light")
{
document.getElementById("inp_search").classList.remove("input-white");
document.getElementById("inp_ApiKey").classList.remove("input-white");
}
else
{
document.getElementById("inp_search").classList.add("input-white");
document.getElementById("inp_ApiKey").classList.add("input-white");
}
};
})(window, undefined);

11
translations/cs-CS.json Normal file
View File

@ -0,0 +1,11 @@
{
"Synonym" : "Stejný význam",
"Lookup" : "Hledat",
"Search" : "Hledat",
"Title" : "Zadejte svůj ApiKey",
"This word not found" : "Toto slovo nenalezeno",
"Noun" : "Podstatné jméno",
"Adjective" : "Přídavné jméno",
"Verb" : "Sloveso",
"Antonyms" : "Opačný význam"
}

View File

@ -1,10 +0,0 @@
{
"Synonym": "Stejný význam",
"Lookup": "Hledat",
"Title" : "Zadejte svůj ApiKey",
"This word not found": "Toto slovo nenalezeno",
"Noun": "Podstatné jméno",
"Adjective": "Přídavné jméno",
"Verb": "Sloveso",
"Antonyms": "Opačný význam"
}

View File

@ -1,10 +1,11 @@
{
"Synonym": "Synonym",
"Lookup": "Suche",
"Synonym" : "Synonym",
"Lookup" : "Suche",
"Search" : "Suche",
"Title" : "Geben Sie Ihren ApiKey ein",
"This word not found": "Dieses Wort wurde nicht gefunden",
"Noun": "Nomen",
"Adjective": "Adjektiv",
"Verb": "Verb",
"Antonyms": "Antonyme"
"This word not found" : "Dieses Wort wurde nicht gefunden",
"Noun" : "Nomen",
"Adjective" : "Adjektiv",
"Verb" : "Verb",
"Antonyms" : "Antonyme"
}

View File

@ -1,10 +1,11 @@
{
"Synonym": "Sinónimo",
"Lookup": "Búsqueda",
"Synonym" : "Sinónimo",
"Lookup" : "Búsqueda",
"Search" : "Búsqueda",
"Title" : "Introduzca su ApiKey",
"This word not found": "Esta palabra no se encuentra",
"Noun": "Sustantivo",
"Adjective": "Adjetivo",
"Verb": "Verbo",
"Antonyms": "Antónimos"
"This word not found" : "Esta palabra no se encuentra",
"Noun" : "Sustantivo",
"Adjective" : "Adjetivo",
"Verb" : "Verbo",
"Antonyms" : "Antónimos"
}

View File

@ -1,10 +1,11 @@
{
"Synonym": "Synonyme",
"Lookup": "Recherche",
"Synonym" : "Synonyme",
"Lookup" : "Recherche",
"Search" : "Recherche",
"Title" : "Entrez votre ApiKey",
"This word not found": "Ce mot n'est pas trouvé",
"Noun": "Nom",
"Adjective": "Adjectif",
"Verb": "Verbe",
"Antonyms": "Antonymes"
"This word not found" : "Ce mot n'est pas trouvé",
"Noun" : "Nom",
"Adjective" : "Adjectif",
"Verb" : "Verbe",
"Antonyms" : "Antonymes"
}

7
translations/langs.json Normal file
View File

@ -0,0 +1,7 @@
[
"cs-CZ",
"de-DE",
"es-ES",
"fr-FR",
"ru-RU"
]

View File

@ -1,10 +1,11 @@
{
"Synonym": "Синоним",
"Lookup": "Поиск",
"Synonym" : "Синоним",
"Lookup" : "Поиск",
"Search" : "Поиск",
"Title" : "Введите свой ApiKey",
"This word not found": "Это слово не найдено",
"Noun": "Имя существительное",
"Adjective": "Имя прилагательное",
"Verb": "Глагол",
"Antonyms": "Антонимы"
"This word not found" : "Это слово не найдено",
"Noun" : "Имя существительное",
"Adjective" : "Имя прилагательное",
"Verb" : "Глагол",
"Antonyms" : "Антонимы"
}