1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 18:23:28 +00:00

Add urlencoded and doubleurlencoded formats to the view widget

This commit is contained in:
Jermolene 2013-11-12 20:29:14 +00:00
parent e68ab95ecb
commit 8ec92405fd

View File

@ -57,6 +57,12 @@ ViewWidget.prototype.execute = function() {
case "htmlencoded":
this.text = this.getValueAsHtmlEncoded();
break;
case "urlencoded":
this.text = this.getValueAsUrlEncoded();
break;
case "doubleurlencoded":
this.text = this.getValueAsDoubleUrlEncoded();
break;
case "date":
this.text = this.getValueAsDate(this.viewTemplate);
break;
@ -133,6 +139,14 @@ ViewWidget.prototype.getValueAsHtmlEncoded = function() {
return $tw.utils.htmlEncode(this.getValueAsText());
};
ViewWidget.prototype.getValueAsUrlEncoded = function() {
return encodeURIComponent(this.getValueAsText());
};
ViewWidget.prototype.getValueAsDoubleUrlEncoded = function() {
return encodeURIComponent(encodeURIComponent(this.getValueAsText()));
};
ViewWidget.prototype.getValueAsDate = function(format) {
return $tw.utils.formatDateString(this.getValue(),format);
};