Provide API to select a file on mobile
This commit is contained in:
@ -176,3 +176,18 @@ window.useAndroidPanes = function() {
|
||||
return (typeof android !== 'undefined' && android && android.addPane && window.isSmartphone());
|
||||
}
|
||||
|
||||
if(typeof android !== 'undefined' && android && android.getFileRequestUrlPrefix) {
|
||||
window.requestFile = function(callback) {
|
||||
do {
|
||||
var funcName = "onFileSelected" + parseInt(Math.random()*0xFFFF).toString(16);
|
||||
} while(window[funcName] !== undefined)
|
||||
|
||||
window[funcName] = function(filename, content) {
|
||||
callback(decodeURIComponent(filename), atob(content));
|
||||
};
|
||||
var script = document.createElement('script');
|
||||
script.src = android.getFileRequestUrlPrefix() + funcName;
|
||||
(document.body || document.head || document.documentElement).appendChild(script);
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user