Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }; function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function geldformat(n, c, d, t){ var //n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }; function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); } function nl2br (str, is_xhtml) { var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
'; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); } function bytesToSize(bytes) { var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (bytes == 0) return '0 Byte'; var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; }; function sortJsonArrayByProperty(objArray, prop, direction){ if (arguments.length<2) throw new Error("sortJsonArrayByProp requires 2 arguments"); var direct = arguments.length>2 ? arguments[2] : 1; //Default to ascending if (objArray && objArray.constructor===Array){ var propPath = (prop.constructor===Array) ? prop : prop.split("."); objArray.sort(function(a,b){ for (var p in propPath){ if (a[propPath[p]] && b[propPath[p]]){ a = a[propPath[p]]; b = b[propPath[p]]; } } // convert numeric strings to integers a = a.match(/^\d+$/) ? +a : a; b = b.match(/^\d+$/) ? +b : b; return ( (a < b) ? -1*direct : ((a > b) ? 1*direct : 0) ); }); } } if(!Array.isArray) { Array.isArray = function (vArg) { return Object.prototype.toString.call(vArg) === "[object Array]"; }; } function isEmpty(value){ return (value == null || value.length === 0); } function zeige_dateiendung(filename){ var endung=filename.split('.').pop(); endung=endung.toLowerCase(); return endung; } function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); } function isset () { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: FremyCompany // + improved by: Onno Marsman // + improved by: RafaƂ Kukawski // * example 1: isset( undefined, true); // * returns 1: false // * example 2: isset( 'Kevin van Zonneveld' ); // * returns 2: true var a = arguments, l = a.length, i = 0, undef; if (l === 0) { throw new Error('Empty isset'); } while (i !== l) { if (a[i] === undef || a[i] === null) { return false; } i++; } return true; } String.prototype.replaceArray = function(find, replace) { var replaceString = this; for (var i = 0; i < find.length; i++) { replaceString = replaceString.replace(find[i], replace[i]); } return replaceString; }; function str_replace($f, $r, $s){ return $s.replace(new RegExp("(" + (typeof($f) == "string" ? $f.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&") : $f.map(function(i){return i.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")}).join("|")) + ")", "g"), typeof($r) == "string" ? $r : typeof($f) == "string" ? $r[0] : function(i){ return $r[$f.indexOf(i)]}); } function show_hide_div(show, hide){ $(show).each(function() { $(this).show(); }); $(hide).each(function() { $(this).hide(); }); } function enable_disable(enable, disable){ if(enable!=""){ $(enable).prop('disabled', false); } if(disable!=""){ $(disable).prop('disabled', true); } } function check_uncheck_checkbox(show, hide){ $(show).each(function() { $(this).prop('checked', true); //console.log("checked"); }); $(hide).each(function() { $(this).prop('checked', false); }); } function check_checkboxen_mit_pruefcheckbox(alle_checkbox, pruef_checkbox){ if($(alle_checkbox).prop('checked')==true){ $(pruef_checkbox).each(function() { $(this).prop('checked', true); //console.log("checked"); }); } else { $(pruef_checkbox).each(function() { $(this).prop('checked', false); //console.log("unchecked"); }); } } function de_date_to_am_date(date){ date = date.split('.'); date = date.reverse().join('-'); return date; } function am_date_to_de_date(date){ date = date.split('-'); date = date.reverse().join('.'); return date; } function ObjectLength( object ) { var length = 0; for( var key in object ) { if( object.hasOwnProperty(key) ) { ++length; } } return length; } function removeOptions(selectbox) { var i; for(i=selectbox.options.length-1;i>=0;i--) { selectbox.remove(i); } } function addOptions(selectbox,id,text) { var opt = document.createElement('option'); opt.value = id; opt.innerHTML = text; selectbox.appendChild(opt); } function isInArray(array, search) { return array.indexOf(search) >= 0; } function encode_utf8(s) { return unescape(encodeURIComponent(s)); } function decode_utf8(s) { return decodeURIComponent(escape(s)); } function htmlEscape(str) { return str .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(//g, '>'); } // I needed the opposite function today, so adding here too: function htmlUnescape(str){ return str .replace(/"/g, '"') .replace(/'/g, "'") .replace(/</g, '<') .replace(/>/g, '>') .replace(/&/g, '&'); } function rahmen_transfer(source, target) { $(source).effect('transfer', { queue: false, to: $(target) }, 2000); } function js_formatedate (date){ var dd = date.getDate(); var mm = date.getMonth()+1; var yyyy = date.getFullYear(); if(dd<10){ dd='0'+dd } if(mm<10){ mm='0'+mm } return yyyy+'-'+mm+'-'+dd; } function js_formatedate_ohne_strich (date){ var dd = date.getDate(); var mm = date.getMonth()+1; var yyyy = date.getFullYear(); if(dd<10){ dd='0'+dd } if(mm<10){ mm='0'+mm } return yyyy+""+mm+""+dd; } function hexToRgbMitMarker(hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : null; } function hexToRgb(str) { if ( /^#([0-9a-f]{3}|[0-9a-f]{6})$/ig.test(str) ) { var hex = str.substr(1); hex = hex.length == 3 ? hex.replace(/(.)/g, '$1$1') : hex; var rgb = parseInt(hex, 16); return [(rgb >> 16) & 255, (rgb >> 8) & 255, rgb & 255].join(','); } return false; } function arr_diff (a1, a2) { var a = [], diff = []; for (var i = 0; i < a1.length; i++) { a[a1[i]] = true; } for (var i = 0; i < a2.length; i++) { if (a[a2[i]]) { delete a[a2[i]]; } else { a[a2[i]] = true; } } for (var k in a) { diff.push(k); } return diff; }