[rkward-cvs] SF.net SVN: rkward:[3969] trunk/rkward/rkward/scriptbackends/common.js

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Tue Oct 18 14:22:19 UTC 2011


Revision: 3969
          http://rkward.svn.sourceforge.net/rkward/?rev=3969&view=rev
Author:   m-eik
Date:     2011-10-18 14:22:19 +0000 (Tue, 18 Oct 2011)
Log Message:
-----------
added JavaScrupt functions shortName() and getValueShort()

Modified Paths:
--------------
    trunk/rkward/rkward/scriptbackends/common.js

Modified: trunk/rkward/rkward/scriptbackends/common.js
===================================================================
--- trunk/rkward/rkward/scriptbackends/common.js	2011-10-18 13:09:57 UTC (rev 3968)
+++ trunk/rkward/rkward/scriptbackends/common.js	2011-10-18 14:22:19 UTC (rev 3969)
@@ -92,3 +92,27 @@
 function str_replace (needle, replacement, haystack) {
 	return (haystack.split (needle).join (replacement));
 }
+
+// should behave similar to rk.get.short.name()
+shortName = function (variables) {
+	var snArray = variables.split("\n");
+	var snArrayShort = new Array();
+	for(var i=0, len=snArray.length; value=snArray[i], i<len; i++) {
+		var loopTmp = value.slice(value.lastIndexOf("[[\"")+3, value.lastIndexOf("\"]]"));
+		if(loopTmp == "") {
+			snArrayShort.push(value);
+		} else {
+			snArrayShort.push(loopTmp);
+		}
+	}
+	return(snArrayShort);
+}
+
+// shortcut to get shortnames from varslots directly, as a
+// replacement for getValue()
+// append '.join(", ")' to get then in a comma separated string
+getValueShort = function (variable) {
+	var gvsVar = getValue(variable);
+	gvsVar = shortName(gvsVar);
+	return(gvsVar);
+}

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list