mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
57 lines
1.0 KiB
JavaScript
57 lines
1.0 KiB
JavaScript
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());
|
|
};
|
|
|
|
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];
|
|
}
|
|
}
|
|
};
|
|
|
|
IsTouchInputDevice = function()
|
|
{
|
|
if (("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
BoolVal = function(test)
|
|
{
|
|
var anything = test.toString().toLowerCase();
|
|
if (anything === true || anything === "true" || anything === "1" || anything === "on")
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|