Skip to content

Commit

Permalink
Bugfixe, update ajax request
Browse files Browse the repository at this point in the history
  • Loading branch information
Silbad committed Jan 2, 2019
1 parent f7700fc commit ab4479f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
Binary file added _build/deeplt-1.5.5.zip
Binary file not shown.
44 changes: 24 additions & 20 deletions app/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,28 @@ $(function() {
$('#trad-search, #lang-origin, #lang-target').on('keyup change', function() {

var text = $('#trad-search').val().trim();
var tmpTimestamp = Date.now();
tmpLangOrigin = $('#lang-origin').val();
tmpLangTarget = $('#lang-target').val();
var request = JSON.stringify({
jsonrpc: '2.0',
method: 'LMT_handle_jobs',
params: {
jobs: [{
kind: 'default',
quality: 'fast',
raw_en_sentence: text
}],
lang: {
user_preferred_langs: [langUI,'EN'],
source_lang_user_selected: tmpLangOrigin,
target_lang: tmpLangTarget
},
priority: -1,
timestamp: tmpTimestamp
},
id: callID
});

if (text.length < 2) {
$('.bar').removeClass('bar-loading');
Expand All @@ -156,27 +176,11 @@ $(function() {
delay(function(){
callID++;
$.ajax({
url: 'https://cors-anywhere.herokuapp.com/https://www2.deepl.com/jsonrpc',
contentType: 'text/plain',
url: 'https://www2.deepl.com/jsonrpc',
contentType: 'application/json',
type: 'POST',
dataType: 'json',
data: JSON.stringify({
jsonrpc: '2.0',
method: 'LMT_handle_jobs',
params: {
jobs: [{
kind: 'default',
raw_en_sentence: text
}],
lang: {
user_preferred_langs: [langUI,'EN'],
source_lang_user_selected: tmpLangOrigin,
target_lang: tmpLangTarget
},
priority: -1
},
id: callID
}),
data: request,
dataType: 'json',
success: function(response) {
text = $('#trad-search').val().trim();
$('.bar').removeClass('bar-loading');
Expand Down
12 changes: 10 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_deepLTName__",
"version": "1.5.4",
"version": "1.5.5",
"description": "__MSG_deepLTDescription__",
"homepage_url": "https://github.com/Silbad/DeepLT",
"default_locale": "en",
Expand All @@ -13,7 +13,15 @@
"page": "app/options.htm",
"browser_style": true
},
"permissions": ["storage", "unlimitedStorage", "contextMenus", "activeTab", "clipboardRead", "clipboardWrite"],
"permissions": [
"*://www2.deepl.com/*",
"storage",
"unlimitedStorage",
"contextMenus",
"activeTab",
"clipboardRead",
"clipboardWrite"
],
"developer": {
"name": "Silbad",
"url": "https://github.com/Silbad/DeepLT"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DeepLT",
"version": "1.5.4",
"version": "1.5.5",
"description": "A simple translation extension for Firefox powered by DeepL",
"repository": "https://github.com/Silbad/DeepLT",
"author": "Silbad",
Expand Down

0 comments on commit ab4479f

Please sign in to comment.