|
Lines 1-5
Link Here
|
| 1 |
////Create javascript namespace |
1 |
////Create javascript namespace |
| 2 |
var FloMax = FloMax || {}; |
2 |
var FloMax = FloMax || {}; |
|
|
3 |
FloMax.Tester = FloMax.Tester || {}; |
| 3 |
|
4 |
|
| 4 |
//// DOCUMENT READY INIT SCRIPTS |
5 |
//// DOCUMENT READY INIT SCRIPTS |
| 5 |
|
6 |
|
|
Lines 15-20
$(document).ready(function() {
Link Here
|
| 15 |
FloMax.changeBranchRuleColor(this); |
16 |
FloMax.changeBranchRuleColor(this); |
| 16 |
}); |
17 |
}); |
| 17 |
|
18 |
|
|
|
19 |
//Bind actions to the FloMax Tester |
| 20 |
$("#floatingRuleTester input[type='submit']").bind({ |
| 21 |
click: function() { |
| 22 |
FloMax.Tester.testFloating(); |
| 23 |
} |
| 24 |
}); |
| 25 |
|
| 18 |
//Bind action listeners to the floating matrix |
26 |
//Bind action listeners to the floating matrix |
| 19 |
$(".branchRule").bind({ |
27 |
$(".branchRule").bind({ |
| 20 |
click: function() { |
28 |
click: function() { |
|
Lines 183-186
FloMax.persistBranchRule = function (brJSON, branchRule) {
Link Here
|
| 183 |
alert("Saving floating rule "+brJSON.fromBranch+"-"+brJSON.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error); |
191 |
alert("Saving floating rule "+brJSON.fromBranch+"-"+brJSON.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error); |
| 184 |
}); |
192 |
}); |
| 185 |
} |
193 |
} |
|
|
194 |
} |
| 195 |
|
| 196 |
FloMax.Tester.defaultTestResultColor = "#B9D8D9"; |
| 197 |
|
| 198 |
FloMax.Tester.testFloating = function() { |
| 199 |
var testCase = FloMax.Tester.buildTestCaseFromHTML(); |
| 200 |
$(".cssload-loader").css('visibility', 'visible'); |
| 201 |
|
| 202 |
$.ajax('floating-matrix-api.pl', |
| 203 |
{method : 'POST', |
| 204 |
data : testCase, |
| 205 |
dataType : 'json', |
| 206 |
}).done(function(data, textStatus, jqXHR){ |
| 207 |
|
| 208 |
FloMax.Tester.displayTestResult(data.testResult); |
| 209 |
|
| 210 |
}).fail(function (data, textStatus, jqXHR) { |
| 211 |
var error = $.parseJSON(data.responseText); //Pass the error as JSON so we don't trigger the default Koha error pages. |
| 212 |
alert("Testing floating rule "+testCase.fromBranch+"-"+testCase.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error); |
| 213 |
FloMax.Tester.displayTestResult("error"); |
| 214 |
}); |
| 215 |
} |
| 216 |
FloMax.Tester.buildTestCaseFromHTML = function () { |
| 217 |
var fromBranch = $("#floatingRuleTester #testerFromBranch").val(); |
| 218 |
var toBranch = $("#floatingRuleTester #testerToBranch").val(); |
| 219 |
var barcode = $("#floatingRuleTester #testerBarcode").val(); |
| 220 |
|
| 221 |
var testCase = { |
| 222 |
'fromBranch' : fromBranch, |
| 223 |
'toBranch' : toBranch, |
| 224 |
'barcode' : barcode, |
| 225 |
'test': true, |
| 226 |
}; |
| 227 |
return testCase; |
| 228 |
} |
| 229 |
FloMax.Tester.displayTestResult = function (testResult) { |
| 230 |
$(".cssload-loader").css('visibility', 'hidden'); |
| 231 |
var color; |
| 232 |
if (testResult == null) { |
| 233 |
color = FloMax.branchRuleDisabledColor; |
| 234 |
} |
| 235 |
else if (testResult == 'ALWAYS') { |
| 236 |
color = FloMax.branchRuleAlwaysColor; |
| 237 |
} |
| 238 |
else if (testResult == 'POSSIBLE') { |
| 239 |
color = FloMax.branchRulePossibleColor; |
| 240 |
} |
| 241 |
else if (testResult == "error") { |
| 242 |
color = FloMax.Tester.defaultTestResultColor; |
| 243 |
} |
| 244 |
else { |
| 245 |
color = FloMax.Tester.defaultTestResultColor; |
| 246 |
alert("Couldn't display test result '"+testResult+"'. Value is unknown."); |
| 247 |
} |
| 248 |
|
| 249 |
$("#testResulDisplay").css('background-color', color); |
| 186 |
} |
250 |
} |