forked from jonoxia/platform-game
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webclient_utils.js
30 lines (28 loc) · 914 Bytes
/
webclient_utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return unescape(results[1]);
}
function playSfx(tagId) {
filename = $("#" + tagId).attr("src");
var snd = new Audio(filename);
snd.play();
}
// shim layer with setTimeout fallback
// Written by Paul Irish
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();