MediaWiki:Common.js: Difference between revisions

From Vixen Village
Created page with "Any JavaScript here will be loaded for all users on every page load.: // Fancy arrows go click click. Maybe. var arrows = document.querySelectorAll('.arrow'); arrows.forEach(function(arr) { arr.addEventListener('click', function(event) { this.classList.toggle('down'); }); }); // This is a bbcode parser. It's a horrible mess and it needs a bunch more testing, which is why I'm sticking it here so I can test it a bunch. <3 "use strict";var _get=function t(e..."
 
No edit summary
 
Line 9: Line 9:
   });
   });
});
});
// Delicious emojis.
mw.loader.using('mediawiki.util', function() {
  var twemojiScript = document.createElement('script');
  twemojiScript.src = 'https://unpkg.com/twemoji@latest/dist/twemoji.min.js';
  twemojiScript.onload = function() {
    twemoji.parse(document.body, {
      folder: 'svg',
      ext: '.svg'
    });
  };
  document.head.appendChild(twemojiScript);
});


// This is a bbcode parser. It's a horrible mess and it needs a bunch more testing, which is why I'm sticking it here so I can test it a bunch. <3
// This is a bbcode parser. It's a horrible mess and it needs a bunch more testing, which is why I'm sticking it here so I can test it a bunch. <3


