| 1234567891011121314151617181920212223242526272829303132333435363738 |
- export default {
- // Parse <value> in: http://server/?variable=value
- getQueryVariable: function (variable) {
- var query = location.search.substring(1);
- var vars = query.split('&');
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split('=');
- if (decodeURIComponent(pair[0]) == variable) {
- return decodeURIComponent(pair[1]);
- }
- }
- throw variable + ': not found';
- },
- // Trim string
- trim: function(str) {
- // Make sure we trim BOM and NBSP
- var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
- return str.replace(rtrim, '');
- },
- uniqueid: function(){
- // always start with a letter (for DOM friendlyness)
- var idstr=String.fromCharCode(Math.floor((Math.random()*25)+65));
- do {
- // between numbers and characters (48 is 0 and 90 is Z (42-48 = 90)
- var ascicode=Math.floor((Math.random()*42)+48);
- if (ascicode<58 || ascicode>64){
- // exclude all chars between : (58) and @ (64)
- idstr+=String.fromCharCode(ascicode);
- }
- } while (idstr.length<32);
- return (idstr);
- },
- validateEmail: function(email) {
- const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- return re.test(String(email).toLowerCase());
- }
- }
|