summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-06-07 17:11:08 +0200
committerPatrick Simianer <p@simianer.de>2016-06-07 17:11:08 +0200
commit83db5f918da692f13bd0fd886caf5374337e1d00 (patch)
treee3907077889037e31221c072d793f40558447187
parent2380944390691789dfaea133cd76f3c921820272 (diff)
pool
-rw-r--r--js/pool.js29
-rw-r--r--pool.php64
-rw-r--r--pool_save.php25
-rw-r--r--static/pool.css14
-rw-r--r--static/pool.html36
5 files changed, 168 insertions, 0 deletions
diff --git a/js/pool.js b/js/pool.js
new file mode 100644
index 0000000..4cb2af8
--- /dev/null
+++ b/js/pool.js
@@ -0,0 +1,29 @@
+var ids = [];
+var clicked = false;
+var clicked_sess = "";
+
+$().ready(function()
+{
+ $(".item").click(function () {
+ var id = $(this).attr("id");
+ if (!ids.includes(id) && !clicked) {
+ $(this).append("<input id='name' />");
+ ids.push(id);
+ clicked = true;
+ clicked_sess = $(this).attr("session");
+ }
+ });
+
+ $("#button").click(function () {
+ if (!clicked) return;
+ if ($("#name").val()=="") return;
+ $.ajax({url: "pool_save.php?name="+encodeURIComponent($("#name").val())+"&session="+encodeURIComponent(clicked_sess), success: function(result){
+ if (result=="ok") {
+ window.location = "http://postedit.cl.uni-heidelberg.de/interface.php?key="+clicked_sess+"&ui_type=t"; // FIXME
+ } else {
+ alert("Session taken, choose another session.");
+ }
+ }});
+ });
+});
+
diff --git a/pool.php b/pool.php
new file mode 100644
index 0000000..6ea0e2a
--- /dev/null
+++ b/pool.php
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
+
+ <title>Pool</title>
+
+ <link rel='stylesheet' type='text/css' href='static/pool.css' />
+ <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/pool.js" type="text/javascript" charset="utf-8"></script>
+</head>
+
+<body>
+ <p style='margin:2em;color:#000'><strong>Click on a table cell, enter your name, and click 'Begin' to begin your session. Reload the page if you clicked on the wrong cell.</strong></p>
+ <table border=1 style="margin-left:10%">
+ <tr><td>#0</td></tr>
+ </table>
+ <br />
+ <br />
+ <br />
+ <br />
+ <center>
+ <table border=1>
+ <tr>
+
+<!--<tr><td>#1</td><td>#2</td><td>#3</td><td>#4</td><td>#5</td></tr>
+ <tr><td>#6</td><td>#7</td><td>#8</td><td>#9</td><td>#10</td></tr>
+ <tr><td>#11</td><td>#12</td><td>#13</td><td>#14</td><td>#15</td></tr>
+ <tr><td>#16</td><td>#17</td><td>#18</td><td>#19</td><td>#20</td></tr>
+ <tr><td>#21</td><td>#22</td><td>#23</td><td>#24</td><td>#25</td></tr>-->
+
+ <?php
+ $f = fopen("../sessions/sessions", "r");
+ $a = array();
+ $b = array();
+ $max = -1;
+ while (($line = fgets($f)) !== false) {
+ $x = explode("\t", $line, 2);
+ $j = intval($x[0]);
+ $a[$x[1]] = $j;
+ $b[$j] = $x[1];
+ if ($j>$max) {
+ $max = $j;
+ }
+ }
+ fclose($f);
+
+ for ($i=1; $i<=$max; $i++) {
+ echo "<td class='item' session='".$b[$i]."' id='item".$i."'>#".$i."<br /><span style='font-size:.5em'>".$b[$i]."</span></td>\n";
+ if ($i%5 == 0) {
+ echo "</tr><tr>\n";
+ }
+ }
+ ?>
+
+ </tr>
+ </table>
+
+ <button style="font-size:2em;margin:2em" id="button">Begin</button>
+
+ </center>
+</body>
+</html>
+
diff --git a/pool_save.php b/pool_save.php
new file mode 100644
index 0000000..5d67a25
--- /dev/null
+++ b/pool_save.php
@@ -0,0 +1,25 @@
+<?php
+
+if (!$_GET['session'] || !$_GET['name']) {
+ echo "empty";
+ return;
+}
+
+$f = fopen(tempnam("../tmp", "assignment-"), "wa");
+
+fwrite($f,urldecode($_GET["name"])."\n");
+fwrite($f,urldecode($_GET["session"])."\n");
+fwrite($f,getdate()[0]."\n");
+fclose($f);
+
+$checkf = "../tmp/".urldecode($_GET["session"]);
+if (file_exists($checkf)) {
+ echo "notok";
+} else {
+ $g = fopen($checkf, "wa");
+ fwrite($g, "x\n");
+ fclose($g);
+ echo "ok";
+}
+
+?>
diff --git a/static/pool.css b/static/pool.css
new file mode 100644
index 0000000..98fde49
--- /dev/null
+++ b/static/pool.css
@@ -0,0 +1,14 @@
+body { background: #fff; color: #fff}
+
+td {
+ background:#eee;
+ color: #000;
+ padding: 2em;
+ font-weight: bold;
+ font-size: 1.2em;
+ text-align:center;
+}
+
+td:hover {
+ background: #fff
+}
diff --git a/static/pool.html b/static/pool.html
new file mode 100644
index 0000000..4e4aad3
--- /dev/null
+++ b/static/pool.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<!-- YYYY-MM-DD -->
+<html>
+<head>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
+ <meta http-equiv='Content-Language' content='de_DE' />
+ <meta name='author' content='Patrick Simianer' />
+ <meta name='robots' content='index, follow' />
+ <meta name='revisit-after' content='15 days' />
+ <meta name='description' content='' />
+ <meta name='keywords' content='' />
+
+ <title>Pool</title>
+
+ <link rel='stylesheet' type='text/css' href='pool.css' />
+</head>
+
+<body>
+ <table border=1 style="margin-left:10%">
+ <tr><td>#0</td></tr>
+ </table>
+ <br />
+ <br />
+ <center>
+ <table border=1>
+ <tr><td>#1</td><td>#2</td><td>#3</td><td>#4</td><td>#5</td></tr>
+ <tr><td>#6</td><td>#7</td><td>#8</td><td>#9</td><td>#10</td></tr>
+ <tr><td>#11</td><td>#12</td><td>#13</td><td>#14</td><td>#15</td></tr>
+ <tr><td>#16</td><td>#17</td><td>#18</td><td>#19</td><td>#20</td></tr>
+ <tr><td>#21</td><td>#22</td><td>#23</td><td>#24</td><td>#25</td></tr>
+ </table>
+
+ </center>
+</body>
+</html>
+