aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-11-12 15:44:49 -0800
committerfriendica <info@friendica.com>2013-11-12 15:44:49 -0800
commit8eaab0642fcddcce86b618913af56a86d6014665 (patch)
treefd307a8d05fe3a970b3296520dc791f0c766b396
parent7cb4c2f8ad813336aafdec05e40f3a8eb1808d00 (diff)
downloadvolse-hubzilla-8eaab0642fcddcce86b618913af56a86d6014665.tar.gz
volse-hubzilla-8eaab0642fcddcce86b618913af56a86d6014665.tar.bz2
volse-hubzilla-8eaab0642fcddcce86b618913af56a86d6014665.zip
very crude zid support for e2ee content and move bbcode converter to main.js so it's available when not logged in (though we might ultimately want to force people to get a matrix account to use our encryption).
-rw-r--r--js/main.js135
-rwxr-xr-xview/tpl/jot-header.tpl123
2 files changed, 135 insertions, 123 deletions
diff --git a/js/main.js b/js/main.js
index a9e670da5..a7421b312 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1038,3 +1038,138 @@ function chanviewFull() {
resize_iframe();
}
}
+
+ function addhtmltext(data) {
+ data = h2b(data);
+ addeditortext(data);
+ }
+
+
+ function addeditortext(data) {
+ if(typeof tinyMCE !== "undefined") {
+ tinyMCE.execCommand('mceInsertRawHTML',false,data);
+ }
+ else {
+ var currentText = $("#profile-jot-text").val();
+ $("#profile-jot-text").val(currentText + 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(/&nbsp;/gi," ");
+ rep(/&quot;/gi,"\"");
+ rep(/&lt;/gi,"<");
+ rep(/&gt;/gi,">");
+ rep(/&amp;/gi,"&");
+
+ return y;
+ };
+
+
+ function b2h(s) {
+ var y = s;
+ function rep(re, str) {
+ y = y.replace(re,str);
+ };
+
+ rep(/\&/gi,"&amp;");
+ rep(/\</gi,"&lt;");
+ rep(/\>/gi,"&gt;");
+ rep(/\"/gi,"&quot;");
+
+ 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(/\[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\" />");
+
+ // FIXME - add zid()
+ rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$2</a>");
+ rep(/\[zrl\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$1</a>");
+ rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3" + '?f=&zid=' + zid + "\" />");
+ rep(/\[zmg\](.*?)\[\/zmg\]/gi,"<img src=\"$1" + '?f=&zid=' + zid + "\" />");
+
+ 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>");
+
+ rep(/\[video\](.*?)\[\/video\]/gi,"<a href=\"$1\">$1</a>");
+ rep(/\[audio\](.*?)\[\/audio\]/gi,"<a href=\"$1\">$1</a>");
+
+ rep(/\[\&amp\;([#a-z0-9]+)\;\]/gi,'&$1;');
+
+ rep(/\<(.*?)(src|href)=\"[^hfm](.*?)\>/gi,'<$1$2="">');
+
+ return y;
+ };
+
+
+function zid(s) {
+ if((! s.length) || (s.indexOf('zid=') != (-1)))
+ return s;
+ if(! zid.length)
+ return s;
+ var has_params = ((s.indexOf('?') == (-1)) ? false : true);
+ var achar = ((has_params) ? '&' : '?');
+ s = s + achar + 'f=&zid=' + zid;
+ return s;
+}
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index c3e020619..97c638fd4 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -292,129 +292,6 @@ function enableOnUser(){
}
- function addhtmltext(data) {
- data = h2b(data);
- addeditortext(data);
- }
-
-
- function addeditortext(data) {
- if(typeof tinyMCE !== "undefined") {
- tinyMCE.execCommand('mceInsertRawHTML',false,data);
- }
- else {
- var currentText = $("#profile-jot-text").val();
- $("#profile-jot-text").val(currentText + 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(/&nbsp;/gi," ");
- rep(/&quot;/gi,"\"");
- rep(/&lt;/gi,"<");
- rep(/&gt;/gi,">");
- rep(/&amp;/gi,"&");
-
- return y;
- };
-
-
- function b2h(s) {
- var y = s;
- function rep(re, str) {
- y = y.replace(re,str);
- };
-
- rep(/\&/gi,"&amp;");
- rep(/\</gi,"&lt;");
- rep(/\>/gi,"&gt;");
- rep(/\"/gi,"&quot;");
-
- 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(/\[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\" />");
-
- // FIXME - add zid
- rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"<a href=\"$1\">$2</a>");
- rep(/\[zrl\](.*?)\[\/zrl\]/gi,"<a href=\"$1\">$1</a>");
- rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
- rep(/\[zmg\](.*?)\[\/zmg\]/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>");
-
- rep(/\[video\](.*?)\[\/video\]/gi,"<a href=\"$1\">$1</a>");
- rep(/\[audio\](.*?)\[\/audio\]/gi,"<a href=\"$1\">$1</a>");
-
- rep(/\[\&amp\;([#a-z0-9]+)\;\]/gi,'&$1;');
-
- rep(/\<(.*?)(src|href)=\"[^hfm](.*?)\>/gi,'<$1$2="">');
-
- return y;
- };
-
{{$geotag}}