Core Docs | Additional Modules Docs
@Description: Write debug information to a pop up window
@File: utils/debugWin.js
@Param: String data The data to write
@Param: String backgroundColor The background color to write behind the data message
@Example:sb.debugWin('hello world error', 'red');
@Description: Monitors a url for a sb.utils.monitor header to verify that the connection is avaiable
@File: utils/monitor.js
@Param: object o
o.url String The url of the resource to monitor
o.onConnected Function The call back function that fires when the monitor senses a connection and is provided the header "sb.utils.monitor:1" fromt he url specifed
o.onDisconnected Function The callback function that fires when the monitor senses a disconnection by not being able to reach the file, or when the file sends a header of "sb.utils.monitor:0"
o.interval Integer The number of milliseconds to wait between checks
o.data String the data value pairs passed ot the url being monitored
o.method String get/post The method used when requesting the resource
@Example:var monitor = new sb.utils.monitor({
url : '/some/url',
data : {
sample : 'data'
},
method : 'post',
onConnected : function(){
$('body').style.backgroundColor = 'red';
},
onDisconnected : function(){
$('body').style.backgroundColor = 'green';
},
interval : 100
});
@Description: A constructor to create a timer, which is an event firing timer that repeats on an increment
@File: utils/timer.js
@Param: Object o
handler - the function to fire after the delay
seconds - the number of seconds to wait before firing
milliseconds - the number of milliseconds to wait before firing
@Example://create a new timer
var myTimer = new sb.utils.timer({
//set the number of seconds between intervals - alternatively you can set the number of milliseconds
seconds : 0.01,
//set the function that will fire reapeatedly on interval
handler : function(){
//reference the this.count property of the time to make sure it has fired less than 255 times
if(this.count <255){
//set the document title to the count for debugging
document.title = this.count;
//set the background color of the body to incremement with the count
document.body.style.backgroundColor = 'rgb('+this.count+',2,3)';
} else {
//it has fired 255 times, end the timer
this.end();
}
}
});
//start the timer;
myTimer.begin();
@Description: These properties are avaiable to any sb.utils.timer instance. All sb.utils.timer.prototype examples below assume a timer name myTimer was instantiated previously in the code
@File: utils/timer.js
@Example://creates a timer which changes the document's title to the current date every 2 seconds
var myTimer = new sb.utils.timer({
handler: function(){
document.title = new Date();
},
seconds : 2
});
@Description: begins the repeat event firing based on the interval specified for a sb.utils.timer instance, if an onbegin property was set than it fires on first firing
@File: utils/timer.js
@Example:myTimer.begin();
@Description: ends the repeat event firing, if an onbegin property was set than it fires on first firing
@File: utils/timer.js
@Param: Boolean resetCount Optional argument. If set the timer instance's counter is reset. I would suggest just calling myTimer.reset which ends the timer and resets automatically.
@Example:myTimer.end();
@Description: ends the repeat event firing and resets the count property on a sb.utils.timer instance
@File: utils/timer.js
@Example:myTimer.reset();
@Description: ends the repeat event firing and resets the count property and starts it again for an sb.utils.timer instance.
@File: utils/timer.js
@Example:myTimer.changeInterval({seconds :10});
@Description: ends the repeat event firing and resets the count property and starts the timer again for an sb.utils.timer instance
@File: utils/timer.js
@Example:myTimer.restart();
@Description: Determines the time it takes to run a function in milliseconds
@File: utils/performance.js
@Param: Function func The function to time
@Return: Number The number of milliseconds required to run the function.
@Example:function getImages(){
var images = sb.$('img');
}
var timeItTakes = sb.performace(getImages);