/*\ title: $:/core/modules/widgets/fields.js type: application/javascript module-type: widget \*/ "use strict"; var Widget = require("$:/core/modules/widgets/widget.js").widget; var FieldsWidget = function(parseTreeNode,options) { this.initialise(parseTreeNode,options); }; FieldsWidget.prototype = new Widget(); FieldsWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; this.computeAttributes(); this.execute(); var textNode = this.document.createTextNode(this.text); parent.insertBefore(textNode,nextSibling); this.domNodes.push(textNode); }; FieldsWidget.prototype.execute = function() { // Get parameters from our attributes this.tiddlerTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); this.template = this.getAttribute("template"); this.sort = this.getAttribute("sort","yes") === "yes"; this.sortReverse = this.getAttribute("sortReverse","no") === "yes"; this.exclude = this.getAttribute("exclude"); this.include = this.getAttribute("include",null); this.stripTitlePrefix = this.getAttribute("stripTitlePrefix","no") === "yes"; // Get the value to display var tiddler = this.wiki.getTiddler(this.tiddlerTitle); // Get the inclusion and exclusion list var excludeArr = (this.exclude) ? this.exclude.split(" ") : ["text"]; // Include takes precedence var includeArr = (this.include) ? this.include.split(" ") : null; // Compose the template var text = []; if(this.template && tiddler) { var fields = []; if (includeArr) { // Include takes precedence for(var i=0; i