aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.WebDashboard/ApiClient.js
diff options
context:
space:
mode:
authorLuis Miguel Almánzar <ruisu15@gmail.com>2013-10-28 20:35:10 -0400
committerLuis Miguel Almánzar <ruisu15@gmail.com>2013-10-28 20:35:10 -0400
commit67354bde5fc8dbf3520c419e2936bacf34e429a8 (patch)
tree7f484a193eec083eb48a1532eb09f9131f6f9401 /MediaBrowser.WebDashboard/ApiClient.js
parentd77122ba0f3c3ca71bfa4c8fa5b25bb3c3f0f1dc (diff)
parent8bd7df410ce1c10cbcc5a223138226bb6986e8b8 (diff)
Merge branch 'master' of github.com:MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.WebDashboard/ApiClient.js')
-rw-r--r--MediaBrowser.WebDashboard/ApiClient.js50
1 files changed, 37 insertions, 13 deletions
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index 97a443e84..8e64e4300 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -2731,16 +2731,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
});
};
- /**
- * Marks an item as played or unplayed
- * This should not be used to update playstate following playback.
- * There are separate playstate check-in methods for that. This should be used for a
- * separate option to reset playstate.
- * @param {String} userId
- * @param {String} itemId
- * @param {Boolean} wasPlayed
- */
- self.updatePlayedStatus = function (userId, itemId, wasPlayed) {
+ self.getDateParamValue = function (date) {
+ function formatDigit(i) {
+ return i < 10 ? "0" + i : i;
+ }
+
+ var d = date;
+
+ return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
+ };
+
+ self.markPlayed = function (userId, itemId, date) {
if (!userId) {
throw new Error("null userId");
@@ -2750,12 +2751,35 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
throw new Error("null itemId");
}
- var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
+ var options = {};
+
+ if (date) {
+ options.DatePlayed = self.getDateParamValue(date);
+ }
- var method = wasPlayed ? "POST" : "DELETE";
+ var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId, options);
return self.ajax({
- type: method,
+ type: "POST",
+ url: url,
+ dataType: "json"
+ });
+ };
+
+ self.markUnplayed = function (userId, itemId) {
+
+ if (!userId) {
+ throw new Error("null userId");
+ }
+
+ if (!itemId) {
+ throw new Error("null itemId");
+ }
+
+ var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
+
+ return self.ajax({
+ type: "DELETE",
url: url,
dataType: "json"
});