X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fcore.js;h=ea6ccf764e929a089fde875c12b2b6d08ca6a974;hb=a21742678e53db58f3d406e355bf0b60fcd46e19;hp=4df8866cdb137c7c7b28573e9114183512347b82;hpb=c6e84b6d8243fd19b8d767c244be789ab45d7401;p=platal.git diff --git a/htdocs/javascript/core.js b/htdocs/javascript/core.js index 4df8866..ea6ccf7 100644 --- a/htdocs/javascript/core.js +++ b/htdocs/javascript/core.js @@ -24,7 +24,7 @@ // {{{ jQuery object extension (function($) { - function assert(condition, text) { + var assert = function(condition, text) { if ($.isFunction(condition)) { condition = condition(); } @@ -36,7 +36,7 @@ } else { throw "Assertion failed: " + text; } - } + }; /* Add new functions to jQuery namesapce */ @@ -47,7 +47,7 @@ if (url.startsWith('http', true)) { return url; } - if (typeof base == 'undefined') { + if (typeof base === 'undefined') { base = $('head base'); if (base.length > 0) { base = base.attr('href'); @@ -59,7 +59,7 @@ } } return base + url; - } + }; }()), /* The goal of the following functions is to provide an AJAX API that @@ -75,17 +75,17 @@ onSuccess = data; data = null; } - if (onError != null && !$.isFunction(onError)) { + if (onError && !$.isFunction(onError)) { type = type || onError; onError = null; } function ajaxHandler(data, textStatus, xhr) { - if (textStatus == 'success') { + if (textStatus === 'success') { if (onSuccess) { onSuccess(data, textStatus, xhr); } - } else if (textStatus == 'error') { + } else if (textStatus === 'error') { if (onError) { onError(data, textStatus, xhr); } else { @@ -125,7 +125,7 @@ closeOnEsc: function() { return $(window).keydown(function (e) { - if (e.keyCode == 27) { + if (e.keyCode === 27) { window.close(); } }); @@ -133,22 +133,27 @@ dynPost: function(action, key, value) { var values; + var k; + var form; + if (!$.isArray(key)) { values = { }; values[key] = value; } else { values = key; } - var form = $('