diff options
| author | pepper <peppersclothescult@gmail.com> | 2014-01-13 18:17:27 -0800 |
|---|---|---|
| committer | pepper <peppersclothescult@gmail.com> | 2014-01-13 18:17:27 -0800 |
| commit | 2263ec93f393c0eaae4df31f0ef3ff2eb99f73e2 (patch) | |
| tree | 10971c8a4b7326b22228ec3f1b45b9f66a5ef514 /cgi-bin/shader_api.js | |
| parent | ba490b2880eb10b198927c044133b35e02446bc7 (diff) | |
| parent | 9401ffc256bc39dc085ebea21de4942083219b88 (diff) | |
merged after making fixes
Merge branch 'master' of ghghgh.us:/home/git/dither into pepper
Diffstat (limited to 'cgi-bin/shader_api.js')
| -rw-r--r-- | cgi-bin/shader_api.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/cgi-bin/shader_api.js b/cgi-bin/shader_api.js new file mode 100644 index 0000000..dd43130 --- /dev/null +++ b/cgi-bin/shader_api.js @@ -0,0 +1,92 @@ +;var ShaderAPI = {} +ShaderAPI.limit = 24 + +// info - fetch a single shader +// id: shader id +ShaderAPI.info = function(id, cb){ + ShaderAPI.fetch({ + f: "info", + id: id + }, cb) +} + +// all - fetch all shaders +ShaderAPI.all = function(cb){ + ShaderAPI.fetch({ + f: "all" + }, cb) +} + +// range - fetch a pageful of results +// limit: number of shaders to fetch +// offset: number of results to skip +ShaderAPI.range = function(limit, offset, cb){ + ShaderAPI.fetch({ + f: "range", + limit: limit || ShaderAPI.limit, + last: offset + }, cb) +} + +// latest - get the latest N shaders +// limit: number of shaders to fetch +ShaderAPI.latest = function(limit, cb){ + ShaderAPI.fetch({ + f: "range", + limit: limit || ShaderAPI.limit + }, cb) +} + +// page - get a page of N results +// page: page number, start counting at 1 +// limit: number of shaders to fetch +ShaderAPI.page = function(page, limit, cb){ + ShaderAPI.fetch({ + f: "range", + last: (page-1) * limit, + limit: limit || ShaderAPI.limit + }, cb) +} + +// history - get all previous versions of a shader +// id: shader id +ShaderAPI.history = function(id, cb){ + ShaderAPI.fetch({ + f: "history", + id: id + }, cb) +} + +// username - get all ids by a user +ShaderAPI.username = function(username, cb){ + ShaderAPI.fetch({ + f: "username", + username: username + }, cb) +} + +// list_users - list all users +ShaderAPI.list_users = function(list_users, cb){ + ShaderAPI.fetch({ + f: "list_users" + }, cb) +} + +// originals - get the earliest version of all named shaders +ShaderAPI.originals = function(cb){ + ShaderAPI.fetch({ + f: "originals" + }, cb) +} + +// fetch - AJAX wrapper +ShaderAPI.fetch = function(params, cb){ + $.getJSON("/cgi-bin/im/shader/view", params, function(data){ + if (data.SUCCESS) { + cb(null, data.data) + } + else if (data.ERROR) { + cb(data.ERROR, data.data) + } + }) +} |
