Skip to content

Commit

Permalink
cleaning up Slycat web client, adding comments and linting #650
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Aug 3, 2016
1 parent ecfbe3a commit c867f14
Showing 1 changed file with 64 additions and 41 deletions.
105 changes: 64 additions & 41 deletions web-server/js/slycat-web-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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",
Expand All @@ -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({
Expand Down Expand Up @@ -905,7 +929,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
{
if(params.error)
params.error(request, status, reason_phrase);
},
}
});
};

Expand All @@ -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",
Expand All @@ -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)
{
Expand All @@ -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",
Expand All @@ -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)
{
Expand All @@ -968,22 +992,21 @@ 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();
},
error: function(request, status, reason_phrase)
{
if(params.error)
params.error(request, status, reason_phrase);
},
}
});
}
};

module.put_model_inputs = function(params)
{
Expand All @@ -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",
Expand All @@ -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)
{
Expand All @@ -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,
Expand All @@ -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)
{
Expand Down Expand Up @@ -1061,7 +1084,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
{
if(params.error)
params.error(request, status, reason_phrase);
},
}
});
};

Expand Down Expand Up @@ -1093,7 +1116,7 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
{
if(params.error)
params.error(request, status, reason_phrase);
},
}
});
};

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
});

0 comments on commit c867f14

Please sign in to comment.