/*!
 * translater.js v1.0.12
 * Simple translation tools.
 * 
 * Copyright (c) 2018 kenny wong <wowohoo@qq.com>
 * http://jaywcjlove.github.io/translater.js/
 * 
 * Licensed under the MIT license.
 * 
 * This flie is different from its origin.
 */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Translater=e()}}((function(){var e=function(e,t){e=e||{},l("lang")&&(e.lang=l("lang")),e.lang?(localStorage["t-lang"]=e.lang,this.lang_name=e.lang):this.lang_name="default",this.callback=t||function(){},this.langs=function(){for(var e=Array.prototype.concat(u(document),r(document,"IMG"),r(document,"INPUT"),r(document,"BUTTON")),t=[],a=new Object,l=0;l<e.length;l++){a=n(e[l]);var o=Object.getOwnPropertyNames(a);(o.length>=2&&"0"==o[0]||o.length>2)&&t.push(a)}return t}()||[],"default"!==this.lang_name&&this.setLang(e.lang);var a=localStorage["t-lang"];a&&"default"!==a&&this.setLang(a)};function t(e){var t=0,n=[],a=e.outerHTML,l=a.match(/src=\"(.*?)\"/),r=a.match(/alt=\"(.*?)\"/),o=a.match(/title=\"(.*?)\"/),u=a.match(/placeholder=\"(.*?)\"/),g=a.match(/value=\"(.*?)\"/),c=function(n,l,r){var o={},u=new RegExp(r+'.(\\w+).\\".*?\\"',"g"),g=new RegExp(r+"(.*?)="),c=new RegExp(r+'(.*?)=\\"(.*?)\\"');if(o.element=e,o.default=2===n.length?n[1]:"",(n=a.match(u))&&n.length>0)for(t=0;t<n.length;t++)o[n[t].match(g,"$1")[1]]=n[t].match(c,"$1")[2],o.type=l;return o};return l&&n.push(c(l,"src","data-lang-")),r&&n.push(c(r,"alt","data-alt-")),o&&n.push(c(o,"title","data-title-")),u&&n.push(c(u,"placeholder","data-placeholder-")),g&&n.push(c(g,"value","data-value-")),n}function n(e,l){if(l=l||{},e.parentElement&&"TITLE"===e.parentElement.tagName)return function(e){var t={},n=e.nodeValue,a=0;if(t.element=e.parentElement,t["lang-default"]=n.replace(/<!--(.*)-->.*/,""),n&&(n=e.nodeValue.match(/<!--\{\w+\}[\s\S]*?-->/gi)),n&&n.length>0)for(;a<n.length;a++){var l=n[a].match(/\{([^\ ]*)\}/)[0];t["lang-"+(l=l.replace(/\{([^\ ]*)\}/g,"$1"))]=n[a].replace(/<!--\{\w+\}(.*)-->/g,"$1")}return e.parentElement.innerHTML=t["lang-default"],t}(e);if("IMG"===e.tagName&&1===e.nodeType)return t(e);if("INPUT"===e.tagName&&1===e.nodeType)return t(e);if("BUTTON"===e.tagName&&1===e.nodeType)return t(e);var r="lang-default",o=e.nodeValue,u=/^\{\w+\}/;8===e.nodeType&&u.test(o)&&(r="lang-"+((r=o.match(u)[0])?r.replace(/\{([^\ ]*)\}/g,"$1"):""),""!==a(o=o.replace(u,""))&&(l[r]=o)),""===a(o)||l["lang-default"]||(l[r]=o,l.element=e);var g=e.nextSibling;return g&&1!==g.nodeType&&n(g,l),l}function a(e){return""+(null==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"").replace(/[\r\n]+/g,""))}function l(e,t){var n=t||location.search,a={};if(-1!=n.indexOf("?"))for(var l=n.substr(1).split("&"),r=0,o=l.length;r<o;r++){var u=l[r].split("=");a[u[0]]=u[1]&&decodeURIComponent(u[1])}return e?a[e]:a}function r(e,t){for(var n=0,a=[],l=e.getElementsByTagName(t);n<l.length;n++)a.push(l[n]);return a}e.prototype={setLang:function(e,t){var n=t||this.langs,a="";this.lang_name=e;for(var l=0;l<n.length;l++)n[l]["lang-"+e]||n[l][e]?(a="TITLE"===n[l].element.tagName?"innerHTML":"IMG"===n[l].element.tagName||"INPUT"===n[l].element.tagName||"BUTTON"===n[l].element.tagName?n[l].type:"nodeValue",n[l].element[a]=n[l]["lang-"+e]||n[l][e]):this.setLang(e,n[l]);localStorage["t-lang"]=e},getLang:function(){return this.lang_name}};var u=window.NodeFilter?function(e){var t,n,l=[];for(n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,null);t=n.nextNode();)"SCRIPT"!==t.parentElement.tagName&&"STYLE"!==t.parentElement.tagName&&"CODE"!==t.parentElement.tagName&&""!==a(t.nodeValue)&&l.push(t);return l}:function(e){switch(e.nodeType){case 3:return[e];case 1:case 9:var t,n=e.childNodes,l=[];if("SCRIPT"!==e.tagName&&"STYLE"!==e.tagName&&"CODE"!==e.tagName&&""!==a(o.nodeValue)){for(t=0;t<n.length;t++)u(n[t])&&l.push(u(n[t]));return Array.prototype.concat.apply([],l)}}};return e}));