Refactor options.js to include credits directly
Bug: translateselectedtext:5
Change-Id: I83306dd3b6fe064f7751ba20913a3acc754e905b
diff --git a/src/options/credits.json5 b/src/options/credits.json5
new file mode 100644
index 0000000..690e2a6
--- /dev/null
+++ b/src/options/credits.json5
@@ -0,0 +1,25 @@
+[
+ {
+ "name": "Metro Uinvert Dock Icon Set",
+ "url": "http://dakirby309.deviantart.com/art/Metro-Uinvert-Dock-Icon-Set-725-Icons-294529071",
+ "author": "dAKirby309"
+ },
+ {
+ "name": "Sortable",
+ "url": "https://github.com/RubaXa/Sortable",
+ "author": "Lebedev Konstantin",
+ "license": "MIT License"
+ },
+ {
+ "name": "Chromium",
+ "url": "https://code.google.com/p/chromium/",
+ "author": "The Chromium Authors",
+ "license": "BSD-like License"
+ },
+ {
+ "name": "What-2-Nite",
+ "url": "https://github.com/enricolucia/what-2-nite/blob/master/isoLangs.json",
+ "author": "Google, Inc.",
+ "license": "MIT License"
+ }
+]
diff --git a/src/options/i18n-credits.json5 b/src/options/i18n-credits.json5
new file mode 100644
index 0000000..2f15495
--- /dev/null
+++ b/src/options/i18n-credits.json5
@@ -0,0 +1,404 @@
+[
+ {
+ "name": "Alexander Simkin",
+ "languages": [
+ {
+ "id": "ru",
+ "name": "Russian"
+ }
+ ]
+ },
+ {
+ "name": "Omer Surer (omersurer)",
+ "languages": [
+ {
+ "id": "nl",
+ "name": "Dutch"
+ },
+ {
+ "id": "tr",
+ "name": "Turkish"
+ }
+ ]
+ },
+ {
+ "name": "myjourney in Steemit (myjourney)",
+ "languages": [
+ {
+ "id": "zh-CN",
+ "name": "Chinese Simplified"
+ },
+ {
+ "id": "zh-TW",
+ "name": "Chinese Traditional"
+ }
+ ]
+ },
+ {
+ "name": "Lukas Novotny (novas78)",
+ "languages": [
+ {
+ "id": "cs",
+ "name": "Czech"
+ },
+ {
+ "id": "sk",
+ "name": "Slovak"
+ }
+ ]
+ },
+ {
+ "name": "Serhiy Dmytryshyn (dies)",
+ "languages": [
+ {
+ "id": "ru",
+ "name": "Russian"
+ },
+ {
+ "id": "uk",
+ "name": "Ukrainian"
+ }
+ ]
+ },
+ {
+ "name": "Dremski",
+ "languages": [
+ {
+ "id": "bg",
+ "name": "Bulgarian"
+ }
+ ]
+ },
+ {
+ "name": "Thoth",
+ "languages": [
+ {
+ "id": "et",
+ "name": "Estonian"
+ }
+ ]
+ },
+ {
+ "name": "Reza Rafsanjani (R3z4_Pr0gramm3r)",
+ "languages": [
+ {
+ "id": "fa",
+ "name": "Persian"
+ }
+ ]
+ },
+ {
+ "name": "HetzblattGegenHetze (hetzegegenhetze)",
+ "languages": [
+ {
+ "id": "de",
+ "name": "German"
+ }
+ ]
+ },
+ {
+ "name": "Nettlebay AP (nettlebay)",
+ "languages": [
+ {
+ "id": "fr",
+ "name": "French"
+ }
+ ]
+ },
+ {
+ "name": "Christian Dos Reis (christianytony)",
+ "languages": [
+ {
+ "id": "it",
+ "name": "Italian"
+ }
+ ]
+ },
+ {
+ "name": "M Angga Ariska (anggaariska)",
+ "languages": [
+ {
+ "id": "id",
+ "name": "Indonesian"
+ }
+ ]
+ },
+ {
+ "name": "Ahmed Mohamed Abbas (moodfactor)",
+ "languages": [
+ {
+ "id": "ar",
+ "name": "Arabic"
+ }
+ ]
+ },
+ {
+ "name": "zararina",
+ "languages": [
+ {
+ "id": "fil",
+ "name": "Filipino"
+ }
+ ]
+ },
+ {
+ "name": "dusttanker (macio955)",
+ "languages": [
+ {
+ "id": "pl",
+ "name": "Polish"
+ }
+ ]
+ },
+ {
+ "name": "Can Altıntaş (crybois)",
+ "languages": [
+ {
+ "id": "en-GB",
+ "name": "English, United Kingdom"
+ }
+ ]
+ },
+ {
+ "name": "Andra (sarmizegetusa)",
+ "languages": [
+ {
+ "id": "ro",
+ "name": "Romanian"
+ }
+ ]
+ },
+ {
+ "name": "Csegöldi Csaba (csacseg)",
+ "languages": [
+ {
+ "id": "hu",
+ "name": "Hungarian"
+ }
+ ]
+ },
+ {
+ "name": "Miguel Dos Reis (siersod)",
+ "languages": [
+ {
+ "id": "pt-PT",
+ "name": "Portuguese"
+ }
+ ]
+ },
+ {
+ "name": "jznsamuel (jasonsamuel88)",
+ "languages": [
+ {
+ "id": "hi",
+ "name": "Hindi"
+ }
+ ]
+ },
+ {
+ "name": "sagorahmed",
+ "languages": [
+ {
+ "id": "bn",
+ "name": "Bengali"
+ }
+ ]
+ },
+ {
+ "name": "Grimpy",
+ "languages": [
+ {
+ "id": "sl",
+ "name": "Slovenian"
+ }
+ ]
+ },
+ {
+ "name": "Zacarias Ponte (wolfteambrconta)",
+ "languages": [
+ {
+ "id": "pt-BR",
+ "name": "Portuguese, Brazilian"
+ }
+ ]
+ },
+ {
+ "name": "Marko Varović (mvarovic)",
+ "languages": [
+ {
+ "id": "de",
+ "name": "German"
+ },
+ {
+ "id": "hr",
+ "name": "Croatian"
+ }
+ ]
+ },
+ {
+ "name": "Marko (MarkoIndaco)",
+ "languages": [
+ {
+ "id": "it",
+ "name": "Italian"
+ }
+ ]
+ },
+ {
+ "name": "Arefat Dev (arefat2005)",
+ "languages": [
+ {
+ "id": "am",
+ "name": "Amharic"
+ }
+ ]
+ },
+ {
+ "name": "Marek Siwak (siwakmarek1971)",
+ "languages": [
+ {
+ "id": "pl",
+ "name": "Polish"
+ }
+ ]
+ },
+ {
+ "name": "hypnotichemionus",
+ "languages": [
+ {
+ "id": "zh-CN",
+ "name": "Chinese Simplified"
+ }
+ ]
+ },
+ {
+ "name": "Emre Kayık (emrekayik)",
+ "languages": [
+ {
+ "id": "tr",
+ "name": "Turkish"
+ }
+ ]
+ },
+ {
+ "name": "NationalPark (nationalpark)",
+ "languages": [
+ {
+ "id": "zh-CN",
+ "name": "Chinese Simplified"
+ }
+ ]
+ },
+ {
+ "name": "Sturix",
+ "languages": [
+ {
+ "id": "ru",
+ "name": "Russian"
+ }
+ ]
+ },
+ {
+ "name": "DAI GIA VO (lecay0945578232)",
+ "languages": [
+ {
+ "id": "vi",
+ "name": "Vietnamese"
+ }
+ ]
+ },
+ {
+ "name": "wpwwsw wpwwsw (wpwwsw)",
+ "languages": [
+ {
+ "id": "zh-CN",
+ "name": "Chinese Simplified"
+ }
+ ]
+ },
+ {
+ "name": "GiorgioHerbie",
+ "languages": [
+ {
+ "id": "it",
+ "name": "Italian"
+ }
+ ]
+ },
+ {
+ "name": "Я. Николов (qroslavnikolaev)",
+ "languages": [
+ {
+ "id": "bg",
+ "name": "Bulgarian"
+ },
+ {
+ "id": "en-GB",
+ "name": "English, United Kingdom"
+ }
+ ]
+ },
+ {
+ "name": "Tomas Santisteban Castaño (santicastano55)",
+ "languages": [
+ {
+ "id": "es-ES",
+ "name": "Spanish"
+ }
+ ]
+ },
+ {
+ "name": "潘忠廷 (zs123sz)",
+ "languages": [
+ {
+ "id": "zh-TW",
+ "name": "Chinese Traditional"
+ }
+ ]
+ },
+ {
+ "name": "ต่าย กันทะพันธ์ (taiprotex)",
+ "languages": [
+ {
+ "id": "th",
+ "name": "Thai"
+ }
+ ]
+ },
+ {
+ "name": "jj jpg (smoes.jpg)",
+ "languages": [
+ {
+ "id": "de",
+ "name": "German"
+ }
+ ]
+ },
+ {
+ "name": "hjeans",
+ "languages": [
+ {
+ "id": "es-ES",
+ "name": "Spanish"
+ }
+ ]
+ },
+ {
+ "name": "se7en9702",
+ "languages": [
+ {
+ "id": "te",
+ "name": "Telugu"
+ }
+ ]
+ },
+ {
+ "name": "Thomas Fritz (thomasfritz88)",
+ "languages": [
+ {
+ "id": "de",
+ "name": "German"
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/src/options/options.js b/src/options/options.js
index 1d47da6..c89f1bd 100644
--- a/src/options/options.js
+++ b/src/options/options.js
@@ -2,6 +2,9 @@
import {isoLangs} from '../common/consts.js';
+import credits from './credits.json5';
+import i18nCredits from './i18n-credits.json5';
+
let sortable;
function $(selector) {
@@ -145,93 +148,81 @@
});
// About credits...
- var normalCredits = fetch('json/credits.json').then(res => res.json());
- var i18nCredits = fetch('json/i18n-credits.json').then(res => res.json());
+ var content = $('dialog#credits_dialog .content_area');
+ credits.forEach(item => {
+ var div = document.createElement('div');
+ div.classList.add('entry');
+ if (item.url) {
+ var a = document.createElement('a');
+ a.classList.add('homepage');
+ a.href = item.url;
+ a.target = '_blank';
+ a.textContent = chrome.i18n.getMessage('options_credits_homepage');
+ div.append(a);
+ }
- Promise.all([normalCredits, i18nCredits])
- .then(values => {
- var credits = values[0];
- var i18nCredits = values[1];
- var content = $('dialog#credits_dialog .content_area');
- credits.forEach(item => {
- var div = document.createElement('div');
- div.classList.add('entry');
- if (item.url) {
- var a = document.createElement('a');
- a.classList.add('homepage');
- a.href = item.url;
- a.target = '_blank';
- a.textContent =
- chrome.i18n.getMessage('options_credits_homepage');
- div.append(a);
- }
+ var h4 = document.createElement('h4');
+ h4.textContent = item.name;
+ div.append(h4);
- var h4 = document.createElement('h4');
- h4.textContent = item.name;
- div.append(h4);
+ if (item.author) {
+ var p = document.createElement('p');
+ p.classList.add('author');
+ p.textContent = chrome.i18n.getMessage('options_credits_by') + ' ' +
+ item.author + (item.license ? ' - ' + item.license : '');
+ div.append(p);
+ }
+ content.append(div);
+ });
- if (item.author) {
- var p = document.createElement('p');
- p.classList.add('author');
- p.textContent = chrome.i18n.getMessage('options_credits_by') +
- ' ' + item.author +
- (item.license ? ' - ' + item.license : '');
- div.append(p);
- }
- content.append(div);
- });
+ var cList = document.getElementById('translators');
+ i18nCredits.forEach(contributor => {
+ var li = document.createElement('li');
+ var languages = [];
+ if (contributor.languages) {
+ contributor.languages.forEach(lang => {
+ languages.push(lang.name || 'undefined');
+ });
+ }
- var cList = document.getElementById('translators');
- i18nCredits.forEach(contributor => {
- var li = document.createElement('li');
- var languages = [];
- if (contributor.languages) {
- contributor.languages.forEach(lang => {
- languages.push(lang.name || 'undefined');
- });
- }
+ var name = document.createElement('span');
+ name.classList.add('name');
+ name.textContent = contributor.name || 'undefined';
+ li.append(name);
- var name = document.createElement('span');
- name.classList.add('name');
- name.textContent = contributor.name || 'undefined';
- li.append(name);
+ if (languages.length > 0) {
+ var languages = document.createTextNode(': ' + languages.join(', '));
+ li.append(languages);
+ }
- if (languages.length > 0) {
- var languages =
- document.createTextNode(': ' + languages.join(', '));
- li.append(languages);
- }
+ cList.append(li);
+ });
- cList.append(li);
- });
+ window.onhashchange = function() {
+ if (location.hash == '#credits') {
+ var credits = document.getElementById('credits_dialog');
+ credits.showModal();
+ credits.querySelector('.scrollable').scrollTo(0, 0);
+ $('#credits_ok').focus();
+ }
+ };
- window.onhashchange = function() {
- if (location.hash == '#credits') {
- var credits = document.getElementById('credits_dialog');
- credits.showModal();
- credits.querySelector('.scrollable').scrollTo(0, 0);
- $('#credits_ok').focus();
- }
- };
+ if (location.hash == '#credits') {
+ $('dialog#credits_dialog').showModal();
+ $('#credits_ok').focus();
+ }
- if (location.hash == '#credits') {
- $('dialog#credits_dialog').showModal();
- $('#credits_ok').focus();
- }
+ $('#credits_ok').addEventListener('click', _ => {
+ $('dialog#credits_dialog').close();
+ });
+ $('dialog#credits_dialog').addEventListener('close', _ => {
+ history.pushState(
+ '', document.title,
+ window.location.pathname + window.location.search);
+ });
- $('#credits_ok').addEventListener('click', _ => {
- $('dialog#credits_dialog').close();
- });
- $('dialog#credits_dialog').addEventListener('close', _ => {
- history.pushState(
- '', document.title,
- window.location.pathname + window.location.search);
- });
-
- // Print language list in the modal dialog
- printListModal();
- })
- .catch(err => console.log(err));
+ // Print language list in the modal dialog
+ printListModal();
});
}