summaryrefslogtreecommitdiff
path: root/html/assets/js/dataTables/search-neutralise.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/assets/js/dataTables/search-neutralise.js')
-rw-r--r--html/assets/js/dataTables/search-neutralise.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/html/assets/js/dataTables/search-neutralise.js b/html/assets/js/dataTables/search-neutralise.js
new file mode 100644
index 0000000..d5c5ba0
--- /dev/null
+++ b/html/assets/js/dataTables/search-neutralise.js
@@ -0,0 +1,40 @@
+function NeutralizeAccent(data){
+ return !data
+ ? ''
+ : typeof data === 'string'
+ ? data
+ .replace( /\n/g, ' ' )
+ .replace( /\u0386/g, "\u0391" ) // 'Ά':'Α'
+ .replace( /\u0388/g, "\u0395" ) // 'Έ':'Ε'
+ .replace( /\u0389/g, "\u0397" ) // 'Ή':'Η'
+ .replace( /\u038A/g, "\u0399" ) // 'Ί':'Ι'
+ .replace( /\u038C/g, "\u039F" ) // 'Ό':'Ο'
+ .replace( /\u038E/g, "\u03A5" ) // 'Ύ':'Υ'
+ .replace( /\u038F/g, "\u03A9" ) // 'Ώ':'Ω'
+ .replace( /\u0390/g, "\u03CA" ) // 'ΐ':'ϊ'
+ .replace( /\u03AC/g, "\u03B1" ) // 'ά':'α'
+ .replace( /\u03AD/g, "\u03B5" ) // 'έ':'ε'
+ .replace( /\u03AE/g, "\u03B7" ) // 'ή':'η'
+ .replace( /\u03AF/g, "\u03B9" ) // 'ί':'ι'
+ .replace( /\u03B0/g, "\u03CB" ) // 'ΰ':'ϋ'
+ .replace( /\u03CC/g, "\u03BF" ) // 'ό':'ο'
+ .replace( /\u03CD/g, "\u03C5" ) // 'ύ':'υ'
+ .replace( /\u03CE/g, "\u03C9" ) // 'ώ':'ω'
+ : data
+}
+
+function custom_search(table_id){
+ var filterVal = '';
+ $('#'+table_id+'_filter input').unbind(); //Unbind default behaviour
+ $('#'+table_id+'_filter input').on('keyup change', function(){
+ var val = NeutralizeAccent(this.value);
+ if(val !== filterVal){
+ filterVal = val;
+ $('#'+table_id+'').DataTable().search(val).draw();
+ }
+ });
+}
+
+jQuery.fn.dataTable.ext.type.search['locale-compare'] = function (data) {
+ return NeutralizeAccent(data);
+} \ No newline at end of file