This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/assets/javascripts/inc/search.js

48 lines
1.9 KiB
JavaScript
Raw Normal View History

2012-05-15 13:25:51 +00:00
// JavaScript Document
// can copy code to any of ur desired javascsript
//extended jquery to search fast.
$.extend($.expr[':'], {
2012-10-08 02:11:45 +00:00
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
2012-05-15 13:25:51 +00:00
});
var interval,sval;
$(document).ready(function(){
2012-10-08 02:11:45 +00:00
$("#user_filter").keyup(function(e){
if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){
sval = $(this).val();
$(".checkbox").popover("hide");
$("div.checkblock").hide();
clearInterval(interval);
interval = setInterval(waitForSearch,1000);
}
})
2012-05-15 13:25:51 +00:00
})
var waitForSearch = function(){
2012-10-08 02:11:45 +00:00
if(sval){
var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range
var re2 = new RegExp("^[\uE7C7-\uE7F3]*$");
if ((re1.test(sval) && (re2.test(sval)))){
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:contains("+sval+")").length
if(totalfoundbyname!=0){
$("div#users_checkbox_ary label.member-name:contains("+sval+")").parent().parent().show();
}else if(totalfoundbyname==0){
$("div#users_checkbox_ary div.for_unit:contains("+sval+")").parent().show();
}
}else{
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length
if(totalfoundbyname!=0){
$("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show();
}else if(totalfoundbyname==0){
$("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show();
}
}
}else{
$(".checkbox").popover('hide');
$("div.checkblock").show();
}
clearInterval(interval);
2012-05-15 13:25:51 +00:00
}