window Class
Extension of 'window' object
Item Index
Methods
Properties
Methods
cancelRequestAnimFrame
()
Polyfill for cancelAnimationFrame on retro browsers
var raf = window.reauestAnimFrame(function() {});
window.cancelRequestAnimFrame(raf);
Returns:
nothing
deserializeURL
-
url
Deserializes a url string, and returns an object containg the keys and values
var url = 'website.com?name=tyler&location=canada';
var obj = window.deserializeURL(url);
// obj ==> { name: 'tyler', location: 'canada' }
Parameters:
-
urlStringA url string
Returns:
Returns an object containing key-value pairs from the arguements in the url
ease
-
t -
c -
b
Easing functions for various usage
var coord = window.ease.sineOut(time, 0, 1);
myDom.style.left = 500 * coord + "px";
Parameters:
-
tNumberThe time value while being eased
-
cNumberThe start value to be eased from
-
bNumberThe destination value to ease
Returns:
Result value
isValidEmail
-
email
Checks if a string represents a properly formatted email address.
var a = 'tyler@KnowRe.com';
var b = 'tyler$KnowRe.com'
var c = window.isValidEmail(a);
var d = window.isValidEmail(b);
// c ==> true
// d ==> false
Parameters:
-
emailStringA string which will be tested to see if it is a properly formatted email adddress.
Returns:
Whether the string was a valid format or not
print
-
level -
msg
Prints messages and associated levels
[Level info]
0: RAW
1: DEBUG(default)
2: INFO
3: WARNING
4: ERROR
print(0, 'Raw message');
// ==> Raw message
print(1, 'Debug message');
// ==> DEBUG/2015-05-07T13:55:35.612Z)
// Debug message
print(2, 'Info message');
// ==> INFO /2015-05-07T13:55:35.612Z)
// Info message
print(3, 'Warning message');
// ==> WARN /2015-05-07T13:55:35.612Z)
// Warning message
print(4, 'Error message');
// ==> ERROR/2015-05-07T13:55:35.612Z)
// Error message
// Setting the printLevel sets a minimum requirement for the levels
printLevel = 3;
print(0, 'Raw message'); // Would not print
print(1, 'Debug message'); // Would not print
print(2, 'Info message'); // Would not print
print(3, 'Warning message'); // Would print
print(4, 'Error message'); // Would print
Parameters:
-
levelNumberThe level of this message.
-
msgStringThe message to be printed.
Returns:
nothing
printPage
()
Calls the regular print window function
Returns:
nothing
requestAnimFrame
()
Polyfill for requestAnimationFrame on retro browsers
window.requestAnimFrame(function() {
console.log('Next frame!');
});
Returns:
nothing
serializeURL
-
obj
Constructs the query string for a url from an object
var obj = { name: 'tyler', location: 'canada' };
var qs = window.serializeURL(obj);
// qs ==> '?name=tyler&location=canada'
Parameters:
-
objObjectAn object containing key-value pairs to be serialized
Returns:
Returns the query string constructed from the object
sprintf
-
format -
vals
Formats strings
var s01 = window.sprintf('Binary: %b', 10);
// s01 ==> 'Binary: 1010'
var s02 = window.sprintf('Unicode: %c', 65);
// s02 ==> 'Unicode: A'
var s03 = window.sprintf('Decimal: %d', 100);
// s03 ==> 'Decimal: 100'
var s04 = window.sprintf('Exponential notation: %e', 123456);
// s04 ==> 'Exponential notation: 1.23456e+5'
var s05 = window.sprintf('Floating point formatting: %10.1f', 65);
// s05 ==> 'Floating point formatting: 65.0'
var s06 = window.sprintf('Octal: %o', 10);
// s06 ==> 'Octal: 12'
var s07 = window.sprintf('String: %s', 'basketball');
// s07 ==> 'String: basketball'
var s08 = window.sprintf('Absolute value: %u', -65);
// s08 ==> 'Absolute value: 65'
var s09 = window.sprintf('Hexadecimal lowercase: %x', 123);
// s09 ==> 'Hexadecimal lowercase: 7b'
var s10 = window.sprintf('Hexadecimal uppercase: %X', 123);
// s10 ==> 'Hexadecimal uppercase: 7B'
// sprintf takes a variable amount of arguments
var s11 = window.sprintf('My name is %s and I am %d', 'tyler', 22);
// s11 ==> 'My name is tyler and I am 22'
Parameters:
-
formatStringA formatted string, containing 0 or more conversion specifications.
-
valsString | NumberA variable amount of arguments which will be inserted into the format string.
Returns:
A formatted string
vsprintf
-
format -
vals
Formats strings. Exactly the same as sprintf except it takes an array of arguments.
var s = sprintf('My name is %s and I am %d', ['tyler', 22]);
// s ==> 'My name is tyler and I am 22'
Parameters:
-
formatStringA formatted string, containing 0 or more conversion specifications.
-
valsArrayAn array containing values that will be inserted into the format string.
Returns:
A formatted string
Properties
printLevel
Number
Represents the minimum level which messages which will be printed
0: RAW
1: DEBUG
2: INFO
3: WARN
4: ERROR
Default: 0
