From 09ca39fd085595f791bec6f8e8c154b4a22d3b1e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 31 Oct 2013 22:08:10 -0700 Subject: provide an html src converter --- view/tpl/jot-header.tpl | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'view/tpl/jot-header.tpl') diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 810ec866f..527db4e4f 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -284,6 +284,13 @@ function enableOnUser(){ $('#profile-nolocation-wrapper').hide(); } + + function addhtmltext(data) { + data = h2b(data); + addeditortext(data); + } + + function addeditortext(data) { if(plaintext == 'none') { var currentText = $("#profile-jot-text").val(); @@ -293,6 +300,60 @@ function enableOnUser(){ tinyMCE.execCommand('mceInsertRawHTML',false,data); } + function h2b(s) { + var y = s; + function rep(re, str) { + y = y.replace(re,str); + }; + + rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); + rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); + rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); + rep(/(.*?)<\/font>/gi,"$1"); + rep(//gi,"[img=$1x$2]$3[/img]"); + rep(//gi,"[img=$2x$1]$3[/img]"); + rep(//gi,"[img=$3x$2]$1[/img]"); + rep(//gi,"[img=$2x$3]$1[/img]"); + rep(//gi,"[img]$1[/img]"); + + + rep(/
    (.*?)<\/ul>/gi,"[list]$1[/list]"); + rep(/
      (.*?)<\/ul>/gi,"[list=]$1[/list]"); + rep(/
        (.*?)<\/ul>/gi,"[list=1]$1[/list]"); + rep(/
          (.*?)<\/ul>/gi,"[list=i]$1[/list]"); + rep(/
            (.*?)<\/ul>/gi,"[list=I]$1[/list]"); + rep(/
              (.*?)<\/ul>/gi,"[list=a]$1[/list]"); + rep(/
                (.*?)<\/ul>/gi,"[list=A]$1[/list]"); + rep(/
              • (.*?)<\/li>/gi,"[li]$1[/li]"); + + rep(/(.*?)<\/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>/gi,"[u]$1[/u]"); + rep(//gi,"[u]"); + rep(/]*>/gi,"[quote]"); + rep(/<\/blockquote>/gi,"[/quote]"); + rep(/
                /gi,"[hr]"); + rep(/
                /gi,"\n"); + rep(//gi,"\n"); + rep(/
                /gi,"\n"); + rep(/

                /gi,""); + rep(/<\/p>/gi,"\n"); + rep(/ /gi," "); + rep(/"/gi,"\""); + rep(/</gi,"<"); + rep(/>/gi,">"); + rep(/&/gi,"&"); + + return y; + }; + + {{$geotag}} -- cgit v1.2.3