File reorg and cleanup

This commit is contained in:
Alex Yatskov 2016-03-24 20:30:18 -07:00
parent 1b27832054
commit ac012b26b3
4 changed files with 15 additions and 18 deletions

View File

@ -5,6 +5,6 @@
<script src="jp/dictionary.js"></script> <script src="jp/dictionary.js"></script>
<script src="jp/deinflector.js"></script> <script src="jp/deinflector.js"></script>
<script src="jp/translator.js"></script> <script src="jp/translator.js"></script>
<script src="jp/init.js"></script> <script src="jp/api.js"></script>
</body> </body>
</html> </html>

View File

@ -17,20 +17,6 @@
*/ */
function onInit() {
const test = trans.findTerm('食べられない');
chrome.runtime.onMessage.addListener(onMessage);
}
const res = {
rules: 'jp/data/rules.json',
edict: 'jp/data/edict.json',
enamdict: 'jp/data/enamdict.json',
kanjidic: 'jp/data/kanjidic.json'
};
window.trans = new Translator(res, onInit);
function onMessage(request, sender, callback) { function onMessage(request, sender, callback) {
switch (request.action.toLowerCase()) { switch (request.action.toLowerCase()) {
case 'define': case 'define':
@ -39,3 +25,15 @@ function onMessage(request, sender, callback) {
} }
} }
(() => {
const res = {
rules: 'jp/data/rules.json',
edict: 'jp/data/edict.json',
enamdict: 'jp/data/enamdict.json',
kanjidic: 'jp/data/kanjidic.json'
};
window.trans = new Translator(res, function() {
chrome.runtime.onMessage.addListener(onMessage);
});
})();

View File

@ -8,8 +8,7 @@
"background": {"page": "background.html"}, "background": {"page": "background.html"},
"content_scripts": [{ "content_scripts": [{
"matches": ["http://*/*", "https://*/*"], "matches": ["*://*/*"],
"js": ["content.js", "util.js"], "js": ["content.js", "api.js"]
"run_at": "document_end"
}] }]
} }