changeset 384:357b81e39ab3

Rename majax.php -> majax.inc.php.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Dec 2013 19:52:23 +0200
parents 2c61dc1e659d
children 8b8b0a83233b
files admin.php majax.inc.php majax.php show.php vote.inc.php
diffstat 5 files changed, 208 insertions(+), 208 deletions(-) [+]
line wrap: on
line diff
--- a/admin.php	Wed Dec 04 19:48:55 2013 +0200
+++ b/admin.php	Wed Dec 04 19:52:23 2013 +0200
@@ -8,7 +8,7 @@
 require_once "mconfig.inc.php";
 require_once "msite.inc.php";
 require_once "msession.inc.php";
-require_once "majax.php";
+require_once "majax.inc.php";
 
 function stCreateSettingsData()
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/majax.inc.php	Wed Dec 04 19:52:23 2013 +0200
@@ -0,0 +1,205 @@
+<?
+//
+// FAPWeb Simple Demoparty System
+// Common AJAX Javascript code module
+// (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
+//
+
+
+function stCommonAJAX($backend, $failover, $script = FALSE)
+{
+if ($script)
+  echo "<script type=\"text/javascript\">\n";
+
+?>
+function closeMessageBox(callback, cb_data)
+{
+  var nitem = document.getElementById("messageBox");
+  if (nitem && nitem.style.display != "none")
+  {
+    nitem.style.display = "none";
+  
+    if (callback && typeof(callback) === "function")
+      callback(cb_data);
+  }
+}
+
+
+function jsMessageBox(msg)
+{
+  var nitem = document.getElementById("messageBox");
+  if (nitem)
+  {
+    nitem.innerHTML = "<div class='messageBoxInner'>"+ msg +
+      "<div class='messageBoxControls'>"+
+      "<input id='msgBoxConfirmClose' type='button' value=' OK '>"+
+      "</div></div>";
+
+    document.getElementById("msgBoxConfirmClose").onclick = function () { closeMessageBox(0, 0); }
+
+    nitem.style.display = "block";
+  }
+}
+
+
+function jsConfirmBox(msg, cb_ok, cb_cancel, cb_data)
+{
+  var nitem = document.getElementById("messageBox");
+  if (nitem)
+  {
+    nitem.innerHTML = "<div class='messageBoxInner'><h1>Confirmation</h1><p>"+ msg +"</p>"+
+      "<div class='messageBoxControls'>"+
+      "<input id='msgBoxConfirmCancel' type='button' value=' Cancel '>"+
+      "<input id='msgBoxConfirmOK' type='button' value=' OK '>"+
+      "</div></div>";
+
+    document.getElementById("msgBoxConfirmCancel").onclick = function () { closeMessageBox(cb_cancel, cb_data); }
+    document.getElementById("msgBoxConfirmOK").onclick = function () { closeMessageBox(cb_ok, cb_data); }
+    
+    nitem.style.display = "block";
+  }
+}
+
+
+function statusMsg(msg)
+{
+  var nitem = document.getElementById("nstatus");
+  if (nitem) nstatus.innerHTML = msg;
+}
+
+
+function strtrim(str)
+{
+  if (!str || str == null)
+    return "";
+  return str.replace(/^\s+|\s+$/g,'')
+}
+
+
+function strencode(str)
+{
+  return encodeURIComponent(str);
+}
+
+
+function jsCreateXMLRequest()
+{
+  var req;
+  if (window.XMLHttpRequest)
+  {
+    // Modern browsers
+    req = new XMLHttpRequest();
+  }
+  else
+  {
+    // Old IE versions
+    req = new ActiveXObject("Microsoft.XMLHTTP");
+  }
+  return req;
+}
+
+
+function jsSendPOSTRequest(params, success, failure)
+{
+<?
+  if (($csrfID = stGetSessionItem("csrfID", FALSE)) !== FALSE)
+    echo "  params += \"&csrfID=".$csrfID."\";\n";
+?>
+  var req = jsCreateXMLRequest();
+  req.open("POST", "<? echo $backend ?>", true);
+  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+  req.setRequestHeader("Content-length", params.length);
+  req.setRequestHeader("Connection", "close");
+
+  req.onreadystatechange = function()
+  {
+    if (req.readyState == 4)
+    {
+      if (req.status == 404)
+      {
+        window.location = "<? echo $failover ?>";
+      }
+      else
+      if (req.status == 902)
+      {
+        statusMsg(req.statusText);
+        jsMessageBox(req.responseText);
+      }
+      else
+      if (req.status == 200)
+      {
+        if (success)
+        {
+          success(req.responseText);
+        }
+        statusMsg(req.statusText);
+      }
+      else
+      {
+        if (failure)
+        {
+          failure(req.status, req.statusText, req.responseText);
+        }
+        else
+        {
+          statusMsg("["+req.status+" - "+req.statusText+"] "+ req.responseText);
+        }
+      }
+    }
+  }
+  req.send(params);
+}
+
+
+//
+// Function for creating AJAX POST request arguments list based
+// on fields and giving them specified types. Also basic check
+// for validity can be performed (e.g. field empty or not)
+//
+var lastPostArgs = Object();
+function jsMakePostArgs(fields, fprefix, fsuffix)
+{
+  var res = [];
+  lastPostArgs = Object();
+
+  for (var id in fields)
+  {
+    var elname = fprefix + id + fsuffix;
+    var elem = document.getElementById(elname);
+    if (!elem)
+    {
+      jsMessageBox("No such DOM element '"+ elname +"'.");
+      return "";
+    }
+
+    switch (fields[id])
+    {
+      case 1:
+        var vstr = strtrim(elem.value);
+        res.push(id+"="+strencode(vstr));
+        lastPostArgs[id] = vstr;
+        break;
+
+      case 2:
+        var vint = parseInt(strtrim(elem.value));
+        res.push(id+"="+vint);
+        lastPostArgs[id] = vint;
+        break;
+
+      case 3:
+        res.push(id+"="+(elem.checked ? "1" : "0"));
+        lastPostArgs[id] = elem.checked;
+        break;
+
+      default:
+        jsMessageBox("Unsupported field type in "+ elname);
+        return "";
+    }
+  }
+  return res.join("&");
+}
+<?
+if ($script)
+  echo "</script>\n";
+}
+?>
\ No newline at end of file
--- a/majax.php	Wed Dec 04 19:48:55 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-<?
-//
-// FAPWeb Simple Demoparty System
-// Common AJAX Javascript code module
-// (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
-//
-
-
-function stCommonAJAX($backend, $failover, $script = FALSE)
-{
-if ($script)
-  echo "<script type=\"text/javascript\">\n";
-
-?>
-function closeMessageBox(callback, cb_data)
-{
-  var nitem = document.getElementById("messageBox");
-  if (nitem && nitem.style.display != "none")
-  {
-    nitem.style.display = "none";
-  
-    if (callback && typeof(callback) === "function")
-      callback(cb_data);
-  }
-}
-
-
-function jsMessageBox(msg)
-{
-  var nitem = document.getElementById("messageBox");
-  if (nitem)
-  {
-    nitem.innerHTML = "<div class='messageBoxInner'>"+ msg +
-      "<div class='messageBoxControls'>"+
-      "<input id='msgBoxConfirmClose' type='button' value=' OK '>"+
-      "</div></div>";
-
-    document.getElementById("msgBoxConfirmClose").onclick = function () { closeMessageBox(0, 0); }
-
-    nitem.style.display = "block";
-  }
-}
-
-
-function jsConfirmBox(msg, cb_ok, cb_cancel, cb_data)
-{
-  var nitem = document.getElementById("messageBox");
-  if (nitem)
-  {
-    nitem.innerHTML = "<div class='messageBoxInner'><h1>Confirmation</h1><p>"+ msg +"</p>"+
-      "<div class='messageBoxControls'>"+
-      "<input id='msgBoxConfirmCancel' type='button' value=' Cancel '>"+
-      "<input id='msgBoxConfirmOK' type='button' value=' OK '>"+
-      "</div></div>";
-
-    document.getElementById("msgBoxConfirmCancel").onclick = function () { closeMessageBox(cb_cancel, cb_data); }
-    document.getElementById("msgBoxConfirmOK").onclick = function () { closeMessageBox(cb_ok, cb_data); }
-    
-    nitem.style.display = "block";
-  }
-}
-
-
-function statusMsg(msg)
-{
-  var nitem = document.getElementById("nstatus");
-  if (nitem) nstatus.innerHTML = msg;
-}
-
-
-function strtrim(str)
-{
-  if (!str || str == null)
-    return "";
-  return str.replace(/^\s+|\s+$/g,'')
-}
-
-
-function strencode(str)
-{
-  return encodeURIComponent(str);
-}
-
-
-function jsCreateXMLRequest()
-{
-  var req;
-  if (window.XMLHttpRequest)
-  {
-    // Modern browsers
-    req = new XMLHttpRequest();
-  }
-  else
-  {
-    // Old IE versions
-    req = new ActiveXObject("Microsoft.XMLHTTP");
-  }
-  return req;
-}
-
-
-function jsSendPOSTRequest(params, success, failure)
-{
-<?
-  if (($csrfID = stGetSessionItem("csrfID", FALSE)) !== FALSE)
-    echo "  params += \"&csrfID=".$csrfID."\";\n";
-?>
-  var req = jsCreateXMLRequest();
-  req.open("POST", "<? echo $backend ?>", true);
-  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-  req.setRequestHeader("Content-length", params.length);
-  req.setRequestHeader("Connection", "close");
-
-  req.onreadystatechange = function()
-  {
-    if (req.readyState == 4)
-    {
-      if (req.status == 404)
-      {
-        window.location = "<? echo $failover ?>";
-      }
-      else
-      if (req.status == 902)
-      {
-        statusMsg(req.statusText);
-        jsMessageBox(req.responseText);
-      }
-      else
-      if (req.status == 200)
-      {
-        if (success)
-        {
-          success(req.responseText);
-        }
-        statusMsg(req.statusText);
-      }
-      else
-      {
-        if (failure)
-        {
-          failure(req.status, req.statusText, req.responseText);
-        }
-        else
-        {
-          statusMsg("["+req.status+" - "+req.statusText+"] "+ req.responseText);
-        }
-      }
-    }
-  }
-  req.send(params);
-}
-
-
-//
-// Function for creating AJAX POST request arguments list based
-// on fields and giving them specified types. Also basic check
-// for validity can be performed (e.g. field empty or not)
-//
-var lastPostArgs = Object();
-function jsMakePostArgs(fields, fprefix, fsuffix)
-{
-  var res = [];
-  lastPostArgs = Object();
-
-  for (var id in fields)
-  {
-    var elname = fprefix + id + fsuffix;
-    var elem = document.getElementById(elname);
-    if (!elem)
-    {
-      jsMessageBox("No such DOM element '"+ elname +"'.");
-      return "";
-    }
-
-    switch (fields[id])
-    {
-      case 1:
-        var vstr = strtrim(elem.value);
-        res.push(id+"="+strencode(vstr));
-        lastPostArgs[id] = vstr;
-        break;
-
-      case 2:
-        var vint = parseInt(strtrim(elem.value));
-        res.push(id+"="+vint);
-        lastPostArgs[id] = vint;
-        break;
-
-      case 3:
-        res.push(id+"="+(elem.checked ? "1" : "0"));
-        lastPostArgs[id] = elem.checked;
-        break;
-
-      default:
-        jsMessageBox("Unsupported field type in "+ elname);
-        return "";
-    }
-  }
-  return res.join("&");
-}
-<?
-if ($script)
-  echo "</script>\n";
-}
-?>
\ No newline at end of file
--- a/show.php	Wed Dec 04 19:48:55 2013 +0200
+++ b/show.php	Wed Dec 04 19:52:23 2013 +0200
@@ -7,7 +7,7 @@
 require_once "mconfig.inc.php";
 require_once "msite.inc.php";
 require_once "msession.inc.php";
-require_once "majax.php";
+require_once "majax.inc.php";
 
 $pageCSS["show.css"] = "";
 
--- a/vote.inc.php	Wed Dec 04 19:48:55 2013 +0200
+++ b/vote.inc.php	Wed Dec 04 19:52:23 2013 +0200
@@ -5,7 +5,7 @@
 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
 //
 $sessionType = "user";
-require_once "majax.php";
+require_once "majax.inc.php";
 
 
 function stGetVoteButton()