"use strict";var _get=function t(e,o,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,o);if(void 0===n){var i=Object.getPrototypeOf(e);return null===i?void 0:t(i,o,r)}if("value"in n)return n.value;var s=n.get;return void 0!==s?s.call(r):void 0},_createClass=function(){function t(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,o,r){return o&&t(e.prototype,o),r&&t(e,r),e}}();function _defineProperty(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var enableWarnings=document.getElementsByClassName("warningbox").length>0,etarget=void 0;if(enableWarnings){var container=document.getElementsByClassName("warningbox")[0];(etarget=document.createElement("div")).style.fontSize="0.75rem",container.appendChild(etarget)}else etarget=new DocumentFragment;var active_source=void 0;function warning(t){etarget.appendChild(function t(e){if(e.child){var o=t(e.child),r=document.createElement("span");r.innerText="which happened somewhere around: ",o.appendChild(r);var n=document.createElement("div");return n.style.maxHeight="80px",n.style.padding="1em",n.style.overflowY="scroll",n.innerText=active_source.slice(e.start,e.end),o.appendChild(n),o}var i=document.createElement("div");i.innerHTML+='Error! <div style="padding: 1em;">',i.textContent+=e.e,i.innerHTML+="</div> Error happened while parsing: ";var s=document.createElement("div");return s.style.maxHeight="80px",s.style.padding="1em",s.style.overflowY="scroll",s.innerText=active_source.slice(e.start,e.end),i.appendChild(s),i}(t))}var BBCodeError=function(){function t(e,o,r,n){_classCallCheck(this,t),this.start=e,this.end=o,this.child=r,this.e=n}return _createClass(t,[{key:"toString",value:function(){return this.child?this.child.toString():this.e}}]),t}(),BBCodeNode=function(){function t(e,o,r,n,i){_classCallCheck(this,t),this.tag=e,this.param=o,this.content=r,this.start=n,this.end=i}return _createClass(t,[{key:"becomeSubType",value:function(){return this.constructor!==t|""===this.tag?this:supportedTags[this.tag.toLowerCase()]?new(supportedTags[this.tag.toLowerCase()])(this.tag,this.param,this.content,this.start,this.end):(warning(new BBCodeError(this.start,this.end,void 0,"Invalid tag with name "+this.tag)),this)}},{key:"toHTML",value:function(){var t=this;return this.content.map(function(e){try{return e.toHTML()}catch(e){return warning(new BBCodeError(Math.max(t.start,e.start-100),Math.min(t.end,e.end+100),e,"")),"<span>[[Error: "+e.toString()+"]]</span>"}}).join("\n")}},{key:"createSpan",value:function(t){return document.createElement("span")}},{key:"createDiv",value:function(t){return document.createElement("div")}}]),t}(),supportedTags=_defineProperty({ruby:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){if(void 0===this.param||""===this.param)throw new BBCodeError(this.start,this.end,void 0,"no text provided for the ruby tag");return"<ruby>"+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"<rt>"+this.param+"</rt></ruby>"}}]),e}(),b:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-bold">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),heading:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-heading">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),i:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-italic">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sup:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sup">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sub:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sub">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),small:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-small">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),big:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-big">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),u:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-underline">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),s:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-strikethrough">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),hr:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<hr/>"}}]),e}(),br:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<br/>"}}]),e}(),img:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){throw new BBCodeError(this.start,this.end,void 0,"[img] is not supported, use mediawiki's image syntax instead.")}}]),e}(),color:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this.createSpan(),o=this.param.toLowerCase().trim();if(-1!==["white","black","red","blue","yellow","green","pink","gray","orange","purple","brown","cyan"].indexOf(o))t.style.color=o;else{if(!o.match(/[#][0-9a-f]{6}([0-9a-f]{2})?/))throw new BBCodeError(this.start,this.end,void 0,"Invalid color: "+o);t.style.color=o}return'<span style="color: '+o+'">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),indent:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-indent">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),left:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-left">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),center:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-center">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),right:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-right">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),justify:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),col:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),e}(),row:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this;if(this.content=this.content.filter(function(t){return"col"===t.tag}),this.content.length<1)throw new BBCodeError(this.start,this.end,void 0,"Need at least 1 column in a row");if(this.content.length>3)throw new BBCodeError(this.start,this.end,void 0,"Can't have more than 3 columns in a row");return this.createDiv().classList.add("bb-row"),'<div class="bb-row">'+this.content.map(function(e){var o=void 0;switch(e.param.trim()){case"small":case"1":o="bb-col-small bb-col-small-large-width bb-col-small-tiny-width";break;case"medium":case"2":o="bb-col-medium bb-col-medium-large-width bb-col-medium-tiny-width";break;case"":case"large":case"3":o="bb-col-large bb-col-large-large-width bb-col-large-tiny-width";break;default:throw new BBCodeError(t.start,t.end,void 0,"Invalid column size: "+e.param)}return'<div class="'+o+'">'+e.toHTML()+"</div>"}).join("")+"</div>"}}]),e}()},"justify",function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}()),BBCodeFragment=function(t){function e(t){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t||[]))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"becomeSubType",value:function(){return new BBCodeNode(this.tag,this.param,this.content.map(function(t){try{return t.becomeSubType()}catch(e){return warning(e),new BBCodePlainText("[[Error: "+e.toString()+"]]",t.start,t.end)}}),this.start,this.end).becomeSubType()}}]),e}(),BBCodePlainText=function(t){function e(t,o,r){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t,o,r))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(t){return this.content}}]),e}(),BBCodeStream=function(){function t(e){_classCallCheck(this,t),this.source=e,this.index=0,this.lookahead=void 0,this.line=1,this.column=1,this.rolloverColumn=-1}return _createClass(t,[{key:"peekWithoutWhitespace",value:function(){for(;" "==this.peek();)this.read();return this.peek()}},{key:"getLine",value:function(){return this.lookahead&&1==this.column?this.line-1:this.line}},{key:"getColumn",value:function(){return this.lookahead&&1==this.column?this.rolloverColumn:this.column}},{key:"peek",value:function(){return this.lookahead?this.lookahead:(this.lookahead=this.read(),this.lookahead)}},{key:"seek",value:function(t){this.index=t,this.lookahead=void 0}},{key:"read",value:function(){if(void 0!==this.lookahead){var t=this.lookahead;return this.lookahead=void 0,t}var e=this.source[this.index++];return"\n"==e?(this.line+=1,this.rolloverColumn=this.column,this.column=1):this.column+=1,e}}]),t}();function parseBBCodeTag(t){var e=t.index,o="";for(t.peekWithoutWhitespace();t.peek().match(/[a-zA-Z]/);)o+=t.read();if(!t.peek()||""==o)throw t.seek(e),"Never found a closing bracket";return o}function parseBBCodeParam(t){var e=t.index,o="";for("="==t.peek()&&t.read(),t.peekWithoutWhitespace();t.peek()&&"]"!=t.peek();)o+=t.read();if(!t.peek())throw t.seek(e),"Never closed a parameter";return o}var nobr=0;function parseBBCode(t,e,o,r){o=void 0===o?"":o,(e=void 0===e||e)&&(nobr=0);var n=t.index,i=void 0;for(e?i=new BBCodeFragment:supportedTags.hasOwnProperty(o.toLowerCase())?i=new(supportedTags[o.toLowerCase()])(o,r,[],0,0):(warning(new BBCodeError(t.index,t.index,void 0,"Invalid tag with name "+o)),i=new BBCodeFragment);void 0!==t.peek();){var s=t.read();if("["==s||"\n"==s)if("\n"==s&&nobr>0)nobr--;else{var a=t.index-1;if(n!=a){var c=t.source.slice(n,a);i.content.push(new BBCodePlainText(c,n,a)),n=a}if("\n"!=s){var l=t.index-1;if("/"==t.peekWithoutWhitespace()){if(t.read(),"]"==t.peekWithoutWhitespace())continue;if(e)continue;var u=parseBBCodeTag(t);if(void 0===u||"]"!=t.peekWithoutWhitespace()){t.read(),i.content.push(new BBCodePlainText(t.source.slice(l,t.index),l,t.index)),n=t.index;continue}if(u.toLowerCase()!==o){warning(new BBCodeError(l,t.index,void 0,"Incorrectly matched tag: "+u+" vs "+o)),t.seek(l);break}t.read();break}var p=void 0;try{p=parseBBCodeTag(t)}catch(e){t.seek(l+1);continue}var h=p.toLowerCase();if("hr"!=h&&"br"!=h&&"nobr"!=h){var d=void 0;try{d="="==t.peekWithoutWhitespace()?parseBBCodeParam(t):""}catch(e){t.seek(l+1);continue}if("]"==t.peekWithoutWhitespace()){t.read();var _=void 0;if("noparse"==p.toLowerCase()){for(var f=t.index,y=void 0;void 0!==t.peek();){if("["==t.read())if(y=t.index-1,"/"==t.peekWithoutWhitespace())if("noparse"==t.source.substring(t.index,t.index+7).toLowerCase()){if(t.seek(t.index+7),"]"==t.peekWithoutWhitespace()){t.read();break}y=void 0}else y=void 0;else y=void 0}void 0===y&&(y=t.source.length),_=new BBCodePlainText(t.source.substring(f,y),f,y)}else(_=parseBBCode(t,!1,p,d)).start=l,_.end=t.index;i.content.push(_),n=t.index}else t.seek(l+1)}else{if("]"!=t.peekWithoutWhitespace())continue;t.read(),"hr"==h?i.content.push(new supportedTags.hr("hr","",[],l,t.index)):"br"==h?i.content.push(new supportedTags.br("br","",[],l,t.index)):nobr+=1,n=t.index}}else i.content.push(new BBCodePlainText("<br/>",t.index-1,t.index))}}if(e&&n<t.source.length){var b=t.source.slice(n,t.source.length);i.content.push(new BBCodePlainText(b,n,t.source.length))}return e?i.becomeSubType():i}function apply(){document.querySelectorAll(".bbcode-target").forEach(function(t){var e=void 0;active_source=t.innerHTML.replace(/<p>/g,"").replace(/<\/p>/g,"\n").replace(/(<[\/]?t([dr]|able([ ]*class=[^>]*?)?)>)[ \n]+/gm,"$1");try{e=parseBBCode(new BBCodeStream(active_source))}catch(t){return void warning("An error happened in such a way that the bbcode parser had to completely give up. Error: "+t)}var o=document.createElement("div");o.innerHTML=e.toHTML(),t.parentNode.replaceChild(o,t)})}apply();
"use strict";var _get=function t(e,o,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,o);if(void 0===n){var i=Object.getPrototypeOf(e);return null===i?void 0:t(i,o,r)}if("value"in n)return n.value;var s=n.get;return void 0!==s?s.call(r):void 0},_createClass=function(){function t(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,o,r){return o&&t(e.prototype,o),r&&t(e,r),e}}();function _defineProperty(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var enableWarnings=document.getElementsByClassName("warningbox").length>0,etarget=void 0;if(enableWarnings){var container=document.getElementsByClassName("warningbox")[0];(etarget=document.createElement("div")).style.fontSize="0.75rem",container.appendChild(etarget)}else etarget=new DocumentFragment;var active_source=void 0;function warning(t){etarget.appendChild(function t(e){if(e.child){var o=t(e.child),r=document.createElement("span");r.innerText="which happened somewhere around: ",o.appendChild(r);var n=document.createElement("div");return n.style.maxHeight="80px",n.style.padding="1em",n.style.overflowY="scroll",n.innerText=active_source.slice(e.start,e.end),o.appendChild(n),o}var i=document.createElement("div");i.innerHTML+='Error! <div style="padding: 1em;">',i.textContent+=e.e,i.innerHTML+="</div> Error happened while parsing: ";var s=document.createElement("div");return s.style.maxHeight="80px",s.style.padding="1em",s.style.overflowY="scroll",s.innerText=active_source.slice(e.start,e.end),i.appendChild(s),i}(t))}var BBCodeError=function(){function t(e,o,r,n){_classCallCheck(this,t),this.start=e,this.end=o,this.child=r,this.e=n}return _createClass(t,[{key:"toString",value:function(){return this.child?this.child.toString():this.e}}]),t}(),BBCodeNode=function(){function t(e,o,r,n,i){_classCallCheck(this,t),this.tag=e,this.param=o,this.content=r,this.start=n,this.end=i}return _createClass(t,[{key:"becomeSubType",value:function(){return this.constructor!==t|""===this.tag?this:supportedTags[this.tag.toLowerCase()]?new(supportedTags[this.tag.toLowerCase()])(this.tag,this.param,this.content,this.start,this.end):(warning(new BBCodeError(this.start,this.end,void 0,"Invalid tag with name "+this.tag)),this)}},{key:"toHTML",value:function(){var t=this;return this.content.map(function(e){try{return e.toHTML()}catch(e){return warning(new BBCodeError(Math.max(t.start,e.start-100),Math.min(t.end,e.end+100),e,"")),"<span>[[Error: "+e.toString()+"]]</span>"}}).join("\n")}},{key:"createSpan",value:function(t){return document.createElement("span")}},{key:"createDiv",value:function(t){return document.createElement("div")}}]),t}(),supportedTags=_defineProperty({ruby:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){if(void 0===this.param||""===this.param)throw new BBCodeError(this.start,this.end,void 0,"no text provided for the ruby tag");return"<ruby>"+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"<rt>"+this.param+"</rt></ruby>"}}]),e}(),b:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-bold">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),heading:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-heading">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),i:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-italic">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sup:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sup">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sub:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sub">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),small:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-small">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),big:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-big">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),u:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-underline">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),s:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-strikethrough">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),hr:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<hr/>"}}]),e}(),br:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<br/>"}}]),e}(),img:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){throw new BBCodeError(this.start,this.end,void 0,"[img] is not supported, use mediawiki's image syntax instead.")}}]),e}(),color:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this.createSpan(),o=this.param.toLowerCase().trim();if(-1!==["white","black","red","blue","yellow","green","pink","gray","orange","purple","brown","cyan"].indexOf(o))t.style.color=o;else{if(!o.match(/[#][0-9a-f]{6}([0-9a-f]{2})?/))throw new BBCodeError(this.start,this.end,void 0,"Invalid color: "+o);t.style.color=o}return'<span style="color: '+o+'">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),indent:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-indent">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),left:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-left">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),center:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-center">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),right:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-right">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),justify:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),col:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),e}(),row:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this;if(this.content=this.content.filter(function(t){return"col"===t.tag}),this.content.length<1)throw new BBCodeError(this.start,this.end,void 0,"Need at least 1 column in a row");if(this.content.length>3)throw new BBCodeError(this.start,this.end,void 0,"Can't have more than 3 columns in a row");return this.createDiv().classList.add("bb-row"),'<div class="bb-row">'+this.content.map(function(e){var o=void 0;switch(e.param.trim()){case"small":case"1":o="bb-col-small bb-col-small-large-width bb-col-small-tiny-width";break;case"medium":case"2":o="bb-col-medium bb-col-medium-large-width bb-col-medium-tiny-width";break;case"":case"large":case"3":o="bb-col-large bb-col-large-large-width bb-col-large-tiny-width";break;default:throw new BBCodeError(t.start,t.end,void 0,"Invalid column size: "+e.param)}return'<div class="'+o+'">'+e.toHTML()+"</div>"}).join("")+"</div>"}}]),e}()},"justify",function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}()),BBCodeFragment=function(t){function e(t){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t||[]))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"becomeSubType",value:function(){return new BBCodeNode(this.tag,this.param,this.content.map(function(t){try{return t.becomeSubType()}catch(e){return warning(e),new BBCodePlainText("[[Error: "+e.toString()+"]]",t.start,t.end)}}),this.start,this.end).becomeSubType()}}]),e}(),BBCodePlainText=function(t){function e(t,o,r){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t,o,r))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(t){return this.content}}]),e}(),BBCodeStream=function(){function t(e){_classCallCheck(this,t),this.source=e,this.index=0,this.lookahead=void 0,this.line=1,this.column=1,this.rolloverColumn=-1}return _createClass(t,[{key:"peekWithoutWhitespace",value:function(){for(;" "==this.peek();)this.read();return this.peek()}},{key:"getLine",value:function(){return this.lookahead&&1==this.column?this.line-1:this.line}},{key:"getColumn",value:function(){return this.lookahead&&1==this.column?this.rolloverColumn:this.column}},{key:"peek",value:function(){return this.lookahead?this.lookahead:(this.lookahead=this.read(),this.lookahead)}},{key:"seek",value:function(t){this.index=t,this.lookahead=void 0}},{key:"read",value:function(){if(void 0!==this.lookahead){var t=this.lookahead;return this.lookahead=void 0,t}var e=this.source[this.index++];return"\n"==e?(this.line+=1,this.rolloverColumn=this.column,this.column=1):this.column+=1,e}}]),t}();function parseBBCodeTag(t){var e=t.index,o="";for(t.peekWithoutWhitespace();t.peek().match(/[a-zA-Z]/);)o+=t.read();if(!t.peek()||""==o)throw t.seek(e),"Never found a closing bracket";return o}function parseBBCodeParam(t){var e=t.index,o="";for("="==t.peek()&&t.read(),t.peekWithoutWhitespace();t.peek()&&"]"!=t.peek();)o+=t.read();if(!t.peek())throw t.seek(e),"Never closed a parameter";return o}var nobr=0;function parseBBCode(t,e,o,r){o=void 0===o?"":o,(e=void 0===e||e)&&(nobr=0);var n=t.index,i=void 0;for(e?i=new BBCodeFragment:supportedTags.hasOwnProperty(o.toLowerCase())?i=new(supportedTags[o.toLowerCase()])(o,r,[],0,0):(warning(new BBCodeError(t.index,t.index,void 0,"Invalid tag with name "+o)),i=new BBCodeFragment);void 0!==t.peek();){var s=t.read();if("["==s||"\n"==s)if("\n"==s&&nobr>0)nobr--;else{var a=t.index-1;if(n!=a){var c=t.source.slice(n,a);i.content.push(new BBCodePlainText(c,n,a)),n=a}if("\n"!=s){var l=t.index-1;if("/"==t.peekWithoutWhitespace()){if(t.read(),"]"==t.peekWithoutWhitespace())continue;if(e)continue;var u=parseBBCodeTag(t);if(void 0===u||"]"!=t.peekWithoutWhitespace()){t.read(),i.content.push(new BBCodePlainText(t.source.slice(l,t.index),l,t.index)),n=t.index;continue}if(u.toLowerCase()!==o){warning(new BBCodeError(l,t.index,void 0,"Incorrectly matched tag: "+u+" vs "+o)),t.seek(l);break}t.read();break}var p=void 0;try{p=parseBBCodeTag(t)}catch(e){t.seek(l+1);continue}var h=p.toLowerCase();if("hr"!=h&&"br"!=h&&"nobr"!=h){var d=void 0;try{d="="==t.peekWithoutWhitespace()?parseBBCodeParam(t):""}catch(e){t.seek(l+1);continue}if("]"==t.peekWithoutWhitespace()){t.read();var _=void 0;if("noparse"==p.toLowerCase()){for(var f=t.index,y=void 0;void 0!==t.peek();){if("["==t.read())if(y=t.index-1,"/"==t.peekWithoutWhitespace())if("noparse"==t.source.substring(t.index,t.index+7).toLowerCase()){if(t.seek(t.index+7),"]"==t.peekWithoutWhitespace()){t.read();break}y=void 0}else y=void 0;else y=void 0}void 0===y&&(y=t.source.length),_=new BBCodePlainText(t.source.substring(f,y),f,y)}else(_=parseBBCode(t,!1,p,d)).start=l,_.end=t.index;i.content.push(_),n=t.index}else t.seek(l+1)}else{if("]"!=t.peekWithoutWhitespace())continue;t.read(),"hr"==h?i.content.push(new supportedTags.hr("hr","",[],l,t.index)):"br"==h?i.content.push(new supportedTags.br("br","",[],l,t.index)):nobr+=1,n=t.index}}else i.content.push(new BBCodePlainText("<br/>",t.index-1,t.index))}}if(e&&n<t.source.length){var b=t.source.slice(n,t.source.length);i.content.push(new BBCodePlainText(b,n,t.source.length))}return e?i.becomeSubType():i}function apply(){document.querySelectorAll(".bbcode-target").forEach(function(t){var e=void 0;active_source=t.innerHTML.replace(/<p>/g,"").replace(/<\/p>/g,"\n").replace(/(<[\/]?t([dr]|able([ ]*class=[^>]*?)?)>)[ \n]+/gm,"$1");try{e=parseBBCode(new BBCodeStream(active_source))}catch(t){return void warning("An error happened in such a way that the bbcode parser had to completely give up. Error: "+t)}var o=document.createElement("div");o.innerHTML=e.toHTML(),t.parentNode.replaceChild(o,t)})}apply();

