[Web UI] Changes in labels implementation

This commit is contained in:
ngosang
2015-07-16 01:04:53 +02:00
parent 4ae2f6c33b
commit a9e9a9c835
7 changed files with 161 additions and 166 deletions

View File

@@ -7,58 +7,41 @@
<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">
window.addEvent('domready', function(){
window.addEvent('domready', function() {
$('newLabel').focus();
$('newLabelButton').addEvent('click', function(e){
// check field
var label_str = $('newLabel').value;
if( label_str == null || label_str == "" ) {
return false;
}
if( label_str.match("[\\\\/:?\"*<>|]") !== null ) {
$('alert_div').style.display = "block";
return false;
}
$('newLabelButton').addEvent('click', function(e) {
new Event(e).stop();
var hashes = new URI().getData('hashes');
var hashesList = hashes.split(',');
var label_json = JSON.stringify( { value : label_str } );
if (hashesList.length) {
var counter = hashesList.length;
hashesList.each(function(hash, index) {
new Request({
url: 'command/setLabel',
method: 'post',
data: {
hash: hash,
label_obj: label_json
},
onComplete: function() {
if( --counter === 0 ) {
window.parent.document.getElementById('newLabelPage').parentNode.removeChild(window.parent.document.getElementById('newLabelPage'));
}
}
}).send();
});
// check field
var labelName = $('newLabel').value.trim();
if (labelName == null || labelName == "")
return false;
if (labelName.match("[\\\\/:?\"*<>|]") !== null) {
alert("QBT_TR(Invalid label name:\nPlease do not use any special characters in the label name.)QBT_TR");
return false;
}
var hashesList = new URI().getData('hashes');
new Request({
url: 'command/setLabel',
method: 'post',
data: {
hashes: hashesList,
label: labelName
},
onComplete: function() {
window.parent.closeWindows();
}
}).send();
});
});
</script>
</head>
<body>
<center>
<h1 class="vcenter">QBT_TR(Label)QBT_TR:
<input type="text" name="label" id="newLabel" value="" maxlength="100" />
</h1>
<div id="alert_div" style="border: 1px #ff0000 solid; display: none; color: #ff0000; background-color: #ffdee8; width: 95%;">
<b>QBT_TR(Invalid label name)QBT_TR</b>:
<br/>
QBT_TR(Please don't use any special characters in the label name.)QBT_TR
<br/>
<div style="padding: 10px 10px 0px 10px;">
<p style="font-weight: bold;">QBT_TR(Label)QBT_TR:</p>
<input type="text" id="newLabel" value="" maxlength="100" style="width: 220px;"/>
<div style="text-align: center;">
<input type="button" value="QBT_TR(Add)QBT_TR" id="newLabelButton"/>
</div>
</div>
<input type="button" value="QBT_TR(Add)QBT_TR" id="newLabelButton"/>
</center>
</body>
</html>