scratch – Diff between revs 79 and 80
?pathlinks?
Rev 79 | Rev 80 | |||
---|---|---|---|---|
Line 141... | Line 141... | |||
141 | </script> |
141 | </script> |
|
142 | <!-- Hiss sounds --> |
142 | <!-- Hiss sounds --> |
|
143 | <script> |
143 | <script> |
|
144 | $(document).ready(() => { |
144 | $(document).ready(() => { |
|
145 | // Get the sound cookie. |
145 | // Get the sound cookie. |
|
146 | var play = (Cookies |
146 | const sound = Cookies.get('sound'); |
|
147 | .get('sound') == 'true' |
- | ||
148 | ); |
147 | |
|
149 | // Play the sounds. |
- | ||
150 | if(play) { |
- | ||
151 | if (!createjs.Sound.initializeDefaultPlugins() || |
148 | if (!createjs.Sound.initializeDefaultPlugins() || |
|
152 | createjs.BrowserDetect.isIOS || |
149 | createjs.BrowserDetect.isIOS || |
|
153 | createjs.BrowserDetect.isAndroid || |
150 | createjs.BrowserDetect.isAndroid || |
|
154 | createjs.BrowserDetect.isBlackberry) |
151 | createjs.BrowserDetect.isBlackberry) |
|
155 | return; |
152 | return; |
|
Line 165... | Line 162... | |||
165 | "snd/hisses/hiss_8.mp3", |
162 | "snd/hisses/hiss_8.mp3", |
|
166 | "snd/hisses/hiss_9.mp3", |
163 | "snd/hisses/hiss_9.mp3", |
|
167 | "snd/hisses/hiss_10.mp3", |
164 | "snd/hisses/hiss_10.mp3", |
|
168 | ]; |
165 | ]; |
|
Line -... | Line 166... | |||
- | 166 | |
||
- | 167 | // Play the sounds. |
||
169 | |
168 | if(sound != 'off') { |
|
170 | createjs.Sound.onLoadComplete = |
169 | createjs.Sound.onLoadComplete = |
|
171 | (event) => createjs.Sound.play(event.src); |
170 | (event) => createjs.Sound.play(event.src); |
|
172 | createjs.Sound.addEventListener("fileload", |
171 | createjs.Sound.addEventListener("fileload", |
|
173 | (event) => createjs.Sound.play(event.src)); |
172 | (event) => createjs.Sound.play(event.src)); |
|
Line 176... | Line 175... | |||
176 | ); |
175 | ); |
|
177 | } |
176 | } |
|
Line 178... | Line 177... | |||
178 | |
177 | |
|
179 | // Load the toggle. |
178 | // Load the toggle. |
|
180 | $('#toggle-sound').bootstrapToggle({ |
179 | $('#toggle-sound').bootstrapToggle({ |
|
181 | on: 'Annoy Kitty', |
180 | on: 'Pet Kitty', |
|
182 | off: 'Pat Kitty', |
181 | off: 'Annoy Kitty', |
|
183 | onstyle: "success", |
182 | onstyle: "danger", |
|
- | 183 | offstyle: "success" |
||
- | 184 | }); |
||
- | 185 | $('#toggle-sound') |
||
184 | offstyle: "danger" |
186 | .bootstrapToggle(sound) |
|
- | 187 | .change(() => { |
||
185 | }).change(() => { |
188 | var checked = $('#toggle-sound').is(":checked"); |
|
186 | Cookies.set('sound', |
189 | Cookies.set('sound', |
|
- | 190 | checked ? 'on' : 'off' |
||
187 | !$('#toggle-sound') |
191 | ); |
|
- | 192 | if(checked) { |
||
- | 193 | createjs.Sound.onLoadComplete = |
||
- | 194 | (event) => createjs.Sound.play(event.src); |
||
- | 195 | createjs.Sound.addEventListener("fileload", |
||
- | 196 | (event) => createjs.Sound.play(event.src)); |
||
- | 197 | createjs.Sound.registerSound( |
||
188 | .is(":checked") |
198 | hiss[~~(Math.random() * hiss.length)] |
|
189 | ); |
199 | ); |
|
190 | }) |
- | ||
191 | .prop('checked', !play) |
200 | } |
|
192 | .change() |
201 | }); |
|
193 | }); |
202 | }); |
|
194 | </script> |
203 | </script> |
|
195 | </body> |
204 | </body> |