ver1.2.1
This commit is contained in:
parent
cf55776396
commit
e9516278ef
|
@ -26,6 +26,12 @@
|
|||
"ifShowMenuLabel":{
|
||||
"message": "Display context menu"
|
||||
},
|
||||
"ifChangeSecondLangLabel":{
|
||||
"message": "Switch to the second language if the input text of the tool bar translation panel is the same as the target language"
|
||||
},
|
||||
"secondTargetLangLabel":{
|
||||
"message": "Second language"
|
||||
},
|
||||
"translatePageMenu":{
|
||||
"message": "Translate this page"
|
||||
},
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
"ifShowMenuLabel":{
|
||||
"message": "コンテキストメニューを表示する"
|
||||
},
|
||||
"ifChangeSecondLangLabel":{
|
||||
"message": "ツールバー翻訳パネルの入力テキストが翻訳先言語と同じ場合は第二言語に切り替える"
|
||||
},
|
||||
"secondTargetLangLabel":{
|
||||
"message": "第二言語"
|
||||
},
|
||||
"translatePageMenu":{
|
||||
"message": "ページ全体を翻訳"
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ browser.storage.onChanged.addListener(getSetting)
|
|||
|
||||
//設定の読み出し
|
||||
function getSetting() {
|
||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
||||
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
||||
if (value.targetLang == undefined) initialSetting(); //初回起動時
|
||||
targetLang = value.targetLang;
|
||||
ifShowButton = value.ifShowButton;
|
||||
|
@ -27,7 +27,7 @@ function initialSetting() {
|
|||
targetLang = "en";
|
||||
break;
|
||||
}
|
||||
browser.storage.sync.set({
|
||||
browser.storage.local.set({
|
||||
'targetLang': targetLang,
|
||||
'ifShowButton': true,
|
||||
'ifCheckLang': true,
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.1",
|
||||
|
||||
"name": "__MSG_extName__",
|
||||
"description": "__MSG_extDescription__",
|
||||
"default_locale": "en",
|
||||
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
|
|
6
simple-translate/options/options.css
Normal file
6
simple-translate/options/options.css
Normal file
|
@ -0,0 +1,6 @@
|
|||
hr{
|
||||
width: 100%;
|
||||
background-color: #d7d7db;
|
||||
height: 1px;
|
||||
border: none;
|
||||
}
|
|
@ -3,25 +3,39 @@
|
|||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="options.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>
|
||||
<label id=targetLangLabel>翻訳先の言語:</label>
|
||||
<select id="targetLang"></select>
|
||||
<label><span id=targetLangLabel>翻訳先の言語:</span>
|
||||
<select id="targetLang"></select></label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="ifShowButton" value="1">
|
||||
<label id=ifShowButtonLabel>テキスト選択時にボタンを表示する</label>
|
||||
<label><input type="checkbox" name="ifShowButton" value="1">
|
||||
<span id=ifShowButtonLabel>テキスト選択時にボタンを表示する</span></label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="ifCheckLang" value="1">
|
||||
<label id=ifCheckLangLabel>選択したテキストが翻訳先言語と同じ時はボタンを表示しない</label>
|
||||
<label><input type="checkbox" name="ifCheckLang" value="1">
|
||||
<span id=ifCheckLangLabel>選択したテキストが翻訳先言語と同じ時はボタンを表示しない</span></label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="ifShowMenu" value="1">
|
||||
<label id=ifShowMenuLabel>コンテキストメニューを表示する</label>
|
||||
<label><input type="checkbox" name="ifShowMenu" value="1">
|
||||
<span id=ifShowMenuLabel>コンテキストメニューを表示する</span></label>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
<label><input type="checkbox" name="ifChangeSecondLang" value="1">
|
||||
<span id=ifChangeSecondLangLabel>ツールバー翻訳パネルの入力テキストが翻訳先言語と同じ場合は第2言語に切り替える</span></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><span id=secondTargetLangLabel>第2言語:</span>
|
||||
<select id="secondTargetLang"></select></label>
|
||||
</p>
|
||||
|
||||
|
||||
<script type="text/javascript" src="options.js"></script>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -2,31 +2,43 @@ var targetLang = document.getElementById("targetLang");
|
|||
var ifShowButton = document.getElementsByName("ifShowButton").item(0);
|
||||
var ifCheckLang = document.getElementsByName("ifCheckLang").item(0);
|
||||
var ifShowMenu = document.getElementsByName("ifShowMenu").item(0);
|
||||
var ifChangeSecondLang = document.getElementsByName("ifChangeSecondLang").item(0);
|
||||
var secondTargetLang = document.getElementById("secondTargetLang");
|
||||
|
||||
targetLang.innerHTML=browser.i18n.getMessage("langList");
|
||||
secondTargetLang.innerHTML=browser.i18n.getMessage("langList");
|
||||
|
||||
document.getElementById("targetLangLabel").innerHTML=browser.i18n.getMessage("langListLabel");
|
||||
document.getElementById("ifShowButtonLabel").innerHTML=browser.i18n.getMessage("ifShowButtonLabel");
|
||||
document.getElementById("ifCheckLangLabel").innerHTML=browser.i18n.getMessage("ifCheckLangLabel");
|
||||
document.getElementById("ifShowMenuLabel").innerHTML=browser.i18n.getMessage("ifShowMenuLabel");
|
||||
document.getElementById("ifChangeSecondLangLabel").innerHTML=browser.i18n.getMessage("ifChangeSecondLangLabel");
|
||||
document.getElementById("secondTargetLangLabel").innerHTML=browser.i18n.getMessage("secondTargetLangLabel");
|
||||
|
||||
//設定を読み込んで反映
|
||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu"], function (value) {
|
||||
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang", "ifShowMenu", "ifChangeSecondLang", "secondTargetLang"], function (value) {
|
||||
targetLang.value = value.targetLang;
|
||||
ifShowButton.checked=value.ifShowButton;
|
||||
ifCheckLang.checked=value.ifCheckLang;
|
||||
ifShowMenu.checked=value.ifShowMenu;
|
||||
ifChangeSecondLang.checked=value.ifChangeSecondLang;
|
||||
secondTargetLang.value=value.secondTargetLang;
|
||||
});
|
||||
|
||||
function save() {
|
||||
browser.storage.sync.set({
|
||||
browser.storage.local.set({
|
||||
'targetLang': targetLang.value,
|
||||
'ifShowButton': ifShowButton.checked,
|
||||
'ifCheckLang': ifCheckLang.checked,
|
||||
'ifShowMenu': ifShowMenu.checked
|
||||
'ifShowMenu': ifShowMenu.checked,
|
||||
'ifChangeSecondLang': ifChangeSecondLang.checked,
|
||||
'secondTargetLang': secondTargetLang.value
|
||||
}, function () {});
|
||||
}
|
||||
|
||||
targetLang.addEventListener("change", save);
|
||||
ifShowButton.addEventListener("change", save);
|
||||
ifCheckLang.addEventListener("change", save);
|
||||
ifShowMenu.addEventListener("change", save);
|
||||
ifShowMenu.addEventListener("change", save);
|
||||
ifChangeSecondLang.addEventListener("change", save);
|
||||
secondTargetLang.addEventListener("change", save);
|
|
@ -7,14 +7,20 @@ langList.innerHTML = browser.i18n.getMessage("langList");
|
|||
textarea.innerText = initialText;
|
||||
|
||||
let targetLang;
|
||||
let secondTargetLang;
|
||||
let defaultTargetLang;
|
||||
let ifChangeSecondLang;
|
||||
let sourceWord = "";
|
||||
|
||||
browser.storage.onChanged.addListener(getTargetLang);
|
||||
getTargetLang(); //翻訳先言語初期化
|
||||
//設定を読み出し
|
||||
function getTargetLang() {
|
||||
browser.storage.sync.get("targetLang", function (value) {
|
||||
browser.storage.local.get(["targetLang", "secondTargetLang","ifChangeSecondLang"], function (value) {
|
||||
defaultTargetLang = value.targetLang;
|
||||
targetLang = value.targetLang;
|
||||
secondTargetLang = value.secondTargetLang;
|
||||
ifChangeSecondLang=value.ifChangeSecondLang;
|
||||
langList.value = targetLang; //リスト初期値をセット
|
||||
langList.addEventListener("change", changeLang);
|
||||
});
|
||||
|
@ -88,8 +94,8 @@ function textAreaClick() {
|
|||
}
|
||||
}
|
||||
|
||||
textarea.addEventListener("keyup", function(event){
|
||||
if(event.keyCode==13) resize();
|
||||
textarea.addEventListener("keyup", function (event) {
|
||||
if (event.keyCode == 13) resize();
|
||||
inputText();
|
||||
});
|
||||
//文字入力時の処理
|
||||
|
@ -129,11 +135,33 @@ function getRequest(word) {
|
|||
function showResult(results) {
|
||||
target.innerText = "";
|
||||
let resultText = "";
|
||||
|
||||
//第二言語に変更
|
||||
if (ifChangeSecondLang) {
|
||||
let lang = results[0].response[2];
|
||||
let percentage = results[0].response[6];
|
||||
if (targetLang == defaultTargetLang && lang == defaultTargetLang && percentage > 0 && !changeLangFlag) changeSecondLang();
|
||||
else if ((lang != defaultTargetLang || percentage == 0) && changeLangFlag) unchangeSecondLang();
|
||||
}
|
||||
for (let j = 0; j < results.length; j++) {
|
||||
for (let i = 0; i < results[j].response[0].length; i++) {
|
||||
resultText += results[j].response[0][i][0];
|
||||
}
|
||||
resultText += "\n"; //
|
||||
resultText += "\n";
|
||||
}
|
||||
target.innerText = resultText;
|
||||
}
|
||||
|
||||
let changeLangFlag = false;
|
||||
|
||||
function changeSecondLang() {
|
||||
changeLangFlag = true;
|
||||
langList.value = secondTargetLang;
|
||||
changeLang();
|
||||
}
|
||||
|
||||
function unchangeSecondLang() {
|
||||
changeLangFlag = false;
|
||||
langList.value = defaultTargetLang;
|
||||
changeLang();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ getSetting();
|
|||
browser.storage.onChanged.addListener(getSetting);
|
||||
//設定を読み出し
|
||||
function getSetting() {
|
||||
browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang"], function (value) {
|
||||
browser.storage.local.get(["targetLang", "ifShowButton", "ifCheckLang"], function (value) {
|
||||
targetLang = value.targetLang;
|
||||
ifShowButton = value.ifShowButton;
|
||||
ifCheckLang = value.ifCheckLang;
|
||||
|
|
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.0.zip
Normal file
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.0.zip
Normal file
Binary file not shown.
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.1.zip
Normal file
BIN
simple-translate/web-ext-artifacts/simple_translate-1.2.1.zip
Normal file
Binary file not shown.
Loading…
Reference in a new issue