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
|
|
|
|
|
2015-07-30 07:34:46 -07:00
|
|
|
|
Name: form.querySelector('#txtUsername').value,
|
2015-08-20 14:13:50 -07:00
|
|
|
|
ConnectUserName: form.querySelector('#txtConnectUserName').value
|
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
|
|
|
|
|
2015-10-26 09:21:00 -07:00
|
|
|
|
}).done(onUpdateUserComplete).fail(function () {
|
|
|
|
|
|
|
|
|
|
var msgKey = form.querySelector('#txtConnectUserName').value ? 'ErrorAddingEmbyConnectAccount' : 'DefaultErrorMessage';
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
|
|
|
|
|
message: Globalize.translate(msgKey)
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
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-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#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-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#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
|
|
|
|
|
2015-07-30 07:34:46 -07:00
|
|
|
|
page.querySelector('#txtUsername').value = user.Name;
|
|
|
|
|
page.querySelector('#txtConnectUserName').value = user.ConnectUserName;
|
2013-04-15 18:46:17 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|