First commit
diff --git a/_locales/ca/messages.json b/_locales/ca/messages.json
new file mode 100644
index 0000000..a825ecd
--- /dev/null
+++ b/_locales/ca/messages.json
@@ -0,0 +1,58 @@
+{
+ "appName": {
+ "message": "Traduïr Text Seleccionat",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Traduïr Text Seleccionat (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription" : {
+ "message": "Tradueix el text que seleccionis amb el Traductor de Google",
+ "description": "The app description"
+ },
+ "contextmenu_title" : {
+ "message": "Tradueix la selecció al...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this prent menu there are the menus"
+ },
+ "contextmenu_edit" : {
+ "message": "Edita idiomes...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome" : {
+ "message": "Benvingut!",
+ "description": "Title of the options page"
+ },
+ "options_introduction" : {
+ "message": "Si us plau, selecciona els idiomes que vols que surtin al menú \"traduïr\".",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader" : {
+ "message": "Idiomes:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader" : {
+ "message": "Altres opcions:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1" : {
+ "message": "Obre Google Traductor en una nova pestanya per a cada traducció.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2" : {
+ "message": "Obre Google Traductor en una única pestanya i reemplaça l'última traducció en comptes d'obrir varies pestanyes.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3" : {
+ "message": "Obre Google Traductor en un panel i reemplaça l'última traducció (fa falta activar la bandera <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a>). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton" : {
+ "message": "Desar",
+ "description": "Save button in the settings app"
+ },
+ "notification_install_title": { "message": "Gràcies per instal·lar 'Traduïr Text Seleccionat'" },
+ "notification_install_message": { "message": "Fes clic en aquesta notificació per a configurar l'extensión." },
+ "notification_upgradedtostorage_title": { "message": "'Traduïr Text Seleccionat' s'ha actualizat a v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "Ara la configuració es sincronitzarà en tots els teus dispositius! La part dolenta és que has de configurar l'extensión una altra vegada :-( Fes clic en aquesta notificación per a configurar-la." }
+}
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
new file mode 100644
index 0000000..66ae9cd
--- /dev/null
+++ b/_locales/en/messages.json
@@ -0,0 +1,58 @@
+{
+ "appName": {
+ "message": "Translate Selected Text",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Translate Selected Text (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription": {
+ "message": "Translate selected text with Google Translator",
+ "description": "The app description"
+ },
+ "contextmenu_title": {
+ "message": "Translate selection into...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this parent menu there are the menus"
+ },
+ "contextmenu_edit": {
+ "message": "Edit languages...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome": {
+ "message": "Welcome!",
+ "description": "Title of the options page"
+ },
+ "options_introduction": {
+ "message": "Please, select the languages you want to show up in the \"translate\" menu.",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader": {
+ "message": "Languages:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader": {
+ "message": "Other options:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1": {
+ "message": "Open Google Translator in a new tab for each translation.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2": {
+ "message": "Open Google Translator in a unique tab and override the last translation instead of opening several tabs.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3": {
+ "message": "Open Google Translator in a panel and override the last translation (need to activate <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a> flag). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton": {
+ "message": "Save",
+ "description": "Save button in the settings page"
+ },
+ "notification_install_title": { "message": "Thanks for installing 'Translate Selected Text'" },
+ "notification_install_message": { "message": "Click this notification to set it up." },
+ "notification_upgradedtostorage_title": { "message": "'Translate Selected Text' was updated to v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "Now your options will be synced across all your devices! The bad side is that you have to set up the extension again :-( Click this notification to set it up." }
+}
diff --git a/_locales/es/messages.json b/_locales/es/messages.json
new file mode 100644
index 0000000..a33c70f
--- /dev/null
+++ b/_locales/es/messages.json
@@ -0,0 +1,58 @@
+{
+ "appName": {
+ "message": "Traducir Texto Seleccionado",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Traducir Texto Seleccionado (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription" : {
+ "message": "Traduce el texto que selecciones con el Traductor de Google.",
+ "description": "The app description"
+ },
+ "contextmenu_title" : {
+ "message": "Traducir selección al...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this prent menu there are the menus"
+ },
+ "contextmenu_edit" : {
+ "message": "Modifica idiomas...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome" : {
+ "message": "¡Bienvenido!",
+ "description": "Title of the options page"
+ },
+ "options_introduction" : {
+ "message": "Por favor, selecciona los idiomas que quieres que se muestren en el menú \"traducir\".",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader" : {
+ "message": "Idiomas:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader" : {
+ "message": "Otras opciones:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1" : {
+ "message": "Abre Google Traductor en una nueva pestaña para cada traducción.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2" : {
+ "message": "Abre Google Traductor en una única pestaña y reemplaza la última traducción en vez de abrir varias pestañas.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3" : {
+ "message": "Abre Google Traductor en un panel y remplaza la última traducción (hace falta activar la bandera <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a>). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton" : {
+ "message": "Guardar",
+ "description": "Save button in the settings app"
+ },
+ "notification_install_title": { "message": "Gracias por instalar 'Traducir Texto Seleccionado'" },
+ "notification_install_message": { "message": "Haz clic en esta notificación para configurar la extensión." },
+ "notification_upgradedtostorage_title": { "message": "'Traducir Texto Seleccionado' se ha actualizado a v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "¡Ahora la configuración se sincronizará en todos tus dispositivos! La parte mala es que tienes que configurar la extensión otra vez :-( Haz clic en esta notificación para configurarla." }
+}
diff --git a/background.js b/background.js
new file mode 100644
index 0000000..ec92764
--- /dev/null
+++ b/background.js
@@ -0,0 +1,144 @@
+var isoLangs = {"af":{"name":"Afrikaans","nativeName":"Afrikaans"},"sq":{"name":"Albanian","nativeName":"Shqip"},"ar":{"name":"Arabic","nativeName":"\u0639\u0631\u0628\u064a"},"hy":{"name":"Armenian","nativeName":"\u0540\u0561\u0575\u0565\u0580\u0567\u0576"},"az":{"name":"Azerbaijani","nativeName":"\u0622\u0630\u0631\u0628\u0627\u06cc\u062c\u0627\u0646 \u062f\u06cc\u0644\u06cc"},"eu":{"name":"Basque","nativeName":"Euskara"},"be":{"name":"Belarusian","nativeName":"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f"},"bg":{"name":"Bulgarian","nativeName":"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438"},"ca":{"name":"Catalan","nativeName":"Catal\u00e0"},"zh-CN":{"name":"Chinese (Simplified)","nativeName":"\u4e2d\u6587\u7b80\u4f53"},"zh-TW":{"name":"Chinese (Traditional)","nativeName":"\u4e2d\u6587\u7e41\u9ad4"},"hr":{"name":"Croatian","nativeName":"Hrvatski"},"cs":{"name":"Czech","nativeName":"\u010ce\u0161tina"},"da":{"name":"Danish","nativeName":"Dansk"},"nl":{"name":"Dutch","nativeName":"Nederlands"},"en":{"name":"English","nativeName":"English"},"et":{"name":"Estonian","nativeName":"Eesti keel"},"tl":{"name":"Filipino","nativeName":"Filipino"},"fi":{"name":"Finnish","nativeName":"Suomi"},"fr":{"name":"French","nativeName":"Fran\u00e7ais"},"gl":{"name":"Galician","nativeName":"Galego"},"ka":{"name":"Georgian","nativeName":"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8"},"de":{"name":"German","nativeName":"Deutsch"},"el":{"name":"Greek","nativeName":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"},"ht":{"name":"Haitian Creole","nativeName":"Krey\u00f2l ayisyen"},"iw":{"name":"Hebrew","nativeName":"\u05e2\u05d1\u05e8\u05d9\u05ea"},"hi":{"name":"Hindi","nativeName":"\u0939\u093f\u0928\u094d\u0926\u0940"},"hu":{"name":"Hungarian","nativeName":"Magyar"},"is":{"name":"Icelandic","nativeName":"\u00cdslenska"},"id":{"name":"Indonesian","nativeName":"Bahasa Indonesia"},"ga":{"name":"Irish","nativeName":"Gaeilge"},"it":{"name":"Italian","nativeName":"Italiano"},"ja":{"name":"Japanese","nativeName":"\u65e5\u672c\u8a9e"},"ko":{"name":"Korean","nativeName":"\ud55c\uad6d\uc5b4"},"lv":{"name":"Latvian","nativeName":"Latvie\u0161u"},"lt":{"name":"Lithuanian","nativeName":"Lietuvi\u0173 kalba"},"mk":{"name":"Macedonian","nativeName":"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438"},"ms":{"name":"Malay","nativeName":"Malay"},"mt":{"name":"Maltese","nativeName":"Malti"},"no":{"name":"Norwegian","nativeName":"Norsk"},"fa":{"name":"Persian","nativeName":"\u0641\u0627\u0631\u0633\u06cc"},"pl":{"name":"Polish","nativeName":"Polski"},"pt":{"name":"Portuguese","nativeName":"Portugu\u00eas"},"ro":{"name":"Romanian","nativeName":"Rom\u00e2n\u0103"},"ru":{"name":"Russian","nativeName":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439"},"sr":{"name":"Serbian","nativeName":"\u0421\u0440\u043f\u0441\u043a\u0438"},"sk":{"name":"Slovak","nativeName":"Sloven\u010dina"},"sl":{"name":"Slovenian","nativeName":"Slovensko"},"es":{"name":"Spanish","nativeName":"Espa\u00f1ol"},"sw":{"name":"Swahili","nativeName":"Kiswahili"},"sv":{"name":"Swedish","nativeName":"Svenska"},"th":{"name":"Thai","nativeName":"\u0e44\u0e17\u0e22"},"tr":{"name":"Turkish","nativeName":"T\u00fcrk\u00e7e"},"uk":{"name":"Ukrainian","nativeName":"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"},"ur":{"name":"Urdu","nativeName":"\u0627\u0631\u062f\u0648"},"vi":{"name":"Vietnamese","nativeName":"Ti\u1ebfng Vi\u1ec7t"},"cy":{"name":"Welsh","nativeName":"Cymraeg"},"yi":{"name":"Yiddish","nativeName":"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9"}};
+
+
+var array_elements = new Array(), translator_tab = false, translator_window = false;
+
+function isEmpty(obj) {
+ return Object.keys(obj).length === 0;
+}
+
+function click(info, tab) {
+ chrome.storage.sync.get("uniquetab", function(items) {
+ var settings_tab = {'url': 'https://translate.google.com/#auto/'+array_elements[info.menuItemId]['langCode']+'/'+encodeURIComponent(info.selectionText)};
+ if (translator_tab && items.uniquetab == "yep") {
+ chrome.tabs.update(translator_tab, settings_tab, function(tab){
+ chrome.tabs.highlight({'windowId': tab.windowId, 'tabs': tab.index}, function() {
+ chrome.windows.update(tab.windowId, {focused: true}, function() {});
+ });
+ });
+ } else if (items.uniquetab == "panel") {
+ chrome.windows.create({
+ type: 'panel', url: 'https://translate.google.com/#auto/'+array_elements[info.menuItemId]['langCode']+'/'+encodeURIComponent(info.selectionText), width: 1000, height: 382}, function(tab) {
+ translator_window = tab.windowId;
+ translator_tab = tab.id;
+ chrome.windows.onRemoved.addListener(function (windowId) {
+ if (windowId == translator_window) {
+ translator_window = false;
+ translator_tab = false;
+ }
+ });
+ }
+ );
+ } else {
+ chrome.tabs.create(settings_tab, function(tab) {
+ translator_window = tab.windowId;
+ translator_tab = tab.id;
+ chrome.tabs.onRemoved.addListener(function (tabId, removeInfo) {
+ if (tabId == translator_tab) {
+ translator_window = false;
+ translator_tab = false;
+ }
+ });
+ });
+ }
+ });
+}
+
+function click2(info, tab) {
+ chrome.tabs.create({'url': 'chrome-extension://'+chrome.i18n.getMessage("@@extension_id")+'/options.html', 'active': true}, function(tab) {
+ chrome.windows.update(tab.windowId, {'focused': true}, function() {});
+ });
+
+}
+
+function createmenus() {
+ chrome.storage.sync.get("languages", function(items) {
+ chrome.contextMenus.removeAll();
+
+ var parent = chrome.contextMenus.create({"title": chrome.i18n.getMessage("contextmenu_title"), "contexts":["selection"]});
+
+ for (var language in items.languages) {
+ var languagem = isoLangs[language];
+ var title = languagem.name + " ("+languagem.nativeName+")";
+ var id = chrome.contextMenus.create({"title": title, "parentId": parent, "contexts":["selection"], "onclick": click});
+ array_elements[id] = new Array();
+ array_elements[id]["langCode"] = language;
+ array_elements[id]["langName"] = languagem.name;
+ array_elements[id]["langNativeName"] = language.nativeName;
+ }
+
+ var id = chrome.contextMenus.create({"type": "separator","parentId": parent, "contexts":["selection"], "onclick": click2});
+
+ var id = chrome.contextMenus.create({"title": chrome.i18n.getMessage("contextmenu_edit"), "parentId": parent, "contexts":["selection"], "onclick": click2});
+ });
+}
+
+chrome.runtime.onInstalled.addListener(function(details) {
+ chrome.storage.sync.get(null, function(items) {
+ if (details.reason == "install") {
+ if (isEmpty(items)) {
+ var settings = {'languages': {}, 'uniquetab': ''}, default_language = chrome.i18n.getMessage("@@ui_locale").split("_")[0];
+ if (isoLangs[default_language] != "undefined") {
+ settings.languages[default_language] = default_language;
+ }
+ chrome.storage.sync.set(settings, function() {
+ chrome.notifications.create("install", {
+ type: "basic",
+ iconUrl: "translate-128.png",
+ title: chrome.i18n.getMessage("notification_install_title"),
+ message: chrome.i18n.getMessage("notification_install_message"),
+ isClickable: true
+ }, function(id) {});
+ });
+ }
+ }
+ if (details.reason == "update") {
+ var version = details.previousVersion.split(".");
+ if (version[0] == "0" && version[1] < "6") {
+ var settings = {'languages': {}, 'uniquetab': ''}, default_language = chrome.i18n.getMessage("@@ui_locale").split("_")[0];
+ if (isoLangs[default_language] != "undefined") {
+ settings.languages[default_language] = default_language;
+ }
+ chrome.storage.sync.set(settings, function() {
+ chrome.notifications.create("upgradedtostorage", {
+ type: "basic",
+ iconUrl: "translate-128.png",
+ title: chrome.i18n.getMessage("notification_upgradedtostorage_title"),
+ message: chrome.i18n.getMessage("notification_upgradedtostorage_message"),
+ isClickable: true
+ }, function(id) {});
+ });
+ }
+ }
+ });
+});
+
+chrome.storage.onChanged.addListener(function(changes, areaName) {
+ if (areaName == "sync")
+ createmenus();
+});
+
+chrome.storage.sync.get(null, function(items) {
+ if (items.languages) {
+ createmenus();
+ } else {
+ chrome.contextMenus.removeAll();
+ var parent = chrome.contextMenus.create({"title": chrome.i18n.getMessage("contextmenu_title"), "contexts":["selection"]});
+ var id = chrome.contextMenus.create({"title": chrome.i18n.getMessage("contextmenu_edit"), "parentId": parent, "contexts":["selection"], "onclick": click2});
+ }
+});
+
+chrome.notifications.onClicked.addListener(function(notification_id) {
+ switch(notification_id) {
+ case "install":
+ click2();
+ break;
+
+ case "upgradedtostorage":
+ click2();
+ break;
+ }
+ chrome.notifications.clear(notification_id, function() {
+
+ });
+});
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..567ee82
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,23 @@
+{
+ "manifest_version": 2,
+ "name": "__MSG_appName__",
+ "description": "__MSG_appDescription__",
+ "version": "0.6.1.1",
+ "permissions": [
+ "contextMenus",
+ "storage",
+ "notifications"
+ ],
+ "icons": {
+ "16": "translate-16.png",
+ "32": "translate-32.png",
+ "64": "translate-64.png",
+ "128": "translate-128.png",
+ "256": "translate-256.png"
+ },
+ "background": {
+ "scripts": ["background.js"]
+ },
+ "options_page": "options.html",
+ "default_locale": "en"
+}
diff --git a/options.css b/options.css
new file mode 100644
index 0000000..b4122d1
--- /dev/null
+++ b/options.css
@@ -0,0 +1,21 @@
+body {
+ padding:10px;
+ font-family:"Roboto", "Arial", sans-serif!important;
+ background-image: url('translate-1.png');
+ background-repeat: repeat;
+ background-position: left top;
+}
+h1 {
+ text-align:center;
+ font-size:30px;
+}
+h2 {
+ font-size:20px;
+}
+#languages {
+ -webkit-column-count:4;
+}
+button#save {
+ display:block;
+ margin:18px auto;
+}
diff --git a/options.html b/options.html
new file mode 100644
index 0000000..414cfff
--- /dev/null
+++ b/options.html
@@ -0,0 +1,22 @@
+<html>
+ <head>
+ <title>Options</title>
+ <meta charset="UTF-8">
+ <script src="options.js"></script>
+ <link rel="stylesheet" type="text/css" href="options.css">
+ <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
+ </head>
+ <body>
+ <h1 id="welcome"></h1>
+ <p id="introduction"></p>
+ <h2 id="languageselectheader"></h2>
+ <div id="languages"></div>
+ <h2 id="otheroptionsheader"></h2>
+ <div id="otheroptions">
+ <input type="radio" name="uniquetab" id="varioustabs" value=""> <label id="varioustabs_label" for="varioustabs"></label><br>
+ <input type="radio" name="uniquetab" id="uniquetab" value="yep"> <label id="uniquetab_label" for="uniquetab"></label><br>
+ <input type="radio" name="uniquetab" id="panel" value="panel"> <label id="panel_label" for="panel"></label>
+ </div>
+ <button id="save"></button>
+ </body>
+</html>
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..d240da1
--- /dev/null
+++ b/options.js
@@ -0,0 +1,107 @@
+var isoLangs = {"af":{"name":"Afrikaans","nativeName":"Afrikaans"},"sq":{"name":"Albanian","nativeName":"Shqip"},"ar":{"name":"Arabic","nativeName":"\u0639\u0631\u0628\u064a"},"hy":{"name":"Armenian","nativeName":"\u0540\u0561\u0575\u0565\u0580\u0567\u0576"},"az":{"name":"Azerbaijani","nativeName":"\u0622\u0630\u0631\u0628\u0627\u06cc\u062c\u0627\u0646 \u062f\u06cc\u0644\u06cc"},"eu":{"name":"Basque","nativeName":"Euskara"},"be":{"name":"Belarusian","nativeName":"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f"},"bg":{"name":"Bulgarian","nativeName":"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438"},"ca":{"name":"Catalan","nativeName":"Catal\u00e0"},"zh-CN":{"name":"Chinese (Simplified)","nativeName":"\u4e2d\u6587\u7b80\u4f53"},"zh-TW":{"name":"Chinese (Traditional)","nativeName":"\u4e2d\u6587\u7e41\u9ad4"},"hr":{"name":"Croatian","nativeName":"Hrvatski"},"cs":{"name":"Czech","nativeName":"\u010ce\u0161tina"},"da":{"name":"Danish","nativeName":"Dansk"},"nl":{"name":"Dutch","nativeName":"Nederlands"},"en":{"name":"English","nativeName":"English"},"et":{"name":"Estonian","nativeName":"Eesti keel"},"tl":{"name":"Filipino","nativeName":"Filipino"},"fi":{"name":"Finnish","nativeName":"Suomi"},"fr":{"name":"French","nativeName":"Fran\u00e7ais"},"gl":{"name":"Galician","nativeName":"Galego"},"ka":{"name":"Georgian","nativeName":"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8"},"de":{"name":"German","nativeName":"Deutsch"},"el":{"name":"Greek","nativeName":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"},"ht":{"name":"Haitian Creole","nativeName":"Krey\u00f2l ayisyen"},"iw":{"name":"Hebrew","nativeName":"\u05e2\u05d1\u05e8\u05d9\u05ea"},"hi":{"name":"Hindi","nativeName":"\u0939\u093f\u0928\u094d\u0926\u0940"},"hu":{"name":"Hungarian","nativeName":"Magyar"},"is":{"name":"Icelandic","nativeName":"\u00cdslenska"},"id":{"name":"Indonesian","nativeName":"Bahasa Indonesia"},"ga":{"name":"Irish","nativeName":"Gaeilge"},"it":{"name":"Italian","nativeName":"Italiano"},"ja":{"name":"Japanese","nativeName":"\u65e5\u672c\u8a9e"},"ko":{"name":"Korean","nativeName":"\ud55c\uad6d\uc5b4"},"lv":{"name":"Latvian","nativeName":"Latvie\u0161u"},"lt":{"name":"Lithuanian","nativeName":"Lietuvi\u0173 kalba"},"mk":{"name":"Macedonian","nativeName":"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438"},"ms":{"name":"Malay","nativeName":"Malay"},"mt":{"name":"Maltese","nativeName":"Malti"},"no":{"name":"Norwegian","nativeName":"Norsk"},"fa":{"name":"Persian","nativeName":"\u0641\u0627\u0631\u0633\u06cc"},"pl":{"name":"Polish","nativeName":"Polski"},"pt":{"name":"Portuguese","nativeName":"Portugu\u00eas"},"ro":{"name":"Romanian","nativeName":"Rom\u00e2n\u0103"},"ru":{"name":"Russian","nativeName":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439"},"sr":{"name":"Serbian","nativeName":"\u0421\u0440\u043f\u0441\u043a\u0438"},"sk":{"name":"Slovak","nativeName":"Sloven\u010dina"},"sl":{"name":"Slovenian","nativeName":"Slovensko"},"es":{"name":"Spanish","nativeName":"Espa\u00f1ol"},"sw":{"name":"Swahili","nativeName":"Kiswahili"},"sv":{"name":"Swedish","nativeName":"Svenska"},"th":{"name":"Thai","nativeName":"\u0e44\u0e17\u0e22"},"tr":{"name":"Turkish","nativeName":"T\u00fcrk\u00e7e"},"uk":{"name":"Ukrainian","nativeName":"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"},"ur":{"name":"Urdu","nativeName":"\u0627\u0631\u062f\u0648"},"vi":{"name":"Vietnamese","nativeName":"Ti\u1ebfng Vi\u1ec7t"},"cy":{"name":"Welsh","nativeName":"Cymraeg"},"yi":{"name":"Yiddish","nativeName":"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9"}};
+
+function $(selector) {
+ return document.querySelector(selector);
+}
+
+function $all(selector) {
+ return document.querySelectorAll(selector);
+}
+
+function isEmpty(obj) {
+ return Object.keys(obj).length === 0;
+}
+
+function init() {
+ $("#welcome").innerHTML = chrome.i18n.getMessage("options_welcome");
+ $("#introduction").innerHTML = chrome.i18n.getMessage("options_introduction");
+ $("#languageselectheader").innerHTML = chrome.i18n.getMessage("options_languageselectheader");
+ $("#otheroptionsheader").innerHTML = chrome.i18n.getMessage("options_otheroptionsheader");
+ $("#varioustabs_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_1");
+ $("#uniquetab_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_2");
+ $("#panel_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_3");
+ chrome.storage.sync.get(null, function(items) {
+ if (isEmpty(items)) {
+ items = {'languages': {}, 'uniquetab': ''};
+ chrome.storage.sync.set({'languages': {}, 'uniquetab': ''});
+ }
+ if (items.uniquetab === "yep")
+ $("#uniquetab").checked = true;
+ if (items.uniquetab === "")
+ $("#varioustabs").checked = true;
+ if (items.uniquetab === "panel")
+ $("#panel").checked = true;
+ $("#panelsflag").addEventListener('click', function() { event.preventDefault(); chrome.tabs.create({url: 'chrome://flags/#enable-panels'}); });
+ $("#save").innerHTML = chrome.i18n.getMessage("options_savebutton");
+ $("#save").addEventListener('click', function() {
+ save_options();
+ });
+ var languages = items.languages;
+ for (var language in isoLangs) {
+ var el = document.createElement('div');
+ el.setAttribute('class','language');
+ el.setAttribute('id', 'cont-'+language);
+ $("#languages").appendChild(el);
+ var el2 = document.createElement('input');
+ el2.setAttribute('type','checkbox');
+ el2.setAttribute('id', language);
+ el2.setAttribute('name', language);
+ el2.setAttribute('data-language', language);
+ el.appendChild(el2);
+ var el3 = document.createElement('label');
+ el3.setAttribute('for', language);
+ el3.innerHTML = isoLangs[language]["name"]+" ("+isoLangs[language]["nativeName"]+")";
+ el.appendChild(el3);
+ }
+ if (!languages) {
+ return;
+ }
+ else {
+ var options = items.languages;
+ for (var language in options) {
+ document.getElementById(language).checked = true;
+ }
+ }
+ var languages_el = document.getElementById("languages");
+ });
+}
+
+function save_options() {
+ var languages = document.getElementById("languages");
+ var options = {"uniquetab": "", "languages": {}};
+
+ options.uniquetab = radio_selected("uniquetab");
+
+ for (var language in isoLangs) {
+ if ($("input[data-language='"+language+"']").checked) {
+ options.languages[language] = language;
+ }
+ }
+
+ chrome.storage.sync.set(options, function() {
+ var background = chrome.extension.getBackgroundPage();
+
+ background.translator_tab = false;
+ background.translator_window = false;
+ window.close();
+ });
+
+ // We don't need the following code because the background.js is already listening to changes in chrome.sync ;-) Yeeey!
+ //chrome.extension.getBackgroundPage().createmenus(JSON.stringify(options));
+}
+
+function toObject(arr) {
+ var rv = {};
+ for (var i = 0; i < arr.length; ++i)
+ if (arr[i] !== undefined) rv[i] = arr[i];
+ return rv;
+}
+
+function radio_selected(a) {
+ var elements = document.getElementsByName(a);
+
+ for (var i=0; i<elements.length; i++)
+ if (elements[i].checked) return elements[i].value;
+}
+
+window.addEventListener('load', init);
diff --git a/translate-1.png b/translate-1.png
new file mode 100644
index 0000000..8bab181
--- /dev/null
+++ b/translate-1.png
Binary files differ
diff --git a/translate-128.png b/translate-128.png
new file mode 100644
index 0000000..1a33921
--- /dev/null
+++ b/translate-128.png
Binary files differ
diff --git a/translate-16.png b/translate-16.png
new file mode 100644
index 0000000..6629ac6
--- /dev/null
+++ b/translate-16.png
Binary files differ
diff --git a/translate-2.png b/translate-2.png
new file mode 100644
index 0000000..9625b12
--- /dev/null
+++ b/translate-2.png
Binary files differ
diff --git a/translate-256.png b/translate-256.png
new file mode 100644
index 0000000..0b2ead1
--- /dev/null
+++ b/translate-256.png
Binary files differ
diff --git a/translate-32.png b/translate-32.png
new file mode 100644
index 0000000..ee6fcfe
--- /dev/null
+++ b/translate-32.png
Binary files differ
diff --git a/translate-4.png b/translate-4.png
new file mode 100644
index 0000000..815085d
--- /dev/null
+++ b/translate-4.png
Binary files differ
diff --git a/translate-512.png b/translate-512.png
new file mode 100644
index 0000000..8fc23a3
--- /dev/null
+++ b/translate-512.png
Binary files differ
diff --git a/translate-64.png b/translate-64.png
new file mode 100644
index 0000000..6de6bb7
--- /dev/null
+++ b/translate-64.png
Binary files differ
diff --git a/translate-8.png b/translate-8.png
new file mode 100644
index 0000000..1e5832c
--- /dev/null
+++ b/translate-8.png
Binary files differ