More stubbing

This commit is contained in:
Alex Yatskov 2016-03-20 10:52:27 -07:00
parent 8f24c5ff6a
commit 84fec940db
6 changed files with 69 additions and 1 deletions

8
background.html Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<body>
<script src="lib/jquery-2.2.2.min.js"></script>
<script src="jp/dictionary.js"></script>
<script src="jp/translator.js"></script>
</body>
</html>

View File

@ -51,4 +51,5 @@ function onMouseDown(e) {
}
window.addEventListener('mousedown', onMouseDown, false);

View File

@ -18,6 +18,11 @@
class Dictionary {
constructor(rules) {
this.rules = rules;
}
deinflect(term, validator) {
}
}

48
jp/translator.js Normal file
View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2016 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class Translator {
constructor(paths) {
this.paths = paths
this.rules = {}
this.initialized = false;
}
initialize(callback) {
if (this.initialized) {
return;
}
$.when(
$.getJSON(chrome.extension.getURL(this.paths['rules']))
).done(rules => {
this.rules = rules;
this.initialized = true;
if (callback) {
callback();
}
});
}
}
let trans = new Translator({
rules: 'jp/data/rules.json'
});
trans.initialize();

4
lib/jquery-2.2.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -8,9 +8,11 @@
"default_icon": "icon.png"
},
"background": { "page": "background.html" },
"content_scripts": [{
"matches": [ "http://*/*", "https://*/*" ],
"js": [ "jp/dictionary.js", "content.js" ],
"js": [ "content.js" ],
"run_at": "document_end"
}]
}