-/**\r
- * editor_plugin_src.js\r
- *\r
- * Copyright 2009, Moxiecode Systems AB\r
- * Released under LGPL License.\r
- *\r
- * License: http://tinymce.moxiecode.com/license\r
- * Contributing: http://tinymce.moxiecode.com/contributing\r
- */\r
-\r
-/* Macgirvin Aug-2010 changed from punbb to dfrn dialect */\r
-\r
-(function() {\r
- tinymce.create('tinymce.plugins.BBCodePlugin', {\r
- init : function(ed, url) {\r
- var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase();\r
-\r
- ed.onBeforeSetContent.add(function(ed, o) {\r
- o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
- });\r
-\r
- ed.onPostProcess.add(function(ed, o) {\r
- if (o.set)\r
- o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
-\r
- if (o.get)\r
- o.content = t['_' + dialect + '_html2bbcode'](o.content);\r
- });\r
- },\r
-\r
- getInfo : function() {\r
- return {\r
- longname : 'BBCode Plugin',\r
- author : 'Moxiecode Systems AB',\r
- authorurl : 'http://tinymce.moxiecode.com',\r
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',\r
- version : tinymce.majorVersion + "." + tinymce.minorVersion\r
- };\r
- },\r
-\r
- // Private methods\r
-\r
- // HTML -> BBCode in DFRN dialect\r
- _dfrn_html2bbcode : function(s) {\r
- s = tinymce.trim(s);\r
-\r
- function rep(re, str) {\r
-\r
-\r
-s = s.replace(re,str);\r
-\r
- //modify code to keep stuff intact within [code][/code] blocks\r
- //Waitman Gobble NO WARRANTY\r
-\r
-/* This doesn't seem to work well with\r
-[code]line1\r
-line2[/code]\r
-commenting out for now\r
-*/\r
-\r
-/*\r
- var o = new Array();\r
- var x = s.split("[code]");\r
- var i = 0;\r
-\r
- var si = "";\r
- si = x.shift();\r
- si = si.replace(re,str);\r
- o.push(si);\r
-\r
- for (i = 0; i < x.length; i++) {\r
- var no = new Array();\r
- var j = x.shift();\r
- var g = j.split("[/code]");\r
- no.push(g.shift());\r
- si = g.shift();\r
- si = si.replace(re,str);\r
- no.push(si);\r
- o.push(no.join("[/code]"));\r
- }\r
-\r
- s = o.join("[code]");\r
-*/\r
- };\r
-\r
-\r
-\r
-\r
- /* oembed */\r
- function _h2b_cb(match) {\r
- /*\r
- function s_h2b(data) {\r
- match = data;\r
- }\r
- $.ajax({\r
- type:"POST",\r
- url: 'oembed/h2b',\r
- data: {text: match},\r
- async: false,\r
- success: s_h2b,\r
- dataType: 'html'\r
- });\r
- */\r
- \r
- var f, g, tof = [], tor = [];\r
- var find_spanc = /<span [^>]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:<span[^>]*>(.*?)<\/span *>)*.*?)<\/span *>/ig;\r
- while (f = find_spanc.exec(match)) {\r
- var find_a = /<a([^>]* rel=[\"']oembed[\"'][^>]*)>.*?<\/a *>/ig;\r
- if (g = find_a.exec(f[1])) {\r
- var find_href = /href=[\"']([^\"']*)[\"']/ig;\r
- var m2 = find_href.exec(g[1]);\r
- if (m2[1]) {\r
- tof.push(f[0]);\r
- tor.push("[EMBED]" + m2[1] + "[/EMBED]");\r
- }\r
- }\r
- }\r
- for (var i = 0; i < tof.length; i++) match = match.replace(tof[i], tor[i]);\r
- \r
- return match;\r
- }\r
- if (s.indexOf('class="oembed')>=0){\r
- //alert("request oembed html2bbcode");\r
- s = _h2b_cb(s);\r
- }\r
- \r
- /* /oembed */\r
-\r
-\r
- // example: <strong> to [b]\r
- rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");\r
- rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");\r
- rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");\r
- rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");\r
- rep(/<font>(.*?)<\/font>/gi,"$1");\r
- rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");\r
- rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");\r
- rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");\r
- rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");\r
- rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");\r
-\r
- rep(/<ul class=\"listbullet\" style=\"list-style-type\: circle\;\">(.*?)<\/ul>/gi,"[list]$1[/list]");\r
- rep(/<ul class=\"listnone\" style=\"list-style-type\: none\;\">(.*?)<\/ul>/gi,"[list=]$1[/list]");\r
- rep(/<ul class=\"listdecimal\" style=\"list-style-type\: decimal\;\">(.*?)<\/ul>/gi,"[list=1]$1[/list]");\r
- rep(/<ul class=\"listlowerroman\" style=\"list-style-type\: lower-roman\;\">(.*?)<\/ul>/gi,"[list=i]$1[/list]");\r
- rep(/<ul class=\"listupperroman\" style=\"list-style-type\: upper-roman\;\">(.*?)<\/ul>/gi,"[list=I]$1[/list]");\r
- rep(/<ul class=\"listloweralpha\" style=\"list-style-type\: lower-alpha\;\">(.*?)<\/ul>/gi,"[list=a]$1[/list]");\r
- rep(/<ul class=\"listupperalpha\" style=\"list-style-type\: upper-alpha\;\">(.*?)<\/ul>/gi,"[list=A]$1[/list]");\r
- rep(/<li>(.*?)<\/li>/gi,'[li]$1[/li]');\r
-\r
- rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");\r
- rep(/<\/(strong|b)>/gi,"[/b]");\r
- rep(/<(strong|b)>/gi,"[b]");\r
- rep(/<\/(em|i)>/gi,"[/i]");\r
- rep(/<(em|i)>/gi,"[i]");\r
- rep(/<\/u>/gi,"[/u]");\r
- rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");\r
- rep(/<u>/gi,"[u]");\r
- rep(/<blockquote[^>]*>/gi,"[quote]");\r
- rep(/<\/blockquote>/gi,"[/quote]");\r
- rep(/<hr \/>/gi,"[hr]");\r
- rep(/<br (.*?)\/>/gi,"\n");\r
- rep(/<br\/>/gi,"\n");\r
- rep(/<br>/gi,"\n");\r
- rep(/<p>/gi,"");\r
- rep(/<\/p>/gi,"\n");\r
- rep(/ /gi," ");\r
- rep(/"/gi,"\"");\r
- rep(/</gi,"<");\r
- rep(/>/gi,">");\r
- rep(/&/gi,"&");\r
-\r
- return s; \r
- },\r
-\r
- // BBCode -> HTML from DFRN dialect\r
- _dfrn_bbcode2html : function(s) {\r
- s = tinymce.trim(s);\r
-\r
-\r
- function rep(re, str) {\r
-\r
-\r
- //modify code to keep stuff intact within [code][/code] blocks\r
- //Waitman Gobble NO WARRANTY\r
-\r
-\r
- var o = new Array();\r
- var x = s.split("[code]");\r
- var i = 0;\r
-\r
- var si = "";\r
- si = x.shift();\r
- si = si.replace(re,str);\r
- o.push(si);\r
-\r
- for (i = 0; i < x.length; i++) {\r
- var no = new Array();\r
- var j = x.shift();\r
- var g = j.split("[/code]");\r
- no.push(g.shift());\r
- si = g.shift();\r
- si = si.replace(re,str);\r
- no.push(si);\r
- o.push(no.join("[/code]"));\r
- }\r
-\r
- s = o.join("[code]");\r
-\r
- };\r
-\r
-\r
-\r
-\r
-\r
- // example: [b] to <strong>\r
- rep(/\n/gi,"<br />");\r
- rep(/\[b\]/gi,"<strong>");\r
- rep(/\[\/b\]/gi,"</strong>");\r
- rep(/\[i\]/gi,"<em>");\r
- rep(/\[\/i\]/gi,"</em>");\r
- rep(/\[u\]/gi,"<u>");\r
- rep(/\[\/u\]/gi,"</u>");\r
- rep(/\[hr\]/gi,"<hr />");\r
- rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");\r
- rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");\r
- rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
- rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");\r
- rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");\r
-\r
- rep(/\[list\](.*?)\[\/list\]/gi, '<ul class="listbullet" style="list-style-type: circle;">$1</ul>');\r
- rep(/\[list=\](.*?)\[\/list\]/gi, '<ul class="listnone" style="list-style-type: none;">$1</ul>');\r
- rep(/\[list=1\](.*?)\[\/list\]/gi, '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>');\r
- rep(/\[list=i\](.*?)\[\/list\]/gi,'<ul class="listlowerroman" style="list-style-type: lower-roman;">$1</ul>');\r
- rep(/\[list=I\](.*?)\[\/list\]/gi, '<ul class="listupperroman" style="list-style-type: upper-roman;">$1</ul>');\r
- rep(/\[list=a\](.*?)\[\/list\]/gi, '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$1</ul>');\r
- rep(/\[list=A\](.*?)\[\/list\]/gi, '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$1</ul>');\r
- rep(/\[li\](.*?)\[\/li\]/gi, '<li>$1</li>');\r
- rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");\r
- rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"<span style=\"font-size: $1;\">$2</span>");\r
- rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");\r
- rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");\r
-\r
- /* oembed */\r
- function _b2h_cb(match, url) {\r
- url = bin2hex(url);\r
- function s_b2h(data) {\r
- match = data;\r
- }\r
- $.ajax({\r
- url: 'oembed/b2h?url=' + url,\r
- async: false,\r
- success: s_b2h,\r
- dataType: 'html'\r
- });\r
- return match;\r
- }\r
- s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb);\r
- \r
- /* /oembed */\r
-\r
- return s; \r
- }\r
- });\r
-\r
- // Register plugin\r
- tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);\r
-})();\r
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+/* Macgirvin Aug-2010 changed from punbb to dfrn dialect */
+
+(function() {
+ tinymce.create('tinymce.plugins.BBCodePlugin', {
+ init : function(ed, url) {
+ var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase();
+
+ ed.onBeforeSetContent.add(function(ed, o) {
+ o.content = t['_' + dialect + '_bbcode2html'](o.content);
+ });
+
+ ed.onPostProcess.add(function(ed, o) {
+ if (o.set)
+ o.content = t['_' + dialect + '_bbcode2html'](o.content);
+
+ if (o.get)
+ o.content = t['_' + dialect + '_html2bbcode'](o.content);
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'BBCode Plugin',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
+
+ // Private methods
+
+ // HTML -> BBCode in DFRN dialect
+ _dfrn_html2bbcode : function(s) {
+ s = tinymce.trim(s);
+
+ function rep(re, str) {
+
+
+ s = s.replace(re,str);
+
+ //modify code to keep stuff intact within [code][/code] blocks
+ //Waitman Gobble NO WARRANTY
+
+ /* This doesn't seem to work well with
+ [code]line1
+ line2[/code]
+ commenting out for now
+ */
+
+/*
+ var o = new Array();
+ var x = s.split("[code]");
+ var i = 0;
+
+ var si = "";
+ si = x.shift();
+ si = si.replace(re,str);
+ o.push(si);
+
+ for (i = 0; i < x.length; i++) {
+ var no = new Array();
+ var j = x.shift();
+ var g = j.split("[/code]");
+ no.push(g.shift());
+ si = g.shift();
+ si = si.replace(re,str);
+ no.push(si);
+ o.push(no.join("[/code]"));
+ }
+
+ s = o.join("[code]");
+*/
+ };
+
+
+ function get(re) {
+ return s.match(re);
+ }
+
+
+ /* oembed */
+ function _h2b_cb(match) {
+ /*
+ function s_h2b(data) {
+ match = data;
+ }
+ $.ajax({
+ type:"POST",
+ url: 'oembed/h2b',
+ data: {text: match},
+ async: false,
+ success: s_h2b,
+ dataType: 'html'
+ });
+ */
+
+ var f, g, tof = [], tor = [];
+ var find_spanc = /<span [^>]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:<span[^>]*>(.*?)<\/span *>)*.*?)<\/span *>/ig;
+ while (f = find_spanc.exec(match)) {
+ var find_a = /<a([^>]* rel=[\"']oembed[\"'][^>]*)>.*?<\/a *>/ig;
+ if (g = find_a.exec(f[1])) {
+ var find_href = /href=[\"']([^\"']*)[\"']/ig;
+ var m2 = find_href.exec(g[1]);
+ if (m2[1]) {
+ tof.push(f[0]);
+ tor.push("[EMBED]" + m2[1] + "[/EMBED]");
+ }
+ }
+ }
+ for (var i = 0; i < tof.length; i++) match = match.replace(tof[i], tor[i]);
+
+ return match;
+ }
+
+ if (s.indexOf('class="oembed')>=0){
+ //alert("request oembed html2bbcode");
+ s = _h2b_cb(s);
+ }
+
+ /* /oembed */
+
+
+ // Preserve HTML tags inside code blocks
+ var codes = get(/<code>(.*?)<\/code>/gi);
+ rep(/<code>(.*?)<\/code>/gi,"[$!$!CODEBLOCK!$!$]");
+
+ // example: <strong> to [b]
+ rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");
+ rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
+ rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
+ rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
+ rep(/<font>(.*?)<\/font>/gi,"$1");
+
+ // Use [^>]* instead of .* to prevent a match against two separate <img> tags
+ rep(/<img[^>]*?width=\"([^>]*?)\"[^>]*?height=\"([^>]*?)\"[^>]*?src=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$1x$2]$3[/img]");
+ rep(/<img[^>]*?height=\"([^>]*?)\"[^>]*?width=\"([^>]*?)\"[^>]*?src=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$2x$1]$3[/img]");
+ rep(/<img[^>]*?src=\"([^>]*?)\"[^>]*?height=\"([^>]*?)\"[^>]*?width=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$3x$2]$1[/img]");
+ rep(/<img[^>]*?src=\"([^>]*?)\"[^>]*?width=\"([^>]*?)\"[^>]*?height=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$2x$3]$1[/img]");
+ rep(/<img[^>]*?src=\"([^>]*?)\"[^>]*?\/>/gi,"[img]$1[/img]");
+
+ rep(/<ul class=\"listbullet\" style=\"list-style-type\: circle\;\">(.*?)<\/ul>/gi,"[list]$1[/list]");
+ rep(/<ul class=\"listnone\" style=\"list-style-type\: none\;\">(.*?)<\/ul>/gi,"[list=]$1[/list]");
+ rep(/<ul class=\"listdecimal\" style=\"list-style-type\: decimal\;\">(.*?)<\/ul>/gi,"[list=1]$1[/list]");
+ rep(/<ul class=\"listlowerroman\" style=\"list-style-type\: lower-roman\;\">(.*?)<\/ul>/gi,"[list=i]$1[/list]");
+ rep(/<ul class=\"listupperroman\" style=\"list-style-type\: upper-roman\;\">(.*?)<\/ul>/gi,"[list=I]$1[/list]");
+ rep(/<ul class=\"listloweralpha\" style=\"list-style-type\: lower-alpha\;\">(.*?)<\/ul>/gi,"[list=a]$1[/list]");
+ rep(/<ul class=\"listupperalpha\" style=\"list-style-type\: upper-alpha\;\">(.*?)<\/ul>/gi,"[list=A]$1[/list]");
+ rep(/<li>(.*?)<\/li>/gi,'[li]$1[/li]');
+
+ //rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
+ rep(/<\/(strong|b)>/gi,"[/b]");
+ rep(/<(strong|b)>/gi,"[b]");
+ rep(/<\/(em|i)>/gi,"[/i]");
+ rep(/<(em|i)>/gi,"[i]");
+ rep(/<\/u>/gi,"[/u]");
+ rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
+ rep(/<u>/gi,"[u]");
+ rep(/<blockquote[^>]*>/gi,"[quote]");
+ rep(/<\/blockquote>/gi,"[/quote]");
+ rep(/<hr \/>/gi,"[hr]");
+ rep(/<br (.*?)\/>/gi,"\n");
+ rep(/<br\/>/gi,"\n");
+ rep(/<br>/gi,"\n");
+ rep(/<p>/gi,"");
+ rep(/<\/p>/gi,"\n");
+ rep(/ |\u00a0/gi," ");
+ rep(/"/gi,"\"");
+ rep(/</gi,"<");
+ rep(/>/gi,">");
+ rep(/&/gi,"&");
+
+ // Hack to fix an annoying bug of TinyMCE where block formats don't
+ // work when forced_root_block = ''. So set forced_root_block = 'div'
+ // and then strip out the divs manually
+ rep(/<div>/gi,"");
+ rep(/<\/div>/gi,"");
+
+ if(codes != null) {
+ for(var i=0; i<codes.length; i++) {
+ codes[i] = codes[i].replace("<code>","");
+ codes[i] = codes[i].replace("</code>","");
+ rep(/\[\$!\$!CODEBLOCK!\$!\$\]/i,"[code]"+codes[i]+"[/code]");
+ }
+ }
+
+ return s;
+ },
+
+ // BBCode -> HTML from DFRN dialect
+ _dfrn_bbcode2html : function(s) {
+ s = tinymce.trim(s);
+
+
+ function rep(re, str) {
+
+
+ /*//modify code to keep stuff intact within [code][/code] blocks
+ //Waitman Gobble NO WARRANTY
+
+
+ var o = new Array();
+ var x = s.split("[code]");
+ var i = 0;
+
+ var si = "";
+ si = x.shift();
+ si = si.replace(re,str);
+ o.push(si);
+
+ for (i = 0; i < x.length; i++) {
+ var no = new Array();
+ var j = x.shift();
+ var g = j.split("[/code]");
+ no.push(g.shift());
+ si = g.shift();
+ si = si.replace(re,str);
+ no.push(si);
+ o.push(no.join("[/code]"));
+ }
+
+ s = o.join("[code]");*/
+
+ s = s.replace(re, str);
+
+ };
+
+
+
+ function get(re) {
+ return s.match(re);
+ }
+
+
+
+ // Preserve HTML tags inside code blocks
+ var codes = get(/\[code\](.*?)\[\/code\]/gi);
+ rep(/\[code\](.*?)\[\/code\]/gi,"[$!$!CODEBLOCK!$!$]");
+
+ // example: [b] to <strong>
+ rep(/\n/gi,"<br />");
+ rep(/\[b\]/gi,"<strong>");
+ rep(/\[\/b\]/gi,"</strong>");
+ rep(/\[i\]/gi,"<em>");
+ rep(/\[\/i\]/gi,"</em>");
+ rep(/\[u\]/gi,"<u>");
+ rep(/\[\/u\]/gi,"</u>");
+ rep(/\[hr\]/gi,"<hr />");
+ rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");
+ rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
+ rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
+ rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
+ rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
+
+ rep(/\[list\](.*?)\[\/list\]/gi, '<ul class="listbullet" style="list-style-type: circle;">$1</ul>');
+ rep(/\[list=\](.*?)\[\/list\]/gi, '<ul class="listnone" style="list-style-type: none;">$1</ul>');
+ rep(/\[list=1\](.*?)\[\/list\]/gi, '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>');
+ rep(/\[list=i\](.*?)\[\/list\]/gi,'<ul class="listlowerroman" style="list-style-type: lower-roman;">$1</ul>');
+ rep(/\[list=I\](.*?)\[\/list\]/gi, '<ul class="listupperroman" style="list-style-type: upper-roman;">$1</ul>');
+ rep(/\[list=a\](.*?)\[\/list\]/gi, '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$1</ul>');
+ rep(/\[list=A\](.*?)\[\/list\]/gi, '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$1</ul>');
+ rep(/\[li\](.*?)\[\/li\]/gi, '<li>$1</li>');
+ rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
+ rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"<span style=\"font-size: $1;\">$2</span>");
+ //rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
+ rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
+
+ /* oembed */
+ function _b2h_cb(match, url) {
+ url = bin2hex(url);
+ function s_b2h(data) {
+ match = data;
+ }
+ $.ajax({
+ url: 'oembed/b2h?url=' + url,
+ async: false,
+ success: s_b2h,
+ dataType: 'html'
+ });
+ return match;
+ }
+
+ s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb);
+
+ /* /oembed */
+
+ if(codes != null) {
+ for(var i=0; i<codes.length; i++) {
+ codes[i] = codes[i].replace("[code]","");
+ codes[i] = codes[i].replace("[/code]","");
+ rep(/\[\$!\$!CODEBLOCK!\$!\$\]/i,"<code>"+codes[i]+"</code>");
+ }
+ }
+
+ return s;
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
+})();