remove depreciated code

This commit is contained in:
Derek Macias 2015-12-14 21:49:10 -07:00
parent 99fb631974
commit 4584e5d39b

View File

@ -1,14 +1,13 @@
$(function(){ $(function(){
//Shadowbox.init({onClose:packageQuery});
//tablesorter options //tablesorter options
$('#tblPackages').tablesorter({headers:{5:{sorter:false}}}); $('#tblPackages').tablesorter({headers:{5:{sorter:false}}});
// "uninstall package" switch and cookie // "uninstall package" switch and cookie
$('#removepkg') $('#removepkg')
.switchButton({ .switchButton({
labels_placement: "right", labels_placement: "left",
on_label: 'uninstall packages On', on_label: 'unInstall Packages',
off_label: 'uninstall packages Off', off_label: 'unInstall Packages',
checked: $.cookie('nerdpack_packages') == 'remove' checked: $.cookie('nerdpack_packages') == 'remove'
}) })
.change(function () { .change(function () {
@ -19,8 +18,8 @@ $(function(){
$('#checkall') $('#checkall')
.switchButton({ .switchButton({
labels_placement: "right", labels_placement: "right",
on_label: 'select all', on_label: 'Select All',
off_label: ' select all', off_label: 'Select All',
checked: $.cookie('nerdpack_checkall') == 'yes' checked: $.cookie('nerdpack_checkall') == 'yes'
}) })
.change(function() { //on change .change(function() { //on change
@ -55,8 +54,9 @@ function packageManager() {
type : "POST", type : "POST",
url : "/update.php", url : "/update.php",
data : $('#package_form').serializeArray(), data : $('#package_form').serializeArray(),
complete: function() { success: function() {
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=webgui&arg2='+$.cookie('nerdpack_packages'),'Manage Packages',600,900,true); openBox('/plugins/NerdPack/scripts/packagemanager&arg1=download&arg2='+
$.cookie('nerdpack_packages'),'Manage Packages',600,900,true);
} }
}); });
}; };
@ -69,127 +69,53 @@ function packageQuery() {
dataType: "json", dataType: "json",
url: "/plugins/NerdPack/include/PackageQuery.php", url: "/plugins/NerdPack/include/PackageQuery.php",
success: function(data) { success: function(data) {
if (data.length > 1){ for( i in data ) {
for( i in data ) { var Update;
$("#tblPackages tbody").append( if (data[i].downloadeq == data[i].downloaded && data[i].installeq == data[i].installed )
"<tr>"+ Update = "<span style=\"color:#44B012;white-space:nowrap;\"><i class=\"fa fa-check\"></i> up-to-date</span>";
"<td>"+data[i].name+"</td>"+ //package name else
"<td></td>"+ //package status Update = "<span style=\"white-space:nowrap;\"><i class=\"fa fa-cloud-download\"></i><a> update ready<a></span>";
"<td>"+(data[i].size / 1000).toFixed(0)+"</td>"+ //package size
"<td>"+data[i].downloaded+"</td>"+ //package installed
"<td>"+data[i].installed+"</td>"+ //package installed
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox'>"+
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'>"+
"</td></tr>");
$('#'+data[i].pkgname)
.switchButton({
labels_placement: 'right',
on_label: 'On',
off_label: 'Off',
checked: data[i].config == "yes"
})
.change(function() {
var par = $(this).parent().parent();
if(this.checked)
par.find('.pkgvalue').val("yes");
else
par.find('.pkgvalue').val("no");
$("#btnApply").prop("disabled", false);
checkDepends();
});
}
}else {
$("#tblPackages tbody").append( $("#tblPackages tbody").append(
"<tr>"+ "<tr>"+
"<td><input type='button' value='Download Packages' onclick='downloadPackages();'></td>"+ "<td>"+data[i].name+"</td>"+ //package name
"<td>"+Update+"</td>"+ //package status
"<td>"+(data[i].size / 1000).toFixed(0)+"</td>"+ //package size
"<td>"+data[i].downloaded+"</td>"+ //package installed
"<td>"+data[i].installed+"</td>"+ //package installed
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox'>"+
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+
data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
"<td><img src='/plugins/dynamix/images/close.png' width='24' height='24' "+
"class='btnRemove' title='remove package from flash drive'/></td>"+
"</tr>"); "</tr>");
$(".btnRemove").unbind("click", Remove).bind("click", Remove);
$('#'+data[i].pkgname)
.switchButton({
labels_placement: 'right',
on_label: 'On',
off_label: 'Off',
checked: data[i].config == "yes"
})
.change(function() {
var par = $(this).parent().parent();
if(this.checked)
par.find('.pkgvalue').val("yes");
else
par.find('.pkgvalue').val("no");
$("#btnApply").prop("disabled", false);
checkDepends();
});
} }
}, },
complete : function () { complete : function () {
$("#tblPackages").trigger("update"); $("#tblPackages").trigger("update");
packageCheck()
}, },
error: function () { error: function () {
} }
}); });
}; };
// check github for newer package and report status
function packageCheck() {
$.ajax({
type: "GET",
url: "/boot/config/plugins/NerdPack/packages.json",
dataType: "json",
success: function(data) {
$('#tblPackages tbody tr').each(function(row, tr) {
var tblPackage = $(tr).children("td:nth-child(1)").html();
var tblName = $(tr).children("td:nth-child(6)").find('.pkgcheckbox').attr("id");
for( i in data ) {
var Package = data[i].name;
var pkgNameArray = Package.split('-');
var pkgName = pkgNameArray[0];
if (pkgNameArray.length > 4){
for( var ii = 1; ii < pkgNameArray.length-3; ii++ ) {
pkgName = pkgName+"-"+pkgNameArray[ii];
}
}
if ( tblName == pkgName){
if (tblPackage == Package)
var Update = "<span style=\"color:#44B012;white-space:nowrap;\"><i class=\"fa fa-check\"></i> up-to-date</span>";
else
var Update = "<span style=\"white-space:nowrap;\"><i class=\"fa fa-cloud-download\"></i><a href='#' onclick='packageUpdate(\""+tblName+"\",\""+tblPackage+"\",\""+Package+"\",\""+data[i].sha+"\");'> update ready<a></span>";
}
}
$(tr).children("td:nth-child(2)").html(Update);
});
},
complete : function () {
$("#tblPackages").trigger("update");
},
error: function () {
}
});
};
// update packages
function packageUpdate(pkgName, pkgOld, pkgNew, pkgSha) {
$.ajax({
type: "POST",
dataType: "json",
url: "/plugins/NerdPack/include/PackageUpdate.php",
data: {pkgname: pkgName, pkgold: pkgOld, pkgnew: pkgNew, pkgsha: pkgSha},
success: function(data) {
alert(data);
},
complete : function () {
//location.reload();
},
error: function () {
}
});
};
function downloadPackages() {
$.ajax({
type: "POST",
url: "/plugins/NerdPack/include/PackageDownload.php",
dataType: "json",
success: function(data) {
for( i in data ) {
packageUpdate(null,null,data[i].name,data[i].sha);
}
},
complete : function () {
$("#tblPackages").trigger("update");
},
error: function () {
}
});
};
function checkDepends() { function checkDepends() {
if ($('#screen').prop('checked') == true){ if ($('#screen').prop('checked') == true){
$('#utempter').switchButton({checked: true}); $('#utempter').switchButton({checked: true});
@ -200,3 +126,22 @@ function checkDepends() {
$('#python','.pkgvalue').val('yes'); $('#python','.pkgvalue').val('yes');
} }
}; };
function Remove(){
var par = $(this).parent().parent();
if (par.children("td:nth-child(4)").html() == "yes"){
var Package = par.children("td:nth-child(1)").html();
var Downloaded = par.children("td:nth-child(4)").html();
var Confirm = confirm("Remove package "+Package+" from flash drive?")
if (Confirm) {
par.children("td:nth-child(4)").html("no");
$.ajax({
type : "POST",
url: '/plugins/NerdPack/include/PackageRemove.php',
data : {pkg:Package},
success: function() {
}
});
}
}
};