mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-28 05:33:14 +00:00

* remove blks first try * dprint.json seems to be OK, some forgotten functions * add some more space-after-keyword settings * server remove blks * add **/files to dprint exclude * dprint.js fixes a typo * add boot.js and bootprefix.js to dprint exclude * dprint change dprint.json * add dprint fmt as script * remove jslint comments * fix whitespace * fix whitespace * remove function-wrapper from geospatial plugin * fix whitespace * add function wrapper to dyannotate-startup * remove dpring.json
76 lines
2.2 KiB
JavaScript
76 lines
2.2 KiB
JavaScript
/*\
|
|
title: $:/core/modules/widgets/setmultiplevariables.js
|
|
type: application/javascript
|
|
module-type: widget
|
|
|
|
Widget to set multiple variables at once from a list of names and a list of values
|
|
|
|
\*/
|
|
|
|
"use strict";
|
|
|
|
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
|
|
var SetMultipleVariablesWidget = function(parseTreeNode,options) {
|
|
this.initialise(parseTreeNode,options);
|
|
};
|
|
|
|
/*
|
|
Inherit from the base widget class
|
|
*/
|
|
SetMultipleVariablesWidget.prototype = new Widget();
|
|
|
|
/*
|
|
Render this widget into the DOM
|
|
*/
|
|
SetMultipleVariablesWidget.prototype.render = function(parent,nextSibling) {
|
|
this.parentDomNode = parent;
|
|
this.computeAttributes();
|
|
this.execute();
|
|
this.renderChildren(parent,nextSibling);
|
|
};
|
|
|
|
/*
|
|
Compute the internal state of the widget
|
|
*/
|
|
SetMultipleVariablesWidget.prototype.execute = function() {
|
|
// Setup our variables
|
|
this.setVariables();
|
|
// Construct the child widgets
|
|
this.makeChildWidgets();
|
|
};
|
|
|
|
|
|
SetMultipleVariablesWidget.prototype.setVariables = function() {
|
|
// Set the variables
|
|
var self = this,
|
|
filterNames = this.getAttribute("$names",""),
|
|
filterValues = this.getAttribute("$values","");
|
|
this.variableNames = [];
|
|
this.variableValues = [];
|
|
if(filterNames && filterValues) {
|
|
this.variableNames = this.wiki.filterTiddlers(filterNames,this);
|
|
this.variableValues = this.wiki.filterTiddlers(filterValues,this);
|
|
$tw.utils.each(this.variableNames,function(varname,index) {
|
|
self.setVariable(varname,self.variableValues[index]);
|
|
});
|
|
}
|
|
};
|
|
|
|
/*
|
|
Refresh the widget by ensuring our attributes are up to date
|
|
*/
|
|
SetMultipleVariablesWidget.prototype.refresh = function(changedTiddlers) {
|
|
var filterNames = this.getAttribute("$names",""),
|
|
filterValues = this.getAttribute("$values",""),
|
|
variableNames = this.wiki.filterTiddlers(filterNames,this),
|
|
variableValues = this.wiki.filterTiddlers(filterValues,this);
|
|
if(!$tw.utils.isArrayEqual(this.variableNames,variableNames) || !$tw.utils.isArrayEqual(this.variableValues,variableValues)) {
|
|
this.refreshSelf();
|
|
return true;
|
|
}
|
|
return this.refreshChildren(changedTiddlers);
|
|
};
|
|
|
|
exports["setmultiplevariables"] = SetMultipleVariablesWidget;
|