mirror of
https://github.com/gabemart/hipku.git
synced 2025-01-31 02:00:50 +00:00
1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
;var Hipku=function(){function r(e){if(e.indexOf(":")!=-1){return true}else if(e.indexOf(".")!=-1){return false}else{throw new Error("Formatting error in IP Address input."+" "+'Contains neither ":" or "."')}}function i(e,t){var n,r,i,o,u;n=[];u=[];i=16;if(t){r=":";o=8}else{r=".";o=4}e=e.replace(/[\n\ ]/g,"");n=e.split(r);if(n.length<o){if(t){var a=o-n.length;n=s(n,a)}else{throw new Error("Formatting error in IP Address input."+" "+"IPv4 address has fewer than 4 octets.")}}if(t){for(var f=0;f<n.length;f++){u[f]=parseInt(n[f],i)}}else{u=n}return u}function s(e,t){var n,r;n=0;r=e.length;if(e[0]===""){e[0]=n}if(e[r-1]===""){e[r-1]=n}for(var i=0;i<r;i++){if(e[i]===""){e[i]=n;for(var s=0;s<t;s++){e.splice(i,0,n)}}}return e}function o(e,t){var n,r;r=[];if(t){n=256}else{n=16}for(var i=0;i<e.length;i++){var s,o,u;s=e[i];o=e[i]%n;s=s-o;u=s/n;r.push(u);r.push(o)}return r}function u(e,t){var n,r;r=[];n=a(t);for(var i=0;i<e.length;i++){var s;s=n[i];r[i]=s[e[i]]}return r}function a(e){var t;if(e){t=[b,w,b,w,E,b,b,b,b,b,w,b,w,E,b,w]}else{t=[S,x,T,N,C,k,L,A]}return t}function f(e,t){var n,r,i,s,o;n="OCTET";r=l(t,n);i=r[0];s=r[1];for(var u=0;u<e.length;u++){for(var a=0;a<i.length;a++){if(i[a]===n){i[a]=e[u];break}}}i=c(i,s);o=i.join("");return o}function l(e,t){var n,r,i,s,o;n=[];r="\n";i=".";s=" ";o=[r,i,s];if(e){n=[t,t,"and",t,t,r,t,t,t,t,t,t,t,i,r,t,t,t,t,t,i,r]}else{n=["The",t,t,t,r,t,"in the",t,t,i,r,t,t,i,r]}for(var u=1;u<n.length;u++){var a=true;for(var f=0;f<o.length;f++){if(n[u]===o[f]){a=false}}if(n[u-1]===r){a=false}if(a){n.splice(u,0,s);u=u+1}}return[n,o]}function c(e,t){var n=".";e[0]=h(e[0]);for(var r=1;r<e.length;r++){if(e[r]===n){var i;i=true;if(e[r+2]===undefined||e[r+2]===null||e[r+2]===""){i=false}for(var s=0;s<t.length;s++){if(e[r+2]===t[s]){i=false}}if(i){e[r+2]=h(e[r+2])}}}return e}function h(e){e=e.substring(0,1).toUpperCase()+e.substring(1,e.length);return e}function p(e){var t;e=e.toLowerCase();e=e.replace(/\n/g," ");e=e.replace(/[^a-z\ -]/g,"");t=e.split(" ");for(var n=0;n<t.length;n++){if(t[n]===""){t.splice(n,1)}}return t}function d(e){var t,n,r;n=a(false);r=n[0];t=true;for(var i=0;i<e.length;i++){var s=e[i];for(var o=0;o<r.length;o++){if(s===r[o]){t=false;break}}if(t===false){break}}return t}function v(e,t){var n,r,i;n=a(t);r=[];i=0;for(var s=0;s<n.length;s++){var o,u,f;o=[];o=m(n[s],n.length,e,i);u=o[0];f=o[1];i=f;r.push(u)}return r}function m(e,t,n,r){var i=null;for(var s=0;s<e.length;s++){var o,u;o=e[s].split(" ").length;u=n.slice(r,r+o);u=u.join(" ");if(e[s]===u){i=s;r=r+(o-1);break}}r=r+1;if(i===null){if(r>=t){throw new Error("Decoding error: one or more dictionary words"+"missing from input haiku")}else{return m(e,t,n,r)}}else{return[i,r]}}function g(e,t){var n,r;n=[];if(t){r=256}else{r=16}for(var i=0;i<e.length;i=i+2){var s,o,u;s=e[i];o=e[i+1];u=s*r+o;if(t){u=u.toString(16)}n.push(u)}return n}function y(e,t){var n,r;n="";if(t){r=":"}else{r="."}for(var i=0;i<e.length;i++){if(i>0){n+=r}n+=e[i]}return n}var e={};var t=function(e){var t,n,s,a,l;t=r(e);n=i(e,t);s=o(n,t);a=u(s,t);l=f(a,t);return l};var n=function(e){var t,n,r,i,s;t=p(e);n=d(t);r=v(t,n);i=g(r,n);s=y(i,n);return s};e.encode=t;e.decode=n;var b,w,E,S,x,T,N,C,k,L,A;S=["agile","bashful","clever","clumsy","drowsy","fearful","graceful","hungry","lonely","morose","placid","ruthless","silent","thoughtful","vapid","weary"];x=["beige","black","blue","bright","bronze","brown","dark","drab","green","gold","grey","jade","pale","pink","red","white"];T=["ape","bear","crow","dove","frog","goat","hawk","lamb","mouse","newt","owl","pig","rat","snake","toad","wolf"];N=["aches","basks","cries","dives","eats","fights","groans","hunts","jumps","lies","prowls","runs","sleeps","thrives","wakes","yawns"];C=["ancient","barren","blazing","crowded","distant","empty","foggy","fragrant","frozen","moonlit","peaceful","quiet","rugged","serene","sunlit","wind-swept"];k=["canyon","clearing","desert","foothills","forest","grasslands","jungle","meadow","mountains","prairie","river","rockpool","sand-dune","tundra","valley","wetlands"];L=["autumn colors","cherry blossoms","chrysanthemums","crabapple blooms","dry palm fronds","fat horse chestnuts","forget-me-nots","jasmine petals","lotus flowers","ripe blackberries","the maple seeds","the pine needles","tiger lillies","water lillies","willow branches","yellowwood leaves"];A=["blow","crunch","dance","drift","drop","fall","grow","pile","rest","roll","show","spin","stir","sway","turn","twist"];b=["ace","apt","arched","ash","bad","bare","beige","big","black","bland","bleak","blond","blue","blunt","blush","bold","bone","both","bound","brash","brass","brave","brief","brisk","broad","bronze","brushed","burned","calm","ceil","chaste","cheap","chilled","clean","coarse","cold","cool","corn","crass","crazed","cream","crisp","crude","cruel","cursed","cute","daft","damp","dark","dead","deaf","dear","deep","dense","dim","drab","dry","dull","faint","fair","fake","false","famed","far","fast","fat","fierce","fine","firm","flat","flawed","fond","foul","frail","free","fresh","full","fun","glum","good","grave","gray","great","green","grey","grim","gruff","hard","harsh","high","hoarse","hot","huge","hurt","ill","jade","jet","jinxed","keen","kind","lame","lank","large","last","late","lean","lewd","light","limp","live","loath","lone","long","loose","lost","louche","loud","low","lush","mad","male","masked","mean","meek","mild","mint","moist","mute","near","neat","new","nice","nude","numb","odd","old","pained","pale","peach","pear","peeved","pink","piqued","plain","plum","plump","plush","poor","posed","posh","prim","prime","prompt","prone","proud","prune","puce","pure","quaint","quartz","quick","rare","raw","real","red","rich","ripe","rough","rude","rushed","rust","sad","safe","sage","sane","scortched","shaped","sharp","sheared","short","shrewd","shrill","shrunk","shy","sick","skilled","slain","slick","slight","slim","slow","small","smart","smooth","smug","snide","snug","soft","sore","sought","sour","spare","sparse","spent","spoilt","spry","squat","staid","stale","stary","staunch","steep","stiff","strange","straw","stretched","strict","striped","strong","suave","sure","svelte","swank","sweet","swift","tall","tame","tan","tart","taut","teal","terse","thick","thin","tight","tiny","tired","toothed","torn","tough","trim","trussed","twin","used","vague","vain","vast","veiled","vexed","vile","warm","weak","webbed","wrong","wry","young"];w=["ants","apes","asps","balls","barb","barbs","bass","bats","beads","beaks","bears","bees","bells","belts","birds","blades","blobs","blooms","boars","boats","bolts","books","bowls","boys","bream","brides","broods","brooms","brutes","bucks","bulbs","bulls","busks","cakes","calfs","calves","cats","char","chests","choirs","clams","clans","clouds","clowns","cod","coins","colts","cones","cords","cows","crabs","cranes","crows","cults","czars","darts","dates","deer","dholes","dice","discs","does","dogs","doors","dopes","doves","dreams","drones","ducks","dunes","dwarves","eels","eggs","elk","elks","elms","elves","ewes","eyes","faces","facts","fawns","feet","ferns","fish","fists","flames","fleas","flocks","flutes","foals","foes","fools","fowl","frogs","fruits","gangs","gar","geese","gems","germs","ghosts","gnomes","goats","grapes","grooms","grouse","grubs","guards","gulls","hands","hares","hawks","heads","hearts","hens","herbs","hills","hogs","holes","hordes","ide","jars","jays","kids","kings","kites","lads","lakes","lambs","larks","lice","lights","limbs","looms","loons","mares","masks","mice","mimes","minks","mists","mites","mobs","molds","moles","moons","moths","newts","nymphs","orbs","orcs","owls","pearls","pears","peas","perch","pigs","pikes","pines","plains","plants","plums","pools","prawns","prunes","pugs","punks","quail","quails","queens","quills","rafts","rains","rams","rats","rays","ribs","rocks","rooks","ruffs","runes","sands","seals","seas","seeds","serfs","shards","sharks","sheep","shells","ships","shoals","shrews","shrimp","skate","skies","skunks","sloths","slugs","smew","smiles","snails","snakes","snipes","sole","songs","spades","sprats","sprouts","squabs","squads","squares","squid","stars","stoats","stones","storks","strays","suns","swans","swarms","swells","swifts","tars","teams","teeth","terns","thorns","threads","thrones","ticks","toads","tools","trees","tribes","trolls","trout","tunes","tusks","veins","verbs","vines","voles","wasps","waves","wells","whales","whelks","whiffs","winds","wolves","worms","wraiths","wrens","yaks"];E=["aid","arm","awe","axe","bag","bait","bare","bash","bathe","beat","bid","bilk","blame","bleach","bleed","bless","bluff","blur","boast","boost","boot","bore","botch","breed","brew","bribe","brief","brine","broil","browse","bruise","build","burn","burst","call","calm","carve","chafe","chant","charge","chart","cheat","check","cheer","chill","choke","chomp","choose","churn","cite","clamp","clap","clasp","claw","clean","cleanse","clip","cloack","clone","clutch","coax","crack","crave","crunch","cry","cull","cure","curse","cuss","dare","daze","dent","dig","ding","doubt","dowse","drag","drain","drape","draw","dread","dredge","drill","drink","drip","drive","drop","drown","dry","dump","eat","etch","face","fail","fault","fear","feed","feel","fetch","fight","find","fix","flap","flay","flee","fling","flip","float","foil","forge","free","freeze","frisk","gain","glimpse","gnaw","goad","gouge","grab","grasp","graze","grieve","grip","groom","guard","guards","guide","gulp","gush","halt","harm","hate","haul","haunt","have","heal","hear","help","herd","hex","hire","hit","hoist","hound","hug","hurl","irk","jab","jeer","join","jolt","keep","kick","kill","kiss","lash","leash","leave","lift","like","love","lugg","lure","maim","make","mask","meet","melt","mend","miss","mould","move","nab","name","need","oust","paint","paw","pay","peck","peeve","pelt","please","pluck","poach","poll","praise","prick","print","probe","prod","prompt","punch","quash","quell","quote","raid","raise","raze","ride","roast","rouse","rule","scald","scalp","scar","scathe","score","scorn","scour","scuff","sear","see","seek","seize","send","sense","serve","shake","shear","shift","shoot","shun","slap","slay","slice","smack","smash","smell","smite","snare","snatch","sniff","snub","soak","spare","splash","split","spook","spray","squash","squeeze","stab","stain","starve","steal","steer","sting","strike","stun","tag","tame","taste","taunt","teach","tend"];return e}() |