// wbbcode.js
-if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode={init:function(){this.opts.initCallback=$.proxy(function(){var e=$.trim(this.getOption("wOriginalValue"));if(e.length){this.toggle();this.$source.val(e);this.toggle()}delete this.opts.wOriginalValue},this);this.opts.pasteBeforeCallback=$.proxy(this._wPasteBeforeCallback,this);this.opts.pasteAfterCallback=$.proxy(this._wPasteAfterCallback,this);this.opts.keydownCallback=$.proxy(this._wKeydownCallback,this);var d=this.syncClean;var b=this;this.syncClean=function(e){e=e.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>");return d.call(b,e)};if(this.getOption("wAutosaveOnce")){this._saveTextToStorage();delete this.opts.wAutosaveOnce}var a=this.buttonGet("table");if(a.length){var c=a.data("dropdown").children("a.redactor_dropdown_add_head");c.prev().remove();c.next().remove();c.remove();a.click($.proxy(this._tableButtonClick,this))}},_tableButtonClick:function(b){var c=$(b.currentTarget);if(!c.hasClass("dropact")){return}var a=this.getBlock()||this.getCurrent();var d=c.data("dropdown");d.children("li").show();var e=d.find("> li > .redactor_dropdown_insert_table").parent();if(a.tagName=="TD"){e.hide().next().hide()}else{e.nextAll().hide()}},insertSmiley:function(a,b,c){if(c){this.registerSmiley(a,b)}if(this.opts.visual){this.bufferSet();this.$editor.focus();this.insertHtml(' <img src="'+b+'" class="smiley" alt="'+a+'" /> ');if(this.opts.air){this.$air.fadeOut(100)}this.sync()}else{this.insertAtCaret(" "+a+" ")}},registerSmiley:function(a,b){if(__REDACTOR_SMILIES[a]){return false}__REDACTOR_SMILIES[a]=b;return true},toggle:function(a){if(this.opts.visual){this.sync(undefined,true);this.toggleCode(a);this._convertFromHtml();this.buttonGet("html").children("i").removeClass("fa-square-o").addClass("fa-square")}else{this._convertToHtml();this.toggleVisual();this._observeQuotes();this.buttonGet("html").children("i").removeClass("fa-square").addClass("fa-square-o")}},_convertFromHtml:function(){var m=this.$source.val();m=m.replace(/\r?\n/g,"");var f=m.split(/(<\/?p>)/);var g="";var x="";for(var a=0;a<f.length;a++){var y=f[a];if(y=="<p>"){continue}else{if(y=="</p>"){x=$.trim(x);if(x!="@@@wcf_empty_line@@@"){x+="\n"}g+=x;x=""}else{if(a==0){g+=y}else{x+=y}}}}m=g;m=m.replace(/@@@wcf_empty_line@@@/g,"\n");m=m.replace(/\n\n$/,"\n");m=m.replace(/<br>$/,"");m=m.replace(/<br>/g,"\n");m=m.replace(/<br>/g,"");m=m.replace(/ /gi," ");m=m.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");m=m.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(B,z,A,C){if(A==C){return"[url]"+A+"[/url]"}return"[url='"+A+"']"+C+"[/url]"});m=m.replace(/<(?:b|strong)>/gi,"[b]");m=m.replace(/<\/(?:b|strong)>/gi,"[/b]");m=m.replace(/<(?:i|em)>/gi,"[i]");m=m.replace(/<\/(?:i|em)>/gi,"[/i]");m=m.replace(/<u>/gi,"[u]");m=m.replace(/<\/u>/gi,"[/u]");m=m.replace(/<(?:s(trike)?|del)>/gi,"[s]");m=m.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");m=m.replace(/<sub>/gi,"[sub]");m=m.replace(/<\/sub>/gi,"[/sub]");m=m.replace(/<sup>/gi,"[sup]");m=m.replace(/<\/sup>/gi,"[/sup]");m=m.replace(/<img [^>]*?alt="([^"]+?)" class="smiley".*?>/gi,"$1");m=m.replace(/<img [^>]*?class="smiley" alt="([^"]+?)".*?>/gi,"$1");m=m.replace(/<img [^>]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)".*?>/gi,"[attach=$1][/attach]");m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi,"[img='$2',$3][/img]");m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");m=m.replace(/<blockquote class="quoteBox" cite="([^"]+)?" data-author="([^"]+)?">/gi,function(z,B,A){if(B){return"[quote='"+A+"','"+B+"']"}else{if(A){return"[quote='"+A+"']"}}return"[quote]"});m=m.replace(/<\/blockquote>/gi,"[/quote]");m=m.replace(/<header data-ignore="true">.*?<\/header>/gi,"");var d=m.split(/(<\/?span[^>]*>)/);var x=[];var p=[];var q="";for(var a=0;a<d.length;a++){var h=d[a];if(h=="</span>"){var c=p.pop();var g=c.start+x.pop()+c.end;if(x.length){x[x.length-1]+=g}else{q+=g}}else{if(h.match(/^<span style="([^"]+)">/)){var k=RegExp.$1;var v;var n;if(k.match(/^color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?$/i)){var u=RegExp.$1;var b=RegExp.$2;var e=RegExp.$3;var s=("0123456789ABCDEF".charAt((u-u%16)/16)+""+"0123456789ABCDEF".charAt(u%16))+""+("0123456789ABCDEF".charAt((b-b%16)/16)+""+"0123456789ABCDEF".charAt(b%16))+""+("0123456789ABCDEF".charAt((e-e%16)/16)+""+"0123456789ABCDEF".charAt(e%16));v="[color=#"+s+"]";n="[/color]"}else{if(k.match(/^color: ?(.*?);?$/i)){v="[color="+RegExp.$1+"]";n="[/color]"}else{if(k.match(/^font-size: ?(\d+)pt;?$/i)){v="[size="+RegExp.$1+"]";n="[/size]"}else{if(k.match(/^font-family: ?(.*?);?$/)){v="[font="+RegExp.$1.replace(/'/g,"")+"]";n="[/font]"}else{v='<span style="'+k+'">';n="</span>"}}}}x[x.length]="";p[x.length]={start:v,end:n}}else{if(h.match(/^<span class="inlineCode">/)){x[x.length]="";p[x.length]={start:"[tt]",end:"[/tt]"}}else{if(x.length){x[x.length-1]+=h}else{q+=h}}}}}m=q;m=m.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(A,z,C,B){return"[align="+C+"]"+$.trim(B)+"[/align]"});m=m.replace(/<li>/gi,"[*]");m=m.replace(/<\/li>/gi,"");m=m.replace(/<ul>/gi,"[list]");m=m.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");m=m.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]");m=m.replace(/<\/(ul|ol)>/gi,"[/list]");m=m.replace(/<table[^>]*>/gi,"[table]\n");m=m.replace(/<\/table>/gi,"[/table]\n");m=m.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(z,A){return $.trim(A)});m=m.replace(/<tr><\/tr>/gi,"");m=m.replace(/<tr>/gi,"[tr]\n");m=m.replace(/<\/tr>/gi,"[/tr]\n");m=m.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");m=m.replace(/(\t)*<td>(\t)*/gi,"[td]");m=m.replace(/(\t)*<\/td>/gi,"[/td]\n");var w={};m.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(z){var A=z.hashCode();w[A]=z.replace(/\$/g,"$$$$");return"@@"+A+"@@"});m=m.replace(/<[^>]+>/g,"");if($.getLength(w)){for(var j in w){var t=new RegExp("@@"+j+"@@","g");data=data.replace(t,w[j])}}m=m.replace(/</g,"<");m=m.replace(/>/g,">");m=m.replace(/&/g,"&");m=m.replace(/%28/g,"(");m=m.replace(/%29/g,")");var r={};for(var a=0,i=__REDACTOR_SOURCE_BBCODES.length;a<i;a++){var o=__REDACTOR_SOURCE_BBCODES[a];var l=new RegExp("\\["+o+"([\\S\\s]+?)\\[\\/"+o+"\\]","gi");m=m.replace(l,function(z){var A=z.hashCode();r[A]=z.replace(/\$/g,"$$$$");return"@@"+A+"@@"})}var g=m.split("\n");for(var a=0,i=g.length;a<i;a++){g[a]=g[a].replace(/^\s*/,"")}m=g.join("\n");m=m.replace(/\[quote([^\]]+)?\](.*?)\[\/quote\]/,function(A,z,B){return"[quote"+(z||"")+"]"+$.trim(B)+"[/quote]"});if($.getLength(r)){for(var j in r){var t=new RegExp("@@"+j+"@@","g");m=m.replace(t,r[j])}}this.$source.val(m)},_convertToHtml:function(){var f=this.$source.val();f=this.removeZeroWidthSpace(f);f=f.replace(/&/g,"&");f=f.replace(/</g,"<");f=f.replace(/>/g,">");var b={};for(var n=0,k=__REDACTOR_SOURCE_BBCODES.length;n<k;n++){var c=__REDACTOR_SOURCE_BBCODES[n];var d=new RegExp("\\["+c+"([\\S\\s]+?)\\[\\/"+c+"\\]","gi");f=f.replace(d,function(p){var q=p.hashCode();b[q]=p.replace(/\$/g,"$$$$");return"@@"+q+"@@"})}f=f.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>');f=f.replace(/\[url\='([^'"]+)'](.+?)\[\/url]/gi,'<a href="$1">$2</a>');f=f.replace(/\[url\=([^'"\]]+)](.+?)\[\/url]/gi,'<a href="$1">$2</a>');f=f.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>');f=f.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>');f=f.replace(/\[b\](.*?)\[\/b]/gi,"<b>$1</b>");f=f.replace(/\[i\](.*?)\[\/i]/gi,"<i>$1</i>");f=f.replace(/\[u\](.*?)\[\/u]/gi,"<u>$1</u>");f=f.replace(/\[s\](.*?)\[\/s]/gi,"<strike>$1</strike>");f=f.replace(/\[sub\](.*?)\[\/sub]/gi,"<sub>$1</sub>");f=f.replace(/\[sup\](.*?)\[\/sup]/gi,"<sup>$1</sup>");f=f.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');f=f.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,'<img src="$1" style="float: $2" />');f=f.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');f=f.replace(/\[size=(\d+)\](.*?)\[\/size\]/gi,'<span style="font-size: $1pt">$2</span>');f=f.replace(/\[color=([#a-z0-9]*?)\](.*?)\[\/color\]/gi,'<span style="color: $1">$2</span>');f=f.replace(/\[font='?([a-z,\- ]*?)'?\](.*?)\[\/font\]/gi,'<span style="font-family: $1">$2</span>');f=f.replace(/\[align=(left|right|center|justify)\](.*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');f=f.replace(/\[\*\](.*?)(?=\[\*\]|\[\/list\])/gi,"<li>$1</li>");f=f.replace(/\[list\]/gi,"<ul>");f=f.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');f=f.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');f=f.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">');f=f.replace(/\[\/list]/gi,"</ul>");f=f.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(p,q){return"[table]"+$.trim(q)+"[/table]"});f=f.replace(/\[table\]/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');f=f.replace(/\[\/table\]/gi,"</table>");f=f.replace(/\[tr\]/gi,"<tr>");f=f.replace(/\[\/tr\]/gi,"</tr>");f=f.replace(/\[td\]/gi,"<td>");f=f.replace(/\[\/td\]/gi,"</td>");f=f.replace(/<td>([\S\s]*?)<\/td>/gi,function(p,r){var q=$.trim(r);if(!q.length){q="​"}return"<td>"+q+"</td>"});var h=this.getOption("wAttachmentUrl");if(h){var l=this._getImageAttachmentIDs();f=f.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(p,q){q=parseInt(q);if(WCF.inArray(q,l)){return'<img src="'+h.replace(/987654321/,q)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+q+'" />'}return p})}for(var o in __REDACTOR_SMILIES){$smileyCode=o.replace(/</g,"<").replace(/>/g,">");var i=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp($smileyCode)+"(?=\\s|<|$)","gi");f=f.replace(i,'$1<img src="'+__REDACTOR_SMILIES[o]+'" class="smiley" alt="'+$smileyCode+'" />')}f=f.replace(/(javascript):/gi,"$1<span></span>:");f=f.replace(/(\r|\r\n)/,"\n");var a=f.split("\n");f="";for(var n=0,k=a.length;n<k;n++){var m=$.trim(a[n]);if(m.indexOf("<")===0){f+=m}else{if(!m){m="<br>"}f+="<p>"+m+"</p>"}}if($.getLength(b)){for(var g in b){var j=new RegExp("@@"+g+"@@","g");f=f.replace(j,b[g])}f=f.replace(/\[tt\](.*?)\[\/tt\]/gi,'<span class="inlineCode">$1</span>')}f=f.replace(/\[code\][\S\s]*?\[\/code\]/,"<pre>$&</pre>");var e=function(p){return p.replace(/^['"]/,"").replace(/['"]$/,"")};f=f.replace(/\[quote([^\]]+)?\]/gi,$.proxy(function(r,q){var s="";var p="";if(q){q=q.substr(1);q=q.split(",");switch(q.length){case 1:s=q[0];break;case 2:s=q[0];p=q[1];break}s=WCF.String.escapeHTML(e($.trim(s)));p=WCF.String.escapeHTML(e($.trim(p)))}var t='<blockquote class="quoteBox" cite="'+p+'" data-author="'+s+'"><div class="container containerPadding"><header data-ignore="true"><h3>'+this._buildQuoteHeader(s,p)+'</h3><a class="redactorQuoteEdit"></a></header><div>';console.debug(t);return t},this));f=f.replace(/\[\/quote\]/gi,"</div></div></blockquote>");f=f.replace(/<p><blockquote/gi,"<blockquote");f=f.replace(/<\/blockquote><\/p>/,"</blockquote>");this.$source.val(f)},_wPasteBeforeCallback:function(a){var b={1:24,2:22,3:18,4:14,5:12,6:10};a=a.replace(/<h([1-6])[^>]+>/g,function(c,d){return"[size="+b[d]+"]"});a=a.replace(/<\/h[1-6]>/g,"[/size]");a=a.replace(/<(article|header)[^>]+>/g,"<div>");a=a.replace(/<\/(article|header)>/g,"</div>");a=a.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>");a=a.replace(/<\/(div|p)><\/(div|p)>/g,"</p>@@@wcf_break@@@");return a},_wPasteAfterCallback:function(a){a=a.replace(/<p>([\s\S]*?)<\/p>/g,"<p>$1<br></p>");a=a.replace(/<header[^>]*>/g,"");a=a.replace(/<\/header>/g,"");a=a.replace(/<div>.*?<\/div>/g,"<p>$1</p>");a=a.replace(/<\/?div>/g,"");a=a.replace(/@@@wcf_break@@@/g,"<p><br></p>");a=a.replace(/<p><p>/g,"<p>");a=a.replace(/\[size=(\d+)\]/g,'<p><br></p><p><inline style="font-size: $1pt">');a=a.replace(/\[\/size\]/g,"</inline></p><p><br></p>");a=a.replace(/<img([^>]+)>/g,function(b,c){b=b.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return b});return a},insertAttachment:function(d){d=parseInt(d);var b=this.getOption("wAttachmentUrl");var c="[attach="+d+"][/attach]";var a=this._getImageAttachmentIDs();if(b&&WCF.inArray(d,a)){this.insertDynamic('<img src="'+b.replace(/987654321/,d)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+d+'" />',c)}else{this.insertDynamic(c)}},_getImageAttachmentIDs:function(){var a=this.getOption("wAttachmentImageIDs")||[];if(a.length){delete this.opts.wAttachmentImageIDs;return a}var b={imageAttachmentIDs:[]};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$source.wcfIdentify(),b);return b.imageAttachmentIDs},_wKeydownCallback:function(a){if(a.which===this.keyCode.DOWN){var b=this.getParent();var c=(b)?$(b).closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};if(b&&c.length){this.insertAfterLastElement($(parent)[0],c[0])}return false}return true},_observeQuotes:function(){this.$editor.find(".redactorQuoteEdit:not(.jsRedactorQuoteEdit)").addClass("jsRedactorQuoteEdit").click($.proxy(this._observeQuotesClick,this))},_observeQuotesClick:function(d){var b=$(d.currentTarget).closest("header");var c=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").click($.proxy(function(f){f.preventDefault();this._openQuoteEditOverlay($(d.currentTarget).closest("blockquote.quoteBox"));$(".redactor-link-tooltip").remove()},this)).appendTo(c);var a=b.offset();c.css({left:a.left+"px",top:(a.top+20)+"px"});$(".redactor-link-tooltip").remove();c.appendTo(document.body)},_openQuoteEditOverlay:function(a){this.modalInit(WCF.Language.get("wcf.bbcode.quote.edit"),this.opts.modal_quote,300,$.proxy(function(){$("#redactorQuoteAuthor").val(a.data("author"));$("#redactorQuoteLink").val(a.attr("cite"));$("#redactorEditQuote").click($.proxy(function(){var b=$("#redactorQuoteAuthor").val();a.data("author",b);a.attr("data-author",b);a.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this._updateQuoteHeader(a);this.modalClose()},this))},this))},_updateQuoteHeader:function(b){var c=b.data("author");var a=b.attr("cite");if(a){a=WCF.String.escapeHTML(a)}b.find("> div > header > h3").empty().append(this._buildQuoteHeader(c,a))},insertQuoteBBCode:function(b,d){if(this.inWysiwygMode()){var a='<blockquote class="quoteBox" cite="'+$link+'" data-author="'+$author+'"><div class="container containerPadding"><header data-ignore="true"><h3>'+this._buildQuoteHeader(b,d)+'</h3><a class="redactorQuoteEdit"></a></header>';+'<div id="redactorInsertedQuote">'+this.opts.invisibleSpace+"</div></div></blockquote>";this.insertHtml(a)}else{var c="[quote][/quote]";if(b){if(d){c="[quote='"+b+"','"+d+"'][/quote]"}else{c="[quote='"+b+"'][/quote]"}}this.insertAtCaret(c)}},_buildQuoteHeader:function(b,c){var a="";if(!b&&c){b=c;c=""}if(b){if(c){a+='<a href="'+c+'">'}a+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(b)});if(c){a+="</a>"}}else{a="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>"}return a}};
+if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode={init:function(){this.opts.initCallback=$.proxy(function(){var e=$.trim(this.getOption("wOriginalValue"));if(e.length){this.toggle();this.$source.val(e);this.toggle()}delete this.opts.wOriginalValue},this);this.opts.pasteBeforeCallback=$.proxy(this._wPasteBeforeCallback,this);this.opts.pasteAfterCallback=$.proxy(this._wPasteAfterCallback,this);this.opts.keydownCallback=$.proxy(this._wKeydownCallback,this);var d=this.syncClean;var b=this;this.syncClean=function(e){e=e.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>");return d.call(b,e)};if(this.getOption("wAutosaveOnce")){this._saveTextToStorage();delete this.opts.wAutosaveOnce}var a=this.buttonGet("table");if(a.length){var c=a.data("dropdown").children("a.redactor_dropdown_add_head");c.prev().remove();c.next().remove();c.remove();a.click($.proxy(this._tableButtonClick,this))}},_tableButtonClick:function(b){var c=$(b.currentTarget);if(!c.hasClass("dropact")){return}var a=this.getBlock()||this.getCurrent();var d=c.data("dropdown");d.children("li").show();var e=d.find("> li > .redactor_dropdown_insert_table").parent();if(a.tagName=="TD"){e.hide().next().hide()}else{e.nextAll().hide()}},insertSmiley:function(a,b,c){if(c){this.registerSmiley(a,b)}if(this.opts.visual){this.bufferSet();this.$editor.focus();this.insertHtml(' <img src="'+b+'" class="smiley" alt="'+a+'" /> ');if(this.opts.air){this.$air.fadeOut(100)}this.sync()}else{this.insertAtCaret(" "+a+" ")}},registerSmiley:function(a,b){if(__REDACTOR_SMILIES[a]){return false}__REDACTOR_SMILIES[a]=b;return true},toggle:function(a){if(this.opts.visual){this.sync(undefined,true);this.toggleCode(a);this._convertFromHtml();this.buttonGet("html").children("i").removeClass("fa-square-o").addClass("fa-square")}else{this._convertToHtml();this.toggleVisual();this._observeQuotes();this.buttonGet("html").children("i").removeClass("fa-square").addClass("fa-square-o")}},_convertFromHtml:function(){var m=this.$source.val();WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:m});m=m.replace(/\r?\n/g,"");var f=m.split(/(<\/?p>)/);var g="";var x="";for(var a=0;a<f.length;a++){var y=f[a];if(y=="<p>"){continue}else{if(y=="</p>"){x=$.trim(x);if(x!="@@@wcf_empty_line@@@"){x+="\n"}g+=x;x=""}else{if(a==0){g+=y}else{x+=y}}}}m=g;m=m.replace(/@@@wcf_empty_line@@@/g,"\n");m=m.replace(/\n\n$/,"\n");m=m.replace(/<br>$/,"");m=m.replace(/<br>/g,"\n");m=m.replace(/<br>/g,"");m=m.replace(/ /gi," ");m=m.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");m=m.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(B,z,A,C){if(A==C){return"[url]"+A+"[/url]"}return"[url='"+A+"']"+C+"[/url]"});m=m.replace(/<(?:b|strong)>/gi,"[b]");m=m.replace(/<\/(?:b|strong)>/gi,"[/b]");m=m.replace(/<(?:i|em)>/gi,"[i]");m=m.replace(/<\/(?:i|em)>/gi,"[/i]");m=m.replace(/<u>/gi,"[u]");m=m.replace(/<\/u>/gi,"[/u]");m=m.replace(/<(?:s(trike)?|del)>/gi,"[s]");m=m.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");m=m.replace(/<sub>/gi,"[sub]");m=m.replace(/<\/sub>/gi,"[/sub]");m=m.replace(/<sup>/gi,"[sup]");m=m.replace(/<\/sup>/gi,"[/sup]");m=m.replace(/<img [^>]*?alt="([^"]+?)" class="smiley".*?>/gi,"$1");m=m.replace(/<img [^>]*?class="smiley" alt="([^"]+?)".*?>/gi,"$1");m=m.replace(/<img [^>]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)".*?>/gi,"[attach=$1][/attach]");m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi,"[img='$2',$3][/img]");m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");m=m.replace(/<blockquote class="quoteBox" cite="([^"]+)?" data-author="([^"]+)?">/gi,function(z,B,A){if(B){return"[quote='"+A+"','"+B+"']"}else{if(A){return"[quote='"+A+"']"}}return"[quote]"});m=m.replace(/<\/blockquote>/gi,"[/quote]");m=m.replace(/<header data-ignore="true">.*?<\/header>/gi,"");var d=m.split(/(<\/?span[^>]*>)/);var x=[];var p=[];var q="";for(var a=0;a<d.length;a++){var h=d[a];if(h=="</span>"){var c=p.pop();var g=c.start+x.pop()+c.end;if(x.length){x[x.length-1]+=g}else{q+=g}}else{if(h.match(/^<span style="([^"]+)">/)){var k=RegExp.$1;var v;var n;if(k.match(/^color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?$/i)){var u=RegExp.$1;var b=RegExp.$2;var e=RegExp.$3;var s=("0123456789ABCDEF".charAt((u-u%16)/16)+""+"0123456789ABCDEF".charAt(u%16))+""+("0123456789ABCDEF".charAt((b-b%16)/16)+""+"0123456789ABCDEF".charAt(b%16))+""+("0123456789ABCDEF".charAt((e-e%16)/16)+""+"0123456789ABCDEF".charAt(e%16));v="[color=#"+s+"]";n="[/color]"}else{if(k.match(/^color: ?(.*?);?$/i)){v="[color="+RegExp.$1+"]";n="[/color]"}else{if(k.match(/^font-size: ?(\d+)pt;?$/i)){v="[size="+RegExp.$1+"]";n="[/size]"}else{if(k.match(/^font-family: ?(.*?);?$/)){v="[font="+RegExp.$1.replace(/'/g,"")+"]";n="[/font]"}else{v='<span style="'+k+'">';n="</span>"}}}}x[x.length]="";p[x.length]={start:v,end:n}}else{if(h.match(/^<span class="inlineCode">/)){x[x.length]="";p[x.length]={start:"[tt]",end:"[/tt]"}}else{if(x.length){x[x.length-1]+=h}else{q+=h}}}}}m=q;m=m.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(A,z,C,B){return"[align="+C+"]"+$.trim(B)+"[/align]"});m=m.replace(/<li>/gi,"[*]");m=m.replace(/<\/li>/gi,"");m=m.replace(/<ul>/gi,"[list]");m=m.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");m=m.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]");m=m.replace(/<\/(ul|ol)>/gi,"[/list]");m=m.replace(/<table[^>]*>/gi,"[table]\n");m=m.replace(/<\/table>/gi,"[/table]\n");m=m.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(z,A){return $.trim(A)});m=m.replace(/<tr><\/tr>/gi,"");m=m.replace(/<tr>/gi,"[tr]\n");m=m.replace(/<\/tr>/gi,"[/tr]\n");m=m.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");m=m.replace(/(\t)*<td>(\t)*/gi,"[td]");m=m.replace(/(\t)*<\/td>/gi,"[/td]\n");var w={};m.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(z){var A=z.hashCode();w[A]=z.replace(/\$/g,"$$$$");return"@@"+A+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:m});m=m.replace(/<[^>]+>/g,"");if($.getLength(w)){for(var j in w){var t=new RegExp("@@"+j+"@@","g");data=data.replace(t,w[j])}}m=m.replace(/</g,"<");m=m.replace(/>/g,">");m=m.replace(/&/g,"&");m=m.replace(/%28/g,"(");m=m.replace(/%29/g,")");var r={};for(var a=0,i=__REDACTOR_SOURCE_BBCODES.length;a<i;a++){var o=__REDACTOR_SOURCE_BBCODES[a];var l=new RegExp("\\["+o+"([\\S\\s]+?)\\[\\/"+o+"\\]","gi");m=m.replace(l,function(z){var A=z.hashCode();r[A]=z.replace(/\$/g,"$$$$");return"@@"+A+"@@"})}var g=m.split("\n");for(var a=0,i=g.length;a<i;a++){g[a]=g[a].replace(/^\s*/,"")}m=g.join("\n");m=m.replace(/\[quote([^\]]+)?\](.*?)\[\/quote\]/,function(A,z,B){return"[quote"+(z||"")+"]"+$.trim(B)+"[/quote]"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:m});if($.getLength(r)){for(var j in r){var t=new RegExp("@@"+j+"@@","g");m=m.replace(t,r[j])}}this.$source.val(m)},_convertToHtml:function(){var f=this.$source.val();WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:f});f=this.removeZeroWidthSpace(f);f=f.replace(/&/g,"&");f=f.replace(/</g,"<");f=f.replace(/>/g,">");var b={};for(var n=0,k=__REDACTOR_SOURCE_BBCODES.length;n<k;n++){var c=__REDACTOR_SOURCE_BBCODES[n];var d=new RegExp("\\["+c+"([\\S\\s]+?)\\[\\/"+c+"\\]","gi");f=f.replace(d,function(p){var q=p.hashCode();b[q]=p.replace(/\$/g,"$$$$");return"@@"+q+"@@"})}f=f.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>');f=f.replace(/\[url\='([^'"]+)'](.+?)\[\/url]/gi,'<a href="$1">$2</a>');f=f.replace(/\[url\=([^'"\]]+)](.+?)\[\/url]/gi,'<a href="$1">$2</a>');f=f.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>');f=f.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>');f=f.replace(/\[b\](.*?)\[\/b]/gi,"<b>$1</b>");f=f.replace(/\[i\](.*?)\[\/i]/gi,"<i>$1</i>");f=f.replace(/\[u\](.*?)\[\/u]/gi,"<u>$1</u>");f=f.replace(/\[s\](.*?)\[\/s]/gi,"<strike>$1</strike>");f=f.replace(/\[sub\](.*?)\[\/sub]/gi,"<sub>$1</sub>");f=f.replace(/\[sup\](.*?)\[\/sup]/gi,"<sup>$1</sup>");f=f.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');f=f.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,'<img src="$1" style="float: $2" />');f=f.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');f=f.replace(/\[size=(\d+)\](.*?)\[\/size\]/gi,'<span style="font-size: $1pt">$2</span>');f=f.replace(/\[color=([#a-z0-9]*?)\](.*?)\[\/color\]/gi,'<span style="color: $1">$2</span>');f=f.replace(/\[font='?([a-z,\- ]*?)'?\](.*?)\[\/font\]/gi,'<span style="font-family: $1">$2</span>');f=f.replace(/\[align=(left|right|center|justify)\](.*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');f=f.replace(/\[\*\](.*?)(?=\[\*\]|\[\/list\])/gi,"<li>$1</li>");f=f.replace(/\[list\]/gi,"<ul>");f=f.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');f=f.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');f=f.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">');f=f.replace(/\[\/list]/gi,"</ul>");f=f.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(p,q){return"[table]"+$.trim(q)+"[/table]"});f=f.replace(/\[table\]/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');f=f.replace(/\[\/table\]/gi,"</table>");f=f.replace(/\[tr\]/gi,"<tr>");f=f.replace(/\[\/tr\]/gi,"</tr>");f=f.replace(/\[td\]/gi,"<td>");f=f.replace(/\[\/td\]/gi,"</td>");f=f.replace(/<td>([\S\s]*?)<\/td>/gi,function(p,r){var q=$.trim(r);if(!q.length){q="​"}return"<td>"+q+"</td>"});var h=this.getOption("wAttachmentUrl");if(h){var l=this._getImageAttachmentIDs();f=f.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(p,q){q=parseInt(q);if(WCF.inArray(q,l)){return'<img src="'+h.replace(/987654321/,q)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+q+'" />'}return p})}for(var o in __REDACTOR_SMILIES){$smileyCode=o.replace(/</g,"<").replace(/>/g,">");var i=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp($smileyCode)+"(?=\\s|<|$)","gi");f=f.replace(i,'$1<img src="'+__REDACTOR_SMILIES[o]+'" class="smiley" alt="'+$smileyCode+'" />')}f=f.replace(/(javascript):/gi,"$1<span></span>:");f=f.replace(/(\r|\r\n)/,"\n");var a=f.split("\n");f="";for(var n=0,k=a.length;n<k;n++){var m=$.trim(a[n]);if(m.indexOf("<")===0){f+=m}else{if(!m){m="<br>"}f+="<p>"+m+"</p>"}}if($.getLength(b)){for(var g in b){var j=new RegExp("@@"+g+"@@","g");f=f.replace(j,b[g])}f=f.replace(/\[tt\](.*?)\[\/tt\]/gi,'<span class="inlineCode">$1</span>')}f=f.replace(/\[code\][\S\s]*?\[\/code\]/,"<pre>$&</pre>");var e=function(p){return p.replace(/^['"]/,"").replace(/['"]$/,"")};f=f.replace(/\[quote([^\]]+)?\]/gi,$.proxy(function(r,q){var s="";var p="";if(q){q=q.substr(1);q=q.split(",");switch(q.length){case 1:s=q[0];break;case 2:s=q[0];p=q[1];break}s=WCF.String.escapeHTML(e($.trim(s)));p=WCF.String.escapeHTML(e($.trim(p)))}var t='<blockquote class="quoteBox" cite="'+p+'" data-author="'+s+'"><div class="container containerPadding"><header data-ignore="true"><h3>'+this._buildQuoteHeader(s,p)+'</h3><a class="redactorQuoteEdit"></a></header><div>';return t},this));f=f.replace(/\[\/quote\]/gi,"</div></div></blockquote>");f=f.replace(/<p><blockquote/gi,"<blockquote");f=f.replace(/<\/blockquote><\/p>/,"</blockquote>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:f});this.$source.val(f)},_wPasteBeforeCallback:function(a){var b={1:24,2:22,3:18,4:14,5:12,6:10};a=a.replace(/<h([1-6])[^>]+>/g,function(c,d){return"[size="+b[d]+"]"});a=a.replace(/<\/h[1-6]>/g,"[/size]");a=a.replace(/<(article|header)[^>]+>/g,"<div>");a=a.replace(/<\/(article|header)>/g,"</div>");a=a.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>");a=a.replace(/<\/(div|p)><\/(div|p)>/g,"</p>@@@wcf_break@@@");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:a});return a},_wPasteAfterCallback:function(a){a=a.replace(/<p>([\s\S]*?)<\/p>/g,"<p>$1<br></p>");a=a.replace(/<header[^>]*>/g,"");a=a.replace(/<\/header>/g,"");a=a.replace(/<div>.*?<\/div>/g,"<p>$1</p>");a=a.replace(/<\/?div>/g,"");a=a.replace(/@@@wcf_break@@@/g,"<p><br></p>");a=a.replace(/<p><p>/g,"<p>");a=a.replace(/\[size=(\d+)\]/g,'<p><br></p><p><inline style="font-size: $1pt">');a=a.replace(/\[\/size\]/g,"</inline></p><p><br></p>");a=a.replace(/<img([^>]+)>/g,function(b,c){b=b.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return b});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:a});return a},insertAttachment:function(d){d=parseInt(d);var b=this.getOption("wAttachmentUrl");var c="[attach="+d+"][/attach]";var a=this._getImageAttachmentIDs();if(b&&WCF.inArray(d,a)){this.insertDynamic('<img src="'+b.replace(/987654321/,d)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+d+'" />',c)}else{this.insertDynamic(c)}},_getImageAttachmentIDs:function(){var a=this.getOption("wAttachmentImageIDs")||[];if(a.length){delete this.opts.wAttachmentImageIDs;return a}var b={imageAttachmentIDs:[]};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$source.wcfIdentify(),b);return b.imageAttachmentIDs},_wKeydownCallback:function(a){if(a.which===this.keyCode.DOWN){var b=this.getParent();var c=(b)?$(b).closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};if(b&&c.length){this.insertAfterLastElement($(parent)[0],c[0])}return false}return true},_observeQuotes:function(){this.$editor.find(".redactorQuoteEdit:not(.jsRedactorQuoteEdit)").addClass("jsRedactorQuoteEdit").click($.proxy(this._observeQuotesClick,this))},_observeQuotesClick:function(d){var b=$(d.currentTarget).closest("header");var c=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").click($.proxy(function(f){f.preventDefault();this._openQuoteEditOverlay($(d.currentTarget).closest("blockquote.quoteBox"));$(".redactor-link-tooltip").remove()},this)).appendTo(c);var a=b.offset();c.css({left:a.left+"px",top:(a.top+20)+"px"});$(".redactor-link-tooltip").remove();c.appendTo(document.body)},_openQuoteEditOverlay:function(a){this.modalInit(WCF.Language.get("wcf.bbcode.quote.edit"),this.opts.modal_quote,300,$.proxy(function(){$("#redactorQuoteAuthor").val(a.data("author"));$("#redactorQuoteLink").val(a.attr("cite"));$("#redactorEditQuote").click($.proxy(function(){var b=$("#redactorQuoteAuthor").val();a.data("author",b);a.attr("data-author",b);a.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this._updateQuoteHeader(a);this.modalClose()},this))},this))},_updateQuoteHeader:function(b){var c=b.data("author");var a=b.attr("cite");if(a){a=WCF.String.escapeHTML(a)}b.find("> div > header > h3").empty().append(this._buildQuoteHeader(c,a))},insertQuoteBBCode:function(b,d){if(this.inWysiwygMode()){var a='<blockquote class="quoteBox" cite="'+$link+'" data-author="'+$author+'"><div class="container containerPadding"><header data-ignore="true"><h3>'+this._buildQuoteHeader(b,d)+'</h3><a class="redactorQuoteEdit"></a></header>';+'<div id="redactorInsertedQuote">'+this.opts.invisibleSpace+"</div></div></blockquote>";this.insertHtml(a)}else{var c="[quote][/quote]";if(b){if(d){c="[quote='"+b+"','"+d+"'][/quote]"}else{c="[quote='"+b+"'][/quote]"}}this.insertAtCaret(c)}},_buildQuoteHeader:function(b,c){var a="";if(!b&&c){b=c;c=""}if(b){if(c){a+='<a href="'+c+'">'}a+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(b)});if(c){a+="</a>"}}else{a="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>"}return a}};
// wbutton.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbutton={_bbcodes:{},init:function(){this._bbcodes={};for(var g=0,d=__REDACTOR_BUTTONS.length;g<d;g++){this._addBBCodeButton(__REDACTOR_BUTTONS[g])}var a={html:"fa-square-o",bold:"fa-bold",italic:"fa-italic",underline:"fa-underline",deleted:"fa-strikethrough",subscript:"fa-subscript",superscript:"fa-superscript",orderedlist:"fa-list-ol",unorderedlist:"fa-list-ul",outdent:"fa-outdent",indent:"fa-indent",link:"fa-link",alignment:"fa-align-left",table:"fa-table"};var b=this.getOption("buttons");var f="";for(var g=0,d=b.length;g<d;g++){var c=b[g];if(c=="separator"){this.buttonGet(f).parent().addClass("separator");continue}var e=this.buttonGet(c);if(e.length){if(a[c]){this.buttonAwesome(c,a[c])}}else{this._addCoreButton(c,(a[c]?a[c]:null),f)}f=c}},_addCoreButton:function(b,a,c){var d=this.buttonBuild(b,{title:b,exec:b},false);$("<li />").append(d).insertAfter(this.buttonGet(c).parent());if(a!==null){this.buttonAwesome(b,a)}},_addBBCodeButton:function(b){var c="__wcf_"+b.name;var a=this.buttonAdd(c,b.label,this._insertBBCode);this._bbcodes[c]=b.name;if(b.icon.match(/^fa\-[a-z\-]+$/)){this.buttonAwesome(c,b.icon)}else{a.css("background-image","url("+__REDACTOR_ICON_PATH+b.icon+")")}},_insertBBCode:function(a,f,b,e){var d=this._bbcodes[a];var c=this.getSelectionHtml();if(d==="tt"){var g=(this.getParent())?$(this.getParent()):null;if(g&&g.closest("inline.inlineCode",this.$editor.get()[0]).length){this.inlineRemoveClass("inlineCode")}else{this.inlineSetClass("inlineCode")}}else{this.insertHtml("["+d+"]"+c+"[/"+d+"]");this.sync()}e.preventDefault();return false}};
// wfontcolor.js