diff --git a/epub/META-INF/container.xml b/epub/META-INF/container.xml new file mode 100644 index 0000000..f17cad9 --- /dev/null +++ b/epub/META-INF/container.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/epub/angry.gif b/epub/angry.gif new file mode 100644 index 0000000..2f2143f Binary files /dev/null and b/epub/angry.gif differ diff --git a/epub/angry2.gif b/epub/angry2.gif new file mode 100644 index 0000000..e06d9f2 Binary files /dev/null and b/epub/angry2.gif differ diff --git a/epub/angry3.gif b/epub/angry3.gif new file mode 100644 index 0000000..eec65f6 Binary files /dev/null and b/epub/angry3.gif differ diff --git a/epub/angry4.gif b/epub/angry4.gif new file mode 100644 index 0000000..464604b Binary files /dev/null and b/epub/angry4.gif differ diff --git a/epub/backbone-min.js b/epub/backbone-min.js new file mode 100644 index 0000000..8ea4b13 --- /dev/null +++ b/epub/backbone-min.js @@ -0,0 +1,2 @@ +(function(t,e){if(typeof define==="function"&&define.amd){define(["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore");e(t,exports,i)}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.2";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events=void 0;return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var $=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend($.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);n.execute(s,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},execute:function(t,e){if(t)t.apply(this,e)},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace(S,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/?]+)"}).replace(A,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t,e){if(e===r.length-1)return t||null;return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var R=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/#.*$/;N.started=false;i.extend(N.prototype,u,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(R,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment();var s=document.documentMode;var n=P.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(O,"/");if(n&&this._wantsHashChange){var a=e.$(''; +// } + + +// //only add scrolling refesh adds +// if (!config.num_ad_scroll_refesh || config.num_ad_scroll_refesh < 2) return + +// //wait for content to load before adjusting window height +// window.setTimeout(function(){ +// //current segment of the page; between 0 and config.num_ad_scroll_refesh - 1 +// var curI = 0 + +// //cache page and window sizes to avoid on scroll DOM reads +// //TODO - update values on resize +// var windowHeight = window.innerHeight +// var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight) + +// d3.select(window).on('scroll.ad-refesh', _.throttle(function(){ +// //calculate current segment of page +// var nextI = Math.floor(scrollY/((pageHeight - windowHeight)/config.num_ad_scroll_refesh)) +// //clamp segment values +// nextI = Math.min(config.num_ad_scroll_refesh - 1, Math.max(0, nextI)) + +// //only update ads if we've moved to different segment +// if (curI == nextI) return +// curI = nextI + +// //assumes we only have one fixed banner add +// var ad = d3.select(ads[0]).style({overflow: 'hidden', height: '90px'}) + +// var randValue = new String(Math.random()).substring(2,11); +// var adStr = new_leader + '&position=leaderboard' + (curI + 1) + '&ord=' + randValue + '">' +// ad.append('div').html(adStr) + +// window.setTimeout(function(){ +// var numIframes = ad.selectAll('iframe').size() +// ad.selectAll('iframe') +// .filter(function(d, i){ return i < numIframes - 1 }) +// .remove() + +// }, 2000) +// }, 500)) + +// }, 2000) + +// })(); + + +//inline ads for mobile and tablet +!(function() { + if (isTerminal) return + var slug = config.bb_slug; + + var ads = d3.selectAll('.bannerad'); + + var sizeStr = innerWidth > 740 ? 'width="728" height="90' : 'width="300" height="250"' + var sizeParm = innerWidth > 740 ? '728x90|1x1' : '300x250' + var sizePos = innerWidth > 740 ? 'leaderboard' : 'box' + + var new_leader = ''; + + d3.select(this) + // .style('display', 'block') + .html(innerHTML) + .style('width', innerWidth > 740 ? '728px' : '300px') + .style('margin', '0px auto') + }) + +})() + + +var tracker = Tracker(config); +//track events +tracker('load', 'initial'); + +// ---------------------------------------------------------------------------- +// Copyright (C) 2015 Bloomberg Finance L.P. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------- END-OF-FILE ---------------------------------- diff --git a/epub/tree.js b/epub/tree.js new file mode 100644 index 0000000..7e5cdfd --- /dev/null +++ b/epub/tree.js @@ -0,0 +1,426 @@ +!(function(){ + + var module = {sel: d3.select('[data-module="tree"]')} + addModule(module) + + module.bot = bot(); + module.sel.append("div.bot").call(module.bot); + + var dialogue = [ + { + "emote": "tree", + "speak": "You are reading a tree right now! Look down there. You’ll see this section of the article organized as a tree. Click the boxes to expand branches for every paragraph, image, and table. Everything you have just read is a branch—even this graphic of a tree. That’s right: This tree contains a tree. Computers are weird." + } + ]; + + module.oninit = function() { + treeMe(module.sel, d3.select("[data-section='2'] .code-content").node()); + module.bot.dialogue(dialogue); + } + + // based on http://bl.ocks.org/mbostock/4339083 + // https://twitter.com/bizweekgraphics/status/608467609416298496 + function treeMe(sel, node) { + + var margin = {top: 20, right: 120, bottom: 20, left: 120}, + width = sel.node().offsetWidth - margin.right - margin.left, + height = 800 - margin.top - margin.bottom; + + var i = 0, + duration = 1000, + nodeSize = 30, + hoverCoef = 5, + root; + + var tree = d3.layout.tree() + .size([height, width]); + + var diagonal = d3.svg.diagonal() + .projection(function(d) { return [d.y, d.x]; }); + + var svg = sel.append("div.svg-container").append("svg") + .attr("width", width + margin.right + margin.left) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + // invisible rect to capture mousemoves + svg.append("rect") + .attr("x", -margin.left) + .attr("y", -margin.top) + .attr("width", width + margin.right + margin.left) + .attr("height", height + margin.top + margin.bottom) + .style("visibility", "hidden") + .style("pointer-events", "all"); + + root = getDomTree(node); + root.x0 = height / 2; + root.y0 = 0; + + // TOO MANY CHILDREN + function truncate(d) { + if (d.children) { + d.children = d.children.slice(0,20); + d.children.forEach(truncate); + } + } + + function collapse(d) { + if (d.children) { + d._children = d.children; + d._children.forEach(collapse); + d.children = null; + } + } + + function findMaxDepth(nodes) { + return _.max(nodes.map(function(node, index) { + return node.children ? findMaxDepth(node.children) : node.depth; + })); + } + + root.children = root.children.slice(48,68); + // truncate(root); + root.children.forEach(collapse); + // collapse(root); + update(root); + + d3.select(self.frameElement).style("height", "800px"); + + function update(source) { + + // Compute the new tree layout. + var nodes = tree.nodes(root).reverse(), + links = tree.links(nodes); + + maxDepth = findMaxDepth(nodes); + + // Normalize for fixed-depth. + nodes.forEach(function(d) { + d.y = maxDepth ? d.depth * (width / maxDepth) : 0; + }); + + // Update the nodes… + var node = svg.selectAll("g.node") + .data(nodes, function(d) { return d.id || (d.id = ++i); }); + + // Enter any new nodes at the parent's previous position. + var nodeEnter = node.enter().append("g") + .classed("node", true) + .classed("child", function(d) { return !d.children; }) + .classed("parent", function(d) { return d.children; }) + .classed("expandable", function(d) { return d._children && d._children.length; }) + .attr("transform", function(d) { return "translate(" + source.x0 + "," + source.y0 + ")"; }) + .on("click", click) + .on("mouseover", mouseover) + .on("mouseout", mouseout); + + nodeEnter.append("rect") + .attr("x", 1e-6) + .attr("y", 1e-6) + .attr("width", 1e-6) + .attr("height", 1e-6); + + nodeEnter.append("text") + .attr("x", function(d) { return d.children || d._children ? -nodeSize/2 : nodeSize/2; }) + .attr("dy", ".35em") + .attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; }) + .text(function(d) { return d.name; }) + .style("fill-opacity", 1e-6) + .style("font-size", function(d) { return nodeSize/2 + "px" }); + + nodeEnter.each(appendIframe); + + // Update classes + node + .classed("child", function(d) { return !d.children; }) + .classed("parent", function(d) { return d.children; }) + .classed("expandable", function(d) { return d._children && d._children.length; }) + + // Transition nodes to their new position. + var nodeUpdate = node.transition() + .duration(duration) + .attr("transform", function(d) { + return "translate(" + d.y + "," + d.x + ")"; + }); + + nodeUpdate.select("rect") + .attr("x", function(d) { return -nodeSize/2; }) + .attr("y", function(d) { return -nodeSize/2; }) + .attr("width", function(d) { return nodeSize; }) + .attr("height", function(d) { return nodeSize; }); + + nodeUpdate.select("text") + .style("fill-opacity", 1) + .attr("x", function(d) { return d.children || d._children ? -nodeSize/2 : nodeSize/2; }) + + node.each(function(d) { + d.iframe + .transition() + .duration(duration) + .style("left", function(d) { return d.y + margin.left + 'px'; }) + .style("top", function(d) { return d.x + margin.top + 'px'; }) + }) + + // Transition exiting nodes to the parent's new position. + var nodeExit = node.exit() + .each(function(d) { d.iframe.remove(); }) + .transition() + .duration(duration) + .attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; }) + .remove(); + + nodeExit.select("rect") + .attr("x", 1e-6) + .attr("y", 1e-6) + .attr("width", 1e-6) + .attr("height", 1e-6); + + nodeExit.select("text") + .style("fill-opacity", 1e-6); + + // Update the links… + var link = svg.selectAll("path.link") + .data(links, function(d) { return d.target.id; }); + + // Enter any new links at the parent's previous position. + link.enter().insert("path", "g") + .attr("class", "link") + .attr("d", function(d) { + var o = {x: d.source.x0, y: d.source.y0}; + return diagonal({source: o, target: o}); + }); + + // Transition links to their new position. + link.transition() + .duration(duration) + .attr("d", function(d) { + var source = {x: d.source.x, y: d.source.y}; + var target = {x: d.target.x, y: d.target.y}; + return diagonal({source: source, target: target}); + }); + + // Transition exiting nodes to the parent's new position. + link.exit().transition() + .duration(duration) + .attr("d", function(d) { + var o = {x: source.x, y: source.y}; + return diagonal({source: o, target: o}); + }) + .remove(); + + // Stash the old positions for transition. + nodes.forEach(function(d) { + d.x0 = d.x; + d.y0 = d.y; + }); + } + + // Toggle children on click. + function click(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(d); + } + + function mouseover(d) { + + d3.select(this).select("rect") + .attr("x", function(d) { return hoverCoef * -nodeSize/2; }) + .attr("y", function(d) { return hoverCoef * -nodeSize/2; }) + .attr("width", function(d) { return hoverCoef * nodeSize; }) + .attr("height", function(d) { return hoverCoef * nodeSize; }); + + d.iframe + .classed("hover", true) + .style("z-index", 3) + .style("border-width", "2px") + .style("transform", function(d) { return "translate(-50%,-50%) scale(" + (hoverCoef * .2) + ")"; }) + .style("-webkit-transform", function(d) { return "translate(-50%,-50%) scale(" + (hoverCoef * .2) + ")"; }) + .style("-moz-transform", function(d) { return "translate(-50%,-50%) scale(" + (hoverCoef * .2) + ")"; }); + } + + function mouseout(d) { + + d3.select(this).select("rect") + .attr("x", function(d) { return -nodeSize/2; }) + .attr("y", function(d) { return -nodeSize/2; }) + .attr("width", function(d) { return nodeSize; }) + .attr("height", function(d) { return nodeSize; }); + + d.iframe + .classed("hover", false) + .style("z-index", 2) + .style("border-width", "10px") + .style("transform", function(d) { return "translate(-50%,-50%) scale(.2)"; }) + .style("-webkit-transform", function(d) { return "translate(-50%,-50%) scale(.2)"; }) + .style("-moz-transform", function(d) { return "translate(-50%,-50%) scale(.2)"; }); + } + + function appendIframe(d) { + d.iframe = sel.select(".svg-container") + .append("div.iframe-container") + .datum(d) + .classed("expandable", function(d) { return d._children && d._children.length; }) + .style("left", function(d) { return d.parent ? d.parent.y0 + margin.left + 'px' : d.x0; }) + .style("top", function(d) { return d.parent ? d.parent.x0 + margin.top + 'px' : d.y0; }); + + d.iframe.append("div.title").text(function(d) { return d.description ? d.description : d.name; }); + + var iframeEl = d.iframe.append("iframe"); + var iframeDocument = iframeEl.node().contentWindow.document; + iframeDocument.open(); + iframeDocument.write(d.ref.innerHTML); + iframeDocument.close(); + } + + function getDomTree(node) { + // from here http://www.w3.org/TR/html4/index/elements.html + // lightly edited, plus new html5 elements and a few relevant svg elements + // (goin' for clarity here, not namespace-spec-conformity...) + var htmlElements = [ + {"name":"a","description":"anchor"}, + {"name":"abbr","description":"abbreviated form"}, + {"name":"acronym","description":"acronym"}, + {"name":"address","description":"information on author"}, + {"name":"applet","description":"Java applet"}, + {"name":"area","description":"image map area"}, + {"name":"article","description":"article"}, + {"name":"aside","description":"aside"}, + {"name":"audio","description":"sound or music"}, + {"name":"b","description":"bold text style"}, + {"name":"base","description":"document base URI"}, + {"name":"basefont","description":"base font size"}, + {"name":"bdi","description":""}, + {"name":"bdo","description":"I18N BiDi over-ride"}, + {"name":"big","description":"large text style"}, + {"name":"blockquote","description":"long quotation"}, + {"name":"body","description":"document body"}, + {"name":"br","description":"forced line break"}, + {"name":"button","description":"push button"}, + {"name":"caption","description":"table caption"}, + {"name":"center","description":"center-aligned"}, + {"name":"cite","description":"citation"}, + {"name":"code","description":"code fragment"}, + {"name":"col","description":"table column"}, + {"name":"colgroup","description":"table column group"}, + {"name":"datalist","description":"datalist input"}, + {"name":"dd","description":"definition description"}, + {"name":"del","description":"deleted text"}, + {"name":"details","description":"details"}, + {"name":"dfn","description":"instance definition"}, + {"name":"dialog","description":"dialog box"}, + {"name":"dir","description":"directory list"}, + {"name":"div","description":"generic block container"}, + {"name":"dl","description":"definition list"}, + {"name":"dt","description":"definition term"}, + {"name":"em","description":"emphasis"}, + {"name":"embed","description":"container for external applications"}, + {"name":"fieldset","description":"form control group"}, + {"name":"figcaption","description":"figure caption"}, + {"name":"figure","description":"figure"}, + {"name":"font","description":"local change to font"}, + {"name":"footer","description":"footer"}, + {"name":"form","description":"interactive form"}, + {"name":"frame","description":"subwindow"}, + {"name":"frameset","description":"window subdivision"}, + {"name":"g","description":"group"}, + {"name":"h1","description":"heading"}, + {"name":"h2","description":"subheading"}, + {"name":"h3","description":"subsubheading"}, + {"name":"h4","description":"subsubsubheading"}, + {"name":"h5","description":"subsubsubsubheading"}, + {"name":"h6","description":"subsubsubsubsubheading"}, + {"name":"head","description":"document head"}, + {"name":"header","description":"header"}, + {"name":"hr","description":"horizontal rule"}, + {"name":"html","description":"document root element"}, + {"name":"i","description":"italic text style"}, + {"name":"iframe","description":"inline subwindow"}, + {"name":"img","description":"Embedded image"}, + {"name":"input","description":"form control"}, + {"name":"ins","description":"inserted text"}, + {"name":"isindex","description":"single line prompt"}, + {"name":"kbd","description":"text to be entered by the user"}, + {"name":"keygen","description":"key-pair generator field"}, + {"name":"label","description":"form field label text"}, + {"name":"legend","description":"fieldset legend"}, + {"name":"li","description":"list item"}, + {"name":"link","description":"a media-independent link"}, + {"name":"main","description":"main content"}, + {"name":"map","description":"client-side image map"}, + {"name":"mark","description":"marked text"}, + {"name":"menu","description":"menu list"}, + {"name":"menuitem ","description":"menu item"}, + {"name":"meta","description":"generic metainformation"}, + {"name":"meter","description":"meter"}, + {"name":"nav","description":"navigation"}, + {"name":"noframes","description":"alternate content container for non frame-based rendering"}, + {"name":"noscript","description":"alternate content container for non script-based rendering"}, + {"name":"object","description":"generic embedded object"}, + {"name":"ol","description":"ordered list"}, + {"name":"optgroup","description":"option group"}, + {"name":"option","description":"selectable choice"}, + {"name":"output","description":"calculation output"}, + {"name":"p","description":"paragraph"}, + {"name":"param","description":"named property value"}, + {"name":"pre","description":"preformatted text"}, + {"name":"progress","description":"progress"}, + {"name":"q","description":"short inline quotation"}, + {"name":"rect","description":"rectangle"}, + {"name":"rp","description":""}, + {"name":"rt","description":"explanation/pronunciation"}, + {"name":"ruby","description":"ruby annotation"}, + {"name":"s","description":"strike-through text style"}, + {"name":"samp","description":"sample program output, scripts, etc."}, + {"name":"script","description":"script statements"}, + {"name":"section","description":"section"}, + {"name":"select","description":"option selector"}, + {"name":"small","description":"small text style"}, + {"name":"source","description":"audio/video source"}, + {"name":"span","description":"generic inline container"}, + {"name":"strike","description":"strike-through text"}, + {"name":"strong","description":"strong emphasis"}, + {"name":"style","description":"style info"}, + {"name":"sub","description":"subscript"}, + {"name":"summary","description":"summary of details"}, + {"name":"sup","description":"superscript"}, + {"name":"svg","description":"scalable vector graphics"}, + {"name":"table","description":"table"}, + {"name":"tbody","description":"table body"}, + {"name":"td","description":"table data cell"}, + {"name":"textarea","description":"multi-line text field"}, + {"name":"tfoot","description":"table footer"}, + {"name":"th","description":"table header cell"}, + {"name":"thead","description":"table header"}, + {"name":"time","description":"date/time"}, + {"name":"title","description":"document title"}, + {"name":"tr","description":"table row"}, + {"name":"track","description":"audio/video track"}, + {"name":"tt","description":"teletype"}, + {"name":"u","description":"underlined text style"}, + {"name":"ul","description":"unordered list"}, + {"name":"var","description":"variable"}, + {"name":"video","description":"video"}, + {"name":"wbr","description":"possible line-break"}]; + + var nodeDescription = _.findWhere(htmlElements, {"name": node.nodeName.toLowerCase()}); + nodeDescription = nodeDescription ? nodeDescription.description : nodeDescription; + + return { + "name": node.nodeName, + "description": nodeDescription, + "ref": node, + "size": (node && node.innerHTML) ? node.innerHTML.length : 0, + "children": Array.prototype.slice.call(node.children).map(getDomTree) + }; + } + + } + +})(); diff --git a/epub/twitter-blk.png b/epub/twitter-blk.png new file mode 100644 index 0000000..c8b3ed1 Binary files /dev/null and b/epub/twitter-blk.png differ diff --git a/epub/underscore-min.js b/epub/underscore-min.js new file mode 100644 index 0000000..f01025b --- /dev/null +++ b/epub/underscore-min.js @@ -0,0 +1,6 @@ +// Underscore.js 1.8.3 +// http://underscorejs.org +// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); +//# sourceMappingURL=underscore-min.map \ No newline at end of file diff --git a/epub/waving.gif b/epub/waving.gif new file mode 100644 index 0000000..5012353 Binary files /dev/null and b/epub/waving.gif differ diff --git a/images/cover.png b/images/cover.png new file mode 100644 index 0000000..04159df Binary files /dev/null and b/images/cover.png differ diff --git a/whatiscode.epub b/whatiscode.epub new file mode 100644 index 0000000..8a497ac Binary files /dev/null and b/whatiscode.epub differ