View wrappedResource.js
1 2 3 4 5 6 7 8 9 10
var wrappedResourceMethods = [
'get', 'query'
];
 
var wrappedResource = function (resource) {
_.each(wrappedResourceMethods, function (method) {
if (_.has(resource, method)) {
var originalMethod = resource[method];
resource[method] = function () {
var result = originalMethod.apply(this, arguments);
View terriblecodeexample.js
1 2 3 4 5 6 7 8 9 10
// Copyright 2013 Host Europe Group - All rights reserved.
// The 123-reg mobile site
if (!Object.keys) {
Object.keys = (function () {
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({
toString: null
}).propertyIsEnumerable('toString'),
dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'],
View formvalidator.js
1 2 3 4 5 6 7 8 9 10
(function ($) {
 
/**
* Override console in this scope so we can squash errors.
*/
var con = window.console;
var console = {
log: function () {
con && con.log && con.log(Array.prototype.slice.call(arguments));
},
View simpleeditable.js
1 2 3 4 5 6 7 8 9 10
$(document).on("click", ".edit_trigger", function () {
var $trigger = $(this);
 
// Find linked editable
var editableID = $trigger.data("editable");
var $editable = $("#" + editableID);
 
// Replace editable with input.
var $input = $("<input>").val($editable.html().trim());
$editable
View models.js
1 2 3 4 5 6 7 8 9 10
var A = function (props) {
this.properties = props;
this.constructor.addModel(this);
};
 
A.models = [];
 
A.addModel = function (model) {
model.properties.id = this.models.length + 1;
this.models.push(model);
View createPoller.js
1 2 3 4 5 6 7 8 9 10
var createPoller = function (pollFunc, interval) {
var timeout;
 
var poll = function () {
pollFunc();
timeout = setTimeout(poll, interval);
};
 
return {
start: function () {
View createClass js
1 2 3 4 5 6 7 8 9 10
var createClass = function (methods, staticMethods) {
if (!methods || !methods.hasOwnProperty("init")) {
throw "you must include an init method";
}
var newClass = function () {
this.init();
};
$.extend(newClass.prototype, methods);
$.extend(newClass, staticMethods);
return newClass;
View gist:3913410
1 2 3 4 5 6 7 8 9 10
(function () {
var isObject = function (foo) {
return foo.constructor == Object;
};
 
var mixin = function (a, b) {
for (var property in b) {
if (b.hasOwnProperty(property)) {
if (isObject(b[property])) {
View gist:3913224
1 2 3 4 5 6 7 8 9 10
(withJQuery = function withJQuery() {
// Check for jQuery
if (!window.jQuery) {
return setTimeout(withJQuery, 100);
}
 
var getISODateFor = function (title) {
var selector = ".DtlDetailTbl td:contains('" + title + "') + .ResConfirmValue";
var date = new Date($(selector).text());
return date.toISOString();
Something went wrong with that request. Please try again.