Tags

Today, I learned some useful javascript way. Thanks for Damian for his IPhone Speed http://iphonespeedcheck.com

First you can write your script like below to use variable

var $ = function(selector) {
return document.querySelector(selector);
}

var $debug = function(msg)
{
if(window.console) {
window.console.log(msg);
}
else {
alert(msg);
}
}

var $dispatch = function(code, delay) {
return window.setTimeout(code, delay);
}

var $repeat = function(code, delay) {
return window.setInterval(code, delay);
}

var $cancel = function(id) {
window.clearInterval(id);
window.clearTimeout(id);
}

var $create = function(tag) {
return document.createElement(tag);
}

var $createText = function(text) {
return document.createTextNode(text);
}

so you can call the function by
$debug(“Running latency test…”);
you can use jquery to get element using particular css id
$(“#blackOut”).style.left = 0;

Advertisements