Chrome, , , - , . , , javascript , , , ( ).
, JavaScript main.js, , window document .
, , main.js , index.html, foreground.js script. :
manifest.json
{
"manifest_version": 2,
"name": "Qaru question test app",
"version": "1",
"offline_enabled": true,
"app": {
"background": {
"persistent": true,
"scripts": [
"/js/background.js"
]
}
},
"permissions": [
"notifications",
"storage",
{"fileSystem": ["directory"]}
]
}
JS/background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create("index.html");
});
index.html
<!DOCTYPE html>
<html>
<head>
<title>TEST</title>
<script src="js/foreground.js"></script>
</head>
<body>
<input id="input" />
</body>
</html>
JS/foreground.js
window.addEventListener('load', function() {
document.getElementById('input').addEventListener('click', function() {
chrome.fileSystem.chooseEntry({type: 'openFile'}, function(readOnlyEntry) {
console.log(readOnlyEntry);
});
});
});
, , . FileEntry, ( , ). " ", " ", .):
FileEntry {filesystem: DOMFileSystem, fullPath: "/TestFile.rtf", name: "TestFile.rtf", isDirectory: false, isFile: true…} foreground.js:4
:
, jQuery DOM . Chrome Apps jQuery, , DOM Node, jQuery.
,
$('input').addEventListener('click', function() {
.
document.querySelector('input').addEventListener('click'), function() {
.