2018-04-14 11:10:38 +02:00
|
|
|
EmptyElementWhenMatches = function(selector, text)
|
|
|
|
{
|
|
|
|
if ($(selector).text() === text)
|
|
|
|
{
|
|
|
|
$(selector).text('');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
String.prototype.contains = function(search)
|
|
|
|
{
|
|
|
|
return this.toLowerCase().indexOf(search.toLowerCase()) !== -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
String.prototype.isEmpty = function()
|
|
|
|
{
|
|
|
|
return (this.length === 0 || !this.trim());
|
|
|
|
};
|
|
|
|
|
2019-05-07 19:48:14 +02:00
|
|
|
String.prototype.replaceAll = function(search, replacement)
|
|
|
|
{
|
|
|
|
return this.replace(new RegExp(search, "g"), replacement);
|
|
|
|
};
|
|
|
|
|
2018-04-14 11:10:38 +02:00
|
|
|
GetUriParam = function(key)
|
|
|
|
{
|
|
|
|
var currentUri = decodeURIComponent(window.location.search.substring(1));
|
|
|
|
var vars = currentUri.split('&');
|
|
|
|
|
|
|
|
for (i = 0; i < vars.length; i++)
|
|
|
|
{
|
|
|
|
var currentParam = vars[i].split('=');
|
|
|
|
|
|
|
|
if (currentParam[0] === key)
|
|
|
|
{
|
|
|
|
return currentParam[1] === undefined ? true : currentParam[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-09-27 13:33:03 +02:00
|
|
|
|
2019-07-06 14:48:46 +02:00
|
|
|
UpdateUriParam = function(key, value)
|
|
|
|
{
|
|
|
|
var queryParameters = new URLSearchParams(location.search);
|
|
|
|
queryParameters.set(key, value);
|
|
|
|
window.history.replaceState({ }, "", decodeURIComponent(`${location.pathname}?${queryParameters}`));
|
|
|
|
};
|
|
|
|
|
2018-09-27 13:33:03 +02:00
|
|
|
IsTouchInputDevice = function()
|
|
|
|
{
|
|
|
|
if (("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-30 17:14:04 +02:00
|
|
|
|
|
|
|
BoolVal = function(test)
|
|
|
|
{
|
|
|
|
var anything = test.toString().toLowerCase();
|
|
|
|
if (anything === true || anything === "true" || anything === "1" || anything === "on")
|
|
|
|
{
|
2018-09-30 19:31:03 +02:00
|
|
|
return true;
|
2018-09-30 17:14:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-10-01 20:20:50 +02:00
|
|
|
|
|
|
|
GetFileNameFromPath = function(path)
|
|
|
|
{
|
|
|
|
return path.split("/").pop().split("\\").pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFileExtension = function(pathOrFileName)
|
|
|
|
{
|
|
|
|
return pathOrFileName.split(".").pop();
|
|
|
|
}
|
2019-03-05 19:17:10 +01:00
|
|
|
|
|
|
|
$.extend($.expr[":"],
|
|
|
|
{
|
|
|
|
"contains_case_insensitive": function(elem, i, match, array)
|
|
|
|
{
|
|
|
|
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
|
|
|
}
|
|
|
|
});
|
2019-05-07 19:48:14 +02:00
|
|
|
|
|
|
|
FindObjectInArrayByPropertyValue = function(array, propertyName, propertyValue)
|
|
|
|
{
|
|
|
|
for (var i = 0; i < array.length; i++)
|
|
|
|
{
|
|
|
|
if (array[i][propertyName] == propertyValue)
|
|
|
|
{
|
|
|
|
return array[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2019-09-16 09:35:20 +02:00
|
|
|
|
|
|
|
FindAllObjectsInArrayByPropertyValue = function(array, propertyName, propertyValue)
|
|
|
|
{
|
|
|
|
var returnArray = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < array.length; i++)
|
|
|
|
{
|
|
|
|
if (array[i][propertyName] == propertyValue)
|
|
|
|
{
|
|
|
|
returnArray.push(array[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnArray;
|
|
|
|
}
|
2019-09-17 19:11:06 +02:00
|
|
|
|
|
|
|
$.fn.hasAttr = function(name)
|
|
|
|
{
|
|
|
|
return this.attr(name) !== undefined;
|
|
|
|
};
|
2019-09-20 16:26:50 +02:00
|
|
|
|
|
|
|
function IsJsonString(text)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
JSON.parse(text);
|
|
|
|
} catch(e)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-10-15 19:59:14 +02:00
|
|
|
|
|
|
|
function Delay(callable, delayMilliseconds)
|
|
|
|
{
|
|
|
|
var timer = 0;
|
|
|
|
return function()
|
|
|
|
{
|
|
|
|
var context = this;
|
|
|
|
var args = arguments;
|
|
|
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
timer = setTimeout(function()
|
|
|
|
{
|
|
|
|
callable.apply(context, args);
|
|
|
|
}, delayMilliseconds || 0);
|
|
|
|
};
|
|
|
|
}
|