[kde-doc-english] [rkward] /: Add JS function makeOption() for convenience

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Jan 13 14:46:56 UTC 2016


Git commit d268396ca40d6bf887d253011c3d2b5c195273f5 by Thomas Friedrichsmeier.
Committed on 13/01/2016 at 13:16.
Pushed by tfry into branch 'master'.

Add JS function makeOption() for convenience

M  +1    -0    ChangeLog
M  +12   -0    doc/rkwardplugins/index.docbook
M  +5    -0    rkward/scriptbackends/common.js

http://commits.kde.org/rkward/d268396ca40d6bf887d253011c3d2b5c195273f5

diff --git a/ChangeLog b/ChangeLog
index 9bcc43f..a4e601e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Add convenience JS-function "makeOption()" for use in plugins
 - Fixed: Numerical (display) precision setting was not honored in data editor
 - Fix several window activation quirks in "Focus follows mouse" mode
 - File selectors in "Import XYZ" plugins now filter for standard file extensions, by default
diff --git a/doc/rkwardplugins/index.docbook b/doc/rkwardplugins/index.docbook
index ae54c20..ee0ff69 100644
--- a/doc/rkwardplugins/index.docbook
+++ b/doc/rkwardplugins/index.docbook
@@ -712,6 +712,18 @@ function calculate () {
 	// ...
 }
 	</programlisting>
+	<para>
+		The simple helper function <function>makeOption()</function> can make it easier to omit parameters that are at their default value, in many cases:
+	</para>
+	<programlisting>
+function calculate () {
+	var options
+	//...
+	// This will do nothing, if VALUE is 0.95 (the default). Otherwise it will append ', conf.int=VALUE' to options.
+	options += makeOption ("conf.int", getString ("confint"), "0.95");
+	//...
+}
+	</programlisting>
 </sect1>
 </chapter>
 
diff --git a/rkward/scriptbackends/common.js b/rkward/scriptbackends/common.js
index bc2e4ca..2a84078 100644
--- a/rkward/scriptbackends/common.js
+++ b/rkward/scriptbackends/common.js
@@ -158,6 +158,11 @@ printValue = function (id) {
 	echo (getValue (id));
 }
 
+makeOption = function (optionname, value, def) {
+	if (typeof (de) == 'undefined') def = "";
+	return ((value == def) ? '' : (', ' + optionname + '=' + value));
+}
+
 include = function (file) {
 	_RK_backend.includeFile (file);
 }



More information about the kde-doc-english mailing list