mirror of
https://github.com/grocy/grocy.git
synced 2026-04-09 05:56:15 +02:00
Create Grocy.Api.Put
This commit is contained in:
parent
6b41e5212c
commit
3db750e211
|
|
@ -21,12 +21,12 @@
|
||||||
|
|
||||||
localizedText = text;
|
localizedText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < placeholderValues.length; i++)
|
for (var i = 0; i < placeholderValues.length; i++)
|
||||||
{
|
{
|
||||||
localizedText = localizedText.replace('#' + (i + 1), placeholderValues[i]);
|
localizedText = localizedText.replace('#' + (i + 1), placeholderValues[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return localizedText;
|
return localizedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ if (window.localStorage.getItem("sidebar_state") === "collapsed")
|
||||||
|
|
||||||
$.timeago.settings.allowFuture = true;
|
$.timeago.settings.allowFuture = true;
|
||||||
RefreshContextualTimeago = function()
|
RefreshContextualTimeago = function()
|
||||||
{
|
{
|
||||||
$("time.timeago").each(function()
|
$("time.timeago").each(function()
|
||||||
{
|
{
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
|
|
@ -177,6 +177,37 @@ Grocy.Api.Post = function(apiFunction, jsonData, success, error)
|
||||||
xhr.send(JSON.stringify(jsonData));
|
xhr.send(JSON.stringify(jsonData));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Grocy.Api.Put = function(apiFunction, jsonData, success, error)
|
||||||
|
{
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
var url = U('/api/' + apiFunction);
|
||||||
|
|
||||||
|
xhr.onreadystatechange = function()
|
||||||
|
{
|
||||||
|
if (xhr.readyState === XMLHttpRequest.DONE)
|
||||||
|
{
|
||||||
|
if (xhr.status === 200)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
success(JSON.parse(xhr.responseText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
error(xhr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.open('PUT', url, true);
|
||||||
|
xhr.setRequestHeader('Content-type', 'application/json');
|
||||||
|
xhr.send(JSON.stringify(jsonData));
|
||||||
|
};
|
||||||
|
|
||||||
Grocy.Api.UploadFile = function(file, group, fileName, success, error)
|
Grocy.Api.UploadFile = function(file, group, fileName, success, error)
|
||||||
{
|
{
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
@ -286,7 +317,7 @@ Grocy.FrontendHelpers.ShowGenericError = function(message, exception)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.error(exception);
|
console.error(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,7 +341,7 @@ $(".user-setting-control").on("change", function()
|
||||||
{
|
{
|
||||||
inputType = element.attr("type").toLowerCase();
|
inputType = element.attr("type").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputType === "checkbox")
|
if (inputType === "checkbox")
|
||||||
{
|
{
|
||||||
value = element.is(":checked");
|
value = element.is(":checked");
|
||||||
|
|
@ -319,9 +350,9 @@ $(".user-setting-control").on("change", function()
|
||||||
{
|
{
|
||||||
var value = element.val();
|
var value = element.val();
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.UserSettings[settingKey] = value;
|
Grocy.UserSettings[settingKey] = value;
|
||||||
|
|
||||||
jsonData = { };
|
jsonData = { };
|
||||||
jsonData.value = value;
|
jsonData.value = value;
|
||||||
Grocy.Api.Post('user/settings/' + settingKey, jsonData,
|
Grocy.Api.Post('user/settings/' + settingKey, jsonData,
|
||||||
|
|
@ -358,7 +389,7 @@ ResizeResponsiveEmbeds = function(fillEntireViewport = false)
|
||||||
{
|
{
|
||||||
var maxHeight = $("body").height();
|
var maxHeight = $("body").height();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".embed-responsive").attr("height", maxHeight.toString() + "px");
|
$(".embed-responsive").attr("height", maxHeight.toString() + "px");
|
||||||
}
|
}
|
||||||
$(window).on('resize', function()
|
$(window).on('resize', function()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user