summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/chat.php34
-rw-r--r--pages/home.php2
-rw-r--r--pages/mapeditor.php283
3 files changed, 311 insertions, 8 deletions
diff --git a/pages/chat.php b/pages/chat.php
index 27122d8..f2d2231 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')
@@ -118,6 +121,8 @@ function getChatDone(data) {
items.push('<div class="chatMessage'+strClass+'" id="C_' + chat.ID + '">' + p + '</div>');
newChats = true;
}
+ lastDisplay = chat.displayName
+ lastMessage = chat.message
if (chat.ID > 0) lastID = chat.ID;
});
@@ -130,15 +135,18 @@ function getChatDone(data) {
var atBottom = (elem.scrollTop() >= elem[0].scrollHeight - elem.outerHeight() - 1);
$("#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 (!document.getElementById('chatMute').checked) {
+ soundManager.setVolume('charm', 20);
+ soundManager.setPan('charm', -60)
+ soundManager.setPosition('charm',150);
+ soundManager.play('charm');
+ }
}
}
@@ -150,10 +158,10 @@ function chatReplaceAndEncode(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='top'>$1</a>");
+ 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='top'>/ig, "<a href='redirect?to=$1%23$3' target='top'>");
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%23$3' target='_blank'>");
return chat;
}
@@ -212,6 +220,10 @@ function htmlEncode(value){
}
}
+function setChatMute(value) {
+ savePref('chatMute', value);
+}
+
</script>
<div class='wrapper'>
@@ -223,6 +235,14 @@ 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">
+
+ <?
+ $chatMute = '';
+ if (isset($_COOKIE['pref_chatMute']) && $_COOKIE['pref_chatMute'] == "true") $chatMute = "checked='checked' ";
+ echo "
+ <input title='Mute sound?' onClick='setChatMute(this.checked)' type='checkbox' id='chatMute' class='chatMute' $chatMute/>";
+ ?>
+
<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/mapeditor.php b/pages/mapeditor.php
new file mode 100644
index 0000000..402f2d6
--- /dev/null
+++ b/pages/mapeditor.php
@@ -0,0 +1,283 @@
+<?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
+ $map->getCode();
+ 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);
+function start() {
+ $('#testMapDisplay').html(mapAsHTML(testMap));
+}
+
+
+var grid_clickOverride = true;
+function mapClick(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);
+ loadPlayableMap();
+}
+
+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();
+}
+
+function loadPlayableMap() {
+
+ 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);
+ }
+ });
+}
+
+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"></div>
+ <div style='clear:both;'></div>
+ <div class='wrapper'>
+ <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