diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-13 02:35:32 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-13 02:35:32 +0200 |
| commit | 4eac9731fe77023488cdf3aa124a6aa1e5444a59 (patch) | |
| tree | 7c9510b23ea7a40a2280b39e87e55a1612309df1 /html/assets/js/dataTables/search-neutralise.js | |
| parent | 33266244e8c75c29f31dd5dce756e55fb10a0b9b (diff) | |
| download | classroom-4eac9731fe77023488cdf3aa124a6aa1e5444a59.tar.gz classroom-4eac9731fe77023488cdf3aa124a6aa1e5444a59.tar.bz2 classroom-4eac9731fe77023488cdf3aa124a6aa1e5444a59.zip | |
setup needed libraries for browser-scripting
Diffstat (limited to 'html/assets/js/dataTables/search-neutralise.js')
| -rw-r--r-- | html/assets/js/dataTables/search-neutralise.js | 40 |
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 |
