Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Re-arranging things in gh-pages

  • Loading branch information...
commit db7f6afb2778dd5fafe7a82c9c56f50944cbec76 1 parent 44954aa
@tristen authored
View
27 README.md
@@ -0,0 +1,27 @@
+##Simple Emphasis
+Simple Emphasis is a stripped down version of the Dynamic Deep-Linking and Highlighting UI, [Emphasis](https://github.com/NYTimes/Emphasis).
+
+### What's Different?
+
+- Only paragraphs are linked.
+- Toggled on by a single <kbd>shift</kbd> key press
+- Paragraphs toggle on and off a unique generated hash
+- A modified UI
+
+### Assumptions
+
+You need to specify what p tags you would like to target. The minified version of the code and source assumes `div.content p` you can edit the source to suit your needs from the line:
+
+ `this.paraSelctors = $('.content p');`
+
+### Dependencies
+
+- jQuery
+
+### Demo
+
+[http://tristen.github.com/simple-emphasis](http://tristen.github.com/simple-emphasis)
+
+
+###Thanks!
+To Michael Donohoe [(@donohoe)](twitter.com/#!/donohoe) and the Nytimes [@timesopen](https://twitter.com/#!/timesopen)
View
0  css/reset.css → demo/css/reset.css
File renamed without changes
View
0  css/style.css → demo/css/style.css
File renamed without changes
View
0  index.html → demo/index.html
File renamed without changes
View
408 simple-emphasis-src.js
@@ -0,0 +1,408 @@
+/* --------------------------------------------------
+
+ Emphasis
+ by Michael Donohoe (@donohoe)
+ https://github.com/NYTimes/Emphasis
+ http://open.blogs.nytimes.com/2011/01/11/emphasis-update-and-source
+
+ - - - - - - - - - -
+
+ Modifications by tristen (@fallsemo)
+ https://github.com/tristen/simple-emphasis
+
+ NOTE * Requires jQuery
+
+ - - - - - - - - - -
+
+ Copyright (C) 2011 The New York Times (http://www.nytimes.com)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ -------------------------------------------------- */
+
+jQuery(function($) {
+
+ var Emphasis = {
+ init: function() {
+ this.config();
+ this.pl = false; // Paragraph List
+ this.p = false; // Paragraph Anchor
+ this.h = false; // Highlighted paragraphs
+ this.vu = false; // Are paragraph links visible or not
+ this.kh = '|';
+
+ this.addCSS();
+ this.readHash();
+
+ $(document).bind('keydown', this.keydown);
+ },
+
+ config: function() {
+ // Eligible Paragraphs
+ // This uses some common markup for plain and simple paragraphs - those that are not empty, no classes.
+ // We use jQuery for its css selector awesomeness, but your needs might be simpler (getElementsByTagName('p') etc.)
+ this.paraSelctors = $('.content p');
+
+ // Class names
+ this.classReady = 'em-ready';
+ this.classActive = 'em-active';
+ this.classInfo = 'em-info';
+ this.classAnchor = 'em-anchor';
+ this.classActiveAnchor = 'em-active-anchor';
+ this.classActiveParagraph = 'active-paragraph';
+ },
+
+ addCSS: function() {
+ // Inject the minimum styles rules required
+ var st = document.createElement('style');
+ st.setAttribute('type', 'text/css');
+ // for validation goodness
+ var stStr = ' span.' + this.classInfo + ' { position: absolute; margin: -1px 0 0 -10px; padding: 0; font-size: 12px; background-color: transparent!important} span.' + this.classInfo + ' a { text-decoration: none; border: 0;} p.' + this.classActiveParagraph + ' { display: block; position: relative; border: 1px solid #CCC; -moz-box-shadow: 0 0 8px rgba(0,0,0,0.25); -webkit-box-shadow: 0 0 8px rgba(0,0,0,0.25); box-shadow: 0 0 8px rgba(0,0,0,0.25); padding: 15px 10px 28px 25px; margin-top: 20px; left: -25px; width: 100%; }' + 'p.' + this.classActiveParagraph + ':hover:after { content: "Link to this paragraph from the url in your browser"; position: absolute; right: 10px; bottom: 5px; font-size: 11px; color: #ccc; }';
+ try {
+ // try the sensible way
+ st.innerHTML = stStr;
+ } catch(e) {
+ // IE's way
+ st.styleSheet.cssText = stStr;
+ }
+ document.getElementsByTagName('head')[0].appendChild(st);
+ },
+
+ readHash: function() {
+ // Read and interpret the URL hash
+ var lh = decodeURI(location.hash),
+ p = false,
+ a, i, findp, findh, hi, key, pos;
+
+ findp = lh.match(/p\[([^[\]]*)\]/);
+ findh = lh.match(/h\[([^[\]]*)\]/);
+
+ p = (findp && findp.length>0) ? findp[1] : false;
+ hi = (findh && findh.length>0) ? findh[1] : false;
+
+ if (hi) {
+ hi = hi.match(/[a-zA-Z]+(,[0-9]+)*/g);
+ for (i = 0; i < hi.length; i++) {
+ a = hi[i].split(',');
+ key = a[0];
+ pos = this.findKey(key).index;
+ }
+ }
+ this.p = p;
+ this.goAnchor(p);
+ this.highlightMatch();
+ },
+
+ keydown: function(e){
+ // Look for shift keypress
+ var self = Emphasis,
+ kc = e.keyCode;
+
+ self.kh = self.kh + kc + '|';
+ if (self.kh.indexOf('|16|')>-1) {
+ self.vu = (self.vu) ? false : true;
+ self.paragraphInfo(self.vu);
+ }
+ setTimeout(function(){ self.kh = '|'; }, 500);
+ },
+
+ paragraphList: function() {
+ // Build a list of Paragrphs, keys, and add meta-data to each Paragraph in DOM, saves list for later re-use
+ if (this.pl && this.pl.list.length > 0) {
+ return this.pl;
+ }
+ var instance = this,
+ list = [],
+ keys = [],
+ c = 0,
+ len = this.paraSelctors.length,
+ p, pr, k;
+
+ for (p=0; p<len; p++) {
+ pr = this.paraSelctors[p];
+ if ((pr.innerText || pr.textContent || '').length>0) {
+ k = instance.createKey(pr);
+ list.push(pr);
+ keys.push(k);
+ pr.setAttribute('data-key', k); // Unique Key
+ pr.setAttribute('data-num', c); // Order
+
+ $(pr).bind('click', function(e) {
+ instance.paragraphClick(e);
+ });
+ c++;
+ }
+ }
+
+ this.pl = { list: list, keys: keys };
+ return this.pl;
+ },
+
+ paragraphClick: function(e) {
+ e.preventDefault();
+ if (!this.vu) { return; }
+
+ var change = false,
+ pr = (e.currentTarget.nodeName === 'P') ? e.currentTarget : false, // Paragraph
+ an = (e.target.nodeName === 'A') ? e.target : false; // Anchor
+
+ if (pr || an) {
+ if (!$(pr).hasClass(this.classActiveParagraph)) {
+ this.updateParagraph(pr);
+ change = true;
+ }
+ }
+ this.updateURLHash(change);
+ },
+
+ paragraphInfo: function(mode) {
+ // Toggle anchor links next to Paragraphs
+ // Add an active link to paragraphs if one exists
+ var hasSpan, pl, len, i, para, key, isActive, spans;
+
+ if (mode) {
+ // If shift is toggled on
+ hasSpan = $('span.' + this.classInfo);
+ if (hasSpan.length === 0) {
+ pl = this.paragraphList();
+ len = pl.list.length;
+ for (i=0; i<len; i++) {
+ para = pl.list[i] || false;
+ if (para) {
+ key = pl.keys[i];
+ isActive = (key === this.p) ? para.className = this.classActiveParagraph : '';
+ para.innerHTML = '<span class="' + this.classInfo + '"><a class="' + this.classAnchor + '" href="#p[' + key + ']" data-key="' + key + '" title="Link to ' + this.ordinal(i+1) + ' paragraph">&para;</a></span>' + para.innerHTML;
+ }
+ }
+ }
+ } else {
+ // If shift is toggled off
+ spans = $('span.' + this.classInfo);
+
+ len = spans.length;
+ // Loop through each and remove all the spans added.
+ for (i=0; i<len; i++) {
+ $(spans[i]).remove();
+ }
+ $(this).removeClass(this.classActive);
+ }
+ },
+
+ updateParagraph: function(pr) {
+ this.p = pr.getAttribute('data-key');
+ $('p.' + this.classActiveParagraph).removeClass(this.classActiveParagraph);
+ $(pr).addClass(this.classActiveParagraph);
+ },
+
+ updateURLHash: function(change) {
+ // Scan the Paragraphs, note selections, highlights and update the URL with the new Hash
+ if (change) {
+ var h = 'h[',
+ paras = $('p.emReady'),
+ pLen = paras.length,
+ p, key, nSent, anchor, hash,s;
+
+ for (p=0; p < pLen; p++) {
+ key = paras[p].getAttribute('data-key');
+ if (nSent!==sLen) {
+ for (s=0; s<sLen; s++) {
+ h += ',' + spans[s].getAttribute('data-num');
+ }
+ }
+ }
+
+ anchor = ((this.p) ? 'p[' + this.p + '],' : '');
+ hash = (anchor + (h.replace('h[,', 'h[') + ']')).replace(',h[]', '');
+ } else {
+ $('p.' + this.classActiveParagraph).removeClass(this.classActiveParagraph);
+ hash = '_';
+ }
+ location.hash = hash;
+ },
+
+ createKey: function(p) {
+ // From a Paragraph, generate a Key
+ var key = '',
+ len = 6,
+ txt = (p.innerText || p.textContent || '').replace(/[^a-z\. ]+/gi, ''),
+ lines, first, last, k, max, i;
+
+ if (txt && txt.length>1) {
+ lines = this.getSentences(txt);
+ if (lines.length>0) {
+ first = this.cleanArray(lines[0].replace(/[\s\s]+/gi, ' ').split(' ')).slice(0, (len/2));
+ last = this.cleanArray(lines[lines.length-1].replace(/[\s\s]+/gi, ' ').split(' ')).slice(0, (len/2));
+ k = first.concat(last);
+
+ max = (k.length>len) ? len : k.length;
+ for (i=0; i<max; i++) {
+ key += k[i].substring(0, 1);
+ }
+ }
+ }
+ return key;
+ },
+
+ findKey: function(key) {
+ // From a list of Keys, locate the Key and corresponding Paragraph
+ var pl = this.paragraphList(),
+ ln = pl.keys.length,
+ ix = false,
+ el = false,
+ i, ls, le;
+
+ for (i=0;i<ln;i++) {
+ if (key===pl.keys[i]) { // Direct Match
+ return { index: i, elm: pl.list[i] };
+ } else { // Look for 1st closest Match
+ if (!ix) {
+ ls = this.lev(key.slice(0, 3), pl.keys[i].slice(0, 3));
+ le = this.lev(key.slice(-3) , pl.keys[i].slice(-3));
+ if ((ls+le)<3) {
+ ix = i;
+ el = pl.list[i];
+ }
+ }
+ }
+ }
+ return { index: ix, elm: el };
+ },
+
+ goAnchor: function(p) {
+ // Move view to top of a given Paragraph
+ if (!p) { return; }
+ var pg = (isNaN(p)) ? this.findKey(p)['elm'] : (this.paragraphList().list[p-1] || false);
+
+ if (pg) {
+ setTimeout(function(){
+ $(window).scrollTop($(pg).offset().top);
+ }, 500);
+ }
+ },
+
+ highlightMatch: function() {
+ var hasSpan, pl, len, i, para, key, isActive;
+
+ hasSpan = $('span.' + this.classInfo);
+ if (hasSpan.length === 0) {
+ pl = this.paragraphList();
+ len = pl.list.length;
+ for (i=0; i<len; i++) {
+ para = pl.list[i] || false;
+ if (para) {
+ key = pl.keys[i];
+ isActive = (key === this.p) ? para.className = this.classActiveParagraph : '';
+ }
+ }
+ }
+ },
+
+ getSentences: function(el) {
+ // Break a Paragraph into Sentences, bearing in mind that the "." is not the definitive way to do so
+ var html = (typeof el === 'string') ? el : el.innerHTML,
+ mrsList = 'Mr,Ms,Mrs,Miss,Msr,Dr,Gov,Pres,Sen,Prof,Gen,Rep,St,Messrs,Col,Sr,Jf,Ph,Sgt,Mgr,Fr,Rev,No,Jr,Snr',
+ topList = 'A,B,C,D,E,F,G,H,I,J,K,L,M,m,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,etc,oz,cf,viz,sc,ca,Ave,St',
+ geoList = 'Calif,Mass,Penn,AK,AL,AR,AS,AZ,CA,CO,CT,DC,DE,FL,FM,GA,GU,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MH,MI,MN,MO,MP,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,PW,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY,AE,AA,AP,NYC,GB,IRL,IE,UK,GB,FR',
+ numList = '0,1,2,3,4,5,6,7,8,9',
+ webList = 'aero,asia,biz,cat,com,coop,edu,gov,info,int,jobs,mil,mobi,museum,name,net,org,pro,tel,travel,xxx',
+ extList = 'www',
+ d = '__DOT__',
+
+ list = (topList + ',' + geoList + ',' + numList + ',' + extList).split(','),
+ len = list.length,
+ i, lines;
+
+ for (i=0;i<len;i++) {
+ html = html.replace(new RegExp((' ' + list[i] + '\\.'), 'g'), (' ' + list[i] + d));
+ }
+
+ list = (mrsList + ',' + numList).split(',');
+ len = list.length;
+ for (i = 0; i < len; i++) {
+ html = html.replace(new RegExp((list[i] + '\\.'), 'g'), (list[i]+d));
+ }
+
+ list = (webList).split(',');
+ len = list.length;
+ for (i=0;i<len;i++) {
+ html = html.replace(new RegExp(('\\.' + list[i]), 'g'), (d+list[i]));
+ }
+
+ lines = this.cleanArray(html.split('. '));
+ return lines;
+ },
+
+ ordinal: function(n) {
+ // http://en.wikipedia.org/wiki/Ordinal_number
+ var sfx = ['th','st','nd','rd'],
+ val = n%100;
+ return n + (sfx[(val-20)%10] || sfx[val] || sfx[0]);
+ },
+
+ lev: function(a, b) {
+ // Get the Levenshtein distance - a measure of difference between two sequences
+ // Based on http://andrew.hedges.name/experiments/levenshtein/levenshtein.js
+ var m = a.length,
+ n = b.length,
+ r = [],
+ c, o, i, j;
+
+ r[0] = [];
+
+ if (m < n) { c = a; a = b; b = c; o = m; m = n; n = o; }
+ for (c = 0; c < n+1; c++) { r[0][c] = c; }
+ for (i = 1; i < m+1; i++) {
+ r[i] = [];
+ r[i][0] = i;
+ for (j=1; j<n+1; j++) {
+ r[i][j] = this.smallest(r[i-1][j]+1, r[i][j-1]+1, r[i-1][j-1]+((a.charAt(i-1)===b.charAt(j-1))? 0 : 1));
+ }
+ }
+ return r[m][n];
+ },
+
+ smallest: function(x,y,z) {
+ // Return the smallest of two values
+ if (x < y && x < z) { return x; }
+ if (y < x && y < z) { return y; }
+ return z;
+ },
+
+ rtrim: function(txt) {
+ // Trim whitespace from right of string
+ return txt.replace(/\s+$/, '');
+ },
+
+ cleanArray: function(a){
+ // Remove empty items from an array
+ var n = [],
+ i;
+ for (i=0; i<a.length; i++){
+ if (a[i] && a[i].replace(/ /g,'').length > 0){ n.push(a[i]); }
+ }
+ return n;
+ }
+
+ };
+
+ $(window).bind('load', function() {
+ Emphasis.init();
+ });
+
+});
View
38 simple-emphasis.min.js
@@ -0,0 +1,38 @@
+/* --------------------------------------------------
+
+ Emphasis
+ by Michael Donohoe (@donohoe)
+ https://github.com/NYTimes/Emphasis
+ http://open.blogs.nytimes.com/2011/01/11/emphasis-update-and-source
+
+ - - - - - - - - - -
+
+ Modifications by tristen (@fallsemo)
+ https://github.com/tristen/simple-emphasis
+
+ NOTE * Requires jQuery
+
+ - - - - - - - - - -
+
+ Copyright (C) 2011 The New York Times (http://www.nytimes.com)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ -------------------------------------------------- */
+ jQuery(function(a){var b={init:function(){this.config(),this.pl=!1,this.p=!1,this.h=!1,this.vu=!1,this.kh="|",this.addCSS(),this.readHash(),a(document).bind("keydown",this.keydown)},config:function(){this.paraSelctors=a(".content p"),this.classReady="em-ready",this.classActive="em-active",this.classInfo="em-info",this.classAnchor="em-anchor",this.classActiveAnchor="em-active-anchor",this.classActiveParagraph="active-paragraph"},addCSS:function(){var a=document.createElement("style");a.setAttribute("type","text/css");var b=" span."+this.classInfo+" { position: absolute; margin: -1px 0 0 -10px; padding: 0; font-size: 12px; background-color: transparent!important} span."+this.classInfo+" a { text-decoration: none; border: 0;} p."+this.classActiveParagraph+" { display: block; position: relative; border: 1px solid #CCC; -moz-box-shadow: 0 0 8px rgba(0,0,0,0.25); -webkit-box-shadow: 0 0 8px rgba(0,0,0,0.25); box-shadow: 0 0 8px rgba(0,0,0,0.25); padding: 15px 10px 28px 25px; margin-top: 20px; left: -25px; width: 100%; }"+"p."+this.classActiveParagraph+':hover:after { content: "Link to this paragraph from the url in your browser"; position: absolute; right: 10px; bottom: 5px; font-size: 11px; color: #ccc; }';try{a.innerHTML=b}catch(c){a.styleSheet.cssText=b}document.getElementsByTagName("head")[0].appendChild(a)},readHash:function(){var a=decodeURI(location.hash),b=!1,c,d,e,f,g,h,i;e=a.match(/p\[([^[\]]*)\]/),f=a.match(/h\[([^[\]]*)\]/),b=e&&e.length>0?e[1]:!1,g=f&&f.length>0?f[1]:!1;if(g){g=g.match(/[a-zA-Z]+(,[0-9]+)*/g);for(d=0;d<g.length;d++)c=g[d].split(","),h=c[0],i=this.findKey(h).index}this.p=b,this.goAnchor(b),this.highlightMatch()},keydown:function(a){var c=b,d=a.keyCode;c.kh=c.kh+d+"|",c.kh.indexOf("|16|")>-1&&(c.vu=c.vu?!1:!0,c.paragraphInfo(c.vu)),setTimeout(function(){c.kh="|"},500)},paragraphList:function(){if(this.pl&&this.pl.list.length>0)return this.pl;var b=this,c=[],d=[],e=0,f=this.paraSelctors.length,g,h,i;for(g=0;g<f;g++)h=this.paraSelctors[g],(h.innerText||h.textContent||"").length>0&&(i=b.createKey(h),c.push(h),d.push(i),h.setAttribute("data-key",i),h.setAttribute("data-num",e),a(h).bind("click",function(a){b.paragraphClick(a)}),e++);this.pl={list:c,keys:d};return this.pl},paragraphClick:function(b){b.preventDefault();if(!!this.vu){var c=!1,d=b.currentTarget.nodeName==="P"?b.currentTarget:!1,e=b.target.nodeName==="A"?b.target:!1;if(d||e)a(d).hasClass(this.classActiveParagraph)||(this.updateParagraph(d),c=!0);this.updateURLHash(c)}},paragraphInfo:function(b){var c,d,e,f,g,h,i,j;if(b){c=a("span."+this.classInfo);if(c.length===0){d=this.paragraphList(),e=d.list.length;for(f=0;f<e;f++)g=d.list[f]||!1,g&&(h=d.keys[f],i=h===this.p?g.className=this.classActiveParagraph:"",g.innerHTML='<span class="'+this.classInfo+'"><a class="'+this.classAnchor+'" href="#p['+h+']" data-key="'+h+'" title="Link to '+this.ordinal(f+1)+' paragraph">&para;</a></span>'+g.innerHTML)}}else{j=a("span."+this.classInfo),e=j.length;for(f=0;f<e;f++)a(j[f]).remove();a(this).removeClass(this.classActive)}},updateParagraph:function(b){this.p=b.getAttribute("data-key"),a("p."+this.classActiveParagraph).removeClass(this.classActiveParagraph),a(b).addClass(this.classActiveParagraph)},updateURLHash:function(b){if(b){var c="h[",d=a("p.emReady"),e=d.length,f,g,h,i,j,k;for(f=0;f<e;f++){g=d[f].getAttribute("data-key");if(h!==sLen)for(k=0;k<sLen;k++)c+=","+spans[k].getAttribute("data-num")}i=this.p?"p["+this.p+"],":"",j=(i+(c.replace("h[,","h[")+"]")).replace(",h[]","")}else a("p."+this.classActiveParagraph).removeClass(this.classActiveParagraph),j="_";location.hash=j},createKey:function(a){var b="",c=6,d=(a.innerText||a.textContent||"").replace(/[^a-z\. ]+/gi,""),e,f,g,h,i,j;if(d&&d.length>1){e=this.getSentences(d);if(e.length>0){f=this.cleanArray(e[0].replace(/[\s\s]+/gi," ").split(" ")).slice(0,c/2),g=this.cleanArray(e[e.length-1].replace(/[\s\s]+/gi," ").split(" ")).slice(0,c/2),h=f.concat(g),i=h.length>c?c:h.length;for(j=0;j<i;j++)b+=h[j].substring(0,1)}}return b},findKey:function(a){var b=this.paragraphList(),c=b.keys.length,d=!1,e=!1,f,g,h;for(f=0;f<c;f++){if(a===b.keys[f])return{index:f,elm:b.list[f]};d||(g=this.lev(a.slice(0,3),b.keys[f].slice(0,3)),h=this.lev(a.slice(-3),b.keys[f].slice(-3)),g+h<3&&(d=f,e=b.list[f]))}return{index:d,elm:e}},goAnchor:function(b){if(!!b){var c=isNaN(b)?this.findKey(b).elm:this.paragraphList().list[b-1]||!1;c&&setTimeout(function(){a(window).scrollTop(a(c).offset().top)},500)}},highlightMatch:function(){var b,c,d,e,f,g,h;b=a("span."+this.classInfo);if(b.length===0){c=this.paragraphList(),d=c.list.length;for(e=0;e<d;e++)f=c.list[e]||!1,f&&(g=c.keys[e],h=g===this.p?f.className=this.classActiveParagraph:"")}},getSentences:function(a){var b=typeof a=="string"?a:a.innerHTML,c="Mr,Ms,Mrs,Miss,Msr,Dr,Gov,Pres,Sen,Prof,Gen,Rep,St,Messrs,Col,Sr,Jf,Ph,Sgt,Mgr,Fr,Rev,No,Jr,Snr",d="A,B,C,D,E,F,G,H,I,J,K,L,M,m,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,etc,oz,cf,viz,sc,ca,Ave,St",e="Calif,Mass,Penn,AK,AL,AR,AS,AZ,CA,CO,CT,DC,DE,FL,FM,GA,GU,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MH,MI,MN,MO,MP,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,PW,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY,AE,AA,AP,NYC,GB,IRL,IE,UK,GB,FR",f="0,1,2,3,4,5,6,7,8,9",g="aero,asia,biz,cat,com,coop,edu,gov,info,int,jobs,mil,mobi,museum,name,net,org,pro,tel,travel,xxx",h="www",i="__DOT__",j=(d+","+e+","+f+","+h).split(","),k=j.length,l,m;for(l=0;l<k;l++)b=b.replace(new RegExp(" "+j[l]+"\\.","g")," "+j[l]+i);j=(c+","+f).split(","),k=j.length;for(l=0;l<k;l++)b=b.replace(new RegExp(j[l]+"\\.","g"),j[l]+i);j=g.split(","),k=j.length;for(l=0;l<k;l++)b=b.replace(new RegExp("\\."+j[l],"g"),i+j[l]);m=this.cleanArray(b.split(". "));return m},ordinal:function(a){var b=["th","st","nd","rd"],c=a%100;return a+(b[(c-20)%10]||b[c]||b[0])},lev:function(a,b){var c=a.length,d=b.length,e=[],f,g,h,i;e[0]=[],c<d&&(f=a,a=b,b=f,g=c,c=d,d=g);for(f=0;f<d+1;f++)e[0][f]=f;for(h=1;h<c+1;h++){e[h]=[],e[h][0]=h;for(i=1;i<d+1;i++)e[h][i]=this.smallest(e[h-1][i]+1,e[h][i-1]+1,e[h-1][i-1]+(a.charAt(h-1)===b.charAt(i-1)?0:1))}return e[c][d]},smallest:function(a,b,c){return a<b&&a<c?a:b<a&&b<c?b:c},rtrim:function(a){return a.replace(/\s+$/,"")},cleanArray:function(a){var b=[],c;for(c=0;c<a.length;c++)a[c]&&a[c].replace(/ /g,"").length>0&&b.push(a[c]);return b}};a(window).bind("load",function(){b.init()})})
Please sign in to comment.
Something went wrong with that request. Please try again.