//--------------------------------------------------- function trim(s){ if (s!=""){ try{ s=s.replace(/ +$/, "") // удаление хвостовых пробелов s=s.replace(/^ +/, "") // удаление ведущих пробелов }catch(err){ s=""; } } return s; } //################################################### //--------------------------------------------------- function strpos (haystack, needle, offset) { var i = (haystack+'').indexOf(needle, (offset ? offset : 0)); return i === -1 ? false : i; } //=================================================== //случайный int в диапазоне---------------------------------------- function randomint(min_value,max_value) { let random_number = Math.random() * (max_value-min_value) + min_value; return Math.floor(random_number); } //================================================================= //отправка формы post---------------------------------------------- function postform(formname){ var domain=getuserhost(); var errorfunctiontype=typeof(errorfunction); var successfunctiontype=typeof(successfunction); if (typeof(errorfunction)!="function"){ alert("Function errorfunction() not defined"); return false; } if (typeof(successfunction)!="function"){ alert("Function successfunction() not defined"); return false; } if (typeof((document.forms[formname]))=="undefined"){ alert("Form "+"'"+formname+"'"+" is undefined"); return false; } if (typeof((document.forms[formname].formaction))=="undefined"){ alert("Field "+"'formaction'"+" is undefined"); return false; } //проход по элементам, определение пустых required-------------------------- var elements=document.forms[formname].elements; var poststr=""; fielderror=false; for (i=0; i=2){ ret=arr[ln-2]+"."+arr[ln-1]; } return ret; } //================================================================== //logout------------------------------------------------------------ function logout(){ erasecookie("id_users"); document.location="/"; } //================================================================== //------------------------------------------------------------------ function shuffle(a) { var j, x, i; for (i = a.length - 1; i > 0; i--) { j = Math.floor(Math.random() * (i + 1)); x = a[i]; a[i] = a[j]; a[j] = x; } return a; } //================================================================== //------------------------------------------------------------------ function copytoclipboard(obj,mess){ obj.focus(); obj.select(); document.execCommand('copy'); $(".copied").text(mess).show().fadeOut(3000); } //================================================================== //------------------------------------------------------------------ function getvalfromjson(valname,json){ var obj=JSON.parse(json); jcode="obj."+valname; ret=eval(jcode); return ret; } //================================================================== //------------------------------------------------------------------ function geterrorfromcode(errorcode,errorcodes){ allok=true; ret=errorcode; try{ var obj=JSON.parse(errorcodes); }catch(err){ alert(err); allok=false; } if (allok){ jcode="obj."+errorcode+".descr"; try{ if (typeof(eval(jcode))!="undefined"){ ret=eval(jcode); } }catch(err){ ret=errorcode; } } return ret; } //================================================================== //------------------------------------------------------------------ function focuserrorfield(formname,errorcode,errorcodes){ var focusedfield=""; if (typeof((document.forms[formname]))=="undefined"){ alert("Form "+"'"+formname+"'"+" is undefined in function 'focuserrorfield'"); return false; } try{ var obj=JSON.parse(errorcodes); }catch(err){ alert("Error parsing json in function focuserrorfield "+err); allok=false; } if (allok){ jcode="obj."+errorcode+".focusedfield"; try{ if (typeof(eval(jcode))!="undefined"){ focusedfield=eval(jcode); } }catch(err){ alert("Error get focusedfield in function focuserrorfield "+err); } } if (focusedfield!=""){ var jcode="document.forms[formname]."+focusedfield+".focus()"; try{ eval(jcode); }catch(err){ alert("Error eval "+focusedfield+" in function focuserrorfield"+err); } } } //================================================================== //------------------------------------------------------------------ function focusfield(formname,fieldname){ if (typeof((document.forms[formname]))=="undefined"){ alert("Form "+"'"+formname+"'"+" is undefined in function 'focuserrorfield'"); return false; } var jcode="document.forms["+"'"+formname+"'"+"]."+fieldname+".focus()"; try{ eval(jcode); }catch(err){ alert("Error eval "+focusedfield+" in function focusfield"+err); } } //================================================================== //------------------------------------------------------------------ function shuffle(array) { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)); // случайный индекс от 0 до i [array[i], array[j]] = [array[j], array[i]]; } } //================================================================== //------------------------------------------------------------------ const bootstrapDetectBreakpoint = function () { // cache some values on first call if (!this.breakpointValues) { this.breakpointNames = ["xxl", "xl", "lg", "md", "sm", "xs"] this.breakpointValues = [] const isPriorBS5 = !!window.getComputedStyle(document.documentElement).getPropertyValue('--breakpoint-sm') const prefix = isPriorBS5 ? "--breakpoint-" : "--bs-breakpoint-" for (const breakpointName of this.breakpointNames) { const value = window.getComputedStyle(document.documentElement).getPropertyValue(prefix + breakpointName) if(value) { this.breakpointValues[breakpointName] = value } } } let i = this.breakpointNames.length for (const breakpointName of this.breakpointNames) { i-- if (window.matchMedia("(min-width: " + this.breakpointValues[breakpointName] + ")").matches) { var ret=[]; ret[0]=breakpointName; ret[1]=i; //return {name: breakpointName, index: i} return ret; } } return null } //================================================================== //------------------------------------------------------------------ function between(number,valmin,valmax){ if ((number>=valmin)&&(number<=valmax)){return true;}else{return false;} } //==================================================================