diff --git a/www/js/updateprofile.js b/www/js/updateprofile.js new file mode 100644 index 0000000..d13e11b --- /dev/null +++ b/www/js/updateprofile.js @@ -0,0 +1,39 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + +function loadProfilePage() { + app.preloader.show(); + callAPI("getprofile", { + key: localStorage.getItem("key"), + }, function (data) { + $("#name").val(data.profile.name); + $("#bio").val(data.profile.bio); + app.input.resizeTextarea($("#bio")); + app.preloader.hide(); + }, function (msg) { + app.preloader.hide(); + app.dialog.alert(msg, "Error loading profile"); + }); +} + +function saveProfile() { + app.preloader.show(); + callAPI("setprofile", { + key: localStorage.getItem("key"), + name: $("#name").val(), + bio: $("#bio").val() + }, function (data) { + app.preloader.hide(); + app.toast.create({ + text: " Profile updated!", + closeTimeout: 2000 + }).open(); + }, function (msg) { + app.preloader.hide(); + app.dialog.alert(msg, "Error saving profile"); + }); +} \ No newline at end of file diff --git a/www/pages/home.html b/www/pages/home.html index 8157790..3005c0e 100644 --- a/www/pages/home.html +++ b/www/pages/home.html @@ -110,7 +110,7 @@ Your position will be visible for one hour. The timer will reset every time you push the button. -