summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php8
-rw-r--r--pages/process.php135
2 files changed, 143 insertions, 0 deletions
diff --git a/index.php b/index.php
index ed7a836..9e47971 100644
--- a/index.php
+++ b/index.php
@@ -230,6 +230,14 @@ switch ($request) {
require 'pages/about.php';
}
break;
+
+ case "process":
+ if ($_SESSION['isAdmin'] == true) {
+ require 'pages/process.php';
+ } else {
+ require 'pages/about.php';
+ }
+ break;
case "massemail":
if ($_SESSION['isAdmin'] == true) {
diff --git a/pages/process.php b/pages/process.php
new file mode 100644
index 0000000..21604de
--- /dev/null
+++ b/pages/process.php
@@ -0,0 +1,135 @@
+<?php
+//include_once('./includes/maps.php');
+//include_once('./includes/mapclass.php');
+
+//Self-ajax.
+if ($_REQUEST['command'] == 'updateTask') {
+ $taskName = 'FAKE RECALCULATION';
+ $progress = $_SESSION['tmp'];
+
+ if ($progress >= 100) $_SESSION['dotask'] = false;
+
+ if ($_SESSION['dotask'] !== true) {
+ $json['percentComplete'] = $_SESSION['tmp'];
+ $json['taskName'] = $taskName;
+ $json['completed'] = true;
+ echo json_encode($json);
+ exit;
+ }
+
+ $_SESSION['tmp'] = $_SESSION['tmp'] + 25;
+
+
+ $json['percentComplete'] = $_SESSION['tmp'];
+ $json['taskName'] = $taskName;
+ $json['completed'] = 'false';
+ echo json_encode($json);
+ exit;
+}
+
+if ($_REQUEST['command'] == 'recalculateStats') {
+ //Already working on a task?
+ if ($_SESSION['dotask'] == true) {
+ $json['error'] = 'Task in progress!';
+ echo json_encode($json);
+ exit;
+ }
+
+ $_SESSION['tmp'] = 0;
+ $_SESSION['dotask'] = true;
+ $json['percentComplete'] = $_SESSION['tmp'];
+ $json['taskName'] = 'FAKE_Recalculation of stats';
+ echo json_encode($json);
+ exit;
+}
+
+htmlHeader(array('stats', 'achievements'), 'Process Tasks',
+ 'Process Tasks',
+ array());
+
+
+?>
+
+<body>
+<?php
+topbar($Links);
+
+?>
+<script>
+//setTimeout("start();", 500);
+function start() {
+}
+
+var requestComplete = true;
+processTimer();
+function processTimer() {
+ setTimeout("processTimer()", 3000);
+ if (requestComplete == false) return;
+ getTaskUpdate('updateTask');
+}
+
+function recalculate() {
+ if (!confirm('Are you sure?')) return;
+ getTaskUpdate('recalculateStats');
+}
+
+function getTaskUpdate(command) {
+ //var URLString = 'process?initiate=true&x'+JSON.stringify(testMap);
+ requestComplete = false;
+ var URLString = 'process?command='+command;
+ $.ajax({
+ type: "GET",
+ url: URLString,
+ cache: true,
+ data: '',
+ fail: function() { alert("error"); },
+ complete: function(data) {
+ if (data.responseText.length <= 1) {
+ console.log('null response');
+ requestComplete = true;
+ return;
+ }
+ json = decryptJSON(data.responseText);
+ if (json.error) {
+ alert('ERROR: "' + json.error + '".')
+ requestComplete = true;
+ return;
+ }
+ $('#taskProgressDisp').width(json.percentComplete+'%');
+ $('#taskProgressName').html(json.taskName);
+ // if (json.completed == true) {
+ // alert("TASK COMPLETE!");
+ // }
+ requestComplete = true;
+ }
+ });
+}
+
+
+</script>
+
+<div class='wrapper'>
+
+<h3>Task Processor</h3>
+ <div class='wrapper'>
+ <form>
+ <fieldset>
+ <legend>Load Map:</legend>
+ <div class='plusMinus'>
+ Recalculate all statistics: <input type="button" value="Recalculate!" class="forminput" onclick='recalculate()'/>
+ </div>
+ Processing: "<span id='taskProgressName'>Loading...</span>"
+ <div class='progressBar' style='width:600px'>
+ <div id='taskProgressDisp' style='width:0%;'>
+ </div>
+ </div>
+
+ </fieldset>
+
+ </form>
+ </div>
+</div>
+
+<?php
+htmlFooter();
+?> \ No newline at end of file