comparison ajax.js @ 876:a397d2be6d53

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 26 Nov 2014 16:03:54 +0200
parents 80f6f31d3711
children 43fa1c4c783f
comparison
equal deleted inserted replaced
875:920e33605102 876:a397d2be6d53
1 // 1 //
2 // FAPWeb - Simple Web-based Demoparty Management System 2 // FAPWeb - Simple Web-based Demoparty Management System
3 // Common JavaScript / AJAX code 3 // Common JavaScript / AJAX code
4 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) 4 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP)
5 // 5 //
6 var jsMessageBoxCancelCB = null, jsMessageBoxCBData = null, jsMessageBoxOKCB = null; 6 var jsMessageBoxCBCancel = null, jsMessageBoxCBData = null, jsMessageBoxCBOK = null;
7
7 8
8 function jsHandleMessageBoxKeys(ev) 9 function jsHandleMessageBoxKeys(ev)
9 { 10 {
10 ev = ev || window.event; 11 ev = ev || window.event;
11 var key = ev.keyCode ? ev.keyCode : ev.which; 12 var key = ev.keyCode ? ev.keyCode : ev.which;
12 if (key == 27) 13 if (key == 27)
13 { 14 {
14 jsCloseMessageBox(jsMessageBoxCancelCB, jsMessageBoxCBData); 15 jsCloseMessageBox(jsMessageBoxCBCancel, jsMessageBoxCBData);
15 return false; 16 return false;
16 } 17 }
17 else 18 else
18 return true; 19 return true;
19 } 20 }
20 21
21 22
23 function jsSetMessageBoxCBs(cb_ok, cb_cancel, cb_data)
24 {
25 jsMessageBoxCBOK = cb_ok;
26 jsMessageBoxCBCancel = cb_cancel;
27 jsMessageBoxCBData = cb_data;
28 }
29
30
22 function jsCloseMessageBox(callback, cb_data) 31 function jsCloseMessageBox(callback, cb_data)
23 { 32 {
24 var nitem = document.getElementById("messageBox"); 33 var nitem = document.getElementById("messageBox");
25 if (nitem) 34 if (nitem)
26 { 35 {
27 document.onkeydown = null; 36 document.onkeydown = null;
28 jsMessageBoxCancelCB = null; 37 jsSetMessageBoxCBs(null, null, null);
29 jsMessageBoxCBData = null;
30 jsMessageBoxOKCB = null;
31 38
32 if (nitem.style.display != "none") 39 if (nitem.style.display != "none")
33 { 40 {
34 nitem.style.display = "none"; 41 nitem.style.display = "none";
35 42
49 "<div class='messageBoxControls'>"+ 56 "<div class='messageBoxControls'>"+
50 "<input id='msgBoxConfirmClose' type='button' value=' OK '>"+ 57 "<input id='msgBoxConfirmClose' type='button' value=' OK '>"+
51 "</div></div>"; 58 "</div></div>";
52 59
53 document.onkeydown = jsHandleMessageBoxKeys; 60 document.onkeydown = jsHandleMessageBoxKeys;
54 jsMessageBoxCancelCB = null; 61 jsSetMessageBoxCBs(null, null, null);
55 jsMessageBoxCBData = null;
56 jsMessageBoxOKCB = null;
57 62
58 var elem = document.getElementById("msgBoxConfirmClose"); 63 var elem = document.getElementById("msgBoxConfirmClose");
59 elem.onclick = function () { jsCloseMessageBox(0, 0); } 64 elem.onclick = function () { jsCloseMessageBox(0, 0); }
60 65
61 nitem.style.display = "block"; 66 nitem.style.display = "block";
85 "<input id='msgBoxConfirmCancel' type='button' value=' Cancel '>"+ 90 "<input id='msgBoxConfirmCancel' type='button' value=' Cancel '>"+
86 "<input id='msgBoxConfirmOK' type='button' value=' OK '>"+ 91 "<input id='msgBoxConfirmOK' type='button' value=' OK '>"+
87 "</div></div>"; 92 "</div></div>";
88 93
89 document.onkeydown = jsHandleMessageBoxKeys; 94 document.onkeydown = jsHandleMessageBoxKeys;
90 jsMessageBoxOKCB = cb_ok; 95 jsSetMessageBoxCBs(cb_ok, cb_cancel, cb_data);
91 jsMessageBoxCancelCB = cb_cancel;
92 jsMessageBoxCBData = cb_data;
93 96
94 var elem = document.getElementById("msgBoxConfirmCancel"); 97 var elem = document.getElementById("msgBoxConfirmCancel");
95 elem.onclick = function () { jsCloseMessageBox(cb_cancel, cb_data); } 98 elem.onclick = function () { jsCloseMessageBox(cb_cancel, cb_data); }
96 99
97 elem = document.getElementById("msgBoxConfirmOK"); 100 elem = document.getElementById("msgBoxConfirmOK");