From b40457114a6f5796229357555c80dfef74937a40 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sat, 9 Feb 2013 15:37:46 -0800 Subject: Code cleanup / deletions. --- do.php | 15 +----- includes/datas.php | 145 +--------------------------------------------------- includes/header.php | 11 ++-- includes/maps.php | 4 +- js/mapspecs.js | 131 +++++++++-------------------------------------- js/scores.js | 3 -- pages/embed.php | 114 +---------------------------------------- pages/home.php | 5 -- pages/tutorial.php | 5 +- 9 files changed, 38 insertions(+), 395 deletions(-) diff --git a/do.php b/do.php index d822541..758ee7d 100644 --- a/do.php +++ b/do.php @@ -104,17 +104,6 @@ if ($_GET['r'] == 'reqScorePage') { die($encoded); } -if ($_GET['r'] == 'getscores') { - $mapID = $_GET['mapid'] + 0; - if (!is_int($mapID)) - return; - $topscores = topScores($mapID, 30); - $json['scores'] = $topscores; - $json['mapid'] = $mapID; - $encoded = json_encode($json); - die($encoded); -} - if ($_GET['r'] == 'getsol') { $mapID = $_GET['mapID'] + 0; //echo "working..."; @@ -289,8 +278,8 @@ if ($_GET['r'] == 'getpath') { $_SESSION['preCompletedTutorial'] = true; $_SESSION['preCompletedTutorialNotified'] = false; } - if ($accepted == false) - die(json_encode($json)); + if ($accepted == false) die(json_encode($json)); + //TODO: Where's $paths coming from? getCompletedChallenges($userID, $mapID, $solution, $moves, $paths); die(json_encode($json)); } diff --git a/includes/datas.php b/includes/datas.php index 3f65466..c64edd6 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -9,69 +9,6 @@ include_once('constants.php'); //require_once('includes/FirePHPCore/FirePHP.class.php'); //FirePHP stuff - TODO: Delete -//Select Stats/Scores. -function topScores($mapid, $top = 5, $bottom = 0) { - $sql = " - SELECT - timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, - users.displayName as display, - solutions.moves as m, - users.ID as ID, - users.displayColor, - users.wallColor, - users.wallEmblem, - solutions.dateModified as cdate - FROM - `users` - JOIN `solutions` - ON users.ID = solutions.userID - WHERE solutions.mapID = '$mapid' - ORDER BY solutions.moves DESC, solutions.dateModified ASC - LIMIT $bottom, $top - "; - $result = mysql_query($sql) or die(mysql_error()); - $utime = date("g:i A (T)"); - $output = ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - //$output .= ""; - $output .= ""; - while (list($diff, $display, $moves, $userID, $displayColor, $wallColor, $wallEmblem, $cdate) = mysql_fetch_row($result)) { - $i++; - - //$cdate = date("g:i A (T)", strtotime($cdate)); - $cdate = relativeTime(strtotime($cdate)); - - $background = '#262631'; - if ($i % 2 == 1) - $background = '#20202a'; - - if ($_SESSION['userID'] == $userID) - $background = '#343c57'; - //$background = '#356'; - - $output .= " $top) - // continue; - // if ($i <= $bottom) - // continue; - // } - if ($wallEmblem == '') - $wallEmblem = 'blank.png'; - - $cdate = $row['cdate']; - $cdate = date("g:i A (T)", strtotime($cdate)); - $row['dateJoined'] = Date("Y-m-d", strtotime($row['dateJoined'])); $row['dateLogin'] = Date("Y-m-d", strtotime($row['dateLogin'])); @@ -834,43 +754,12 @@ function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy $foundUser = true; } - // if is blind map. - // $row['moves'] = '???'; - $output['users'][$i] = $row; - $output['users'][$i]['scoredDate'] = $cdate; $output['users'][$i]['secondsSinceScored'] = $secondsSinceScored; $output['users'][$i]['background'] = $background; - $output['users'][$i]['medal'] = $medal; $output['users'][$i]['isUser'] = $userPosition == $i; - //$output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves"; } // END WHILE - //Need to look this up. - //$output['pageCount'] = ceil(($i / $pageDivide)); - //$output['pageCount'] = 5; - if ($prevPage > 0) { - $navi .= " << "; - $navi .= " < "; - } else { - $navi .= " << "; - $navi .= " <"; - } - for ($x = 1; $x <= $pageCount; $x++) { - if ($x < $pageNumber - 3 OR $x > $pageNumber + 3) - continue; - if ($x == $pageNumber) - $navi .= " $x "; - elseif ($userPage == $x) - $navi .= " $x "; - else - $navi .= " $x "; - } - if ($nextPage <= $pageCount) { - $navi .= " > "; - $navi .= " >> "; - } - return $output; } @@ -962,12 +851,6 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { continue; } - if ($wallEmblem == '') - $wallEmblem = 'blank.png'; - - $cdate = $row['cdate']; - $cdate = date("g:i A (T)", strtotime($cdate)); - $scoredDate = strtotime($row['cdate']); $secondsSinceScored = strtotime("now") - $scoredDate ; @@ -988,16 +871,13 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { $medal = 'gold'; // if is blind map. - if ($isBlindMap AND $myBestMoves < $moves) - $row['moves'] = '???'; + if ($isBlindMap AND $myBestMoves < $moves) $row['moves'] = '???'; $output['users'][$i] = $row; - $output['users'][$i]['scoredDate'] = $cdate; $output['users'][$i]['secondsSinceScored'] = $secondsSinceScored; $output['users'][$i]['background'] = $background; $output['users'][$i]['medal'] = $medal; $output['users'][$i]['isUser'] = $userPosition == $i; - //$output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves"; } // END WHILE if ($foundUser) { @@ -1007,29 +887,6 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { } $output['pageCount'] = ceil(($i / $pageDivide)); - - if ($prevPage > 0) { - $navi .= " << "; - $navi .= " < "; - } else { - $navi .= " << "; - $navi .= " <"; - } - for ($x = 1; $x <= $pageCount; $x++) { - if ($x < $pageNumber - 3 OR $x > $pageNumber + 3) - continue; - if ($x == $pageNumber) - $navi .= " $x "; - elseif ($userPage == $x) - $navi .= " $x "; - else - $navi .= " $x "; - } - if ($nextPage <= $pageCount) { - $navi .= " > "; - $navi .= " >> "; - } - return $output; } diff --git a/includes/header.php b/includes/header.php index 428ccfd..e654cd3 100644 --- a/includes/header.php +++ b/includes/header.php @@ -14,11 +14,9 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a foreach ($css as $c) { echo " \n"; } - if ($desc !== '') - echo " "; + if ($desc !== '') echo " "; - foreach ($scripts as $s) - echo ""; + foreach ($scripts as $s) echo ""; ?> @@ -157,10 +155,11 @@ function topbar($links) { echo '
'; foreach ($links as $key => $value) { - if ($request == $key) + if ($request == $key) { $selected = " selected"; - else + } else { $selected = ""; + } echo "$value"; } diff --git a/includes/maps.php b/includes/maps.php index 9ee6984..efe17b8 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -1,5 +1,6 @@ "; echo "Error in selecting $indexTarget ($x,$y). Replacement stopped on $new[0].
"; - echo "indexTarget = $indextarget
"; + echo "indexTarget = $indexTarget
"; echo "indexReplace = $indexReplace
"; echo "array = "; diff --git a/js/mapspecs.js b/js/mapspecs.js index 4adc3d1..adbf5d8 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -249,6 +249,7 @@ function clearwalls(mapid) { getmapdata(mapid); } +//TODO:An undo button rather than confirm.. function resetwalls(mapid) { answer = confirm("Remove walls and start fresh?"); if (answer) { @@ -464,23 +465,7 @@ function doanimate(x, y, p, c, mapid, pathNumber) { //Outs case 'u': case 'n': case 'h': case 'j': case 'l': - case 'r': - // if (handle.pressed == true) - // break; - //case 'a': case 'b': case 'c': case 'd': case 'e': - - //handle.setAttribute('class', 'grid_td_pressed'); - //handle.classOrigName = 'grid_td_pressed'; - //if (handle.pressed == true) { - - //var currentColor = rgbStringToHex(handle.style.backgroundColor); - //if (currentColor == '') - // break; - //var dulled = '#'+dullColor(currentColor, .6); - //console.log('bgcolor', dulled, currentColor); - //handle.style.backgroundColor = dulled; - //setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+dulled+"';", 865); - + case 'r': if (mapdata[mapid].isMultiPath == false) { handle.style.backgroundColor = '#dddddd'; setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '#dddddd';", 865); @@ -723,7 +708,6 @@ function targetColor(target) { } - function flashelement(eid, times, color, speed) { if (document.getElementById(eid) == undefined) return; if (!color) { @@ -769,82 +753,6 @@ function contains(a, obj) { } -function dullColor(colorAsHex, value) { - var r = hexToR(colorAsHex); - var g = hexToG(colorAsHex); - var b = hexToB(colorAsHex); - - r = r + ((221 - r) * value) - g = g + ((221 - g) * value) - b = b + ((221 - b) * value) - r = parseInt(r); - g = parseInt(g); - b = parseInt(b); - return rgbToHex(r, g, b); -} - -//Color modifications -// Thanks javascripter.net -function rgbToHex(R,G,B) { - return toHex(R)+toHex(G)+toHex(B) - } -function toHex(n) { - n = parseInt(n,10); - if (isNaN(n)) return "00"; - n = Math.max(0,Math.min(n,255)); - return "0123456789ABCDEF".charAt((n-n%16)/16) - + "0123456789ABCDEF".charAt(n%16); -} -function hexToR(h) { - return parseInt((cutHex(h)).substring(0,2),16) - } -function hexToG(h) { - return parseInt((cutHex(h)).substring(2,4),16) - } -function hexToB(h) { - return parseInt((cutHex(h)).substring(4,6),16) - } -function cutHex(h) { - return (h.charAt(0)=="#") ? h.substring(1,7):h - } - -//Thanks stackExchange -function rgbStringToHex(rgbString) { - if (rgbString == '') - return ''; - // var rgbString = "rgb(0, 70, 255)"; // get this in whatever way. - - var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); - // parts now should be ["rgb(0, 70, 255", "0", "70", "255"] - - delete (parts[0]); - for (var i = 1; i <= 3; ++i) { - parts[i] = parseInt(parts[i]).toString(16); - if (parts[i].length == 1) parts[i] = '0' + parts[i]; - } - return hexString ='#'+parts.join('').toUpperCase(); // "#0070FF" -} - -var ignoreMuteChecks = false; -function setMute(value) -{ - if(!ignoreMuteChecks) - { - //Prevent changes to other checkboxes from calling this function: - ignoreMuteChecks = true; - - //Set all other checkboxes - var muteButtons = document.getElementsByClassName("checkbox_mute"); - for(var i=0; i < muteButtons.length; i++) - { - muteButtons[i].checked = value; - } - savePref('mute', value); - - ignoreMuteChecks = false; - } -} - //Shows a solution temporarly function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem) { solution[mapid] = inputSolution; @@ -857,7 +765,7 @@ function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem) setTimeout(animateA, 250); setTimeout(animateB, 450); } -//TODO +//Shows a solution for temporary use, see 'RestoreSolution' function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmblem) { //console.log('showTempSolution', mapid, solution, moves, tempWallColor, tempWallEmblem); @@ -884,14 +792,12 @@ function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmb mapdata[mapid].savedSolution = savedSolution; } - +//Restores a solution after a showTempSolution function restoreSolution(mapid) { showTempSolution(mapid, mapdata[mapid].savedSolution, 0, false, false); } - -//NEW MAP INSERTING METHOD -//Map as object. +//Map as object. If target width is NULL or False, default width is used. function mapAsHTML(map, targetWidth, demo) { console.log("loading MapHTML for ", map); @@ -985,6 +891,26 @@ function mapAsHTML(map, targetWidth, demo) { return r; } +var ignoreMuteChecks = false; +function setMute(value) +{ + if(!ignoreMuteChecks) + { + //Prevent changes to other checkboxes from calling this function: + ignoreMuteChecks = true; + + //Set all other checkboxes + var muteButtons = document.getElementsByClassName("checkbox_mute"); + for(var i=0; i < muteButtons.length; i++) + { + muteButtons[i].checked = value; + } + savePref('mute', value); + + ignoreMuteChecks = false; + } +} + function getMuteOption(mapID) { var selectedSpeed = 2; var r = ''; @@ -1016,13 +942,6 @@ function getSpeedOptions(mapID) { r += " "; return r; } -//END METHOD - - - - - - function savePref(pref, value) { diff --git a/js/scores.js b/js/scores.js index c327fe2..47a37c3 100644 --- a/js/scores.js +++ b/js/scores.js @@ -480,6 +480,3 @@ function membersFormatPage(JO) { p = p+"
RankBadgeNameMovesTime
"; return p; } - - - diff --git a/pages/embed.php b/pages/embed.php index 7d7e615..ba3ca3d 100644 --- a/pages/embed.php +++ b/pages/embed.php @@ -1,113 +1 @@ - - - - - -Normal'; - break; - - case "hard": - case "3": - $maptype = 3; - $hard = 'Complex'; - break; - - case "day": - case "4": - $maptype = 4; - $special = "$special"; - break; - - case "easy": - case "1": - default: - $maptype = 1; - $easy = 'Simple'; -} - -$motd = MapOfTheDay($maptype); -$mapID = $motd['id']; -$map = $motd['map']; -$userID = $_SESSION['userID']; -$date = date("m-d-y"); -//$mergesolution = mergeMapSolution($map, $mysolution); -$topscores = topScores($motd['id'], 30); -$topscorediv = "
\n$topscores\n
"; -$mergesolution = $map; - -?> -
-Easy | "; -echo "Normal | "; -echo "Hard | "; -echo "Special"; - -echo DisplayMap($mergesolution, $mapID); - -$mysolution = getSolution($userID, $mapID); -$solutiondiv .= " - - - - +Service no longer available. \ No newline at end of file diff --git a/pages/home.php b/pages/home.php index f8841b5..cc94068 100644 --- a/pages/home.php +++ b/pages/home.php @@ -196,11 +196,6 @@ function displayMaze($motd, $mapType) { //Gather data for map; $mapID = $motd['id']; $map = $motd['map']; - $width = $map[0][0]; - - //data for the topscores - //$topscores = topScores($motd['id'], 30); - //$topscorediv = "
\n$topscores\n
"; $topscorediv = "
diff --git a/pages/tutorial.php b/pages/tutorial.php index 88095da..10e5372 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -1,8 +1,5 @@ -- cgit v1.2.3