summaryrefslogtreecommitdiff
path: root/www/static/js/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/static/js/api.js')
-rwxr-xr-xwww/static/js/api.js132
1 files changed, 0 insertions, 132 deletions
diff --git a/www/static/js/api.js b/www/static/js/api.js
deleted file mode 100755
index c6bc082..0000000
--- a/www/static/js/api.js
+++ /dev/null
@@ -1,132 +0,0 @@
-var API =
- {
- HEADER: "#@scanjam 0.3b",
- BASE_URL: "http://"+serverHost+":"+serverPort,
- URL:
- {
- auth:
- {
- login: "/api/auth/login",
- logout: "/api/auth/logout",
- checkin: "/api/auth/checkin",
- sneakin: "/api/auth/sneakin",
- },
- room:
- {
- join: "/api/room/join",
- list: "/api/room/list",
- view: "/api/room/view",
- poll: "/api/room/poll",
- watch: "/api/room/watch",
- say: "/api/room/say",
- settings: "/api/room/settings",
- stats: "/stats",
- },
- video:
- {
- date: "/api/video/date",
- like: "/api/video/like",
- unlike: "/api/video/unlike",
- remove: "/api/video/remove",
- search: "/api/video/search",
- },
- user:
- {
- settings: "/api/user/settings",
- videos: "/api/user/videos",
- likes: "/api/user/likes",
- },
- },
- error: function (s)
- {
- d.error("API: "+s)
- return false
- },
- parse: function (api, raw)
- {
- if (! raw)
- return API.error("no result")
- var lines = raw.split("\n")
- if (lines.shift() !== API.HEADER)
- return API.error("bad header")
- if (! lines.length)
- return API.error("no content")
- return lines
- },
- init: function ()
- {
- d.warn("INIT API")
- for (type in API.URL)
- {
- for (name in API.URL[type])
- {
- API.URL[type][name] = API.BASE_URL + API.URL[type][name]
- }
- }
- // $.ajaxSetup({ timeout: 1000 })
- }
- }
-var Local =
- {
- support: false,
- hash: null,
- get: null,
- set: null,
- _html5_get: function (key)
- {
- var val = localStorage["scanjam."+key]
- if (val === "true") return true
- if (val === "false") return false
- if (val === "undefined") return undefined
- return val
- },
- _html5_set: function (key, val)
- {
- if (val === undefined)
- localStorage["scanjam."+key] = ""
- else
- localStorage["scanjam."+key] = val
- },
- _hash_get: function (key)
- {
- if (key in Local.hash)
- return Local.hash[key]
- },
- _hash_set: function (key, val)
- {
- Local.hash[key] = val
- },
- _supports_html5_storage: function ()
- {
- try
- { return 'localStorage' in window && window['localStorage'] !== null; }
- catch (e)
- { return false }
- },
- like: function (videoid)
- { Local.set("like."+videoid, true) },
- unlike: function (videoid)
- { Local.set("like."+videoid, false) },
- isLiked: function (videoid)
- { return Local.get("like."+videoid) },
- init: function ()
- {
- Local.support = Local._supports_html5_storage()
- if (Local.support)
- {
- d.warn("SUPPORTS LOCAL STORAGE")
- Local.get = Local._html5_get
- Local.set = Local._html5_set
- }
- else
- {
- d.error("NO LOCAL STORAGE")
- Local.hash = {}
- Local.get = Local._hash_get
- Local.set = Local._hash_set
- }
- }
- }
-API.init()
-Local.init()
-