Skip to content

Instantly share code, notes, and snippets.

@kangax
Created October 2, 2009 20:16
Show Gist options
  • Save kangax/200075 to your computer and use it in GitHub Desktop.
Save kangax/200075 to your computer and use it in GitHub Desktop.
// Excerpt from http://www.mtv.com/sitewide/scripts/reporting/mtvi_reporting.js
/*Build Date: Fri May 15, 2009 14:20:51*/
try {
var com = typeof com === 'object' ? com : {};
com.mtvi = typeof com.mtvi === 'object' ? com.mtvi : {};
com.mtvi.util = typeof com.mtvi.util === 'object' ? com.mtvi.util : {};
com.mtvi.logger = typeof com.mtvi.logger === 'object' ? com.mtvi.logger : {};
com.mtvi.config = typeof com.mtvi.config === 'object' ? com.mtvi.config : {};
com.mtvi.ads = typeof com.mtvi.ads === 'object' ? com.mtvi.ads : {};
com.mtvi.reporting = typeof com.mtvi.reporting === 'object' ? com.mtvi.reporting : {};
} catch(e) {}
try {
String.prototype.trim = function () {
try {
return this.replace(/^\\s+|\\s+$/g, '');
} catch(e) {}
};
} catch(e) {}
try {
String.prototype.trimAfterStrings = function (strings) {
try {
if (typeof strings == "string") strings = [strings];
for (i = 0; i < strings.length; i++) {
if (this.indexOf(strings[i]) > -1) {
return this.substring(0, this.indexOf(strings[i]) + strings[i].length);
}
}
return this;
} catch(e) {
return this;
}
}
} catch(e) {}
try {
String.prototype.chop = function (n) {
try {
if (isNaN(n)) n = this.length - 1;
return this.substring(0, n);
} catch(e) {}
};
} catch(e) {}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment