2013-04-15 18:46:17 -07:00
|
|
|
|
(function ($, document, window) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
function getApiClient() {
|
|
|
|
|
return ApiClient;
|
2014-10-19 20:04:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
function onUpdateUserComplete(result) {
|
2014-09-08 18:15:31 -07:00
|
|
|
|
|
2013-04-15 18:46:17 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
if (result.UserLinkResult) {
|
2014-09-08 18:15:31 -07:00
|
|
|
|
|
2015-03-21 11:12:12 -07:00
|
|
|
|
var msgKey = result.UserLinkResult.IsPending ? 'MessagePendingEmbyAccountAdded' : 'MessageEmbyAccountAdded';
|
2014-09-08 18:15:31 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate(msgKey),
|
2015-03-21 11:12:12 -07:00
|
|
|
|
title: Globalize.translate('HeaderEmbyAccountAdded'),
|
2014-09-08 18:15:31 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
callback: function () {
|
|
|
|
|
Dashboard.navigate('wizardlibrary.html');
|
|
|
|
|
}
|
2014-10-19 20:04:45 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
});
|
2014-10-19 20:04:45 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
} else {
|
2014-10-19 20:04:45 -07:00
|
|
|
|
Dashboard.navigate('wizardlibrary.html');
|
2014-11-14 19:31:03 -07:00
|
|
|
|
}
|
2013-04-15 18:46:17 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-19 20:04:45 -07:00
|
|
|
|
function submit(form) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-19 20:04:45 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
var apiClient = getApiClient();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
apiClient.ajax({
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
type: 'POST',
|
|
|
|
|
data: {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
Name: $('#txtUsername', form).val(),
|
|
|
|
|
ConnectUserName: $('#txtConnectUserName', form).val()
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
},
|
|
|
|
|
url: apiClient.getUrl('Startup/User'),
|
|
|
|
|
dataType: 'json'
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
}).done(onUpdateUserComplete);
|
2014-10-19 20:04:45 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
function onSubmit() {
|
|
|
|
|
var form = this;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
submit(form);
|
2014-10-19 20:04:45 -07:00
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-10-19 20:04:45 -07:00
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#wizardUserPage", function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
$('.wizardUserForm').off('submit', onSubmit).on('submit', onSubmit);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-05-19 12:15:40 -07:00
|
|
|
|
}).on('pageshowready', "#wizardUserPage", function () {
|
2013-04-15 18:46:17 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
var apiClient = getApiClient();
|
2013-04-15 18:46:17 -07:00
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Startup/User')).done(function (user) {
|
2013-04-15 18:46:17 -07:00
|
|
|
|
|
|
|
|
|
$('#txtUsername', page).val(user.Name);
|
2014-10-19 20:04:45 -07:00
|
|
|
|
$('#txtConnectUserName', page).val(user.ConnectUserName);
|
2013-04-15 18:46:17 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|