From c1233eee5dc4dc20e15b81e9d808c5f23967fd40 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sun, 10 Mar 2013 01:06:50 -0800 Subject: Mute button for maps. --- css/maps.css | 26 +++++++++++++++++++++++++- js/mapspecs.js | 56 ++++++++++++++++++++++---------------------------------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/css/maps.css b/css/maps.css index 86a2f76..085b273 100644 --- a/css/maps.css +++ b/css/maps.css @@ -200,6 +200,30 @@ +.mapMute { + display:inline-block; + width:17px; + height:17px; + background-size: 100%; + position: relative; + top: 5px; + margin-right: 5px; + border-radius:5px; +} +.mapMute_true { + background-image: url(../images/Mute.png); + background-color: transparent; +} +.mapMute_false { + background-image: url(../images/Sound.png); + background-color: transparent; +} +.mapMute_false:hover { + background-color:#000; +} +.mapMute_true:hover { + background-color:#CC0; +} .grid_dsp_data { @@ -242,7 +266,7 @@ white-space: nowrap; position: relative; float: left; - padding:2px; + padding:0px; color: #FFFFFF; } .grid_dsp_left { diff --git a/js/mapspecs.js b/js/mapspecs.js index 3e649fd..0f9be4a 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -330,12 +330,14 @@ function animatePath(path, mapid, start, pathNumber) { } function animatePathDone(mapid) { - if (typeof(currentPage) == "object") - scoresRequestPage(mapid, currentPage[mapid]); document.getElementById(mapid+',btn').disabled = false; if (isChallenge == true) { challengeGo(mapid); + } + if (typeof(currentPage) == "object") { + scoresRequestPage(mapid, currentPage[mapid]); } + //Mark off challenges //TODO: This hack is stupidd :( if(isChallenge && isTutorial == false) @@ -355,7 +357,7 @@ function animatePathDone(mapid) { } function checkSound(mapid) { - if (document.getElementById(mapid+',mute').checked) { + if (getCookie('pref_mute') == 'true') { return false; } if (typeof(soundManager) != 'object') { @@ -901,22 +903,22 @@ function mapAsHTML(map, targetWidth, mapEditor) { } } } - mapgrid += ''; + mapgrid += '
'; if (mapEditor == true) return mapgrid; var r = ''; //TODO: Track down where that 1 pixel is comingfrom, width-1 is a hack. - r += "
"; + r += "
"; - r += "
"; + r += "
"; r += "
"; r += " MapID: "+map.ID; r += "
"; r += "
"; - r += "
"; + r += "
"; r += " "; r += " "+map.walls+" walls"; r += " "; @@ -928,19 +930,17 @@ function mapAsHTML(map, targetWidth, mapEditor) { r += mapgrid; - r += "
"; + r += "
"; r += " "; r += " Speed:"; r += getSpeedOptions(map.ID); r += "
"; - // stopped here, mute button next - - r += "
"; + r += "
"; r += getMuteOption(map.ID); r += "
"; - r += "
"; + r += "
"; r += "
"; r += " 0 moves"; r += "
"; @@ -981,36 +981,24 @@ function mapThumbnailHTML(map, targetWidth, isActive) { 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; - } + var value = getCookie('pref_mute'); + $('.mapMute').removeClass("mapMute_"+value); + if (value == 'true') value = 'false'; + else value = 'true'; + savePref('mute', value); + $('.mapMute').addClass("mapMute_"+value); + } function getMuteOption(mapID) { - var selectedSpeed = 2; var r = ''; - var checked = ''; + var muted = 'false'; if (getCookie('pref_mute') == 'true') { - checked = "checked='checked' "; + muted = "true"; } - r += ""; + r += ""; return r; } -- cgit v1.2.3