From b0d995392b10b518129ccf98738aecbf19b1fa51 Mon Sep 17 00:00:00 2001 From: yackob03 Date: Thu, 9 Jan 2014 20:22:22 -0500 Subject: [PATCH] Add a polyfill for the bind function. Update the screenshots script to stop worrying about olark and to wait for the logs to animate in. --- screenshots/screenshots.js | 66 ++++++++++++++++++++++---------------- static/js/graphing.js | 27 ++++++++++++++++ 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/screenshots/screenshots.js b/screenshots/screenshots.js index a58666c57..4fa588e02 100644 --- a/screenshots/screenshots.js +++ b/screenshots/screenshots.js @@ -10,20 +10,6 @@ var casper = require('casper').create({ logLevel: "debug" }); -var disableOlark = function() { - casper.then(function() { - this.waitForText('Chat with us!', function() { - this.evaluate(function() { - console.log(olark); - window.olark.configure('box.start_hidden', true); - window.olark('api.box.hide'); - }); - }, function() { - // Do nothing, if olark never loaded we're ok with that - }); - }); -}; - var options = casper.cli.options; var isDebug = !!options['d']; @@ -56,12 +42,18 @@ casper.thenClick('.form-signin button[type=submit]', function() { this.waitForText('Top Repositories'); }); -disableOlark(); +casper.then(function() { + this.log('Generating user home screenshot.'); +}); casper.then(function() { this.capture(outputDir + 'user-home.png'); }); +casper.then(function() { + this.log('Generating repository view screenshot.'); +}); + casper.thenOpen(rootUrl + 'repository/devtable/' + repo + '?tag=v2.0', function() { // Wait for the tree to initialize. this.waitForSelector('.image-tree', function() { @@ -70,12 +62,14 @@ casper.thenOpen(rootUrl + 'repository/devtable/' + repo + '?tag=v2.0', function( }); }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'repo-view.png'); }); +casper.then(function() { + this.log('Generating repository changes screenshot.'); +}); + casper.thenClick('#current-image dd a', function() { this.waitForSelector('.result-count', function() { this.capture(outputDir + 'repo-changes.png', { @@ -87,58 +81,74 @@ casper.thenClick('#current-image dd a', function() { }); }) +casper.then(function() { + this.log('Generating repository admin screenshot.'); +}); + casper.thenOpen(rootUrl + 'repository/devtable/' + repo + '/admin', function() { this.waitForSelector('.repo-access-state'); }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'repo-admin.png'); }); +casper.then(function() { + this.log('Generating organization repo list screenshot.'); +}); + casper.thenOpen(rootUrl + 'repository/?namespace=' + org, function() { this.waitForText('Repositories'); }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'org-repo-list.png'); }); +casper.then(function() { + this.log('Generating organization teams screenshot.'); +}); + casper.thenOpen(rootUrl + 'organization/' + org, function() { this.waitForSelector('.organization-name'); }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'org-teams.png'); }); +casper.then(function() { + this.log('Generating organization admin screenshot.'); +}); + casper.thenOpen(rootUrl + 'organization/' + org + '/admin', function() { this.waitForSelector('#repository-usage-chart'); }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'org-admin.png'); }); +casper.then(function() { + this.log('Generating organization logs screenshot.'); +}); + casper.thenClick('a[data-target="#logs"]', function() { this.waitForSelector('svg > g', function() { - this.capture(outputDir + 'org-logs.png'); + this.wait(1000, function() { + this.capture(outputDir + 'org-logs.png'); + }); }); }); +casper.then(function() { + this.log('Generating oganization repository admin screenshot.'); +}); + casper.thenOpen(rootUrl + 'repository/' + org + '/' + orgrepo + '/admin', function() { this.waitForText('outsideorg') }); -disableOlark(); - casper.then(function() { this.capture(outputDir + 'org-repo-admin.png'); }); diff --git a/static/js/graphing.js b/static/js/graphing.js index fa5816fc6..bfbb7a099 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -1,3 +1,30 @@ +/** + * Bind polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility + */ +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + var DEPTH_HEIGHT = 100; var DEPTH_WIDTH = 132;