Commit 8f2646fe authored by Florent Chehab's avatar Florent Chehab
Browse files

js update

parent 56d05519
......@@ -108,7 +108,7 @@
<select id='UV-select' onchange="update_display(this.value);">
</select>
<input id="UV-input-text" type="text">
<input type="button" value="Visualiser" onclick="update_display($('#UV-input-text').val())">
<input type="button" value="Visualiser" onclick="update_select($('#UV-input-text').val())">
</form>
</div>
......@@ -311,26 +311,35 @@
update_display(all_uvs[0]);
}, 200);
// js for handling input uv name
var update_select = function (uv){
for (ind in all_uvs) {
if (all_uvs[ind] == uv) {
$("#UV-select").val(uv).change();
return true;
}
}
return false;
}
$('#UV-input-text').keyup(function (event) {
var val = $('#UV-input-text').val().toUpperCase();
if (event.keyCode === 13) {
event.preventDefault();
for (ind in all_uvs) {
if (all_uvs[ind] == val) {
update_display(val);
}
}
update_select(val);
} else {
var valid = false;
for (ind in all_uvs) {
var uv = all_uvs[ind];
var re = new RegExp('^' + val);
if (uv.match(re)) {
valid = true;
break;
var check_input = function(value) {
var valid = false;
for (ind in all_uvs) {
var uv = all_uvs[ind];
var re = new RegExp('^' + value);
if (uv.match(re)) {
return true;
}
}
return false;
}
if (!valid) {
while(!check_input(val)) {
val = val.substring(0, val.length - 1);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment