summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorAdrian Lang <lang@cosmocode.de>2011-08-22 15:25:15 +0200
committerAdrian Lang <lang@cosmocode.de>2011-08-22 15:27:55 +0200
commitcb42e5f1de77ce65441002c0b0b94d5855cab1f0 (patch)
tree250f89facc459f6b6a112b0363375de14ef5863c /lib/scripts
parent10ecffd81cdbfc2eb72dda53c4039701687aae33 (diff)
downloadrpg-cb42e5f1de77ce65441002c0b0b94d5855cab1f0.tar.gz
rpg-cb42e5f1de77ce65441002c0b0b94d5855cab1f0.tar.bz2
Deprecate several helper functions, JSLINT helpers.js
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/compatibility.js172
-rw-r--r--lib/scripts/helpers.js176
2 files changed, 174 insertions, 174 deletions
diff --git a/lib/scripts/compatibility.js b/lib/scripts/compatibility.js
index ddc8823d3..39f703c71 100644
--- a/lib/scripts/compatibility.js
+++ b/lib/scripts/compatibility.js
@@ -1,6 +1,3 @@
-/*jslint sloppy: true */
-/*global dw_index, dw_qsearch, DEPRECATED_WRAP */
-
/**
* Mark a JavaScript function as deprecated
*
@@ -209,4 +206,173 @@ function jsEscape(text){
return text;
}
+/**
+ * Simple function to check if a global var is defined
+ *
+ * @author Kae Verens
+ * @link http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-2835
+ */
+function isset(varname){
+ DEPRECATED("Use `typeof var !== 'undefined'` instead");
+ return(typeof(window[varname])!='undefined');
+}
+
+/**
+ * Checks if property is undefined
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isUndefined (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'undefined'` instead");
+ return (typeof prop == 'undefined');
+}
+
+/**
+ * Checks if property is function
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isFunction (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'function'` instead");
+ return (typeof prop == 'function');
+}
+/**
+ * Checks if property is string
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isString (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'string'` instead");
+ return (typeof prop == 'string');
+}
+
+/**
+ * Checks if property is number
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isNumber (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'number'` instead");
+ return (typeof prop == 'number');
+}
+
+/**
+ * Checks if property is the calculable number
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isNumeric (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'number' && !isNaN(var) && isFinite(var)` instead");
+ return isNumber(prop)&&!isNaN(prop)&&isFinite(prop);
+}
+
+/**
+ * Checks if property is array
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isArray (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `var instanceof Array` instead");
+ return (prop instanceof Array);
+}
+
+/**
+ * Checks if property is regexp
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isRegExp (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `var instanceof RegExp` instead");
+ return (prop instanceof RegExp);
+}
+
+/**
+ * Checks if property is a boolean value
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isBoolean (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'boolean'` instead");
+ return ('boolean' == typeof prop);
+}
+
+/**
+ * Checks if property is a scalar value (value that could be used as the hash key)
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isScalar (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED("Use `typeof var === 'string' || (typeof var === 'number' &&" +
+ " !isNaN(var) && isFinite(var))` instead");
+ return isNumeric(prop)||isString(prop);
+}
+
+/**
+ * Checks if property is empty
+ *
+ * @param {Object} prop value to check
+ * @return {Boolean} true if matched
+ * @scope public
+ * @author Ilya Lebedev <ilya@lebedev.net>
+ */
+function isEmpty (prop /* :Object */) /* :Boolean */ {
+ DEPRECATED();
+ var i;
+ if (isBoolean(prop)) {
+ return false;
+ } else if (isRegExp(prop) && new RegExp("").toString() == prop.toString()) {
+ return true;
+ } else if (isString(prop) || isNumber(prop)) {
+ return !prop;
+ } else if (Boolean(prop) && false != prop) {
+ for (i in prop) {
+ if(prop.hasOwnProperty(i)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+/**
+ * Get the computed style of a node.
+ *
+ * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/
+ * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js
+ */
+function gcs(node){
+ DEPRECATED('Use jQuery(node).style() instead');
+ if(node.currentStyle){
+ return node.currentStyle;
+ }else{
+ return node.ownerDocument.defaultView.getComputedStyle(node, null);
+ }
+}
diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js
index b0f76cdb0..d6f36967d 100644
--- a/lib/scripts/helpers.js
+++ b/lib/scripts/helpers.js
@@ -2,156 +2,6 @@
* Various helper functions
*/
-
-/**
- * Simple function to check if a global var is defined
- *
- * @author Kae Verens
- * @link http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-2835
- */
-function isset(varname){
- return(typeof(window[varname])!='undefined');
-}
-
-/**
- * Checks if property is undefined
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isUndefined (prop /* :Object */) /* :Boolean */ {
- return (typeof prop == 'undefined');
-}
-
-/**
- * Checks if property is function
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isFunction (prop /* :Object */) /* :Boolean */ {
- return (typeof prop == 'function');
-}
-/**
- * Checks if property is string
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isString (prop /* :Object */) /* :Boolean */ {
- return (typeof prop == 'string');
-}
-
-/**
- * Checks if property is number
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isNumber (prop /* :Object */) /* :Boolean */ {
- return (typeof prop == 'number');
-}
-
-/**
- * Checks if property is the calculable number
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isNumeric (prop /* :Object */) /* :Boolean */ {
- return isNumber(prop)&&!isNaN(prop)&&isFinite(prop);
-}
-
-/**
- * Checks if property is array
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isArray (prop /* :Object */) /* :Boolean */ {
- return (prop instanceof Array);
-}
-
-/**
- * Checks if property is regexp
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isRegExp (prop /* :Object */) /* :Boolean */ {
- return (prop instanceof RegExp);
-}
-
-/**
- * Checks if property is a boolean value
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isBoolean (prop /* :Object */) /* :Boolean */ {
- return ('boolean' == typeof prop);
-}
-
-/**
- * Checks if property is a scalar value (value that could be used as the hash key)
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isScalar (prop /* :Object */) /* :Boolean */ {
- return isNumeric(prop)||isString(prop);
-}
-
-/**
- * Checks if property is empty
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isEmpty (prop /* :Object */) /* :Boolean */ {
- if (isBoolean(prop)) return false;
- if (isRegExp(prop) && new RegExp("").toString() == prop.toString()) return true;
- if (isString(prop) || isNumber(prop)) return !prop;
- if (Boolean(prop)&&false != prop) {
- for (var i in prop) if(prop.hasOwnProperty(i)) return false;
- }
- return true;
-}
-
-/**
- * Checks if property is derived from prototype, applies method if it is not exists
- *
- * @param string property name
- * @return bool true if prototyped
- * @access public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-if ('undefined' == typeof Object.hasOwnProperty) {
- Object.prototype.hasOwnProperty = function (prop) {
- return !('undefined' == typeof this[prop] || this.constructor && this.constructor.prototype[prop] && this[prop] === this.constructor.prototype[prop]);
- };
-}
-
/**
* Very simplistic Flash plugin check, probably works for Flash 8 and higher only
*
@@ -163,13 +13,12 @@ function hasFlash(version){
if(navigator.plugins != null && navigator.plugins.length > 0){
ver = navigator.plugins["Shockwave Flash"].description.split(' ')[2].split('.')[0];
}else{
- var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- ver = axo.GetVariable("$version").split(' ')[1].split(',')[0];
+ ver = (new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))
+ .GetVariable("$version").split(' ')[1].split(',')[0];
}
}catch(e){ }
- if(ver >= version) return true;
- return false;
+ return ver >= version;
}
/**
@@ -204,11 +53,11 @@ function substr_replace(str, replace, start, length) {
* @returns functionref
*/
function bind(fnc/*, ... */) {
- var Aps = Array.prototype.slice;
+ var Aps = Array.prototype.slice,
// Store passed arguments in this scope.
// Since arguments is no Array nor has an own slice method,
// we have to apply the slice method from the Array.prototype
- var static_args = Aps.call(arguments, 1);
+ static_args = Aps.call(arguments, 1);
// Return a function evaluating the passed function with the
// given args and optional arguments passed on invocation.
@@ -219,18 +68,3 @@ function bind(fnc/*, ... */) {
static_args.concat(Aps.call(arguments, 0)));
};
}
-
-/**
- * Get the computed style of a node.
- *
- * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/
- * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js
- */
-function gcs(node){
- if(node.currentStyle){
- return node.currentStyle;
- }else{
- return node.ownerDocument.defaultView.getComputedStyle(node, null);
- }
-}
-