This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689e8b0
commit 8bec403
Showing
6 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
var path; | ||
|
||
|
||
window.addEventListener('DOMContentLoaded', function() { | ||
var sdcard = navigator.getDeviceStorage('sdcard'); | ||
|
||
sdcard.addEventListener("change", function(event) { | ||
var reason = event.reason; | ||
var path = event.path; | ||
|
||
install(path) | ||
|
||
}); | ||
|
||
function install(param) { | ||
|
||
var request = sdcard.get(param); | ||
|
||
request.onsuccess = function() { | ||
var file = this.result; | ||
//alert("Get the file: " + file.name); | ||
installPkg(file) | ||
} | ||
|
||
request.onerror = function() { | ||
//alert("Unable to get the file: " + this.error); | ||
} | ||
} | ||
|
||
|
||
var request = sdcard.get("my-file.txt"); | ||
|
||
request.onsuccess = function() { | ||
var file = this.result; | ||
console.log("Get the file: " + file.name); | ||
} | ||
|
||
request.onerror = function() { | ||
console.warn("Unable to get the file: " + this.error); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
function fparts(fName) { | ||
let parts = fName.split('/') | ||
let basename = parts.pop() | ||
return { dirname: parts.join('/'), basename: basename } | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
function installPkg(packageFile) { | ||
navigator.mozApps.mgmt.import(packageFile).then(function() { | ||
alert('Installation successful!') | ||
}).catch(e => { | ||
alert('Installation error: ' + e.name + ' ' + e.message) | ||
}) | ||
let appGetter = navigator.mozApps.mgmt.getAll() | ||
appGetter.onsuccess = function() { | ||
let apps = appGetter.result | ||
alert.dir(apps) | ||
} | ||
appGetter.onerror = function(e) { | ||
alert.dir(this.error) | ||
} | ||
} | ||
|
||
|
||
|
||
window.addEventListener('keydown', function(e) { | ||
switch (e.key) { | ||
|
||
case '1': | ||
alert(path) | ||
installPkg(path) | ||
|
||
break; | ||
|
||
|
||
|
||
|
||
|
||
} | ||
}) | ||
|
||
|
||
}, false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.