Sha256: 90c2206097bb1d4694b8c0e6c44737092d798799f5132ec067b100df1dd2e159
Contents?: true
Size: 1.34 KB
Versions: 32
Compression:
Stored size: 1.34 KB
Contents
var mumuki = mumuki || {}; (function (mumuki) { var lastSubmission = {}; function Laboratory(exerciseId){ this.exerciseId = exerciseId; } function asString(json){ return JSON.stringify(json); } function sameAsLastSolution(newSolution){ return asString(lastSubmission.content) === asString(newSolution); } function lastSubmissionFinishedSuccessfully(){ return lastSubmission.result && lastSubmission.result.status !== 'aborted'; } function sendNewSolution(solution){ var token = new mumuki.CsrfToken(); var request = token.newRequest({ type: 'POST', url: window.location.origin + window.location.pathname + '/solutions' + window.location.search, data: solution }); return $.ajax(request).done(function (result) { lastSubmission = { content: solution, result: result }; }); } mumuki.load(function () { lastSubmission = {}; }); Laboratory.prototype = { runLocalTests: function (solution) { if(lastSubmissionFinishedSuccessfully() && sameAsLastSolution(solution)){ return $.Deferred().resolve(lastSubmission.result); } else { return sendNewSolution(solution); } }, runTests: function(content) { return this.runLocalTests({ solution: content }); } }; mumuki.bridge = { Laboratory: Laboratory }; }(mumuki));
Version data entries
32 entries across 32 versions & 1 rubygems