From c867f149aff322025b0248aabcb9d61d6233ae36 Mon Sep 17 00:00:00 2001 From: Matthew Letter Date: Wed, 3 Aug 2016 14:28:11 -0600 Subject: [PATCH] cleaning up Slycat web client, adding comments and linting #650 --- web-server/js/slycat-web-client.js | 105 ++++++++++++++++++----------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/web-server/js/slycat-web-client.js b/web-server/js/slycat-web-client.js index 4c32ef7b5..9a336288f 100644 --- a/web-server/js/slycat-web-client.js +++ b/web-server/js/slycat-web-client.js @@ -8,6 +8,14 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { var module = {}; + /** + * delete a model for a slycat project + * @param params: object{ + * mid: model id that is to be deleted from the Slycat project + * success(): function called upon success + * error(request, status, reason_phrase): function called upon error + * } + */ module.delete_model = function(params) { $.ajax( @@ -23,10 +31,18 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; + /** + * delete a project in Slycat + * @param params: object{ + * pid: project id of project that is to be deleted from the Slycat + * success(): function called upon success + * error(request, status, reason_phrase): function called upon error + * } + */ module.delete_project = function(params) { $.ajax( @@ -42,10 +58,18 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; + /** + * delete a reference in Slycat + * @param params: object{ + * pid: project id of project that is to be deleted from the Slycat + * success(): function called upon success + * error(request, status, reason_phrase): function called upon error + * } + */ module.delete_reference = function(params) { $.ajax( @@ -61,9 +85,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.delete_remote = function(params) { @@ -602,9 +626,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_projects = function(params) { @@ -627,9 +651,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_project_models = function(params) { @@ -654,9 +678,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_project_references = function(params) { @@ -684,9 +708,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_remotes = function(params) { @@ -698,7 +722,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se hostname: params.hostname, username: params.username, password: params.password, - agent: params.agent !== undefined ? params.agent : null, + agent: params.agent !== undefined ? params.agent : null }), type: "POST", url: server_root + "remotes", @@ -711,9 +735,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_checksid = function(params) { $.ajax({ @@ -905,7 +929,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); }; @@ -917,7 +941,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se data: JSON.stringify( { "content-type": params["content-type"], - "images": params.images, + "images": params.images }), type: "POST", url: server_root + "remotes/" + params.sid + "/videos", @@ -930,9 +954,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_uploads = function(params) { @@ -944,7 +968,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se "mid": params.mid, "input": params.input, "parser": params.parser, - "aids": params.aids, + "aids": params.aids }), type: "POST", url: server_root + "uploads", @@ -957,9 +981,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.post_upload_finished = function(params) { @@ -968,12 +992,11 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se contentType: "application/json", data: JSON.stringify( { - "uploaded": params.uploaded, + "uploaded": params.uploaded }), type: "POST", url: server_root + "uploads/" + params.uid + "/finished", - success: function(result) - { + success: function () { if(params.success) params.success(); }, @@ -981,9 +1004,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.put_model_inputs = function(params) { @@ -993,7 +1016,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se data: JSON.stringify( { sid: params.sid, - "deep-copy": params["deep-copy"] || false, + "deep-copy": params["deep-copy"] || false }), type: "PUT", url: server_root + "models/" + params.mid + "/inputs", @@ -1006,9 +1029,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.put_model_parameter = function(params) { @@ -1018,7 +1041,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se data: JSON.stringify( { value: params.value, - input: params.input === undefined ? true: params.input ? true: false, + input: params.input === undefined ? true: params.input ? true: false }), type: "PUT", url: server_root + "models/" + params.mid + "/parameters/" + params.aid, @@ -1031,9 +1054,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.put_project = function(params) { @@ -1061,7 +1084,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); }; @@ -1093,7 +1116,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); }; @@ -1126,9 +1149,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; module.sign_out = function(params) { @@ -1145,9 +1168,9 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se { if(params.error) params.error(request, status, reason_phrase); - }, + } }); - } + }; return module; });