1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

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

View file

@ -42,7 +42,7 @@
var channelId = getParameterByName('id'); 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) { if (features.CanFilter) {
@ -121,7 +121,7 @@
query.folderId = folderId; 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 // Scroll back up so they can see the results from the beginning
$(document).scrollTop(0); $(document).scrollTop(0);

View file

@ -12,7 +12,7 @@
query.UserId = Dashboard.getCurrentUserId(); 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 // Scroll back up so they can see the results from the beginning
$(document).scrollTop(0); $(document).scrollTop(0);

View file

@ -84,7 +84,7 @@
var page = this; var page = this;
var promise1 = ApiClient.getNamedConfiguration("channels"); 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) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -21,7 +21,7 @@
var promise1 = ApiClient.getServerConfiguration(); 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) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -29,7 +29,7 @@
var url = id ? 'Dlna/Profiles/' + id : var url = id ? 'Dlna/Profiles/' + id :
'Dlna/Profiles/Default'; 'Dlna/Profiles/Default';
return $.getJSON(ApiClient.getUrl(url)); return ApiClient.getJSON(ApiClient.getUrl(url));
} }
function renderProfile(page, profile, users) { function renderProfile(page, profile, users) {
@ -627,7 +627,7 @@
if (id) { if (id) {
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("Dlna/Profiles/" + id), url: ApiClient.getUrl("Dlna/Profiles/" + id),
data: JSON.stringify(profile), data: JSON.stringify(profile),
@ -639,7 +639,7 @@
} else { } else {
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("Dlna/Profiles"), url: ApiClient.getUrl("Dlna/Profiles"),
data: JSON.stringify(profile), data: JSON.stringify(profile),

View file

@ -4,7 +4,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).done(function (result) { ApiClient.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).done(function (result) {
renderProfiles(page, result); renderProfiles(page, result);
@ -88,7 +88,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.ajax({ ApiClient.ajax({
type: "DELETE", type: "DELETE",
url: ApiClient.getUrl("Dlna/Profiles/" + id) url: ApiClient.getUrl("Dlna/Profiles/" + id)

View file

@ -184,7 +184,7 @@
}); });
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: url url: url
@ -217,7 +217,7 @@
}); });
$.ajax({ ApiClient.ajax({
type: "DELETE", type: "DELETE",
url: url url: url

View file

@ -44,7 +44,7 @@
var languages = response2[0]; var languages = response2[0];
var countries = response3[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); loadExternalIds(page, item, idList);
}); });
@ -1002,7 +1002,7 @@
var item = currentItem; 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 = ''; var html = '';
@ -1100,7 +1100,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type), url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
data: JSON.stringify(lookupInfo), data: JSON.stringify(lookupInfo),
@ -1180,7 +1180,7 @@
var currentResult = results[index]; var currentResult = results[index];
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/Apply/" + currentItem.Id), url: ApiClient.getUrl("Items/RemoteSearch/Apply/" + currentItem.Id),
data: JSON.stringify(currentResult), data: JSON.stringify(currentResult),

View file

@ -52,7 +52,7 @@
var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id; var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl(url) url: ApiClient.getUrl(url)
@ -75,7 +75,7 @@
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index; var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
$.ajax({ ApiClient.ajax({
type: "DELETE", type: "DELETE",
url: ApiClient.getUrl(url) url: ApiClient.getUrl(url)
@ -257,7 +257,7 @@
var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language); var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
$.getJSON(url).done(function (results) { ApiClient.getJSON(url).done(function (results) {
renderSearchResults(page, results); renderSearchResults(page, results);
}); });

View file

@ -123,7 +123,7 @@
function loadMediaFolders(service, openItems, callback) { 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) { var nodes = result.Items.map(function (i) {

View file

@ -175,7 +175,7 @@
UserId: userId 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 = ''; var html = '';
@ -327,7 +327,7 @@
SupportsLatestItems: true SupportsLatestItems: true
}); });
$.getJSON(ApiClient.getUrl("Channels", options)).done(function (result) { ApiClient.getJSON(ApiClient.getUrl("Channels", options)).done(function (result) {
var channels = result.Items; var channels = result.Items;
@ -362,7 +362,7 @@
ChannelIds: channel.Id 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 = ''; var html = '';

View file

@ -1423,7 +1423,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.ajax({ ApiClient.ajax({
type: "DELETE", type: "DELETE",
url: ApiClient.getUrl("Videos/" + id + "/AlternateSources") url: ApiClient.getUrl("Videos/" + id + "/AlternateSources")

View file

@ -436,7 +436,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') }) url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') })

View file

@ -117,7 +117,7 @@
var page = this; var page = this;
var promise1 = ApiClient.getNamedConfiguration("chapters"); 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) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -27,7 +27,7 @@
currentType = type; currentType = type;
var promise1 = ApiClient.getServerConfiguration(); 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) { $.when(promise1, promise2).done(function (response1, response2) {
@ -46,7 +46,7 @@
} else { } else {
$.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultConfig) { ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).done(function (defaultConfig) {
config = defaultConfig; config = defaultConfig;
@ -510,7 +510,7 @@
} else { } 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; defaultOptions.ItemType = type;
config.MetadataOptions.push(defaultOptions); config.MetadataOptions.push(defaultOptions);

View file

@ -289,7 +289,7 @@
}); });
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: url, url: url,
dataType: "json" dataType: "json"
@ -320,7 +320,7 @@
Ids: $('.fldSelectedItemIds', page).val() || '' Ids: $('.fldSelectedItemIds', page).val() || ''
}); });
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: url url: url

View file

@ -83,7 +83,7 @@
Fields: "PrimaryImageAspectRatio" Fields: "PrimaryImageAspectRatio"
}); });
$.getJSON(url).done(function (recommendations) { ApiClient.getJSON(url).done(function (recommendations) {
if (!recommendations.length) { if (!recommendations.length) {

View file

@ -37,7 +37,7 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
$.getJSON(ApiClient.getUrl("Channels", { ApiClient.getJSON(ApiClient.getUrl("Channels", {
UserId: user.Id UserId: user.Id

View file

@ -27,8 +27,8 @@
var promise1 = ApiClient.getUsers(); var promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getServerConfiguration(); var promise2 = ApiClient.getServerConfiguration();
var promise3 = $.getJSON(ApiClient.getUrl("Notifications/Types")); var promise3 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Types"));
var promise4 = $.getJSON(ApiClient.getUrl("Notifications/Services")); var promise4 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Services"));
$.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) { $.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) {
@ -98,7 +98,7 @@
var type = getParameterByName('type'); var type = getParameterByName('type');
var promise1 = ApiClient.getServerConfiguration(); 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) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -4,7 +4,7 @@
Dashboard.showLoadingMsg(); 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">'; var html = '<ul data-role="listview" data-inset="true">';

View file

@ -10,7 +10,7 @@
var promise1 = ApiClient.getInstalledPlugins(); var promise1 = ApiClient.getInstalledPlugins();
var promise2 = $.getJSON("configurationpages?pageType=PluginConfiguration"); var promise2 = ApiClient.getJSON("configurationpages?pageType=PluginConfiguration");
$.when(promise1, promise2).done(function (response1, response2) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -577,7 +577,7 @@
var url = ApiClient.getUrl("Items", query); var url = ApiClient.getUrl("Items", query);
var reportType = $('#selectView', page).val(); var reportType = $('#selectView', page).val();
$.getJSON(url).done(function (result) { ApiClient.getJSON(url).done(function (result) {
renderItems(page, result, reportType); renderItems(page, result, reportType);

View file

@ -428,7 +428,7 @@ var Dashboard = {
reloadPageWhenServerAvailable: function (retryCount) { reloadPageWhenServerAvailable: function (retryCount) {
// Don't use apiclient method because we don't want it reporting authentication under the old version // 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 this is back to false, the restart completed
if (!info.HasPendingRestart) { if (!info.HasPendingRestart) {
@ -503,7 +503,7 @@ var Dashboard = {
var deferred = $.Deferred(); var deferred = $.Deferred();
// Don't let this blow up the dashboard when it fails // Don't let this blow up the dashboard when it fails
$.ajax({ ApiClient.ajax({
type: "GET", type: "GET",
url: ApiClient.getUrl("Plugins/SecurityInfo"), url: ApiClient.getUrl("Plugins/SecurityInfo"),
dataType: 'json', dataType: 'json',

View file

@ -13,7 +13,7 @@
query.ParentId = LibraryMenu.getTopParentId(); 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; var items = result.Items;

View file

@ -242,9 +242,9 @@
var promise3 = ApiClient.getParentalRatings(); 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) { $.when(promise1, promise2, promise3, promise4, promise5).done(function (response1, response2, response3, response4, response5) {

View file

@ -4,7 +4,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
$.ajax({ ApiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl("System/Configuration/VideoImageExtraction", { Enabled: $('#chkVideoImages', page).checked() }) url: ApiClient.getUrl("System/Configuration/VideoImageExtraction", { Enabled: $('#chkVideoImages', page).checked() })

View file

@ -36,7 +36,7 @@
var promise1 = ApiClient.getServerConfiguration(); 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) { $.when(promise1, promise2).done(function (response1, response2) {

View file

@ -147,6 +147,15 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return $.ajax(request); 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 * Creates an api url based on a handler name and query string parameters
* @param {String} name * @param {String} name