summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/achievements.php8
-rw-r--r--pages/admin.php2
-rw-r--r--pages/challenge.php10
-rw-r--r--pages/challengelist.php16
-rw-r--r--pages/chat.php142
-rw-r--r--pages/home.php2
-rw-r--r--pages/login.php2
-rw-r--r--pages/mapeditor.php314
-rw-r--r--pages/massemail.php2
-rw-r--r--pages/scores.php196
-rw-r--r--pages/share.php20
11 files changed, 571 insertions, 143 deletions
diff --git a/pages/achievements.php b/pages/achievements.php
index 6717cbe..249077c 100644
--- a/pages/achievements.php
+++ b/pages/achievements.php
@@ -1,5 +1,5 @@
<?php
-htmlHeader(array('profile'), 'Pathery Achievements');
+htmlHeader(array('achievements'), 'Pathery Achievements');
?>
<body>
@@ -533,9 +533,9 @@ foreach($achievements as $aType => $a) {
echo "Last level earned $aCompleted";
echo "<br />Currently $pronoun $nUCurrent $currency";
echo "
- <div title='$percent% to $nRequired' style='align:left;width:210px;height:16px;background-color:#222;border:1px solid #26b;'>
- <div style='border-right:1px solid #37e;width:$percent%;height:16px;background-color:#26b;'>
- </div>
+ <div class='progressBar' title='$percent% to $nRequired'>
+ <div style='width:$percent%;'>
+ </div>
</div>
";
echo "Next level at $nRequired will unlock: ";
diff --git a/pages/admin.php b/pages/admin.php
index 24feda4..e98dc49 100644
--- a/pages/admin.php
+++ b/pages/admin.php
@@ -9,7 +9,7 @@ topbar($Links);
include_once('./includes/datas.php');
include_once('./includes/maps.php');
include_once('./includes/mapoftheday.php');
-include_once('./includes/sqli.php');
+include_once('./includes/sqlEmbedded.php');
include_once('./includes/playerStats.php');
include_once('./includes/chats.php');
diff --git a/pages/challenge.php b/pages/challenge.php
index e6dbff2..efc0361 100644
--- a/pages/challenge.php
+++ b/pages/challenge.php
@@ -97,7 +97,15 @@ $challengeMapID = $_GET["challengeMapID"] + 0;
if (!is_int($challengeMapID))
return;
-$mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["challengeMapID"]);
+ $challengeID = $_GET["challengeMapID"];
+
+//$mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["challengeMapID"]);
+
+$mapContent .= "<div id='innerChallengeMapDsp_$challengeID'>\n";
+$mapContent .= "</div>\n";
+$mapContent .= "<script>";
+$mapContent .= " displayMap($challengeID, 'innerChallengeMapDsp_$challengeID', false, '$mysolution', '$mymoves', true);";
+$mapContent .= "</script>";
$challengeResultset = loadChallengesForMap($challengeMapID, $userID);
if($challengeResultset === NULL)
{
diff --git a/pages/challengelist.php b/pages/challengelist.php
index ade47b6..51c8f69 100644
--- a/pages/challengelist.php
+++ b/pages/challengelist.php
@@ -82,14 +82,20 @@ function getChallengeListHtml($challengeListResultset) {
$challengeMapID = $firstChallenge['challengeMapID'];
//$mapCode = getMapCode($mapid);
- $mapCode = $firstChallenge['mapCode'];
- $map = new map($mapCode);
- $thumbnail = DisplayMapThumbnail($map);
+ //$mapCode = $firstChallenge['mapCode'];
+ //$map = new map($mapCode);
+ //$thumbnail = DisplayMapThumbnail($map);
$r .= "<div class='challengelist_map' onclick='document.location.href=\"challenge?challengeMapID=$challengeMapID\"'>";
- $r .= "$map->name";
- $r .= $thumbnail;
+ //$r .= "$map->name";
+ //$r .= $thumbnail;
+ $r .= "<div id='innerChallengeMapDspThumb_$challengeMapID'>\n";
+ $r .= "</div>\n";
+ $r .= "<script>";
+ $r .= " displayMap($challengeMapID, 'innerChallengeMapDspThumb_$challengeMapID', 170, '', '', true, true);";
+ $r .= "</script>";
+
foreach ($challenge as $ordering => $content) {
//Each challenge gets its own star
if($content["dateSolved"] !== NULL)
diff --git a/pages/chat.php b/pages/chat.php
index b90226c..c6ff79c 100644
--- a/pages/chat.php
+++ b/pages/chat.php
@@ -45,6 +45,9 @@ function getChatDone(data) {
var p; //our prep string
var newChats = false;
+ var lastDisplay = '';
+ var lastMessage = '';
+
////console.log('datalength', data.length);
if (data.length < 3 || data == 'false')
@@ -58,52 +61,69 @@ function getChatDone(data) {
//console.log("JSON PREPED");
- $.each(json, function(key, user) {
+ $.each(json, function(key, chat) {
var postDate = new Date();
- postDate.setTime(postDate.getTime() + user.secondsSince * 1000);
+ postDate.setTime(postDate.getTime() + chat.secondsSince * 1000);
//var timestamp = postDate.format("ddd h:MM TT");
//var timestamp = postDate.format("h:MM:ss");
var timestamp = postDate.format("hh:MM:ss");
+ var timestampDetails = postDate.format("ddd h:MM TT");
var strClass = '';
- if (user.userID == userObj.ID) {
+ if (chat.userID == userObj.ID) {
strClass += ' self';
- }
- if (user.userID == '-1') {
+ }
+ if (chat.userID == '-1') {
strClass += ' server';
- user.displayName = 'SERVER'
+ chat.displayName = 'SERVER'
}
-
+
+ var usernameClass = '';
+ if (chat.message.indexOf("/me ") == 0) {
+ chat.message = chat.message.substring(4);
+ usernameClass = ' me';
+ }
+
+ var isSpoiler = false;
+ if (chat.message.indexOf("/spoiler ") == 0) {
+ chat.message = chat.message.substring(9);
+ isSpoiler = true;
+ }
+
+
//console.log("INSIDE BUILD START");
p = '';
p = p+ " <div class='chatColumn1'>";
- p = p+ " <span class='chatTimestamp'>["+timestamp+"]</span>";
- p = p+ " <div class='grid_td chatBadge' style='float:left; width:35px; height:35px; background:"+user.wallColor+" url(images/marks/"+user.wallEmblem+");'>";
+ p = p+ " <span class='chatTimestamp' title='"+timestampDetails+"'>["+timestamp+"]</span>";
+ p = p+ " <div class='grid_td chatBadge' style='float:left; width:35px; height:35px; background:"+chat.wallColor+" url(images/marks/"+chat.wallEmblem+");'>";
p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
p = p+ " </div>";
p = p+ " </div>";
p = p+ " </div>";
p = p+ " <div class='chatColumn2'>";
- if (user.userID == '-1') {
- p = p+ "<span class='chatUsername'><a href='home'>";
+ if (chat.userID == '-1') {
+ p = p+ "<span class='chatUsername"+usernameClass+"'><a href='home'>";
} else {
- p = p+ "<span class='chatUsername'><a href='achievements?id="+user.userID+"' style='color:"+user.displayColor+"'>";
+ p = p+ "<span class='chatUsername"+usernameClass+"'><a href='achievements?id="+chat.userID+"' style='color:"+chat.displayColor+"'>";
}
- p = p+ user.displayName+"</a>:</span>";
+ p = p+ chat.displayName+"</a></span>";
- p = p+ " <span class='chatText'>";
- p = p+ htmlEncode(user.message);
+ if (isSpoiler == true) p = p+ " <span class='chatText spoiler' onclick='spoil(this);'>";
+ else p = p+ " <span class='chatText'>";
+ p = p+ chatReplaceAndEncode(chat.message);
p = p+ " </span>";
p = p+ " </div>";
//Message is legitmently new or a server message?
- if (user.ID > lastID || typeof(user.ID) == 'undefined') {
- items.push('<div class="chatMessage'+strClass+'" id="C_' + user.ID + '">' + p + '</div>');
+ if (chat.ID > lastID || typeof(chat.ID) == 'undefined') {
+ items.push('<div class="chatMessage'+strClass+'" id="C_' + chat.ID + '">' + p + '</div>');
newChats = true;
}
- if (user.ID > 0) lastID = user.ID;
+ lastDisplay = chat.displayName
+ lastMessage = chat.message
+ if (chat.ID > 0) lastID = chat.ID;
});
//console.log("BUILD DONE");
@@ -111,32 +131,55 @@ function getChatDone(data) {
if (newChats) {
if (chatTimerDelay > chatTimerDelayLower) chatTimerDelay -= 1000;
- var new_chatDiv = $('<div/>', {
- 'class': 'my-new-list',
- //'style': 'display: none',
- html: items.join('')
- });
var elem = $("#chatContainer");
- //var atBottom = (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight());
var atBottom = (elem.scrollTop() >= elem[0].scrollHeight - elem.outerHeight() - 1);
-
-
- //var elem = $("#chatContainer"); console.log ("Ret", elem[0].scrollHeight, elem.scrollTop(), elem.outerHeight(), elem[0].scrollHeight - elem.scrollTop());
-
- //new_chatDiv.appendTo('#chatContainer').slideDown('fast');
- new_chatDiv.appendTo('#chatContainer');
-
+
+ $("#chatContainer").append(items.join(''));
+
if (atBottom || firstGetChat) {
$("#chatContainer").scrollTop($("#chatContainer")[0].scrollHeight);
firstGetChat = false;
}
- soundManager.setVolume('charm', 20);
- soundManager.setPan('charm', -60)
- soundManager.setPosition('charm',150);
- soundManager.play('charm');
+ document.title = lastDisplay+': '+lastMessage.substring(0, 10)+'... Pathery Chat';
+ if (chatIsMuted == 'true') {
+ soundManager.setVolume('charm', 20);
+ soundManager.setPan('charm', -60)
+ soundManager.setPosition('charm',150);
+ soundManager.play('charm');
+ }
}
}
+function chatReplaceAndEncode(chat) {
+ chat = htmlEncode(chat);
+ chat = chat.replace(/\*\*(\S(.*?\S)?)\*\*/gm, "<b>$1</b>");
+ chat = chat.replace(/\~\~(\S(.*?\S)?)\~\~/gm, "<s>$1</s>");
+ chat = chat.replace(/\*(\S(.*?\S)?)\*/gm, "<i>$1</i>");
+
+ chat = replaceSmileys(chat);
+
+ //Surround all URLs with a <a> link
+ var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
+ chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='_blank'>$1</a>");
+
+ //Replace # in the URL with %23
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%23$3' target='_blank'>");
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(&amp;)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%26$3' target='_blank'>");
+ //Making the bet that not all browsers do the same:
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%26$3' target='_blank'>");
+
+ return chat;
+}
+
+function replaceSmileys(chat) {
+ chat = chat.replace(/:\)/g, '<img class="chatSmiley" src="images/smileys/Smiling.png" />');
+ chat = chat.replace(/\(:/g, '<img class="chatSmiley" src="images/smileys/Smiling.png" />');
+ //chat = chat.replace(/:\//g, '<img class="chatSmiley" src="images/smileys/Uncertain.png" />');
+ chat = chat.replace(/:\(/g, '<img class="chatSmiley" src="images/smileys/Unhappy.png" />');
+ chat = chat.replace(/\&lt;3/g, '<img class="chatSmiley" src="images/smileys/Heart.png" />');
+ return chat;
+}
+
function prepChat(chat) {
chat = chat.join('|:|');
chat = chat.replace(/\&/g,'%26')
@@ -144,6 +187,10 @@ function prepChat(chat) {
return chat;
}
+function spoil(obj) {
+ $(obj).removeClass("spoiler");
+}
+
function getChat(message) {
var dataString = 'getChatFromID='+lastID;
if (chatBuffer.length > 0) {
@@ -166,8 +213,8 @@ function sendChat() {
$("input#message").val('');
if (skipNextGetChat == false) {
skipNextGetChat = true;
- getChat();
}
+ getChat();
return false;
}
@@ -187,6 +234,23 @@ function htmlEncode(value){
}
}
+
+<?
+$chatMute = (isset($_COOKIE['pref_chatMute']) && $_COOKIE['pref_chatMute'] == "true");
+$chatMute = ($chatMute) ? 'true' : 'false';
+?>
+var chatIsMuted = '<? echo $chatMute; ?>';
+function setChatMute() {
+ var value = chatIsMuted;
+
+ $('#chatMute').removeClass("chatMute_"+value);
+ if (value == 'true') value = 'false';
+ else value = 'true';
+ chatIsMuted = value;
+ $('#chatMute').addClass("chatMute_"+value);
+ savePref('chatMute', value);
+}
+
</script>
<div class='wrapper'>
@@ -198,6 +262,12 @@ function htmlEncode(value){
<form id='sendChat' onsubmit="return false">
<? if($accepted) { /*Only show the chat button if we're logged in*/ ?>
<input type="hidden" name="stuff" value="1724">
+
+ <?
+ echo "
+ <a title='Mute sound?' class='chatMute_$chatMute unselectable' href='javascript:setChatMute()' id='chatMute'/></a>";
+ ?>
+
<input class='chatButton' type="button" class="send" id='chatSendBtn' value='Send' onClick="sendChat();">
<input class='chatInputMessage' type="text" name="message" id="message" value="" maxlength="255" autocomplete="off" >
<? } ?>
diff --git a/pages/home.php b/pages/home.php
index 544b3fe..8c88d49 100644
--- a/pages/home.php
+++ b/pages/home.php
@@ -9,7 +9,7 @@ include_once ('./includes/constants.php');
htmlHeader(
array('stats'), 'Pathery',
- 'Compete to create the longest path possible. New maps every day!',
+ 'Path lengthening competition inspired by Tower Defense mazing concepts',
array('scores', 'dateformat')
);
diff --git a/pages/login.php b/pages/login.php
index 9358d89..e9bc13a 100644
--- a/pages/login.php
+++ b/pages/login.php
@@ -132,6 +132,8 @@ try {
throwLoginError($d, "Unknown DB Registration failure");
exit;
}
+ include_once('includes/chats.php');
+ addchat(-1, "New user registered: \"$display\"");
}
//If 'remember me' use this for cookie password
//$_SESSION['Passcode'] = MD5($Password.$Pepper.$Username);
diff --git a/pages/mapeditor.php b/pages/mapeditor.php
new file mode 100644
index 0000000..0d6cf94
--- /dev/null
+++ b/pages/mapeditor.php
@@ -0,0 +1,314 @@
+<?php
+include_once('./includes/maps.php');
+include_once('./includes/mapclass.php');
+
+//Self-ajax.
+if ($_REQUEST['mapByCode']) {
+ $map = new map($_REQUEST['mapByCode']);
+ echo json_encode($map);
+ exit;
+}
+
+if ($_REQUEST['mapByMap']) {
+ $jsonMap = json_decode($_REQUEST['mapByMap']);
+
+ $map = new map();
+ foreach ($jsonMap as $key => $value) {
+ $map->$key = $value;
+ }
+ //Store the code in the object
+ $code = $map->getOldCode();
+ $map->code = $code;
+ echo json_encode($map);
+ exit;
+}
+
+
+htmlHeader(array('stats', 'mapeditor'), 'Map Editor',
+ 'Map Editor',
+ array('dateformat'));
+
+
+?>
+
+<body>
+<?php
+echo soundManager2();
+topbar($Links);
+
+?>
+<script>
+
+
+var testMap = new Object;
+
+testMap.ID = 0;
+testMap.editMap = true;
+testMap.width = 6;
+testMap.height = 5;
+testMap.tiles = constructTiles(6, 5);
+testMap.name = 'Testmap';
+testMap.walls = 5;
+
+setTimeout("reloadMap();", 500);
+setTimeout("start();", 500);
+function start() {
+ //$('#testMapDisplay').html(mapAsHTML(testMap));
+
+ $(window).mousedown(function(){
+ mouseIsDown = true;
+
+ });
+
+ $(window).mouseup(function(){
+ mouseIsDown = false;
+ });
+
+}
+
+var mouseIsDown = false;
+
+var mapHasChanged = false;
+function mapEditOver(obj) {
+ if (mouseIsDown == true) mapEditClick(obj);
+}
+function mapEditClick(obj) {
+
+ console.log("Map Click");
+ tmp = obj.id.split(',');
+ mapid = tmp[0] - 0;
+ //hack hacky hack.
+ y = tmp[1] - 1;
+ x = tmp[2];
+
+ testMap.tiles[y][x] = Array(palleteType, palleteValue);
+ y++;
+ $(obj).attr('class', 'mapcell '+palleteType+palleteValue);
+ mapHasChanged = true;
+}
+
+getMapTimer();
+function getMapTimer() {
+ setTimeout("getMapTimer()", 3000);
+ if (mapHasChanged) {
+ loadPlayableMap();
+ mapHasChanged = false;
+ }
+}
+
+
+var palleteType = 's';
+var palleteValue = '';
+function paletteSelect(type, value) {
+ palleteValue = value;
+ palleteType = type;
+}
+
+function plusWalls() {
+ testMap.walls = testMap.walls - 0 + 1;
+ reloadMap();
+}
+function minusWalls() {
+ testMap.walls = testMap.walls - 1;
+ reloadMap();
+}
+function plusWidth() {
+ changeDimensions(testMap.width - 0 + 1, testMap.height)
+}
+function minusWidth() {
+ changeDimensions(testMap.width - 1, testMap.height)
+}
+function plusHeight() {
+ changeDimensions(testMap.width, testMap.height - 0 + 1)
+}
+function minusHeight() {
+ changeDimensions(testMap.width, testMap.height - 1)
+}
+
+function changeDimensions(width, height) {
+
+ testMap.tiles = constructTiles(width, height, testMap);
+ //testMap.tiles[0][3] = Array('s');
+ //testMap.tiles[4][3] = Array('f');
+ testMap.width = width;
+ testMap.height = height;
+ console.log('rl');
+ reloadMap();
+}
+
+var playableMap;
+function reloadMap() {
+ $('#testMapDisplay').html(mapAsHTML(testMap, 590, true));
+ //Duplicate object
+ var returnedMap = jQuery.extend(true, {}, testMap);
+
+ loadPlayableMap();
+}
+
+var isLoadingMap = false;
+function loadPlayableMap() {
+
+ if (isLoadingMap == true) return;
+ isLoadingMap = true;
+
+ var URLString = 'mapeditor?mapByMap='+JSON.stringify(testMap);
+ $.ajax({
+ type: "GET",
+ url: URLString,
+ cache: true,
+ data: '',
+ fail: function() { alert("error"); },
+ complete: function(data) {
+ playableMap = decryptJSON(data.responseText);
+ playableMap.editMap = false;
+ playableMap.ID = -1;
+ $('#playableMapDisplay').html(mapAsHTML(playableMap, 960));
+ $('#playableMapCodeDisplay').val(playableMap.code);
+ isLoadingMap = false;
+ }
+ });
+}
+
+function loadMap(by) {
+
+ var URLString = '';
+ var mapID = 0;
+ if (by == 'ID') {
+ mapID = $('#mapID').val();
+ URLString = 'a/map/'+mapID+'.js';
+ } else if (by == 'code') {
+ mapCode = $('#mapCode').val();
+ URLString = 'mapeditor?mapByCode='+mapCode;
+ }
+ $.ajax({
+ type: "GET",
+ url: URLString,
+ cache: true,
+ data: '',
+ fail: function() { alert("error"); },
+ complete: function(data) {
+ var map = decryptJSON(data.responseText);
+ testMap = map;
+ testMap.ID = 0;
+ testMap.editMap = true;
+ reloadMap();
+ }
+ });
+}
+
+function constructTiles(width, height, baseMap) {
+ console.log('construct start');
+ var tiles = new Array;
+ for (var y = 0; y < height; y++) {
+ tiles[y] = new Array;
+ for (var x = 0; x < width; x++) {
+ tiles[y][x] = new Array;
+ if (typeof(baseMap) !== 'undefined' &&
+ typeof(baseMap.tiles[y]) !== 'undefined' &&
+ typeof(baseMap.tiles[y][x]) !== 'undefined'
+ ) tiles[y][x] = baseMap.tiles[y][x];
+ else tiles[y][x][0] = 'o';
+ }
+ }
+ console.log('construct done');
+ return tiles;
+}
+
+</script>
+
+<div class='wrapper'>
+
+<h3>Map Editor Beta</h3>
+
+
+ <div class='wrapper'>
+ <form>
+ <fieldset>
+ <legend>Load Map:</legend>
+ <div class='plusMinus'>
+ Load map by ID:<input id='mapID' size="5" type="text" value="" class="forminput"/>
+ <input type="button" value="Load" class="forminput" onclick='loadMap("ID")'/>
+ </div>
+
+ <div class='plusMinus' style='width:300px;'>
+ Load map by code:<input id='mapCode' size="30" type="text" value="" class="forminput"/>
+ <input type="button" value="Load" class="forminput" onclick='loadMap("code")'/>
+ </div>
+
+ </fieldset>
+
+ </form>
+ </div>
+
+ <form><div>
+ <div class='' id='' style='float:left; width:340px;height:350px;'>
+
+ <fieldset style='width:300px'>
+ <legend>Settings:</legend>
+ <div class='plusMinus'>
+ Height:<input type="button" value="+" class="forminput" onclick='plusHeight()'/>
+ <input type="button" value="-" class="forminput" onclick='minusHeight()'/>
+ </div>
+ <div class='plusMinus'>
+ <span style='width:70px;'>Width:</span><input type="button" value="+" class="forminput" onclick='plusWidth()'/>
+ <input type="button" value="-" class="forminput" onclick='minusWidth()'/>
+ </div>
+ <div class='plusMinus'>
+ <span style='width:70px;'>Walls:</span><input type="button" value="+" class="forminput" onclick='plusWalls()'/>
+ <input type="button" value="-" class="forminput" onclick='minusWalls()'/>
+ </div>
+
+ <div style='clear:both'></div>
+
+ <?PHP
+ $tilesArray = array(
+ 's', 's2', 'f', 'w',
+ 'space',
+ 'r', 'r2', 'o', 'q', 'x', 'x2',
+ 'space',
+ 'c', 'c2', 'c3', 'c4', 'c5',
+ 'space',
+ 't', 't2', 't3', 't4', 't5',
+ 'space',
+ 'u', 'u2', 'u3', 'u4', 'u5'
+ );
+
+ foreach($tilesArray as $key) {
+ if ($key == 'space') {
+ echo '<div style="clear:both"></div>';
+ continue;
+ }
+
+ echo "
+ <div class='tileDisplay map'>
+ <div class='$key' onclick=\"paletteSelect('$key[0]', '$key[1]')\"></div>
+ </div>";
+ }
+
+ ?>
+
+ </fieldset>
+ </div>
+ <fieldset style='width:590px'>
+ <legend>Edit Map:</legend>
+ <div id='testMapDisplay' style='float:left;'>
+ Loading...
+ </div>
+ </fieldset>
+ </div></form>
+ <div style='clear:both;'></div>
+
+ <div class="divide"><strong>Playable Map</strong></div>
+ <div style='clear:both;'></div>
+ <div class='wrapper'>
+ MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/>
+ </div>
+ <div id='playableMapDisplay' style='float:left;'>
+ Returned map goes here.
+ </div>
+ <div style='clear:both;'></div>
+</div>
+
+<?php
+htmlFooter();
+?> \ No newline at end of file
diff --git a/pages/massemail.php b/pages/massemail.php
index 4bbd26b..d2634ef 100644
--- a/pages/massemail.php
+++ b/pages/massemail.php
@@ -77,7 +77,7 @@ if ($_POST['queueMassEmail'] == 'true') {
exit;
}
-include_once('./includes/sqli.php');
+include_once('./includes/sqlEmbedded.php');
$res = mysqli_query($mysqli, "SELECT count(*) as count FROM `emailQueue`");
$row = mysqli_fetch_assoc($res);
diff --git a/pages/scores.php b/pages/scores.php
index f3ce459..90c87bb 100644
--- a/pages/scores.php
+++ b/pages/scores.php
@@ -1,6 +1,6 @@
<?php
htmlHeader(
- array('stats', 'challenge'), 'Scores',
+ array('stats'), 'Scores',
'Score history for Pathery',
array('scores', 'dateformat')
);
@@ -15,13 +15,13 @@ if (isset($_GET['date'])) {
} else $dateLookup = $dateDisplay;
-$dateNextDay = date('Y-m-d', strtotime("+1 day", $dateAgo));
-
-//!! TODO:
-$timeUntilNewDailyMap = strtotime("tomorrow") - strtotime("now");
+$jsYear = date("Y");
+//The part where you face palm...
+$jsMonth = date("n") - 1;
+$jsDay = date("j");
+$jsDate = "$jsYear,$jsMonth,$jsDay";
?>
-
<script type="text/javascript" src="js/jquery.keystrokes.min.js"></script>
<script type="text/javascript">
@@ -30,18 +30,12 @@ playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
</script>
<script>
+var startOfPathery = new Date(2011,2,13);
-
-var tomorrow = new Date();
-tomorrow.setTime(tomorrow.getTime() + <? echo $timeUntilNewDailyMap; ?> * 1000);
-var serverTomorrow = '<? echo $dateNextDay; ?>';
-
-var serverTime = new Date();
-serverTime.setTime(<? echo time() * 1000; ?>);
+var serverToday = new Date(<? echo $jsDate; ?>);
var pointerTime = new Date();
-pointerTime.setTime(serverTime.getTime())
-
+pointerTime.setTime(serverToday.getTime())
setTimeout("start();", 500);
@@ -55,12 +49,28 @@ function start() {
if (typeof(hashParts[1]) !== 'undefined') {
pointerMapID = hashParts[1];
}
+ if (typeof(hashParts[2]) !== 'undefined' && hashParts[2]-0 > 0) {
+ pointerPage = hashParts[2];
+ } else pointerPage = 1;
+ if (typeof(hashParts[3]) !== 'undefined') {
+ pointerUserID = hashParts[3];
+ }
//+1 because i'm gonna use prev.
pointerTime = new Date(dateSplit[0],dateSplit[1]-1,dateSplit[2]-0+1);
}
getMapIDs('prev');
}
-//$(window).on('hashchange', function() {
+
+function addDay(dateObj) {
+ var d = dateObj;
+ d.setDate(d.getDate()+1);
+ return d;
+}
+function minusDay(dateObj) {
+ var d = dateObj;
+ d.setDate(d.getDate()-1);
+ return d;
+}
//Contra
$(document).bind('keystrokes', {
@@ -80,47 +90,80 @@ function displayMapScores(mapID) {
$('#scoreDisplay').empty();
newDiv.prependTo('#scoreDisplay');
}
- scoresShowPage(1, mapID);
+
+ //Set the 'selectedMap' class
+ $('.selectedMap').removeClass('selectedMap');
+ var currentMapDiv = $('#thumb_'+mapID).children();
+ currentMapDiv.addClass('selectedMap');
+
+ //Hack: display the "current map" div for currently running maps
+ //Relies on the fact that the #thumb_<mapId> div has a single child with the 'current' class..
+ var showCurrentMapMessage = currentMapDiv.hasClass('currentlyRunning');
+ $('#currentlyRunningMessage').toggle(showCurrentMapMessage);
+
$("#mapDisplay").fadeOut('fast');
- displayMap(mapID, "mapDisplay", 622);
+ displayMap(mapID, "mapDisplay", 682);
+ scoresShowPage(pointerPage, mapID);
+ //console.log(pointerPage, mapID);
}
-
function updateHash() {
var tmp = document.location + '';
tmp = tmp.split("#");
var anchorTag = tmp[0]+'#'+pointerDate;
anchorTag += "_"+pointerMapID;
+ if (pointerPage) anchorTag += "_"+pointerPage;
+ else anchorTag += "_";
+ if (pointerUserID) anchorTag += "_"+pointerUserID;
+ else anchorTag += "_";
document.location=anchorTag;
}
+var pointerPage = 1, pointerUserID
+function saveScoreLocation(page, userID) {
+ pointerPage = page;
+ pointerUserID = userID;
+ updateHash();
+ console.log("SaveScoreLoc");
+}
+
var pointerDate;
function getMapIDs(request) {
switch (request) {
case "next":
- if (pointerTime.getTime() + (24*60*60*1000) < serverTime.getTime()) {
- pointerTime.setTime(pointerTime.getTime() + (24*60*60*1000));
+ if (pointerTime.getTime() < serverToday.getTime()) {
+ addDay(pointerTime);
pointerDate = pointerTime.format("yyyy-mm-dd");
} else return;
break;
case "prev":
- if (pointerTime.getTime() + (24*60*60*1000) > 1) {
- pointerTime.setTime(pointerTime.getTime() - (24*60*60*1000));
+ if (pointerTime.getTime() > startOfPathery.getTime()) {
+ minusDay(pointerTime);
pointerDate = pointerTime.format("yyyy-mm-dd");
} else return;
break;
}
- $('#displayDate').html(pointerTime.format("dddd, mmmm dS, yyyy"));
- if (pointerTime.getTime() + (1*24*60*60*1000) > serverTime.getTime()) {
+ var timeDisplayPrefix = '';
+ if (pointerTime.getTime() >= serverToday.getTime()) {
$('#mapNavRight').removeClass('mapNavActive');
$('#mapNavRight').addClass('mapNavDisabled');
+ timeDisplayPrefix = '<i title="(Server Time)">Today </i>';
} else {
$('#mapNavRight').addClass('mapNavActive');
$('#mapNavRight').removeClass('mapNavDisabled');
}
+ if (pointerTime.getTime() <= startOfPathery.getTime()) {
+ $('#mapNavLeft').removeClass('mapNavActive');
+ $('#mapNavLeft').addClass('mapNavDisabled');
+ timeDisplayPrefix = '<i title="The start!">Pathery Started </i>';
+ } else {
+ $('#mapNavLeft').addClass('mapNavActive');
+ $('#mapNavLeft').removeClass('mapNavDisabled');
+ }
+ $('#displayDate').html(timeDisplayPrefix+pointerTime.format("dddd, mmmm dS, yyyy"));
- var urlString = "ajax/scores.ajax.php?getmapidsbydate="+pointerDate;
+ var urlString = "a/mapsbydate/"+pointerDate+'.js';
updateHash();
$.ajax({
type: "GET",
@@ -152,15 +195,18 @@ function getMapIDsResponse(response) {
//Add non-existing maps
//console.log("going through json", json);
+ var lastMapID = 0;
$.each(json, function(key, mapID) {
//console.log("add: compare:", mapID, mapsInNav);
if (jQuery.inArray(mapID, mapsInNav) == -1) {
addMapToNav(mapID);
- if (goToPointer == true && pointerMapID < 0) {
- pointerMapID = mapID;
- }
+ lastMapID = mapID;
}
});
+ if (goToPointer == true && pointerMapID < 0) {
+ pointerMapID = lastMapID;
+ }
+
//Don't queue animations...
if ($('#mapNavigation').is(':animated')) {
$("#mapNavigation").show(0);
@@ -176,12 +222,9 @@ function addMapToNav(mapID) {
//console.log("adding map to nav:", mapID);
var $newdiv1 = $("<div style='float:left;min-width:120px;' id='thumb_"+mapID+"'/>");
- //$("#mapNavigation").append($newdiv1);
$("#mapNavigation").prepend($newdiv1);
-
- //var URLString = 'map/'+mapID+'.js';
- var URLString = 'map/'+mapID;
-
+
+ var URLString = 'a/map/'+mapID+'.js';
$.ajax({
type: "GET",
url: URLString,
@@ -189,70 +232,43 @@ function addMapToNav(mapID) {
data: '',
fail: function() { alert("error"); },
complete: function(data) {
- $("#thumb_"+mapID).html(mapThumbnailHTML(decryptJSON(data.responseText), 120)).show();
+ var map = decryptJSON(data.responseText);
+ var mapDate = new Date(map.dateExpires*1000);
+ isActive = mapDate.getTime() > serverToday.getTime();
+
+
+ $("#thumb_"+mapID).html(formatMapThumbForNav(data.responseText)).show();
+ //$("#thumb_"+mapID).html(mapThumbnailHTML(map, 120, isActive)).show();
}
});
mapsInNav.unshift(mapID);
}
-function removeMapFromNav(mapID) {
- //console.log("remove map:", mapID, mapsInNav.indexOf(mapID));
- $("#thumb_"+mapID).hide('fast', function(){ $("#thumb_"+mapID).remove(); });
-}
-
-var Tile = {"Wall" : "w",
-"Empty" : "o",
-"Start" : "o",
-"Finish" : "o",
-"Checkpoint" : "o",
-"TileRock" : "o",
-"TeleportIn" : "o",
-"TeleportOut" : "o",
-"Unbuildable" : "o",
-"SinglePath" : "o"};
-
-function mapThumbnailHTML(map, targetWidth) {
- if (!targetWidth) targetWidth = 120;
- var scale = map.width / targetWidth;
-
- var width = parseInt(map.width / scale);
- var height = parseInt(map.height / scale);
- var tileWidth = parseInt(width / map.width);
-
- width = tileWidth * map.width;
- height = tileWidth * map.height;
-
- var mapgrid = '';
-
+function formatMapThumbForNav(json) {
+ var map = decryptJSON(json);
+ var mapDate = new Date(map.dateExpires*1000);
var mapClass = '';
var toolTip = 'Inactive map';
- var mapDate = new Date(map.dateExpires*1000);
- if (mapDate.getTime() > serverTime.getTime()) {
- mapClass = ' current';
+
+ var isCurrentlyRunning = mapDate.getTime() > serverToday.getTime();
+
+ if (isCurrentlyRunning) {
+ mapClass = ' currentlyRunning';
toolTip = 'This map can still be played.';
}
-
+
var r = '';
r += "<div class='mapThumbnail"+mapClass+"' title='"+toolTip+"'; onclick='displayMapScores("+map.ID+")'>";
- r += map.name;
-
- mapgrid += '<div class="map" style="width:'+width+'px; height:'+height+'px">';
- for (var y in map.tiles) {
- for (var x in map.tiles[y]) {
- var type = map.tiles[y][x][0];
- var value = map.tiles[y][x][1];
- if (!value) value = '';
-
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"'>";
- mapgrid += "</div>";
- }
- }
- mapgrid += '</div>';
-
- r += mapgrid;
+ r += mapThumbnailHTML(map, 120, isActive);
r += '</div>';
return r;
+
+}
+
+function removeMapFromNav(mapID) {
+ //console.log("remove map:", mapID, mapsInNav.indexOf(mapID));
+ $("#thumb_"+mapID).hide('fast', function(){ $("#thumb_"+mapID).remove(); });
}
</script>
@@ -265,22 +281,22 @@ topbar($Links);
<div class="wrapper">
- <div style='font-size: 105%;text-align:center;padding-bottom:7px;' id='displayDate'>
+ <div id='displayDate'>
Loading...
</div>
<div class='mapNavCon'>
- <div id='mapNavLeft' class='mapNavLeft mapNavActive' onclick='javascript:getMapIDs("prev");'>&lt;</div>
- <div id='mapNavRight' class='mapNavRight mapNavActive' onclick='javascript:getMapIDs("next");'>&gt;</div>
+ <a id='mapNavLeft' class='mapNavLeft mapNavActive unselectable' href='javascript:getMapIDs("prev");'>&lt;</a>
+ <a id='mapNavRight' class='mapNavRight mapNavActive unselectable' href='javascript:getMapIDs("next");'>&gt;</a>
<div class='mapNavCenter'>
<div id='mapNavigation'></div>
</div>
</div>
-
+ <div id="currentlyRunningMessage"><span>This map hasn't completed yet, so points/solutions are not available</span></div>
<div style='clear:both'></div>
<div>
- <div id='scoreDisplay' style="float:left;"></div>
- <div id='mapDisplay' style='display:none; float:left;' class="col2"></div>
+ <div class='scoreCol' id='scoreDisplay'></div>
+ <div class="mapCol" id='mapDisplay' style='display:none; float:left;'></div>
</div>
diff --git a/pages/share.php b/pages/share.php
index 098c281..3c72c11 100644
--- a/pages/share.php
+++ b/pages/share.php
@@ -6,10 +6,12 @@ htmlHeader(array('stats'));
<body>
<?php
+echo soundManager2();
topbar($Links);
include('./includes/maps.php');
+include('./includes/mapclass.php');
@@ -18,18 +20,28 @@ if (is_int($_GET['mapid'] + 0))
$mapcode = getMapCode($mapID);
//New code:
-if ($_GET['mapcode'])
- $mapcode = $_GET['mapcode'];
+if ($_GET['mapcode']) $mapcode = $_GET['mapcode'];
-$map = GenerateMapByCode($mapcode);
+//$map = GenerateMapByCode($mapcode);
+$map = new map($mapcode);
+$map->ID = 0;
+
+echo "<div class='wrapper'>";
+echo "<script>";
+echo "document.write(mapAsHTML(";
+echo json_encode($map);
+echo "))";
+echo "</script>";
+echo "</div>";
//echo DisplayMap($map, 1, 'example', 1);
-echo DisplayMap($map, 1);
+//echo DisplayMap($map, 1);
?>
+
<script>
loadSol('1:<? echo $_GET[solution]; ?>');
</script>