jellyfin-web/dashboard-ui/scripts/wizarduserpage.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var WizardUserPage = {
onPageShow: function () {
Dashboard.showLoadingMsg();
var page = this;
2013-03-21 13:43:42 -07:00
ApiClient.getUsers().done(function (users) {
2013-02-20 18:33:05 -07:00
var user = users[0] || { Name: "User" };
$('#txtUsername', page).val(user.Name);
Dashboard.hideLoadingMsg();
});
},
onSubmit: function() {
Dashboard.showLoadingMsg();
var page = $.mobile.activePage;
2013-03-21 13:43:42 -07:00
ApiClient.getUsers().done(function (users) {
2013-02-20 18:33:05 -07:00
var user;
if (users.length) {
user = users[0];
user.Name = $('#txtUsername', page).val();
ApiClient.updateUser(user).done(WizardUserPage.saveComplete);
} else {
user = { Name: $('#txtUsername', page).val() };
ApiClient.createUser(user).done(WizardUserPage.saveComplete);
}
});
return false;
},
saveComplete: function () {
Dashboard.hideLoadingMsg();
2013-03-28 17:10:15 -07:00
Dashboard.navigate('wizardlibrary.html');
2013-02-20 18:33:05 -07:00
}
};
$(document).on('pageshow', "#wizardUserPage", WizardUserPage.onPageShow);