provide an html src converter
This commit is contained in:
parent
3a7a671738
commit
09ca39fd08
@ -45,63 +45,12 @@
|
|||||||
s = tinymce.trim(s);
|
s = tinymce.trim(s);
|
||||||
|
|
||||||
function rep(re, str) {
|
function rep(re, str) {
|
||||||
|
|
||||||
|
|
||||||
s = s.replace(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]");
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* oembed */
|
/* oembed */
|
||||||
function _h2b_cb(match) {
|
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 f, g, tof = [], tor = [];
|
||||||
var find_spanc = /<span [^>]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:<span[^>]*>(.*?)<\/span *>)*.*?)<\/span *>/ig;
|
var find_spanc = /<span [^>]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:<span[^>]*>(.*?)<\/span *>)*.*?)<\/span *>/ig;
|
||||||
while (f = find_spanc.exec(match)) {
|
while (f = find_spanc.exec(match)) {
|
||||||
@ -124,11 +73,8 @@ commenting out for now
|
|||||||
s = _h2b_cb(s);
|
s = _h2b_cb(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /oembed */
|
|
||||||
|
|
||||||
|
|
||||||
// example: <strong> to [b]
|
// 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(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||||
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
||||||
@ -222,7 +168,6 @@ commenting out for now
|
|||||||
rep(/\[u\]/gi,"<u>");
|
rep(/\[u\]/gi,"<u>");
|
||||||
rep(/\[\/u\]/gi,"</u>");
|
rep(/\[\/u\]/gi,"</u>");
|
||||||
rep(/\[hr\]/gi,"<hr />");
|
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\">$2</a>");
|
||||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
||||||
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
|
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
|
||||||
|
@ -20,7 +20,6 @@ require_once('include/zot.php');
|
|||||||
* remote_return= absolute URL to return after posting is finished
|
* remote_return= absolute URL to return after posting is finished
|
||||||
* type= choices are 'html' or 'bbcode', default is 'bbcode'
|
* type= choices are 'html' or 'bbcode', default is 'bbcode'
|
||||||
*
|
*
|
||||||
* currently content type is Red Matrix bbcode, though HTML is possible. This is left as an exercise for future developers
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -85,13 +84,13 @@ function rpost_content(&$a) {
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
|
// $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
|
||||||
'$baseurl' => $a->get_baseurl(),
|
// '$baseurl' => $a->get_baseurl(),
|
||||||
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
|
// '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
|
||||||
'$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'),
|
// '$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'),
|
||||||
'$geotag' => $geotag,
|
// '$geotag' => $geotag,
|
||||||
'$nickname' => $channel['channel_address']
|
// '$nickname' => $channel['channel_address']
|
||||||
));
|
// ));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2013-10-30.482
|
2013-10-31.483
|
||||||
|
@ -284,6 +284,13 @@ function enableOnUser(){
|
|||||||
$('#profile-nolocation-wrapper').hide();
|
$('#profile-nolocation-wrapper').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addhtmltext(data) {
|
||||||
|
data = h2b(data);
|
||||||
|
addeditortext(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function addeditortext(data) {
|
function addeditortext(data) {
|
||||||
if(plaintext == 'none') {
|
if(plaintext == 'none') {
|
||||||
var currentText = $("#profile-jot-text").val();
|
var currentText = $("#profile-jot-text").val();
|
||||||
@ -293,6 +300,60 @@ function enableOnUser(){
|
|||||||
tinyMCE.execCommand('mceInsertRawHTML',false,data);
|
tinyMCE.execCommand('mceInsertRawHTML',false,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function h2b(s) {
|
||||||
|
var y = s;
|
||||||
|
function rep(re, str) {
|
||||||
|
y = y.replace(re,str);
|
||||||
|
};
|
||||||
|
|
||||||
|
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");
|
||||||
|
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(/ /gi," ");
|
||||||
|
rep(/"/gi,"\"");
|
||||||
|
rep(/</gi,"<");
|
||||||
|
rep(/>/gi,">");
|
||||||
|
rep(/&/gi,"&");
|
||||||
|
|
||||||
|
return y;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
{{$geotag}}
|
{{$geotag}}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user