lost changes to tinymce/bbcode

This commit is contained in:
friendica 2012-03-17 22:18:21 -07:00
parent 9e731506c2
commit 4bb280bc2f

View file

@ -45,7 +45,33 @@
s = tinymce.trim(s); s = tinymce.trim(s);
function rep(re, str) { function rep(re, str) {
s = s.replace(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]");
}; };
@ -53,6 +79,7 @@
/* oembed */ /* oembed */
function _h2b_cb(match) { function _h2b_cb(match) {
/*
function s_h2b(data) { function s_h2b(data) {
match = data; match = data;
} }
@ -64,6 +91,23 @@
success: s_h2b, success: s_h2b,
dataType: 'html' 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; return match;
} }
if (s.indexOf('class="oembed')>=0){ if (s.indexOf('class="oembed')>=0){
@ -124,10 +168,41 @@
_dfrn_bbcode2html : function(s) { _dfrn_bbcode2html : function(s) {
s = tinymce.trim(s); s = tinymce.trim(s);
function rep(re, str) { function rep(re, str) {
s = s.replace(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]");
}; };
// example: [b] to <strong> // example: [b] to <strong>
rep(/\n/gi,"<br />"); rep(/\n/gi,"<br />");
rep(/\[b\]/gi,"<strong>"); rep(/\[b\]/gi,"<strong>");