diff options
author | Case Duckworth | 2015-03-14 11:33:14 -0700 |
---|---|---|
committer | Case Duckworth | 2015-03-14 11:33:14 -0700 |
commit | 4fe237fa977eb7fca100aac29960a21c09107217 (patch) | |
tree | 32d87372b7c258ebb5aac53c2ee2bdb8358b7554 /test/js | |
parent | Change link underline style (diff) | |
download | autocento-4fe237fa977eb7fca100aac29960a21c09107217.tar.gz autocento-4fe237fa977eb7fca100aac29960a21c09107217.zip |
Move test suite into its own folder
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/hylo.js | 21 | ||||
-rw-r--r-- | test/js/lozenge.js | 29 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/js/hylo.js b/test/js/hylo.js new file mode 100644 index 0000000..5a39427 --- /dev/null +++ b/test/js/hylo.js | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * Hyphenator_Loader 1.1.0 - client side hyphenation for webbrowsers | ||
3 | * Copyright (C) 2014 Mathias Nater, Zürich (mathias at mnn dot ch) | ||
4 | * Project and Source hosted on http://code.google.com/p/hyphenator/ | ||
5 | * | ||
6 | * This JavaScript code is free software: you can redistribute | ||
7 | * it and/or modify it under the terms of the GNU Lesser | ||
8 | * General Public License (GNU LGPL) as published by the Free Software | ||
9 | * Foundation, either version 3 of the License, or (at your option) | ||
10 | * any later version. The code is distributed WITHOUT ANY WARRANTY; | ||
11 | * without even the implied warranty of MERCHANTABILITY or FITNESS | ||
12 | * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | ||
13 | * | ||
14 | * As additional permission under GNU GPL version 3 section 7, you | ||
15 | * may distribute non-source (e.g., minimized or compacted) forms of | ||
16 | * that code without the copy of the GNU GPL normally required by | ||
17 | * section 4, provided you include this license notice and a URL | ||
18 | * through which recipients can access the Corresponding Source. | ||
19 | */ | ||
20 | |||
21 | var Hyphenator_Loader=(function(window){'use strict';var languages,config,path,createElem=function(tagname){var r;if(window.document.createElementNS){r=window.document.createElementNS('http://www.w3.org/1999/xhtml',tagname);}else if(window.document.createElement){r=window.document.createElement(tagname);}return r;},checkLangSupport=function(lang,longword){var shadow,computedHeight,bdy=window.document.getElementsByTagName('body')[0];shadow=createElem('div');shadow.style.width='5em';shadow.style.MozHyphens='auto';shadow.style['-webkit-hyphens']='auto';shadow.style['-ms-hyphens']='auto';shadow.style.hyphens='auto';shadow.style.fontSize='12px';shadow.style.lineHeight='12px';shadow.style.visibility='hidden';shadow.lang=lang;shadow.style['-webkit-locale']="'"+lang+"'";shadow.innerHTML=longword;bdy.appendChild(shadow);computedHeight=shadow.offsetHeight;bdy.removeChild(shadow);return(computedHeight>12)?true:false;},loadNrunHyphenator=function(config){var head,script,interval;head=window.document.getElementsByTagName('head').item(0);script=createElem('script');script.src=path;script.type='text/javascript';head.appendChild(script);interval=window.setInterval(function(){if(window.Hyphenator!==undefined){window.clearInterval(interval);Hyphenator.config(config);Hyphenator.run();}},10);},runner=function(){var loadHyphenator=false,r,results={},lang;for(lang in languages){if(languages.hasOwnProperty(lang)){r=checkLangSupport(lang,languages[lang]);results[lang]=r;loadHyphenator=loadHyphenator||!r;}}if(loadHyphenator){loadNrunHyphenator(config);}},runOnContentLoaded=function(window,f){var toplevel,hyphRunForThis={},doFrames=false,contextWindow,documentLoaded,add=window.document.addEventListener?'addEventListener':'attachEvent',rem=window.document.addEventListener?'removeEventListener':'detachEvent',pre=window.document.addEventListener?'':'on',init=function(context){contextWindow=context||window;if(!hyphRunForThis[contextWindow.location.href]&&(!documentLoaded||!!contextWindow.frameElement)){documentLoaded=true;f();hyphRunForThis[contextWindow.location.href]=true;}},doScrollCheck=function(){try{window.document.documentElement.doScroll("left");}catch(error){window.setTimeout(doScrollCheck,1);return;}init(window);},doOnLoad=function(){var i,haveAccess,fl=window.frames.length;if(doFrames&&fl>0){for(i=0;i<fl;i+=1){haveAccess=undefined;try{haveAccess=window.frames[i].document.toString();}catch(e){haveAccess=undefined;}if(!!haveAccess){if(window.frames[i].location.href!=='about:blank'){init(window.frames[i]);}}}contextWindow=window;f();hyphRunForThis[window.location.href]=true;}else{init(window);}},DOMContentLoaded=function(e){if(e.type==='readystatechange'&&window.document.readyState!=='complete'){return;}window.document[rem](pre+e.type,DOMContentLoaded,false);if(!doFrames&&window.frames.length===0){init(window);}};if(window.document.readyState==="complete"||window.document.readyState==="interactive"){window.setTimeout(doOnLoad,1);}else{window.document[add](pre+"DOMContentLoaded",DOMContentLoaded,false);window.document[add](pre+'readystatechange',DOMContentLoaded,false);window[add](pre+'load',doOnLoad,false);toplevel=false;try{toplevel=!window.frameElement;}catch(ignore){}if(window.document.documentElement.doScroll&&toplevel){doScrollCheck();}}};return{init:function(langs,p,configs){languages=langs;path=p;config=configs||{};runOnContentLoaded(window,runner);}};}(window));Hyphenator_Loader.init({"en":"hyphenationalgorithm",},"./Hyphenator.js",{classname:'prose',defaultlanguage:'en',displaytogglebox:true,togglebox:function(){var bdy,myTextNode,text=(Hyphenator.doHyphenation?'-':'~'),myBox=contextWindow.document.getElementById('HyphenatorToggleBox');if(!!myBox){myBox.firstChild.data=text;}else{bdy=contextWindow.document.getElementsByTagName('body')[0];myBox=createElem('div',contextWindow);myBox.setAttribute('id','HyphenatorToggleBox');myBox.setAttribute('class',dontHyphenateClass);myTextNode=contextWindow.document.createTextNode(text);myBox.appendChild(myTextNode);myBox.onclick=Hyphenator.toggleHyphenation;myBox.style.position='absolute';myBox.style.top='0px';myBox.style.right='0px';myBox.style.margin='0';myBox.style.backgroundColor=rgba(0,0,0,255);myBox.style.color=rgba(255,255,255,100);myBox.style.font='6pt Arial';myBox.style.letterSpacing='0.2em';myBox.style.padding='3px';myBox.style.cursor='pointer';myBox.style.WebkitBorderBottomLeftRadius='4px';myBox.style.MozBorderRadiusBottomleft='4px';myBox.style.borderBottomLeftRadius='4px';bdy.appendChild(myBox);}},useCSS3hyphenation:true}); | ||
diff --git a/test/js/lozenge.js b/test/js/lozenge.js new file mode 100644 index 0000000..d600d24 --- /dev/null +++ b/test/js/lozenge.js | |||
@@ -0,0 +1,29 @@ | |||
1 | /* Lozenge.js for Autocento of the breakfast table | ||
2 | * Cause a#lozenge to link to random file in array | ||
3 | * vim: fdm=marker | ||
4 | */ | ||
5 | |||
6 | function _lozenge() { | ||
7 | var lozenge = document.getElementById('lozenge'); | ||
8 | // array with all files {{{ | ||
9 | var files=["100-lines.html", "about-the-author.html", "amber-alert.html", "and.html", "angeltoabraham.html", "apollo11.html", "arspoetica.html", "art.html", "axe.html", "big-dipper.html", "boar.html", "boy_bus.html", "building.html", "call-me-aural-pleasure.html", "cereal.html", "cold-wind.html", "creation-myth.html", "deadman.html", "death-zone.html", "deathstrumpet.html", "dream.html", "early.html", "elegyforanalternateself.html", "epigraph.html", "ex-machina.html", "exasperated.html", "father.html", "feedingtheraven.html", "finding-the-lion.html", "fire.html", "found-typewriter-poem.html", "hands.html", "hard-game.html", "hardware.html", "howithappened.html", "howtoread.html", "hymnal.html", "i-am.html", "i-think-its-you.html", "i-wanted-to-tell-you-something.html", "in-bed.html", "index.html", "initial-conditions.html", "january.html", "joke.html", "lappel-du-vide.html", "largest-asteroid.html", "last-bastion.html", "last-passenger.html", "leaf.html", "leg.html", "likingthings.html", "listen.html", "love-as-god.html", "lovesong.html", "man.html", "moon-drowning.html", "moongone.html", "mountain.html", "movingsideways.html", "music-433.html", "no-nothing.html", "notes.html", "nothing-is-ever-over.html", "onformalpoetry.html", "options.html", "ouroboros_memory.html", "paul.html", "philosophy.html", "phone.html", "planks.html", "plant.html", "poetry-time.html", "prelude.html", "problems.html", "proverbs.html", "punch.html", "purpose-dogs.html", "question.html", "real-writer.html", "reports.html", "riptide_memory.html", "ronaldmcdonald.html", "roughgloves.html", "sapling.html", "seasonal-affective-disorder.html", "sense-of-it.html", "serengeti.html", "shed.html", "shipwright.html", "sixteenth-chapel.html", "snow.html", "something-simple.html", "spittle.html", "squirrel.html", "stagnant.html", "statements-frag.html", "stayed-on-the-bus.html", "stump.html", "swansong-alt.html", "swansong.html", "swear.html", "table_contents.html", "tapestry.html", "telemarketer.html", "the-night-we-met.html", "the-sea_the-beach.html", "theoceanoverflowswithcamels.html", "time-looks-up-to-the-sky.html", "todaniel.html", "toilet.html", "toothpaste.html", "treatise.html", "underwear.html", "wallpaper.html", "weplayedthosegamestoo.html", "when-im-sorry-i.html", "window.html", "words-meaning.html", "worse-looking-over.html", "writing.html", "x-ray.html", "yellow.html"] | ||
10 | // }}} | ||
11 | |||
12 | var index = Math.floor(Math.random() * files.length); | ||
13 | |||
14 | var url = window.location.pathname; | ||
15 | var current = url.substring(url.lastIndexOf('/')+1); | ||
16 | |||
17 | if (current != files[index]) { | ||
18 | lozenge.setAttribute("href", files[index]); | ||
19 | lozenge.setAttribute("title", "Random article"); | ||
20 | } else { | ||
21 | _lozenge() | ||
22 | } | ||
23 | } | ||
24 | |||
25 | window.onload = function () { | ||
26 | _lozenge() | ||
27 | }; | ||
28 | |||
29 | |||