run all ajax through apiclient

This commit is contained in:
Luke Pulverenti
2014-07-02 01:16:59 -04:00
parent 683e6f472c
commit db0a6eb632
28 changed files with 55 additions and 46 deletions
+2 -2
View File
@@ -42,7 +42,7 @@
var channelId = getParameterByName('id');
$.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Features", query)).done(function (features) {
ApiClient.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Features", query)).done(function (features) {
if (features.CanFilter) {
@@ -121,7 +121,7 @@
query.folderId = folderId;
$.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Items", query)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Items", query)).done(function (result) {
// Scroll back up so they can see the results from the beginning
$(document).scrollTop(0);
+1 -1
View File
@@ -12,7 +12,7 @@
query.UserId = Dashboard.getCurrentUserId();
$.getJSON(ApiClient.getUrl("Channels", query)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Channels", query)).done(function (result) {
// Scroll back up so they can see the results from the beginning
$(document).scrollTop(0);
+1 -1
View File
@@ -84,7 +84,7 @@
var page = this;
var promise1 = ApiClient.getNamedConfiguration("channels");
var promise2 = $.getJSON(ApiClient.getUrl("Channels/Features"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Channels/Features"));
$.when(promise1, promise2).done(function (response1, response2) {
+1 -1
View File
@@ -21,7 +21,7 @@
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("Localization/Options"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
$.when(promise1, promise2).done(function (response1, response2) {
+3 -3
View File
@@ -29,7 +29,7 @@
var url = id ? 'Dlna/Profiles/' + id :
'Dlna/Profiles/Default';
return $.getJSON(ApiClient.getUrl(url));
return ApiClient.getJSON(ApiClient.getUrl(url));
}
function renderProfile(page, profile, users) {
@@ -627,7 +627,7 @@
if (id) {
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Dlna/Profiles/" + id),
data: JSON.stringify(profile),
@@ -639,7 +639,7 @@
} else {
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Dlna/Profiles"),
data: JSON.stringify(profile),
+2 -2
View File
@@ -4,7 +4,7 @@
Dashboard.showLoadingMsg();
$.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).done(function (result) {
renderProfiles(page, result);
@@ -88,7 +88,7 @@
Dashboard.showLoadingMsg();
$.ajax({
ApiClient.ajax({
type: "DELETE",
url: ApiClient.getUrl("Dlna/Profiles/" + id)
+2 -2
View File
@@ -184,7 +184,7 @@
});
$.ajax({
ApiClient.ajax({
type: "POST",
url: url
@@ -217,7 +217,7 @@
});
$.ajax({
ApiClient.ajax({
type: "DELETE",
url: url
+4 -4
View File
@@ -44,7 +44,7 @@
var languages = response2[0];
var countries = response3[0];
$.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
loadExternalIds(page, item, idList);
});
@@ -1002,7 +1002,7 @@
var item = currentItem;
$.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
var html = '';
@@ -1100,7 +1100,7 @@
Dashboard.showLoadingMsg();
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
data: JSON.stringify(lookupInfo),
@@ -1180,7 +1180,7 @@
var currentResult = results[index];
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/Apply/" + currentItem.Id),
data: JSON.stringify(currentResult),
+3 -3
View File
@@ -52,7 +52,7 @@
var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl(url)
@@ -75,7 +75,7 @@
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
$.ajax({
ApiClient.ajax({
type: "DELETE",
url: ApiClient.getUrl(url)
@@ -257,7 +257,7 @@
var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
$.getJSON(url).done(function (results) {
ApiClient.getJSON(url).done(function (results) {
renderSearchResults(page, results);
});
+1 -1
View File
@@ -123,7 +123,7 @@
function loadMediaFolders(service, openItems, callback) {
$.getJSON(ApiClient.getUrl("Library/MediaFolders")).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders")).done(function (result) {
var nodes = result.Items.map(function (i) {
+3 -3
View File
@@ -175,7 +175,7 @@
UserId: userId
};
$.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
var html = '';
@@ -327,7 +327,7 @@
SupportsLatestItems: true
});
$.getJSON(ApiClient.getUrl("Channels", options)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Channels", options)).done(function (result) {
var channels = result.Items;
@@ -362,7 +362,7 @@
ChannelIds: channel.Id
};
$.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).done(function (result) {
var html = '';
+1 -1
View File
@@ -1423,7 +1423,7 @@
Dashboard.showLoadingMsg();
$.ajax({
ApiClient.ajax({
type: "DELETE",
url: ApiClient.getUrl("Videos/" + id + "/AlternateSources")
+1 -1
View File
@@ -436,7 +436,7 @@
Dashboard.showLoadingMsg();
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') })
+1 -1
View File
@@ -117,7 +117,7 @@
var page = this;
var promise1 = ApiClient.getNamedConfiguration("chapters");
var promise2 = $.getJSON(ApiClient.getUrl("Providers/Chapters"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Providers/Chapters"));
$.when(promise1, promise2).done(function (response1, response2) {
+3 -3
View File
@@ -27,7 +27,7 @@
currentType = type;
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("System/Configuration/MetadataPlugins"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataPlugins"));
$.when(promise1, promise2).done(function (response1, response2) {
@@ -46,7 +46,7 @@
} else {
$.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultConfig) {
ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultConfig) {
config = defaultConfig;
@@ -510,7 +510,7 @@
} else {
$.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultOptions) {
ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultOptions) {
defaultOptions.ItemType = type;
config.MetadataOptions.push(defaultOptions);
+2 -2
View File
@@ -289,7 +289,7 @@
});
$.ajax({
ApiClient.ajax({
type: "POST",
url: url,
dataType: "json"
@@ -320,7 +320,7 @@
Ids: $('.fldSelectedItemIds', page).val() || ''
});
$.ajax({
ApiClient.ajax({
type: "POST",
url: url
+1 -1
View File
@@ -83,7 +83,7 @@
Fields: "PrimaryImageAspectRatio"
});
$.getJSON(url).done(function (recommendations) {
ApiClient.getJSON(url).done(function (recommendations) {
if (!recommendations.length) {
+1 -1
View File
@@ -37,7 +37,7 @@
Dashboard.hideLoadingMsg();
});
$.getJSON(ApiClient.getUrl("Channels", {
ApiClient.getJSON(ApiClient.getUrl("Channels", {
UserId: user.Id
+3 -3
View File
@@ -27,8 +27,8 @@
var promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getServerConfiguration();
var promise3 = $.getJSON(ApiClient.getUrl("Notifications/Types"));
var promise4 = $.getJSON(ApiClient.getUrl("Notifications/Services"));
var promise3 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Types"));
var promise4 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Services"));
$.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) {
@@ -98,7 +98,7 @@
var type = getParameterByName('type');
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("Notifications/Types"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Types"));
$.when(promise1, promise2).done(function (response1, response2) {
+1 -1
View File
@@ -4,7 +4,7 @@
Dashboard.showLoadingMsg();
$.getJSON(ApiClient.getUrl("Notifications/Types")).done(function (list) {
ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).done(function (list) {
var html = '<ul data-role="listview" data-inset="true">';
+1 -1
View File
@@ -10,7 +10,7 @@
var promise1 = ApiClient.getInstalledPlugins();
var promise2 = $.getJSON("configurationpages?pageType=PluginConfiguration");
var promise2 = ApiClient.getJSON("configurationpages?pageType=PluginConfiguration");
$.when(promise1, promise2).done(function (response1, response2) {
+1 -1
View File
@@ -577,7 +577,7 @@
var url = ApiClient.getUrl("Items", query);
var reportType = $('#selectView', page).val();
$.getJSON(url).done(function (result) {
ApiClient.getJSON(url).done(function (result) {
renderItems(page, result, reportType);
+2 -2
View File
@@ -428,7 +428,7 @@ var Dashboard = {
reloadPageWhenServerAvailable: function (retryCount) {
// Don't use apiclient method because we don't want it reporting authentication under the old version
$.getJSON(ApiClient.getUrl("System/Info")).done(function (info) {
ApiClient.getJSON(ApiClient.getUrl("System/Info")).done(function (info) {
// If this is back to false, the restart completed
if (!info.HasPendingRestart) {
@@ -503,7 +503,7 @@ var Dashboard = {
var deferred = $.Deferred();
// Don't let this blow up the dashboard when it fails
$.ajax({
ApiClient.ajax({
type: "GET",
url: ApiClient.getUrl("Plugins/SecurityInfo"),
dataType: 'json',
+1 -1
View File
@@ -13,7 +13,7 @@
query.ParentId = LibraryMenu.getTopParentId();
$.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).done(function (result) {
ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).done(function (result) {
var items = result.Items;
+2 -2
View File
@@ -242,9 +242,9 @@
var promise3 = ApiClient.getParentalRatings();
var promise4 = $.getJSON(ApiClient.getUrl("Library/MediaFolders", {IsHidden: false}));
var promise4 = ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {IsHidden: false}));
var promise5 = $.getJSON(ApiClient.getUrl("Channels"));
var promise5 = ApiClient.getJSON(ApiClient.getUrl("Channels"));
$.when(promise1, promise2, promise3, promise4, promise5).done(function (response1, response2, response3, response4, response5) {
+1 -1
View File
@@ -4,7 +4,7 @@
Dashboard.showLoadingMsg();
$.ajax({
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("System/Configuration/VideoImageExtraction", { Enabled: $('#chkVideoImages', page).checked() })
+1 -1
View File
@@ -36,7 +36,7 @@
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("Localization/Options"));
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
$.when(promise1, promise2).done(function (response1, response2) {
+9
View File
@@ -147,6 +147,15 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return $.ajax(request);
};
self.getJSON = function(url) {
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
};
/**
* Creates an api url based on a handler name and query string parameters
* @param {String} name