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