// table.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.table=function(){return{getTemplate:function(){return String()+'<section id="redactor-modal-table-insert"><label>'+this.lang.get("rows")+'</label><input type="text" size="5" value="2" id="redactor-table-rows" /><label>'+this.lang.get("columns")+'</label><input type="text" size="5" value="3" id="redactor-table-columns" /></section>'},init:function(){var b={};b.insert_table={title:this.lang.get("insert_table"),func:this.table.show};b.insert_row_above={title:this.lang.get("insert_row_above"),func:this.table.addRowAbove};b.insert_row_below={title:this.lang.get("insert_row_below"),func:this.table.addRowBelow};b.insert_column_left={title:this.lang.get("insert_column_left"),func:this.table.addColumnLeft};b.insert_column_right={title:this.lang.get("insert_column_right"),func:this.table.addColumnRight};b.add_head={title:this.lang.get("add_head"),func:this.table.addHead};b.delete_head={title:this.lang.get("delete_head"),func:this.table.deleteHead};b.delete_column={title:this.lang.get("delete_column"),func:this.table.deleteColumn};b.delete_row={title:this.lang.get("delete_row"),func:this.table.deleteRow};b.delete_table={title:this.lang.get("delete_table"),func:this.table.deleteTable};this.observe.addButton("td","table");this.observe.addButton("th","table");var a=this.button.addBefore("link","table",this.lang.get("table"));this.button.addDropdown(a,b)},show:function(){this.modal.addTemplate("table",this.table.getTemplate());this.modal.load("table",this.lang.get("insert_table"),300);this.modal.createCancelButton();var a=this.modal.createActionButton(this.lang.get("insert"));a.on("click",this.table.insert);this.selection.save();this.modal.show();$("#redactor-table-rows").focus()},insert:function(){var n=$("#redactor-table-rows").val(),c=$("#redactor-table-columns").val(),a=$("<div>"),b=Math.floor(Math.random()*99999),l=$('<table id="table'+b+'"><tbody></tbody></table>'),e,h,j,k;for(e=0;e<n;e++){h=$("<tr>");for(j=0;j<c;j++){k=$("<td>"+this.opts.invisibleSpace+"</td>");if(e===0&&j===0){k.append(this.selection.getMarker())}$(h).append(k)}l.append(h)}a.append(l);var f=a.html();this.modal.close();this.selection.restore();if(this.table.getTable()){return}this.buffer.set();var g=this.selection.getBlock()||this.selection.getCurrent();if(g&&g.tagName!="BODY"){if(g.tagName=="LI"){g=$(g).closest("ul, ol")}$(g).after(f)}else{this.insert.html(f)}this.selection.restore();var m=this.$editor.find("#table"+b);if(!this.opts.linebreaks&&(this.utils.browser("mozilla")||this.utils.browser("msie"))){var d=m.next();if(d.length===0){m.after(this.opts.emptyHtml)}}this.observe.buttons();m.find("span.redactor-selection-marker").remove();m.removeAttr("id");this.code.sync();this.core.setCallback("insertedTable",m)},getTable:function(){var a=$(this.selection.getParent()).closest("table");if(!this.utils.isRedactorParent(a)){return false}if(a.size()===0){return false}return a},restoreAfterDelete:function(a){this.selection.restore();a.find("span.redactor-selection-marker").remove();this.code.sync()},deleteTable:function(){var b=this.table.getTable();if(!b){return}this.buffer.set();var a=b.next();if(!this.opts.linebreaks&&a.length!==0){this.caret.setStart(a)}else{this.caret.setAfter(b)}b.remove();this.code.sync()},deleteRow:function(){var a=this.table.getTable();if(!a){return}var c=$(this.selection.getCurrent());this.buffer.set();var e=c.closest("tr");var b=e.prev().length?e.prev():e.next();if(b.length){var d=b.children("td, th").first();if(d.length){d.prepend(this.selection.getMarker())}}e.remove();this.table.restoreAfterDelete(a)},deleteColumn:function(){var c=this.table.getTable();if(!c){return}this.buffer.set();var d=$(this.selection.getCurrent());var a=d.closest("td, th");var b=a[0].cellIndex;c.find("tr").each($.proxy(function(f,g){var e=$(g);var h=b-1<0?b+1:b-1;if(f===0){e.find("td, th").eq(h).prepend(this.selection.getMarker())}e.find("td, th").eq(b).remove()},this));this.table.restoreAfterDelete(c)},addHead:function(){var a=this.table.getTable();if(!a){return}this.buffer.set();if(a.find("thead").size()!==0){this.table.deleteHead();return}var b=a.find("tr").first().clone();b.find("td").html(this.opts.invisibleSpace);$thead=$("<thead></thead>").append(b);a.prepend($thead);this.code.sync()},deleteHead:function(){var a=this.table.getTable();if(!a){return}var b=a.find("thead");if(b.size()===0){return}this.buffer.set();b.remove();this.code.sync()},addRowAbove:function(){this.table.addRow("before")},addRowBelow:function(){this.table.addRow("after")},addColumnLeft:function(){this.table.addColumn("before")},addColumnRight:function(){this.table.addColumn("after")},addRow:function(c){var a=this.table.getTable();if(!a){return}this.buffer.set();var b=$(this.selection.getCurrent());var d=b.closest("tr");var e=d.clone();e.find("th").replaceWith(function(){var f=$("<td>");f[0].attributes=this.attributes;return f.append($(this).contents())});e.find("td").html(this.opts.invisibleSpace);if(c=="after"){d.after(e)}else{d.before(e)}this.code.sync()},addColumn:function(d){var c=this.table.getTable();if(!c){return}var b=0;var e=$(this.selection.getCurrent());this.buffer.set();var f=e.closest("tr");var a=e.closest("td, th");f.find("td, th").each($.proxy(function(g,h){if($(h)[0]===a[0]){b=g}},this));c.find("tr").each($.proxy(function(g,j){var h=$(j).find("td, th").eq(b);var k=h.clone();k.html(this.opts.invisibleSpace);if(d=="after"){h.after(k)}else{h.before(k)}},this));this.code.sync()}}};
// wbbcode.js
-if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode=function(){return{init:function(){var c=this.$textarea.wcfIdentify();this.opts.initCallback=$.proxy(function(){var e=$.trim(this.wutil.getOption("woltlab.originalValue"));if(e.length){this.wutil.replaceText(e);this.wutil.selectionEndOfEditor()}delete this.opts.woltlab.originalValue;$(document).trigger("resize")},this);this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this);this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var b=this.clean.onSync;this.clean.onSync=function(e){e=e.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>");return b.call(self,e)};if(this.wutil.getOption("woltlab.autosaveOnce")){this.wutil._saveTextToStorage();delete this.opts.woltlab.autosaveOnce}var a=this.button.get("table");if(a.length){var d=a.data("dropdown");d.find(".redactor-dropdown-add_head").parent().remove();d.find(".redactor-dropdown-delete_head").parent().remove();$('<li class="dropdownDivider" />').insertBefore(d.find(".redactor-dropdown-delete_table").parent());a.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+c,$.proxy(function(e){e.cancel=true;this.wbbcode._handleInsertQuote()},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+c,$.proxy(this.wbbcode._keydownCallback,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+c,$.proxy(this.wbbcode._keyupCallback,this));this.code.sync=function(){};this.code.toggle=(function(){if(this.opts.visual){this.code.startSync();this.code.showCode();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()));this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square")}else{this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val()));this.code.showVisual();this.wbbcode._observeQuotes();this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o")}}).bind(this);this.wutil.setOption("clickCallback",(function(e){if(e.target===this.$editor[0]){if(this.$editor[0].lastElementChild&&this.$editor[0].lastElementChild.tagName==="BLOCKQUOTE"){this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}}}).bind(this))},_tableButtonClick:function(b){var c=$(b.currentTarget);if(!c.hasClass("dropact")){return}var a=this.selection.getBlock()||this.selection.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()}else{e.nextAll().hide()}},insertSmiley:function(a,b,c){if(c){this.wbbcode.registerSmiley(a,b)}if(this.opts.visual){this.insert.html(' <img src="'+b+'" class="smiley" alt="'+a+'" /> ',false)}else{this.wutil.insertAtCaret(" "+a+" ")}},registerSmiley:function(a,b){if(__REDACTOR_SMILIES[a]){return false}__REDACTOR_SMILIES[a]=b;return true},convertFromHtml:function(n){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:n});n=n.replace(/™/gi,"\u2122");n=n.replace(/©/gi,"\u00a9");n=n.replace(/…/gi,"\u2026");n=n.replace(/—/gi,"\u2014");n=n.replace(/‐/gi,"\u2010");n=n.replace(/\r?\n/g,"");n=n.replace(/<a[^>]*?><\/a>/g,"");n=n.replace(/<p><\/p>/g,"");n=n.replace(/<br( \/)?><\/p>/g,"");var g=n.split(/(<\/?(?:div|p)>)/);var h="";var y="";for(var a=0;a<g.length;a++){var z=g[a];if(z=="<p>"||z=="<div>"){continue}else{if(z=="</p>"||z=="</div>"){y=$.trim(y);if(y!="@@@wcf_empty_line@@@"){y+="\n"}h+=y;y=""}else{if(a==0||a+1==g.length){h+=z}else{y+=z}}}}if(y){h+=y;y=""}n=h;n=n.replace(/@@@wcf_empty_line@@@/g,"\n");n=n.replace(/\n\n$/,"\n");n=n.replace(/<br>$/,"");n=n.replace(/<br>/g,"\n");n=n.replace(/<br>/g,"");n=n.replace(/ /gi," ");n=n.replace(/<blockquote class="quoteBox" cite="([^"]+)?" data-author="([^"]+)?">\n?<div[^>]+>\n?<header(?:[^>]*?)>[\s\S]*?<\/header>/gi,function(A,C,B,D){var E;if(B){B=WCF.String.unescapeHTML(B)}if(C){C=WCF.String.unescapeHTML(C)}if(C){E="[quote='"+B+"','"+C+"']"}else{if(B){E="[quote='"+B+"']"}else{E="[quote]"}}return E});n=n.replace(/(?:\n*)<\/blockquote>\n?/gi,"[/quote]\n");n=n.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");n=n.replace(/<a[^>]+><\/a>/,"");n=n.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(C,A,B,D){if(B==D){return"[url]"+B+"[/url]"}return"[url='"+B+"']"+D+"[/url]"});n=n.replace(/<(?:b|strong)>/gi,"[b]");n=n.replace(/<\/(?:b|strong)>/gi,"[/b]");n=n.replace(/<(?:i|em)>/gi,"[i]");n=n.replace(/<\/(?:i|em)>/gi,"[/i]");n=n.replace(/<u>/gi,"[u]");n=n.replace(/<\/u>/gi,"[/u]");n=n.replace(/<(?:s(trike)?|del)>/gi,"[s]");n=n.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");n=n.replace(/<sub>/gi,"[sub]");n=n.replace(/<\/sub>/gi,"[/sub]");n=n.replace(/<sup>/gi,"[sup]");n=n.replace(/<\/sup>/gi,"[/sup]");n=n.replace(/<img [^>]*?alt="([^"]+?)" class="smiley".*?> ?/gi,"$1 ");n=n.replace(/<img [^>]*?class="smiley" alt="([^"]+?)".*?> ?/gi,"$1 ");n=n.replace(/<img [^>]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)"( style="float: (left|right)")?>/gi,function(B,C,A,D){if(D){return"[attach="+C+","+D+"][/attach]"}return"[attach="+C+"][/attach]"});n=n.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi,"[img='$2',$3][/img]");n=n.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");var e=n.split(/(<\/?span[^>]*>)/);var y=[];var q=[];var r="";var c={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36};for(var a=0;a<e.length;a++){var i=e[a];if(i=="</span>"){var d=q.pop();var h=d.start+y.pop()+d.end;if(y.length){y[y.length-1]+=h}else{r+=h}}else{if(i.match(/^<span/)){if(i.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var w;var o;if(l.match(/color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var v=RegExp.$1;var b=RegExp.$2;var f=RegExp.$3;var t=("0123456789ABCDEF".charAt((v-v%16)/16)+""+"0123456789ABCDEF".charAt(v%16))+""+("0123456789ABCDEF".charAt((b-b%16)/16)+""+"0123456789ABCDEF".charAt(b%16))+""+("0123456789ABCDEF".charAt((f-f%16)/16)+""+"0123456789ABCDEF".charAt(f%16));w="[color=#"+t+"]";o="[/color]"}else{if(l.match(/color: ?(.*?);?/i)){w="[color="+RegExp.$1+"]";o="[/color]"}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){w="[size="+RegExp.$1+"]";o="[/size]"}else{if(c[RegExp.$1]){w="[size="+c[RegExp.$1]+"]";o="[/size]"}else{w="";o=""}}}else{if(l.match(/font-family: ?(.*?);?/)){w="[font="+RegExp.$1.replace(/'/g,"")+"]";o="[/font]"}else{w='<span style="'+l+'">';o="</span>"}}}}y[y.length]="";q[y.length]={start:w,end:o}}else{if(i.match(/^<span class="inlineCode">/)){y[y.length]="";q[y.length]={start:"[tt]",end:"[/tt]"}}else{y[y.length]="";q[y.length]={start:"",end:""}}}}else{if(y.length){y[y.length-1]+=i}else{r+=i}}}}n=r;n=n.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(B,A,D,C){return"[align="+D+"]"+$.trim(C)+"[/align]"});n=n.replace(/<li>/gi,"[*]");n=n.replace(/<\/li>/gi,"");n=n.replace(/<ul>/gi,"[list]");n=n.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");n=n.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]");n=n.replace(/<\/(ul|ol)>/gi,"[/list]");n=n.replace(/<table[^>]*>/gi,"[table]\n");n=n.replace(/<\/table>/gi,"[/table]\n");n=n.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(A,B){return $.trim(B)});n=n.replace(/<tr><\/tr>/gi,"");n=n.replace(/<tr>/gi,"[tr]\n");n=n.replace(/<\/tr>/gi,"[/tr]\n");n=n.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");n=n.replace(/(\t)*<td>(\t)*/gi,"[td]");n=n.replace(/(\t)*<\/td>/gi,"[/td]\n");var x={};n.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(A){var B=A.hashCode();x[B]=A.replace(/\$/g,"$$$$");return"@@"+B+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:n});n=n.replace(/<[^(<|>)]+>/g,"");if($.getLength(x)){for(var k in x){var u=new RegExp("@@"+k+"@@","g");data=data.replace(u,x[k])}}n=n.replace(/</g,"<");n=n.replace(/>/g,">");n=n.replace(/&/g,"&");n=n.replace(/%28/g,"(");n=n.replace(/%29/g,")");var s={};for(var a=0,j=__REDACTOR_SOURCE_BBCODES.length;a<j;a++){var p=__REDACTOR_SOURCE_BBCODES[a];var m=new RegExp("\\["+p+"([\\S\\s]+?)\\[\\/"+p+"\\]","gi");n=n.replace(m,function(A){var B=A.hashCode();s[B]=A.replace(/\$/g,"$$$$");return"@@"+B+"@@"})}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:n});if($.getLength(s)){for(var k in s){var u=new RegExp("@@"+k+"@@","g");n=n.replace(u,s[k])}}n=$.trim(n);n+="\n";return n},convertToHtml:function(C){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:C});C=this.wutil.removeZeroWidthSpace(C);C=C.replace(/&/g,"&");C=C.replace(/</g,"<");C=C.replace(/>/g,">");var t={};for(var a=0,l=__REDACTOR_SOURCE_BBCODES.length;a<l;a++){var r=__REDACTOR_SOURCE_BBCODES[a];var n=new RegExp("\\["+r+"([\\S\\s]+?)\\[\\/"+r+"\\]","gi");C=C.replace(n,function(D){var E=D.hashCode();t[E]=D.replace(/\$/g,"$$$$");return"@@"+E+"@@"})}C=C.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>');C=C.replace(/\[url\='([^'"]+)'](.+?)\[\/url]/gi,'<a href="$1">$2</a>');C=C.replace(/\[url\=([^'"\]]+)](.+?)\[\/url]/gi,'<a href="$1">$2</a>');C=C.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>');C=C.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>');C=C.replace(/\[b\](.*?)\[\/b]/gi,"<b>$1</b>");C=C.replace(/\[i\](.*?)\[\/i]/gi,"<i>$1</i>");C=C.replace(/\[u\](.*?)\[\/u]/gi,"<u>$1</u>");C=C.replace(/\[s\](.*?)\[\/s]/gi,"<strike>$1</strike>");C=C.replace(/\[sub\](.*?)\[\/sub]/gi,"<sub>$1</sub>");C=C.replace(/\[sup\](.*?)\[\/sup]/gi,"<sup>$1</sup>");C=C.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');C=C.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,'<img src="$1" style="float: $2" />');C=C.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');C=C.replace(/\[size=(\d+)\](.*?)\[\/size\]/gi,'<span style="font-size: $1pt">$2</span>');C=C.replace(/\[color=([#a-z0-9]*?)\](.*?)\[\/color\]/gi,'<span style="color: $1">$2</span>');C=C.replace(/\[font='?([a-z,\- ]*?)'?\](.*?)\[\/font\]/gi,'<span style="font-family: $1">$2</span>');C=C.replace(/\[align=(left|right|center|justify)\](.*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');C=C.replace(/\[\*\](.*?)(?=\[\*\]|\[\/list\])/gi,"<li>$1</li>");C=C.replace(/\[list\]/gi,"<ul>");C=C.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');C=C.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');C=C.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">');C=C.replace(/\[\/list]\n?/gi,"</ul>\n");C=C.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(D,E){return"[table]"+$.trim(E)+"[/table]"});C=C.replace(/\[table\]/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');C=C.replace(/\[\/table\]/gi,"</table>");C=C.replace(/\[tr\]/gi,"<tr>");C=C.replace(/\[\/tr\]/gi,"</tr>");C=C.replace(/\[td\]/gi,"<td>");C=C.replace(/\[\/td\]/gi,"</td>");C=C.replace(/<td>([\S\s]*?)<\/td>/gi,function(D,F){var E=$.trim(F);if(!E.length){E="​"}return"<td>"+E+"</td>"});var c=this.wutil.getOption("woltlab.attachmentUrl");if(c){var g=this.wbbcode._getImageAttachmentIDs();C=C.replace(/\[attach=(\d+)(,[^\]]*)?\]\[\/attach\]/g,function(E,F,G){F=parseInt(F);if(WCF.inArray(F,g)){var D="";if(G){if(G.match(/^,'?(left|right)'?/)){D=' style="float: '+RegExp.$1+'"'}}return'<img src="'+c.replace(/987654321/,F)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+F+'"'+D+" />"}return E})}for(var v in __REDACTOR_SMILIES){var j=v.replace(/</g,"<").replace(/>/g,">");var i=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(j)+"(?=\\s|<|$)","gi");C=C.replace(i,'$1<img src="'+__REDACTOR_SMILIES[v]+'" class="smiley" alt="'+j+'" />')}C=C.replace(/(javascript):/gi,"$1<span></span>:");C=C.replace(/(\r|\r\n)/g,"\n");var x=[];var A=[];var h=C.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/);var d=WCF.getUUID();while(true){var o=false;for(var a=0;a<h.length;a++){var z=h[a];if(z==="[/quote]"){o=true;var e="";var m=h.slice(0,a);var b=false;while(m.length){var y=m.pop();e=y+e;if(y.match(/^\[quote/)){z=e+z;var k=WCF.getUUID();x.push({hashCode:k,content:z.replace(/\$/g,"$$$$")});A.push(k);z="@@"+k+"@@";b=true;break}}if(!b){m=h.slice(0,a);z=d}h=m.concat(z,h.slice(a+1));break}}if(!o){break}}C=h.join("");C=C.replace(new RegExp(d,"g"),"[/quote]");C=C.replace(/\n*$/,"");var f=C.split("\n");C="";for(var a=0,l=f.length;a<l;a++){var s=$.trim(f[a]);if(s.match(/^<([a-z]+)/)){if(!this.reIsBlock.test(RegExp.$1.toUpperCase())){s="<p>"+s+"</p>"}C+=s}else{if(!s){s="<br>"}else{if(s.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,A)){C+=s;continue}}}C+="<p>"+s+"</p>"}}if($.getLength(t)){for(var k in t){var w=new RegExp("@@"+k+"@@","g");C=C.replace(w,t[k])}C=C.replace(/\[tt\](.*?)\[\/tt\]/gi,'<span class="inlineCode">$1</span>')}C=C.replace(/\[code\][\S\s]*?\[\/code\]/,"<pre>$&</pre>");if(x.length){var B=function(D){return D.replace(/^['"]/,"").replace(/['"]$/,"")};var q=this;var p=function(D){return D.replace(/\[quote(=['"].+['"])?\]([\S\s]*)\[\/quote\]/gi,function(G,F,I){var M="";var H="";if(F){F=F.substr(1);F=F.split(",");switch(F.length){case 1:M=F[0];break;case 2:M=F[0];H=F[1];break}M=WCF.String.escapeHTML(B($.trim(M)));H=WCF.String.escapeHTML(B($.trim(H)))}var N='<blockquote class="quoteBox" cite="'+H+'" data-author="'+M+'"><div class="container containerPadding"><header contenteditable="false"><h3>'+q.wbbcode._buildQuoteHeader(M,H)+'</h3><a class="redactorQuoteEdit"></a></header>';I=$.trim(I);var E="";if(I.length){var L=I.split("\n");for(var K=0;K<L.length;K++){var J=L[K];if(J.length===0){J=q.opts.invisibleSpace}else{if(J.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,A)){E+=J;continue}}}E+="<div>"+J+"</div>"}}else{E="<div>"+q.opts.invisibleSpace+"</div>"}N+=E;N+="</div></blockquote>";return N})};for(var a=x.length-1;a>=0;a--){var u=x[a];var w=new RegExp("@@"+u.hashCode+"@@","g");C=C.replace(w,p(u.content))}}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:C});return C},_pasteBeforeCallback: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>");a=a.replace(/<(div|p)><br><\/(div|p)>/g,"<p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:a});return a},_pasteCallback:function(a){a=a.replace(/<p>([\s\S]*?)<\/p>/g,function(b,c){if(c.match(/<br( \/)?>$/)){return b}return"<p>"+c+"</p><p><br></p>"});a=a.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');a=a.replace(/\[\/size\]/g,"</span></p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:a});return a;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.wutil.getOption("woltlab.attachmentUrl");var c="[attach="+d+"][/attach]";var a=this.wbbcode._getImageAttachmentIDs();if(b&&WCF.inArray(d,a)){this.wutil.insertDynamic('<img src="'+b.replace(/987654321/,d)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+d+'" />',c)}else{this.wutil.insertDynamic(c)}},_getImageAttachmentIDs:function(){var a=this.wutil.getOption("woltlab.attachmentImageIDs")||[];if(a.length){delete this.opts.wAttachmentImageIDs;return a}var b={imageAttachmentIDs:[]};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),b);return b.imageAttachmentIDs},_keydownCallback:function(f){switch(f.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.TAB:case $.ui.keyCode.UP:break;default:return;break}this.selection.get();var a=$(this.selection.getCurrent());var e=this.selection.getParent();e=(e)?$(e):e;var k=(e)?e.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(f.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){if(k.length){var c=true;k.find("div > div").each(function(){if($(this).text().replace(/\u200B/,"").length){c=false;return false}});if(c){var g=window.getSelection();if(g.rangeCount){g.removeAllRanges()}var h=document.createRange();h.selectNode(k[0]);g.addRange(h);f.cancel=true}}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()){if(this.wutil.isEndOfElement(a[0])&&a.next("blockquote").length){var g=window.getSelection();if(g.rangeCount){g.removeAllRanges()}var h=document.createRange();h.selectNode(a.next()[0]);g.addRange(h);f.cancel=true}}break;case $.ui.keyCode.DOWN:if(a.next("blockquote").length){this.caret.setStart(a.next().find("> div > div:first"));f.cancel=true}else{if(e){if(e.next("blockquote").length){this.caret.setStart(e.next().find("> div > div:first"));f.cancel=true}else{if(k.length){var j=a.closest("div",k[0]);if(!j.next().length){if(k.next().length){this.caret.setStart(k.next())}else{this.wutil.setCaretAfter(k)}f.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(k.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.TAB:var d=this.selection.getBlock();if(!d||d.tagName!=="LI"){f.cancel=true}break;case $.ui.keyCode.UP:if(!e||!k.length){return}var j=a.closest("div",k[0]);var b=j.prev();if(b[0].tagName==="DIV"){return}else{if(b[0].tagName==="BLOCKQUOTE"){return}}var i=k.prev();if(i.length===0){this.wutil.setCaretBefore(k)}else{if(i[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(i.find("> div > div:last"))}else{if($.trim(i.html())==""){i.html(this.opts.invisibleSpace)}this.caret.setEnd(i)}}f.cancel=true;break}},_keyupCallback:function(a){if(a.event.which!==$.ui.keyCode.BACKSPACE&&a.event.which!==$.ui.keyCode.DELETE){return}this.$editor.find("blockquote").each(function(b,d){var c=$(d);if(!c.find("> div > header").length){c.remove()}})},_observeQuotes:function(){this.$editor.find(".redactorQuoteEdit:not(.jsRedactorQuoteEdit)").addClass("jsRedactorQuoteEdit").click($.proxy(this.wbbcode._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"),false);$(".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);$('<div contenteditable="true" />').appendTo(document.body).focus().remove()},_openQuoteEditOverlay:function(a,c){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(c?"insert":"edit")),400);var b=this.modal.createActionButton(this.lang.get("save"));if(c){b.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();var d=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.wbbcode.insertQuoteBBCode(e,d);this.modal.close()},this))}else{$("#redactorQuoteAuthor").val(a.data("author"));$("#redactorQuoteLink").val(WCF.String.unescapeHTML(a.attr("cite")));b.click($.proxy(function(){var d=$("#redactorQuoteAuthor").val();a.data("author",d);a.attr("data-author",d);a.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this.wbbcode._updateQuoteHeader(a);this.modalClose()},this))}this.modal.show()},_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.wbbcode._buildQuoteHeader(c,a))},insertQuoteBBCode:function(c,h,d,e){var g="[quote]";var a="[/quote]";if(c){if(h){g="[quote='"+c+"','"+h+"']"}else{g="[quote='"+c+"']"}}if(this.wutil.inWysiwygMode()){var f=(e)?this.wbbcode.convertToHtml(e):"";var i=WCF.getUUID();var b=this.wbbcode.convertToHtml(g+i+a);b=b.replace(i,f);b=b.replace(/(<p>)?<blockquote/,'$1<blockquote id="'+i+'"');this.insert.html(b,false);var j=this.$editor.find("#"+i);if(j.length){j.removeAttr("id");this.wutil.setCaretAfter(j[0])}this.wbbcode._observeQuotes();this.$toolbar.find("a.re-__wcf_quote").addClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(g+e+a)}},_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},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,true)}}};
+if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode=function(){return{init:function(){var c=this.$textarea.wcfIdentify();this.opts.initCallback=$.proxy(function(){var e=$.trim(this.wutil.getOption("woltlab.originalValue"));if(e.length){this.wutil.replaceText(e);this.wutil.selectionEndOfEditor()}delete this.opts.woltlab.originalValue;$(document).trigger("resize")},this);this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this);this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var b=this.clean.onSync;this.clean.onSync=function(e){e=e.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>");return b.call(self,e)};if(this.wutil.getOption("woltlab.autosaveOnce")){this.wutil._saveTextToStorage();delete this.opts.woltlab.autosaveOnce}var a=this.button.get("table");if(a.length){var d=a.data("dropdown");d.find(".redactor-dropdown-add_head").parent().remove();d.find(".redactor-dropdown-delete_head").parent().remove();$('<li class="dropdownDivider" />').insertBefore(d.find(".redactor-dropdown-delete_table").parent());a.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+c,$.proxy(function(e){e.cancel=true;this.wbbcode._handleInsertQuote()},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+c,$.proxy(this.wbbcode._keydownCallback,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+c,$.proxy(this.wbbcode._keyupCallback,this));this.code.sync=function(){};this.code.toggle=(function(){if(this.opts.visual){this.code.startSync();this.code.showCode();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()));this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square")}else{this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val()));this.code.showVisual();this.wbbcode._observeQuotes();this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o")}}).bind(this);this.wutil.setOption("clickCallback",(function(e){if(e.target===this.$editor[0]){if(this.$editor[0].lastElementChild&&this.$editor[0].lastElementChild.tagName==="BLOCKQUOTE"){this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}}}).bind(this))},_tableButtonClick:function(b){var c=$(b.currentTarget);if(!c.hasClass("dropact")){return}var a=this.selection.getBlock()||this.selection.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()}else{e.nextAll().hide()}},insertSmiley:function(a,b,c){if(c){this.wbbcode.registerSmiley(a,b)}if(this.opts.visual){this.insert.html(' <img src="'+b+'" class="smiley" alt="'+a+'" /> ',false)}else{this.wutil.insertAtCaret(" "+a+" ")}},registerSmiley:function(a,b){if(__REDACTOR_SMILIES[a]){return false}__REDACTOR_SMILIES[a]=b;return true},convertFromHtml:function(n){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:n});n=n.replace(/™/gi,"\u2122");n=n.replace(/©/gi,"\u00a9");n=n.replace(/…/gi,"\u2026");n=n.replace(/—/gi,"\u2014");n=n.replace(/‐/gi,"\u2010");n=n.replace(/\r?\n/g,"");n=n.replace(/<a[^>]*?><\/a>/g,"");n=n.replace(/<p><\/p>/g,"");n=n.replace(/<br( \/)?><\/p>/g,"");var g=n.split(/(<\/?(?:div|p)>)/);var h="";var y="";for(var a=0;a<g.length;a++){var z=g[a];if(z=="<p>"||z=="<div>"){continue}else{if(z=="</p>"||z=="</div>"){y=$.trim(y);if(y!="@@@wcf_empty_line@@@"){y+="\n"}h+=y;y=""}else{if(a==0||a+1==g.length){h+=z}else{y+=z}}}}if(y){h+=y;y=""}n=h;n=n.replace(/@@@wcf_empty_line@@@/g,"\n");n=n.replace(/\n\n$/,"\n");n=n.replace(/<br>$/,"");n=n.replace(/<br>/g,"\n");n=n.replace(/<br>/g,"");n=n.replace(/ /gi," ");n=n.replace(/<blockquote class="quoteBox" cite="([^"]+)?" data-author="([^"]+)?">\n?<div[^>]+>\n?<header(?:[^>]*?)>[\s\S]*?<\/header>/gi,function(A,C,B,D){var E;if(B){B=WCF.String.unescapeHTML(B)}if(C){C=WCF.String.unescapeHTML(C)}if(C){E="[quote='"+B+"','"+C+"']"}else{if(B){E="[quote='"+B+"']"}else{E="[quote]"}}return E});n=n.replace(/(?:\n*)<\/blockquote>\n?/gi,"[/quote]\n");n=n.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");n=n.replace(/<a[^>]+><\/a>/,"");n=n.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(C,A,B,D){if(B==D){return"[url]"+B+"[/url]"}return"[url='"+B+"']"+D+"[/url]"});n=n.replace(/<(?:b|strong)>/gi,"[b]");n=n.replace(/<\/(?:b|strong)>/gi,"[/b]");n=n.replace(/<(?:i|em)>/gi,"[i]");n=n.replace(/<\/(?:i|em)>/gi,"[/i]");n=n.replace(/<u>/gi,"[u]");n=n.replace(/<\/u>/gi,"[/u]");n=n.replace(/<(?:s(trike)?|del)>/gi,"[s]");n=n.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");n=n.replace(/<sub>/gi,"[sub]");n=n.replace(/<\/sub>/gi,"[/sub]");n=n.replace(/<sup>/gi,"[sup]");n=n.replace(/<\/sup>/gi,"[/sup]");n=n.replace(/<img [^>]*?alt="([^"]+?)" class="smiley".*?> ?/gi,"$1 ");n=n.replace(/<img [^>]*?class="smiley" alt="([^"]+?)".*?> ?/gi,"$1 ");n=n.replace(/<img [^>]*?class="redactorEmbeddedAttachment" data-attachment-id="(\d+)"( style="float: (left|right)")?>/gi,function(B,C,A,D){if(D){return"[attach="+C+","+D+"][/attach]"}return"[attach="+C+"][/attach]"});n=n.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi,"[img='$2',$3][/img]");n=n.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");var e=n.split(/(<\/?span[^>]*>)/);var y=[];var q=[];var r="";var c={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36};for(var a=0;a<e.length;a++){var i=e[a];if(i=="</span>"){var d=q.pop();var h=d.start+y.pop()+d.end;if(y.length){y[y.length-1]+=h}else{r+=h}}else{if(i.match(/^<span/)){if(i.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var w;var o;if(l.match(/color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var v=RegExp.$1;var b=RegExp.$2;var f=RegExp.$3;var t=("0123456789ABCDEF".charAt((v-v%16)/16)+""+"0123456789ABCDEF".charAt(v%16))+""+("0123456789ABCDEF".charAt((b-b%16)/16)+""+"0123456789ABCDEF".charAt(b%16))+""+("0123456789ABCDEF".charAt((f-f%16)/16)+""+"0123456789ABCDEF".charAt(f%16));w="[color=#"+t+"]";o="[/color]"}else{if(l.match(/color: ?(.*?);?/i)){w="[color="+RegExp.$1+"]";o="[/color]"}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){w="[size="+RegExp.$1+"]";o="[/size]"}else{if(c[RegExp.$1]){w="[size="+c[RegExp.$1]+"]";o="[/size]"}else{w="";o=""}}}else{if(l.match(/font-family: ?([^;]+);?/)){w="[font='"+RegExp.$1.replace(/'/g,"")+"']";o="[/font]"}else{w='<span style="'+l+'">';o="</span>"}}}}y[y.length]="";q[y.length]={start:w,end:o}}else{if(i.match(/^<span class="inlineCode">/)){y[y.length]="";q[y.length]={start:"[tt]",end:"[/tt]"}}else{y[y.length]="";q[y.length]={start:"",end:""}}}}else{if(y.length){y[y.length-1]+=i}else{r+=i}}}}n=r;n=n.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(B,A,D,C){return"[align="+D+"]"+$.trim(C)+"[/align]"});n=n.replace(/<li>/gi,"[*]");n=n.replace(/<\/li>/gi,"");n=n.replace(/<ul>/gi,"[list]");n=n.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");n=n.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]");n=n.replace(/<\/(ul|ol)>/gi,"[/list]");n=n.replace(/<table[^>]*>/gi,"[table]\n");n=n.replace(/<\/table>/gi,"[/table]\n");n=n.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(A,B){return $.trim(B)});n=n.replace(/<tr><\/tr>/gi,"");n=n.replace(/<tr>/gi,"[tr]\n");n=n.replace(/<\/tr>/gi,"[/tr]\n");n=n.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");n=n.replace(/(\t)*<td>(\t)*/gi,"[td]");n=n.replace(/(\t)*<\/td>/gi,"[/td]\n");var x={};n.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(A){var B=A.hashCode();x[B]=A.replace(/\$/g,"$$$$");return"@@"+B+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:n});n=n.replace(/<[^(<|>)]+>/g,"");if($.getLength(x)){for(var k in x){var u=new RegExp("@@"+k+"@@","g");data=data.replace(u,x[k])}}n=n.replace(/</g,"<");n=n.replace(/>/g,">");n=n.replace(/&/g,"&");n=n.replace(/%28/g,"(");n=n.replace(/%29/g,")");var s={};for(var a=0,j=__REDACTOR_SOURCE_BBCODES.length;a<j;a++){var p=__REDACTOR_SOURCE_BBCODES[a];var m=new RegExp("\\["+p+"([\\S\\s]+?)\\[\\/"+p+"\\]","gi");n=n.replace(m,function(A){var B=A.hashCode();s[B]=A.replace(/\$/g,"$$$$");return"@@"+B+"@@"})}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:n});if($.getLength(s)){for(var k in s){var u=new RegExp("@@"+k+"@@","g");n=n.replace(u,s[k])}}n=$.trim(n);n+="\n";return n},convertToHtml:function(C){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:C});C=this.wutil.removeZeroWidthSpace(C);C=C.replace(/&/g,"&");C=C.replace(/</g,"<");C=C.replace(/>/g,">");var t={};for(var a=0,l=__REDACTOR_SOURCE_BBCODES.length;a<l;a++){var r=__REDACTOR_SOURCE_BBCODES[a];var n=new RegExp("\\["+r+"([\\S\\s]+?)\\[\\/"+r+"\\]","gi");C=C.replace(n,function(D){var E=D.hashCode();t[E]=D.replace(/\$/g,"$$$$");return"@@"+E+"@@"})}C=C.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>');C=C.replace(/\[url\='([^'"]+)'](.+?)\[\/url]/gi,'<a href="$1">$2</a>');C=C.replace(/\[url\=([^'"\]]+)](.+?)\[\/url]/gi,'<a href="$1">$2</a>');C=C.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>');C=C.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>');C=C.replace(/\[b\](.*?)\[\/b]/gi,"<b>$1</b>");C=C.replace(/\[i\](.*?)\[\/i]/gi,"<i>$1</i>");C=C.replace(/\[u\](.*?)\[\/u]/gi,"<u>$1</u>");C=C.replace(/\[s\](.*?)\[\/s]/gi,"<strike>$1</strike>");C=C.replace(/\[sub\](.*?)\[\/sub]/gi,"<sub>$1</sub>");C=C.replace(/\[sup\](.*?)\[\/sup]/gi,"<sup>$1</sup>");C=C.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');C=C.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,'<img src="$1" style="float: $2" />');C=C.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');C=C.replace(/\[size=(\d+)\](.*?)\[\/size\]/gi,'<span style="font-size: $1pt">$2</span>');C=C.replace(/\[color=([#a-z0-9]*?)\](.*?)\[\/color\]/gi,'<span style="color: $1">$2</span>');C=C.replace(/\[font='?([a-z,\- ]*?)'?\](.*?)\[\/font\]/gi,'<span style="font-family: $1">$2</span>');C=C.replace(/\[align=(left|right|center|justify)\](.*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');C=C.replace(/\[\*\](.*?)(?=\[\*\]|\[\/list\])/gi,"<li>$1</li>");C=C.replace(/\[list\]/gi,"<ul>");C=C.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');C=C.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');C=C.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">');C=C.replace(/\[\/list]\n?/gi,"</ul>\n");C=C.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(D,E){return"[table]"+$.trim(E)+"[/table]"});C=C.replace(/\[table\]/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');C=C.replace(/\[\/table\]/gi,"</table>");C=C.replace(/\[tr\]/gi,"<tr>");C=C.replace(/\[\/tr\]/gi,"</tr>");C=C.replace(/\[td\]/gi,"<td>");C=C.replace(/\[\/td\]/gi,"</td>");C=C.replace(/<td>([\S\s]*?)<\/td>/gi,function(D,F){var E=$.trim(F);if(!E.length){E="​"}return"<td>"+E+"</td>"});var c=this.wutil.getOption("woltlab.attachmentUrl");if(c){var g=this.wbbcode._getImageAttachmentIDs();C=C.replace(/\[attach=(\d+)(,[^\]]*)?\]\[\/attach\]/g,function(E,F,G){F=parseInt(F);if(WCF.inArray(F,g)){var D="";if(G){if(G.match(/^,'?(left|right)'?/)){D=' style="float: '+RegExp.$1+'"'}}return'<img src="'+c.replace(/987654321/,F)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+F+'"'+D+" />"}return E})}for(var v in __REDACTOR_SMILIES){var j=v.replace(/</g,"<").replace(/>/g,">");var i=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(j)+"(?=\\s|<|$)","gi");C=C.replace(i,'$1<img src="'+__REDACTOR_SMILIES[v]+'" class="smiley" alt="'+j+'" />')}C=C.replace(/(javascript):/gi,"$1<span></span>:");C=C.replace(/(\r|\r\n)/g,"\n");var x=[];var A=[];var h=C.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/);var d=WCF.getUUID();while(true){var o=false;for(var a=0;a<h.length;a++){var z=h[a];if(z==="[/quote]"){o=true;var e="";var m=h.slice(0,a);var b=false;while(m.length){var y=m.pop();e=y+e;if(y.match(/^\[quote/)){z=e+z;var k=WCF.getUUID();x.push({hashCode:k,content:z.replace(/\$/g,"$$$$")});A.push(k);z="@@"+k+"@@";b=true;break}}if(!b){m=h.slice(0,a);z=d}h=m.concat(z,h.slice(a+1));break}}if(!o){break}}C=h.join("");C=C.replace(new RegExp(d,"g"),"[/quote]");C=C.replace(/\n*$/,"");var f=C.split("\n");C="";for(var a=0,l=f.length;a<l;a++){var s=$.trim(f[a]);if(s.match(/^<([a-z]+)/)){if(!this.reIsBlock.test(RegExp.$1.toUpperCase())){s="<p>"+s+"</p>"}C+=s}else{if(!s){s="<br>"}else{if(s.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,A)){C+=s;continue}}}C+="<p>"+s+"</p>"}}if($.getLength(t)){for(var k in t){var w=new RegExp("@@"+k+"@@","g");C=C.replace(w,t[k])}C=C.replace(/\[tt\](.*?)\[\/tt\]/gi,'<span class="inlineCode">$1</span>')}C=C.replace(/\[code\][\S\s]*?\[\/code\]/,"<pre>$&</pre>");if(x.length){var B=function(D){return D.replace(/^['"]/,"").replace(/['"]$/,"")};var q=this;var p=function(D){return D.replace(/\[quote(=['"].+['"])?\]([\S\s]*)\[\/quote\]/gi,function(G,F,I){var M="";var H="";if(F){F=F.substr(1);F=F.split(",");switch(F.length){case 1:M=F[0];break;case 2:M=F[0];H=F[1];break}M=WCF.String.escapeHTML(B($.trim(M)));H=WCF.String.escapeHTML(B($.trim(H)))}var N='<blockquote class="quoteBox" cite="'+H+'" data-author="'+M+'"><div class="container containerPadding"><header contenteditable="false"><h3>'+q.wbbcode._buildQuoteHeader(M,H)+'</h3><a class="redactorQuoteEdit"></a></header>';I=$.trim(I);var E="";if(I.length){var L=I.split("\n");for(var K=0;K<L.length;K++){var J=L[K];if(J.length===0){J=q.opts.invisibleSpace}else{if(J.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,A)){E+=J;continue}}}E+="<div>"+J+"</div>"}}else{E="<div>"+q.opts.invisibleSpace+"</div>"}N+=E;N+="</div></blockquote>";return N})};for(var a=x.length-1;a>=0;a--){var u=x[a];var w=new RegExp("@@"+u.hashCode+"@@","g");C=C.replace(w,p(u.content))}}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:C});return C},_pasteBeforeCallback: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>");a=a.replace(/<(div|p)><br><\/(div|p)>/g,"<p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:a});return a},_pasteCallback:function(a){a=a.replace(/<p>([\s\S]*?)<\/p>/g,function(b,c){if(c.match(/<br( \/)?>$/)){return b}return"<p>"+c+"</p><p><br></p>"});a=a.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');a=a.replace(/\[\/size\]/g,"</span></p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:a});return a;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.wutil.getOption("woltlab.attachmentUrl");var c="[attach="+d+"][/attach]";var a=this.wbbcode._getImageAttachmentIDs();if(b&&WCF.inArray(d,a)){this.wutil.insertDynamic('<img src="'+b.replace(/987654321/,d)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+d+'" />',c)}else{this.wutil.insertDynamic(c)}},_getImageAttachmentIDs:function(){var a=this.wutil.getOption("woltlab.attachmentImageIDs")||[];if(a.length){delete this.opts.wAttachmentImageIDs;return a}var b={imageAttachmentIDs:[]};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),b);return b.imageAttachmentIDs},_keydownCallback:function(f){switch(f.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.TAB:case $.ui.keyCode.UP:break;default:return;break}this.selection.get();var a=$(this.selection.getCurrent());var e=this.selection.getParent();e=(e)?$(e):e;var k=(e)?e.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(f.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){if(k.length){var c=true;k.find("div > div").each(function(){if($(this).text().replace(/\u200B/,"").length){c=false;return false}});if(c){var g=window.getSelection();if(g.rangeCount){g.removeAllRanges()}var h=document.createRange();h.selectNode(k[0]);g.addRange(h);f.cancel=true}}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()){if(this.wutil.isEndOfElement(a[0])&&a.next("blockquote").length){var g=window.getSelection();if(g.rangeCount){g.removeAllRanges()}var h=document.createRange();h.selectNode(a.next()[0]);g.addRange(h);f.cancel=true}}break;case $.ui.keyCode.DOWN:if(a.next("blockquote").length){this.caret.setStart(a.next().find("> div > div:first"));f.cancel=true}else{if(e){if(e.next("blockquote").length){this.caret.setStart(e.next().find("> div > div:first"));f.cancel=true}else{if(k.length){var j=a.closest("div",k[0]);if(!j.next().length){if(k.next().length){this.caret.setStart(k.next())}else{this.wutil.setCaretAfter(k)}f.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(k.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.TAB:var d=this.selection.getBlock();if(!d||d.tagName!=="LI"){f.cancel=true}break;case $.ui.keyCode.UP:if(!e||!k.length){return}var j=a.closest("div",k[0]);var b=j.prev();if(b[0].tagName==="DIV"){return}else{if(b[0].tagName==="BLOCKQUOTE"){return}}var i=k.prev();if(i.length===0){this.wutil.setCaretBefore(k)}else{if(i[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(i.find("> div > div:last"))}else{if($.trim(i.html())==""){i.html(this.opts.invisibleSpace)}this.caret.setEnd(i)}}f.cancel=true;break}},_keyupCallback:function(a){if(a.event.which!==$.ui.keyCode.BACKSPACE&&a.event.which!==$.ui.keyCode.DELETE){return}this.$editor.find("blockquote").each(function(b,d){var c=$(d);if(!c.find("> div > header").length){c.remove()}})},_observeQuotes:function(){this.$editor.find(".redactorQuoteEdit:not(.jsRedactorQuoteEdit)").addClass("jsRedactorQuoteEdit").click($.proxy(this.wbbcode._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"),false);$(".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);$('<div contenteditable="true" />').appendTo(document.body).focus().remove()},_openQuoteEditOverlay:function(a,c){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(c?"insert":"edit")),400);var b=this.modal.createActionButton(this.lang.get("save"));if(c){b.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();var d=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.wbbcode.insertQuoteBBCode(e,d);this.modal.close()},this))}else{$("#redactorQuoteAuthor").val(a.data("author"));$("#redactorQuoteLink").val(WCF.String.unescapeHTML(a.attr("cite")));b.click($.proxy(function(){var d=$("#redactorQuoteAuthor").val();a.data("author",d);a.attr("data-author",d);a.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this.wbbcode._updateQuoteHeader(a);this.modalClose()},this))}this.modal.show()},_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.wbbcode._buildQuoteHeader(c,a))},insertQuoteBBCode:function(c,h,d,e){var g="[quote]";var a="[/quote]";if(c){if(h){g="[quote='"+c+"','"+h+"']"}else{g="[quote='"+c+"']"}}if(this.wutil.inWysiwygMode()){var f=(e)?this.wbbcode.convertToHtml(e):"";var i=WCF.getUUID();var b=this.wbbcode.convertToHtml(g+i+a);b=b.replace(i,f);b=b.replace(/(<p>)?<blockquote/,'$1<blockquote id="'+i+'"');this.insert.html(b,false);var j=this.$editor.find("#"+i);if(j.length){j.removeAttr("id");this.wutil.setCaretAfter(j[0])}this.wbbcode._observeQuotes();this.$toolbar.find("a.re-__wcf_quote").addClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(g+e+a)}},_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},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,true)}}};
// wbutton.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbutton=function(){return{_bbcodes:{},init:function(){this._bbcodes={};for(var h=0,e=__REDACTOR_BUTTONS.length;h<e;h++){this.wbutton._addBBCodeButton(__REDACTOR_BUTTONS[h])}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 d={fontcolor:WCF.Language.get("wcf.bbcode.button.fontColor"),fontfamily:WCF.Language.get("wcf.bbcode.button.fontFamily"),fontsize:WCF.Language.get("wcf.bbcode.button.fontSize"),image:WCF.Language.get("wcf.bbcode.button.image"),subscript:WCF.Language.get("wcf.bbcode.button.subscript"),superscript:WCF.Language.get("wcf.bbcode.button.superscript")};var b=this.wutil.getOption("buttons");var g="";for(var h=0,e=b.length;h<e;h++){var c=b[h];if(c=="separator"){this.button.get(g).parent().addClass("separator");continue}var f=this.button.get(c);if(f.length){if(a[c]){this.button.setAwesome(c,a[c])}if(c==="table"&&g){f.parent().insertAfter(this.button.get(g).parent())}}else{this.wbutton._addCoreButton(c,(d[c]?d[c]:null),(a[c]?a[c]:null),g)}g=c}this.button.addCallback(this.button.get("image"),$.proxy(this.wbutton.insertImage,this))},_addCoreButton:function(b,c,a,d){var f={title:(c===null?b:c)};if(b==="subscript"||b==="superscript"){f.command=b}var e=this.button.build(b,f);$("<li />").append(e).insertAfter(this.button.get(d).parent());if(a!==null){this.button.setAwesome(b,a)}},_addBBCodeButton:function(b){var c="__wcf_"+b.name;var a=this.button.add(c,b.label);this.button.addCallback(a,this.wbutton._insertBBCode);this._bbcodes[c]=b.name;if(b.icon.match(/^fa\-[a-z\-]+$/)){this.button.setAwesome(c,b.icon)}else{a.css("background-image","url("+__REDACTOR_ICON_PATH+b.icon+")")}},_insertBBCode:function(a){var d=this._bbcodes[a];var b={buttonName:a,cancel:false};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","insertBBCode_"+d+"_"+this.$textarea.wcfIdentify(),b);if(b.cancel===false){var c=this.selection.getHtml();if(false&&d==="tt"){var e=(this.selection.getParent())?$(this.selection.getParent()):null;if(e&&e.closest("inline.inlineCode",this.$editor.get()[0]).length){this.inline.toggleClass("inlineCode")}else{this.inline.toggleClass("inlineCode")}}else{this.insert.html("["+d+"]"+c+this.selection.getMarkerAsHtml()+"[/"+d+"]",false);this.selection.restore()}}event.preventDefault();return false},insertImage:function(){this.image.show()},_insertImage:function(){var d=$("#redactor-image-link-source");var b=d.val().trim();if(b.length){this.buffer.set();var c=$("#redactor-image-align").val();var a="";if(c==="left"||c==="right"){a=' style="float: '+c+'"'}this.insert.html('<img src="'+b+'"'+a+">",false);this.modal.close();this.observe.images()}else{if(!d.next("small.innerError")){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(d)}}}}};
// wfontcolor.js