2011-07-11 23:29:21 +00:00
|
|
|
var opkg = '/cgi-bin/opkg.jim?cmd=';
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2011-07-14 22:22:54 +00:00
|
|
|
|
2012-08-04 00:29:57 +00:00
|
|
|
var busy = false;
|
2012-09-21 20:56:53 +00:00
|
|
|
var reload = false;
|
2012-08-04 00:29:57 +00:00
|
|
|
|
2011-07-14 22:22:54 +00:00
|
|
|
$('#opkgupdate')
|
|
|
|
.button()
|
2012-09-21 20:56:53 +00:00
|
|
|
.click(function() { reload = true; execopkg('update'); })
|
2011-07-14 22:22:54 +00:00
|
|
|
.fadeIn('slow');
|
2011-07-11 23:29:21 +00:00
|
|
|
|
2011-10-05 22:07:22 +00:00
|
|
|
$('#opkgupgradeall')
|
|
|
|
.button()
|
2012-09-21 20:56:53 +00:00
|
|
|
.click(function() { reload = true; execopkg('upgrade'); })
|
2011-10-05 22:07:22 +00:00
|
|
|
.fadeIn('slow');
|
|
|
|
|
2011-07-12 18:57:30 +00:00
|
|
|
$('#pkgtabs').tabs({
|
2012-08-04 00:29:57 +00:00
|
|
|
select: function() {
|
|
|
|
if (busy)
|
|
|
|
{
|
|
|
|
alert('Please wait until the current ' +
|
|
|
|
'operation completes.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
busy = true;
|
|
|
|
$('#pkgtabs')
|
|
|
|
.tabs('option', 'disabled', [0,1,2]);
|
|
|
|
},
|
|
|
|
load: function() {
|
|
|
|
busy = false;
|
|
|
|
setup_buttons();
|
|
|
|
$('#pkgtabs').tabs('option', 'disabled', []);
|
|
|
|
},
|
2011-07-12 18:57:30 +00:00
|
|
|
spinner: '<img border=0 src=/img/loading.gif> ' +
|
|
|
|
'<em>Loading...</em>'
|
|
|
|
});
|
2011-07-11 23:29:21 +00:00
|
|
|
|
|
|
|
var $dialog = $('#dialogue').dialog({
|
|
|
|
title: "Package Management Results",
|
|
|
|
modal: false, autoOpen: false,
|
|
|
|
height: 500, width: 700,
|
|
|
|
show: 'scale', hide: 'fade',
|
|
|
|
draggable: true, resizable: true,
|
|
|
|
buttons: { "Close":
|
|
|
|
function() {$(this).dialog('close');}},
|
2011-10-05 22:07:22 +00:00
|
|
|
close: function(e,u) {
|
2012-09-21 20:56:53 +00:00
|
|
|
if (reload)
|
|
|
|
{
|
|
|
|
$('#refreshing').show('slow');
|
|
|
|
$('#pkgtabs').hide('fast');
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var pkg = $('#dialogue').attr('pkg');
|
|
|
|
$('tr[pkg="' + pkg + '"]')
|
|
|
|
.disable()
|
|
|
|
.find('button').removeClass('va');
|
|
|
|
$('button.va').enable();
|
|
|
|
}
|
2011-10-05 22:07:22 +00:00
|
|
|
}
|
2011-07-11 23:29:21 +00:00
|
|
|
});
|
|
|
|
|
2011-10-05 22:07:22 +00:00
|
|
|
jQuery.ajaxSetup({progressInterval: 1});
|
|
|
|
|
|
|
|
function loaddata(data, isfinal)
|
|
|
|
{
|
2013-02-09 22:46:15 +00:00
|
|
|
if (window.console)
|
|
|
|
{
|
|
|
|
console.log('loaddata called, final=' + isfinal);
|
|
|
|
console.log('Data: ' + data);
|
|
|
|
}
|
2011-10-05 22:07:22 +00:00
|
|
|
if (isfinal)
|
|
|
|
{
|
2013-02-09 22:46:15 +00:00
|
|
|
$('#dresults').text(data);
|
2011-10-05 22:07:22 +00:00
|
|
|
$('#dspinner').hide('slow');
|
2013-02-09 22:46:15 +00:00
|
|
|
$('#complete').show('slow');
|
2011-10-05 22:07:22 +00:00
|
|
|
}
|
2013-02-09 22:46:15 +00:00
|
|
|
else
|
|
|
|
$('#dresults').append(data);
|
2011-10-05 22:07:22 +00:00
|
|
|
}
|
2011-07-14 22:22:54 +00:00
|
|
|
|
2012-08-04 00:29:57 +00:00
|
|
|
function execopkg(arg, pkg)
|
2011-07-14 22:22:54 +00:00
|
|
|
{
|
2012-08-04 00:29:57 +00:00
|
|
|
if (busy)
|
|
|
|
{
|
|
|
|
alert('Please wait until the current ' +
|
|
|
|
'operation completes.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
busy = true;
|
|
|
|
$('button.va').disable();
|
2011-07-14 22:22:54 +00:00
|
|
|
$('#dspinner').show();
|
2012-02-13 21:02:12 +00:00
|
|
|
$('#complete').hide();
|
2011-10-05 22:07:22 +00:00
|
|
|
$('#dresults').empty();
|
2012-08-04 00:29:57 +00:00
|
|
|
$('#dialogue').attr('pkg', pkg);
|
2011-07-14 22:22:54 +00:00
|
|
|
$dialog.dialog('open');
|
2011-10-05 22:07:22 +00:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: opkg + arg,
|
|
|
|
progress: loaddata,
|
|
|
|
success: function(data) {
|
|
|
|
loaddata(data, true);
|
|
|
|
},
|
|
|
|
error: function(_, _, e) {
|
2013-02-09 22:46:15 +00:00
|
|
|
if (window.console)
|
|
|
|
console.log("ajax error");
|
2011-10-05 22:07:22 +00:00
|
|
|
alert(e);
|
|
|
|
}
|
|
|
|
});
|
2012-08-04 00:29:57 +00:00
|
|
|
busy = false;
|
2011-07-14 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
function setup_buttons()
|
|
|
|
{
|
|
|
|
$('button.remove, button.install, button.upgrade')
|
|
|
|
.button()
|
|
|
|
.click(function() {
|
|
|
|
if ($(this).attr('action') == 'remove' &&
|
|
|
|
!confirm('Please confirm removal of the ' +
|
|
|
|
$(this).attr('id') + ' package.'))
|
|
|
|
return;
|
2012-08-04 00:29:57 +00:00
|
|
|
|
2011-07-14 22:22:54 +00:00
|
|
|
execopkg(encodeURIComponent($(this).attr('action') +
|
2012-08-04 00:29:57 +00:00
|
|
|
' ' + $(this).attr('id')),
|
|
|
|
$(this).closest('tr').attr('pkg'));
|
2011-07-11 23:29:21 +00:00
|
|
|
}).fadeIn('slow');
|
2012-08-04 00:29:57 +00:00
|
|
|
|
|
|
|
$('a.depends').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var pkg = $(this).closest('tr').attr('pkg');
|
|
|
|
execopkg(encodeURIComponent('whatdepends ' + pkg),
|
|
|
|
false);
|
|
|
|
});
|
2011-07-11 23:29:21 +00:00
|
|
|
}
|
|
|
|
|
2012-08-04 00:29:57 +00:00
|
|
|
});
|
2011-07-11 23:29:21 +00:00
|
|
|
|