add sandbox stub

This commit is contained in:
Alex Yatskov 2017-09-05 12:34:52 -07:00
parent 4cb02c398f
commit 9eac50ea05
4 changed files with 46 additions and 1 deletions

View File

@ -24,5 +24,7 @@
<script src="/mixed/js/japanese.js"></script>
<script src="/bg/js/backend.js"></script>
<iframe src="/sb/sandbox.html"></iframe>
</body>
</html>

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Yomichan",
"version": "1.3.4",
"version": "1.3.5",
"description": "Japanese dictionary with Anki integration",
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},
@ -55,5 +55,8 @@
"strict_min_version": "52.0",
"update_url": "https://foosoft.net/projects/yomichan/dl/updates.json"
}
},
"sandbox": {
"pages": ["sb/sandbox.html"]
}
}

30
ext/sb/js/sandbox.js Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2017 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
window.addEventListener('message', event => {
if (event.data.command === 'render') {
const template = Handlebars.compile(event.data.template || '');
const result = template(event.data.context || {});
event.source.postMessage({result, sequence: event.data.sequence});
}
});

10
ext/sb/sandbox.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="/mixed/lib/handlebars.min.js"></script>
<script src="/sb/js/sandbox.js"></script>
</body>
</html>