Browse Source

[Web UI] Clean up JavaScript code

adaptive-webui-19844
ngosang 9 years ago
parent
commit
e922275c72
  1. 31
      src/webui/www/public/addtrackers.html
  2. 88
      src/webui/www/public/confirmdeletion.html
  3. 9
      src/webui/www/public/scripts/mocha-init.js
  4. 3
      src/webui/www/public/transferlist.html

31
src/webui/www/public/addtrackers.html

@ -6,20 +6,23 @@
<link rel="stylesheet" href="css/style.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
window.addEvent('domready', function(){ window.addEvent('domready', function(){
$('trackersUrls').focus(); $('trackersUrls').focus();
$('addTrackersButton').addEvent('click', function(e){ $('addTrackersButton').addEvent('click', function(e){
new Event(e).stop(); new Event(e).stop();
var hash = new URI().getData('hash'); var hash = new URI().getData('hash');
new Request({url: 'command/addTrackers', method: 'post', data: {hash: hash, urls: $('trackersUrls').value}, new Request({
onComplete: function() { url: 'command/addTrackers',
window.parent.document.getElementById('trackersPage').parentNode.removeChild(window.parent.document.getElementById('trackersPage')); method: 'post',
} data: {hash: hash, urls: $('trackersUrls').value},
}).send(); onComplete: function() {
}); window.parent.closeWindows();
}); }
</script> }).send();
});
});
</script>
</head> </head>
<body> <body>
<center> <center>

88
src/webui/www/public/confirmdeletion.html

@ -1,65 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>QBT_TR(Deletion confirmation - qBittorrent)QBT_TR</title> <title>QBT_TR(Deletion confirmation - qBittorrent)QBT_TR</title>
<link rel="stylesheet" href="css/style.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript">
<script type="text/javascript"> var hashes = new URI().getData('hashes').split('|');
function $get(key,url){ window.addEvent('domready', function(){
if(arguments.length < 2) url =location.href; $('cancelBtn').focus();
if(arguments.length > 0 && key != ""){ $('cancelBtn').addEvent('click', function(e){
if(key == "#"){ new Event(e).stop();
var regex = new RegExp("[#]([^$]*)"); window.parent.closeWindows();
} else if(key == "?"){ });
var regex = new RegExp("[?]([^#$]*)"); $('confirmBtn').addEvent('click', function(e){
} else { new Event(e).stop();
var regex = new RegExp("[?&]"+key+"=([^&#]*)"); var cmd = 'command/delete';
}
var results = regex.exec(url);
return (results == null )? "" : results[1].replace(/%22/g, "'");
} else {
url = url.split("?");
var results = {};
if(url.length > 1){
url = url[1].split("#");
if(url.length > 1) results["hash"] = url[1];
url[0].split("&").each(function(item,index){
item = item.split("=");
results[item[0]] = item[1].replace(/%22/g, "'");
});
}
return results;
}
}
var hashes = $get('hashes').split(',');
window.addEvent('domready', function(){
$('cancelBtn').focus();
$('cancelBtn').addEvent('click', function(e){
new Event(e).stop();
window.parent.document.getElementById('confirmDeletionPage').parentNode.removeChild(window.parent.document.getElementById('confirmDeletionPage'));
});
$('confirmBtn').addEvent('click', function(e){
new Event(e).stop();
var cmd = 'command/delete';
if($('deleteFromDiskCB').get('checked')) if($('deleteFromDiskCB').get('checked'))
cmd = 'command/deletePerm'; cmd = 'command/deletePerm';
new Request({url: cmd, new Request({
method: 'post', url: cmd,
data: {hashes: hashes.join('|')}, method: 'post',
onComplete: function() { data: {
window.parent.document.getElementById('confirmDeletionPage').parentNode.removeChild(window.parent.document.getElementById('confirmDeletionPage')); 'hashes': hashes.join('|')
} },
}).send(); onComplete: function() {
window.parent.closeWindows();
}); }
}); }).send();
</script> });
});
</script>
</head> </head>
<body> <body>
<br/> <br/>

9
src/webui/www/public/scripts/mocha-init.js

@ -234,17 +234,12 @@ initializeWindows = function() {
deleteFN = function() { deleteFN = function() {
var h = myTable.selectedIds(); var h = myTable.selectedIds();
/*if(h.length && confirm('QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR')) {
h.each(function(item, index){
new Request({url: 'command/delete', method: 'post', data: {hash: item}}).send();
});
}*/
if (h.length) { if (h.length) {
new MochaUI.Window({ new MochaUI.Window({
id: 'confirmDeletionPage', id: 'confirmDeletionPage',
title: "QBT_TR(Deletion confirmation - qBittorrent)QBT_TR", title: "QBT_TR(Deletion confirmation)QBT_TR",
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'confirmdeletion.html?hashes=' + h.join(','), contentURL: 'confirmdeletion.html?hashes=' + h.join("|"),
scrollbars: false, scrollbars: false,
resizable: false, resizable: false,
maximizable: false, maximizable: false,

3
src/webui/www/public/transferlist.html

@ -16,9 +16,6 @@
Delete : function (element, ref) { Delete : function (element, ref) {
deleteFN(); deleteFN();
}, },
DeleteHD : function (element, ref) {
deleteHDFN();
},
Start : function (element, ref) { Start : function (element, ref) {
startFN(); startFN();
}, },

Loading…
Cancel
Save