|
|
|
@ -7,12 +7,13 @@
@@ -7,12 +7,13 @@
|
|
|
|
|
<link rel="stylesheet" href="css/style.css" type="text/css" /> |
|
|
|
|
<script src="scripts/lib/mootools-1.2-core-yc.js"></script> |
|
|
|
|
<script src="scripts/lib/mootools-1.2-more.js"></script> |
|
|
|
|
<script src="scripts/misc.js"></script> |
|
|
|
|
<script> |
|
|
|
|
var newCategoryKeyboardEvents = new Keyboard({ |
|
|
|
|
defaultEventType: 'keydown', |
|
|
|
|
events: { |
|
|
|
|
'enter': function(event) { |
|
|
|
|
$('newCategoryButton').click(); |
|
|
|
|
$('categoryNameButton').click(); |
|
|
|
|
event.preventDefault(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -20,42 +21,99 @@
@@ -20,42 +21,99 @@
|
|
|
|
|
newCategoryKeyboardEvents.activate(); |
|
|
|
|
|
|
|
|
|
window.addEvent('domready', function() { |
|
|
|
|
$('newCategory').focus(); |
|
|
|
|
$('newCategoryButton').addEvent('click', function(e) { |
|
|
|
|
new Event(e).stop(); |
|
|
|
|
// check field |
|
|
|
|
var categoryName = $('newCategory').value.trim(); |
|
|
|
|
if (categoryName == null || categoryName == "") |
|
|
|
|
return false; |
|
|
|
|
if (categoryName.match("^([^\\\\\\/]|[^\\\\\\/]([^\\\\\\/]|\\/(?=[^\\/]))*[^\\\\\\/])$") === null) { |
|
|
|
|
alert("QBT_TR(Invalid category name:\nPlease do not use any special characters in the category name.)QBT_TR[CONTEXT=HttpServer]"); |
|
|
|
|
var uriAction = safeTrim(new URI().getData('action')); |
|
|
|
|
var uriHashes = safeTrim(new URI().getData('hashes')); |
|
|
|
|
var uriCategoryName = safeTrim(new URI().getData('categoryName')); |
|
|
|
|
var uriSavePath = safeTrim(new URI().getData('savePath')); |
|
|
|
|
|
|
|
|
|
if (uriAction === "create") { |
|
|
|
|
$('categoryName').focus(); |
|
|
|
|
} |
|
|
|
|
else if (uriAction === "edit") { |
|
|
|
|
if (!uriCategoryName) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var hashesList = new URI().getData('hashes'); |
|
|
|
|
if (!hashesList) { |
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/createCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
category: categoryName |
|
|
|
|
}, |
|
|
|
|
onComplete: function() { |
|
|
|
|
window.parent.closeWindows(); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/setCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
hashes: hashesList, |
|
|
|
|
category: categoryName |
|
|
|
|
}, |
|
|
|
|
onComplete: function() { |
|
|
|
|
window.parent.closeWindows(); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
|
|
|
|
|
$('categoryName').set('disabled', true); |
|
|
|
|
$('categoryName').set('value', escapeHtml(uriCategoryName)); |
|
|
|
|
$('savePath').set('value', escapeHtml(uriSavePath)); |
|
|
|
|
$('savePath').focus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('categoryNameButton').addEvent('click', function(e) { |
|
|
|
|
new Event(e).stop(); |
|
|
|
|
|
|
|
|
|
var savePath = $('savePath').value.trim(); |
|
|
|
|
var categoryName = $('categoryName').value.trim(); |
|
|
|
|
|
|
|
|
|
var verifyCategoryName = function(name) { |
|
|
|
|
if ((name === null) || (name === "")) |
|
|
|
|
return false; |
|
|
|
|
if (name.match("^([^\\\\\\/]|[^\\\\\\/]([^\\\\\\/]|\\/(?=[^\\/]))*[^\\\\\\/])$") === null) { |
|
|
|
|
alert("QBT_TR(Invalid category name:\nPlease do not use any special characters in the category name.)QBT_TR[CONTEXT=HttpServer]"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
switch (uriAction) { |
|
|
|
|
case "set": |
|
|
|
|
if ((uriHashes === "") || !verifyCategoryName(categoryName)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/createCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
category: categoryName, |
|
|
|
|
savePath: savePath |
|
|
|
|
}, |
|
|
|
|
onSuccess: function() { |
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/setCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
hashes: uriHashes, |
|
|
|
|
category: categoryName |
|
|
|
|
}, |
|
|
|
|
onComplete: function() { |
|
|
|
|
window.parent.closeWindows(); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
}, |
|
|
|
|
onError: function() { |
|
|
|
|
alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=HttpServer] " + escapeHtml(categoryName)); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
break; |
|
|
|
|
case "create": |
|
|
|
|
if (!verifyCategoryName(categoryName)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/createCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
category: categoryName, |
|
|
|
|
savePath: savePath |
|
|
|
|
}, |
|
|
|
|
onComplete: function() { |
|
|
|
|
window.parent.closeWindows(); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
break; |
|
|
|
|
case "edit": |
|
|
|
|
new Request({ |
|
|
|
|
url: 'api/v2/torrents/editCategory', |
|
|
|
|
method: 'post', |
|
|
|
|
data: { |
|
|
|
|
category: uriCategoryName, // category name can't be changed |
|
|
|
|
savePath: savePath |
|
|
|
|
}, |
|
|
|
|
onComplete: function() { |
|
|
|
|
window.parent.closeWindows(); |
|
|
|
|
} |
|
|
|
|
}).send(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
@ -65,9 +123,11 @@
@@ -65,9 +123,11 @@
|
|
|
|
|
<body> |
|
|
|
|
<div style="padding: 10px 10px 0px 10px;"> |
|
|
|
|
<p style="font-weight: bold;">QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]:</p> |
|
|
|
|
<input type="text" id="newCategory" value="" maxlength="100" style="width: 220px;" /> |
|
|
|
|
<input type="text" id="categoryName" value="" maxlength="100" style="width: 220px;" /> |
|
|
|
|
<p style="font-weight: bold;">QBT_TR(Save path)QBT_TR[CONTEXT=TransferListWidget]:</p> |
|
|
|
|
<input type="text" id="savePath" value="" style="width: 220px;" /> |
|
|
|
|
<div style="text-align: center; padding-top: 10px;"> |
|
|
|
|
<input type="button" value="QBT_TR(Add)QBT_TR[CONTEXT=HttpServer]" id="newCategoryButton" /> |
|
|
|
|
<input type="button" value="QBT_TR(Add)QBT_TR[CONTEXT=HttpServer]" id="categoryNameButton" /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</body> |
|
|
|
|