// [mor.js](http://neocotic.com/mor.js) 1.0.2 // (c) 2011 Alasdair Mercer // Freely distributable under the MIT license. // For all details and documentation: // http://neocotic.com/mor.js (function(a){function m(a,b,c){try{var d=a.apply(c||this);if(typeof b==="function")return b(null,d);return d}catch(e){if(typeof b==="function")return b(e);throw e}}function l(a,b,c,d){if(typeof a!=="string"){throw new TypeError("Invalid value type: "+typeof a)}var e=typeof d!=="undefined",f=a.trim().split(b);for(var g=0;g<f.length;g++){f[g]=f[g].split(c);if(e){for(var h=0;h<f[g].length;h++){f[g][h]=f[g][h].split(d).join("")}}}return f}function k(a,b,c,d,e,f){var g=typeof f==="string",h="";for(var i=0;i<a.length;i++){if(g&&i>0)h+=f;switch(a[i]){case b:h+=c;break;case d:h+=e;break}}return h}function j(a){if(typeof a==="string"){a=a.toLowerCase();for(var c=0;c<f.length;c++){if(f[c][0]===a)return f[c]}}return j(b)}function i(){for(var a=arguments.length;a>=0;--a){if(typeof arguments[a]==="function")return arguments[a]}}function h(a,b){a=a.toUpperCase();for(var c=0;c<e.length;c++){if(e[c][b]===a)return e[c]}}var b="classic",c="L",d="S";var e=[["A","SL"],["B","LSSS"],["C","LSLS"],["D","LSS"],["E","S"],["F","SSLS"],["G","LLS"],["H","SSSS"],["I","SS"],["J","SLLL"],["K","LSL"],["L","SLSS"],["M","LL"],["N","LS"],["O","LLL"],["P","SLLS"],["Q","LLSL"],["R","SLS"],["S","SSS"],["T","L"],["U","SSL"],["V","SSSL"],["W","SLL"],["X","LSSL"],["Y","LSLL"],["Z","LLSS"],["0","LLLLL"],["1","SLLLL"],["2","SSLLL"],["3","SSSLL"],["4","SSSSL"],["5","SSSSS"],["6","LSSSS"],["7","LLSSS"],["8","LLLSS"],["9","LLLLS"],[".","SLSLSL"],[",","LLSSLL"],["?","SSLLSS"],["'","SLLLLS"],["!","LSLSLL"],["/","LSSLS"],["(","LSLLS"],[")","LSLLSL"],["&","SLSSS"],[":","LLLSSS"],[";","LSLSLS"],["=","LSSSL"],["+","SLSLS"],["-","LSSSSL"],["_","SSLLSL"],['"',"SLSSLS"],["$","SSSLSSL"],["@","SLLSLS"],["Ä","SLSL"],["Æ","SLSL"],["Ą","SLSL"],["À","SLLSL"],["Å","SLLSL"],["Ç","LSLSS"],["Ĉ","LSLSS"],["Ć","LSLSS"],["Š","LLLL"],["Ð","SSLLS"],["Ś","SSSLSSS"],["È","SLSSL"],["Ł","SLSSL"],["É","SSLSS"],["Đ","SSLSS"],["Ę","SSLSS"],["Ĝ","LLSLS"],["Ĥ","LLLL"],["Ĵ","SLLLS"],["Ź","LLSSLS"],["Ñ","LLSLL"],["Ń","LLSLL"],["Ö","LLLS"],["Ø","LLLS"],["Ó","LLLS"],["Ŝ","SSSLS"],["Þ","SLLSS"],["Ü","SSLL"],["Ŭ","SSLL"],["Ż","LLSSL"]],f=function(){function a(a,b){for(var c=0,d="";c<b;c++)d+=a;return d}return[["classic",["·","-"," ",a(" ",3),a(" ",7)]],["classic-entities",["·","-"," ",a(" ",3),a(" ",7)]],["digital",["1",a("1",3),"0",a("0",3),a("0",7)]],["simple",["0","1","",","," "]]]}(),g=a.morjs;var n={VERSION:"1.0.2",decode:function(a,b){b=i(a,b);return m(function(){switch(typeof a){case"object":break;case"string":a={message:a};break;default:a={};break}var b=j(a.mode)[1],e="",f=l(a.message||"",b[4],b[3],b[2]);if(f){for(var g=0;g<f.length;g++){if(g>0)e+=" ";for(var i=0;i<f[g].length;i++){var m=k(f[g][i],b[0],d,b[1],c);if(m){var n=h(m,1);if(n)e+=n[0]}}}}return e},b,this)},encode:function(a,b){b=i(a,b);return m(function(){switch(typeof a){case"object":break;case"string":a={message:a};break;default:a={};break}var b=j(a.mode)[1],e="",f=l(a.message||"",/\s+/,"");if(f){for(var g=0;g<f.length;g++){if(g>0)e+=b[4];for(var i=0;i<f[g].length;i++){if(i>0)e+=b[3];var m=h(f[g][i],0);if(m)e+=k(m[1],d,b[0],c,b[1],b[2])}}}return e},b,this)},defineChar:function(a,b,c){return m(function(){if(typeof a!=="string"){throw new TypeError("Invalid character type: "+typeof a)}else if(typeof b!=="string"){throw new TypeError("Invalid pattern type: "+typeof b)}if(a.length>1){throw new Error("Invalid character length: "+a.length)}var c=b.trim().toUpperCase();if(!/^[SL]+$/.test(c)){throw new Error("Invalid pattern: "+b)}a=a.toUpperCase();var d=h(a,0);if(d){d[1]=c}else{e.push([a,c])}},c,this)},defineMode:function(a,b,e){return m(function(){if(typeof a!=="string"){throw new TypeError("Invalid name type: "+typeof a)}else if(typeof b!=="object"){throw new TypeError("Invalid characters type: "+typeof b)}if(b.length!==5){throw new Error("Invalid characters length: "+b.length)}for(var e=0,g="";e<b.length;e++){g=b[e];if(typeof g!=="string"){throw new TypeError("Invalid character type at ["+e+"]: "+typeof g)}g=g.toUpperCase();if(g.indexOf(c)!==-1){throw new Error("Invalid character found at ["+e+"]: "+c)}else if(g.indexOf(d)!==-1){throw new Error("Invalid character found at ["+e+"]: "+d)}}a=a.toLowerCase();var h=j(a);if(h){h[1]=b}else{f.push([a,b])}},e,this)},chars:function(a){return m(function(){var a=[];for(var b=0;b<e.length;b++)a.push(e[b]);return a},a,this)},modes:function(a){return m(function(){var a=[];for(var b=0;b<f.length;b++)a.push(f[b]);return a},a,this)},noConflict:function(b){return m(function(){a.morjs=g;return this},b,this)}};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=n}exports.morjs=n}else if(typeof define==="function"&&define.amd){define("morjs",function(){return n})}else{a.morjs=n}})(this)