summaryrefslogtreecommitdiffstats
path: root/js/mapspecs.js
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-02-09 15:37:46 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-02-09 15:37:46 -0800
commitb40457114a6f5796229357555c80dfef74937a40 (patch)
tree21669b29bba7c64a0a030cf50aaabad92cc11a27 /js/mapspecs.js
parent519b360a15bfdeb1aa5cc560281f97def797050a (diff)
downloadpathery-b40457114a6f5796229357555c80dfef74937a40.tar.xz
Code cleanup / deletions.
Diffstat (limited to 'js/mapspecs.js')
-rw-r--r--js/mapspecs.js131
1 files changed, 25 insertions, 106 deletions
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 += " </select>";
return r;
}
-//END METHOD
-
-
-
-
-
-
function savePref(pref, value) {