Latest revision as of 13:00, 4 November 2025

/* Any JavaScript here will be loaded for all users on every page load. */

// Fancy arrows go click click. Maybe.
var arrows = document.querySelectorAll('.arrow');

arrows.forEach(function(arr) {
  arr.addEventListener('click', function(event) {
    this.classList.toggle('down');
  });
});

// Delicious emojis.
mw.loader.using('mediawiki.util', function() {
  var twemojiScript = document.createElement('script');
  twemojiScript.src = 'https://unpkg.com/twemoji@latest/dist/twemoji.min.js';
  twemojiScript.onload = function() {
    twemoji.parse(document.body, {
      folder: 'svg',
      ext: '.svg'
    });
  };
  document.head.appendChild(twemojiScript);
});


// This is a bbcode parser. It's a horrible mess and it needs a bunch more testing, which is why I'm sticking it here so I can test it a bunch. <3

"use strict";var _get=function t(e,o,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,o);if(void 0===n){var i=Object.getPrototypeOf(e);return null===i?void 0:t(i,o,r)}if("value"in n)return n.value;var s=n.get;return void 0!==s?s.call(r):void 0},_createClass=function(){function t(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,o,r){return o&&t(e.prototype,o),r&&t(e,r),e}}();function _defineProperty(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var enableWarnings=document.getElementsByClassName("warningbox").length>0,etarget=void 0;if(enableWarnings){var container=document.getElementsByClassName("warningbox")[0];(etarget=document.createElement("div")).style.fontSize="0.75rem",container.appendChild(etarget)}else etarget=new DocumentFragment;var active_source=void 0;function warning(t){etarget.appendChild(function t(e){if(e.child){var o=t(e.child),r=document.createElement("span");r.innerText="which happened somewhere around: ",o.appendChild(r);var n=document.createElement("div");return n.style.maxHeight="80px",n.style.padding="1em",n.style.overflowY="scroll",n.innerText=active_source.slice(e.start,e.end),o.appendChild(n),o}var i=document.createElement("div");i.innerHTML+='Error! <div style="padding: 1em;">',i.textContent+=e.e,i.innerHTML+="</div> Error happened while parsing: ";var s=document.createElement("div");return s.style.maxHeight="80px",s.style.padding="1em",s.style.overflowY="scroll",s.innerText=active_source.slice(e.start,e.end),i.appendChild(s),i}(t))}var BBCodeError=function(){function t(e,o,r,n){_classCallCheck(this,t),this.start=e,this.end=o,this.child=r,this.e=n}return _createClass(t,[{key:"toString",value:function(){return this.child?this.child.toString():this.e}}]),t}(),BBCodeNode=function(){function t(e,o,r,n,i){_classCallCheck(this,t),this.tag=e,this.param=o,this.content=r,this.start=n,this.end=i}return _createClass(t,[{key:"becomeSubType",value:function(){return this.constructor!==t|""===this.tag?this:supportedTags[this.tag.toLowerCase()]?new(supportedTags[this.tag.toLowerCase()])(this.tag,this.param,this.content,this.start,this.end):(warning(new BBCodeError(this.start,this.end,void 0,"Invalid tag with name "+this.tag)),this)}},{key:"toHTML",value:function(){var t=this;return this.content.map(function(e){try{return e.toHTML()}catch(e){return warning(new BBCodeError(Math.max(t.start,e.start-100),Math.min(t.end,e.end+100),e,"")),"<span>[[Error: "+e.toString()+"]]</span>"}}).join("\n")}},{key:"createSpan",value:function(t){return document.createElement("span")}},{key:"createDiv",value:function(t){return document.createElement("div")}}]),t}(),supportedTags=_defineProperty({ruby:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){if(void 0===this.param||""===this.param)throw new BBCodeError(this.start,this.end,void 0,"no text provided for the ruby tag");return"<ruby>"+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"<rt>"+this.param+"</rt></ruby>"}}]),e}(),b:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-bold">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),heading:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-heading">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),i:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-italic">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sup:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sup">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),sub:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-sub">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),small:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-small">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),big:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-big">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),u:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-underline">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),s:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<span class="bb-strikethrough">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),hr:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<hr/>"}}]),e}(),br:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return"<br/>"}}]),e}(),img:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){throw new BBCodeError(this.start,this.end,void 0,"[img] is not supported, use mediawiki's image syntax instead.")}}]),e}(),color:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this.createSpan(),o=this.param.toLowerCase().trim();if(-1!==["white","black","red","blue","yellow","green","pink","gray","orange","purple","brown","cyan"].indexOf(o))t.style.color=o;else{if(!o.match(/[#][0-9a-f]{6}([0-9a-f]{2})?/))throw new BBCodeError(this.start,this.end,void 0,"Invalid color: "+o);t.style.color=o}return'<span style="color: '+o+'">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</span>"}}]),e}(),indent:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-indent">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),left:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-left">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),center:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-center">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),right:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-right">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),justify:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}(),col:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),e}(),row:function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){var t=this;if(this.content=this.content.filter(function(t){return"col"===t.tag}),this.content.length<1)throw new BBCodeError(this.start,this.end,void 0,"Need at least 1 column in a row");if(this.content.length>3)throw new BBCodeError(this.start,this.end,void 0,"Can't have more than 3 columns in a row");return this.createDiv().classList.add("bb-row"),'<div class="bb-row">'+this.content.map(function(e){var o=void 0;switch(e.param.trim()){case"small":case"1":o="bb-col-small bb-col-small-large-width bb-col-small-tiny-width";break;case"medium":case"2":o="bb-col-medium bb-col-medium-large-width bb-col-medium-tiny-width";break;case"":case"large":case"3":o="bb-col-large bb-col-large-large-width bb-col-large-tiny-width";break;default:throw new BBCodeError(t.start,t.end,void 0,"Invalid column size: "+e.param)}return'<div class="'+o+'">'+e.toHTML()+"</div>"}).join("")+"</div>"}}]),e}()},"justify",function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(){return'<div class="bb-justify">'+_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toHTML",this).call(this)+"</div>"}}]),e}()),BBCodeFragment=function(t){function e(t){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t||[]))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"becomeSubType",value:function(){return new BBCodeNode(this.tag,this.param,this.content.map(function(t){try{return t.becomeSubType()}catch(e){return warning(e),new BBCodePlainText("[[Error: "+e.toString()+"]]",t.start,t.end)}}),this.start,this.end).becomeSubType()}}]),e}(),BBCodePlainText=function(t){function e(t,o,r){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"","",t,o,r))}return _inherits(e,BBCodeNode),_createClass(e,[{key:"toHTML",value:function(t){return this.content}}]),e}(),BBCodeStream=function(){function t(e){_classCallCheck(this,t),this.source=e,this.index=0,this.lookahead=void 0,this.line=1,this.column=1,this.rolloverColumn=-1}return _createClass(t,[{key:"peekWithoutWhitespace",value:function(){for(;" "==this.peek();)this.read();return this.peek()}},{key:"getLine",value:function(){return this.lookahead&&1==this.column?this.line-1:this.line}},{key:"getColumn",value:function(){return this.lookahead&&1==this.column?this.rolloverColumn:this.column}},{key:"peek",value:function(){return this.lookahead?this.lookahead:(this.lookahead=this.read(),this.lookahead)}},{key:"seek",value:function(t){this.index=t,this.lookahead=void 0}},{key:"read",value:function(){if(void 0!==this.lookahead){var t=this.lookahead;return this.lookahead=void 0,t}var e=this.source[this.index++];return"\n"==e?(this.line+=1,this.rolloverColumn=this.column,this.column=1):this.column+=1,e}}]),t}();function parseBBCodeTag(t){var e=t.index,o="";for(t.peekWithoutWhitespace();t.peek().match(/[a-zA-Z]/);)o+=t.read();if(!t.peek()||""==o)throw t.seek(e),"Never found a closing bracket";return o}function parseBBCodeParam(t){var e=t.index,o="";for("="==t.peek()&&t.read(),t.peekWithoutWhitespace();t.peek()&&"]"!=t.peek();)o+=t.read();if(!t.peek())throw t.seek(e),"Never closed a parameter";return o}var nobr=0;function parseBBCode(t,e,o,r){o=void 0===o?"":o,(e=void 0===e||e)&&(nobr=0);var n=t.index,i=void 0;for(e?i=new BBCodeFragment:supportedTags.hasOwnProperty(o.toLowerCase())?i=new(supportedTags[o.toLowerCase()])(o,r,[],0,0):(warning(new BBCodeError(t.index,t.index,void 0,"Invalid tag with name "+o)),i=new BBCodeFragment);void 0!==t.peek();){var s=t.read();if("["==s||"\n"==s)if("\n"==s&&nobr>0)nobr--;else{var a=t.index-1;if(n!=a){var c=t.source.slice(n,a);i.content.push(new BBCodePlainText(c,n,a)),n=a}if("\n"!=s){var l=t.index-1;if("/"==t.peekWithoutWhitespace()){if(t.read(),"]"==t.peekWithoutWhitespace())continue;if(e)continue;var u=parseBBCodeTag(t);if(void 0===u||"]"!=t.peekWithoutWhitespace()){t.read(),i.content.push(new BBCodePlainText(t.source.slice(l,t.index),l,t.index)),n=t.index;continue}if(u.toLowerCase()!==o){warning(new BBCodeError(l,t.index,void 0,"Incorrectly matched tag: "+u+" vs "+o)),t.seek(l);break}t.read();break}var p=void 0;try{p=parseBBCodeTag(t)}catch(e){t.seek(l+1);continue}var h=p.toLowerCase();if("hr"!=h&&"br"!=h&&"nobr"!=h){var d=void 0;try{d="="==t.peekWithoutWhitespace()?parseBBCodeParam(t):""}catch(e){t.seek(l+1);continue}if("]"==t.peekWithoutWhitespace()){t.read();var _=void 0;if("noparse"==p.toLowerCase()){for(var f=t.index,y=void 0;void 0!==t.peek();){if("["==t.read())if(y=t.index-1,"/"==t.peekWithoutWhitespace())if("noparse"==t.source.substring(t.index,t.index+7).toLowerCase()){if(t.seek(t.index+7),"]"==t.peekWithoutWhitespace()){t.read();break}y=void 0}else y=void 0;else y=void 0}void 0===y&&(y=t.source.length),_=new BBCodePlainText(t.source.substring(f,y),f,y)}else(_=parseBBCode(t,!1,p,d)).start=l,_.end=t.index;i.content.push(_),n=t.index}else t.seek(l+1)}else{if("]"!=t.peekWithoutWhitespace())continue;t.read(),"hr"==h?i.content.push(new supportedTags.hr("hr","",[],l,t.index)):"br"==h?i.content.push(new supportedTags.br("br","",[],l,t.index)):nobr+=1,n=t.index}}else i.content.push(new BBCodePlainText("<br/>",t.index-1,t.index))}}if(e&&n<t.source.length){var b=t.source.slice(n,t.source.length);i.content.push(new BBCodePlainText(b,n,t.source.length))}return e?i.becomeSubType():i}function apply(){document.querySelectorAll(".bbcode-target").forEach(function(t){var e=void 0;active_source=t.innerHTML.replace(/<p>/g,"").replace(/<\/p>/g,"\n").replace(/(<[\/]?t([dr]|able([ ]*class=[^>]*?)?)>)[ \n]+/gm,"$1");try{e=parseBBCode(new BBCodeStream(active_source))}catch(t){return void warning("An error happened in such a way that the bbcode parser had to completely give up. Error: "+t)}var o=document.createElement("div");o.innerHTML=e.toHTML(),t.parentNode.replaceChild(o,t)})}apply();