RepoZilla/content/js/repo.js

36 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-10-31 00:21:09 +00:00
function install(){
var scop = document.getElementById('m').value;
var manifestUrl = document.getElementById('repo').value;
if(manifestUrl != ''){
switch(scop){
case 'host':
var request = window.navigator.mozApps.install(manifestUrl);
var msgints = 'Installation successful!';
break;
case 'pack':
var request = navigator.mozApps.installPackage(manifestUrl,opt.data || {});
var msgints = 'Installation in process!';
break;
}
request.onsuccess = function () {
alert(msgints);
};
request.onerror = function () {
alert('Install failed, error: ' + this.error.name + '\nRepo: ' + manifestUrl);
};
} else {
alert("Insert a url like:\nhttp://example.com/app/manifest.webapp");
}
}
$(document).ready(function(){
var plhd;
$("select[id=m]").change(function(){
var opt = $('select[id=m]').val();
if(opt == 'host'){
plhd = "http://example.com/app/manifest.webapp";
} else if(opt == 'pack'){
plhd = "http://example.com/app/package.webapp";
}
$("#repo").attr("placeholder", plhd);
});
});