[rkward] packages/rkwarddev: fixed ugly indentation of generated optionset JavaScript code

m.eik michalke meik.michalke at uni-duesseldorf.de
Sat Nov 28 21:38:03 UTC 2015


Git commit 403c955c984b2d9bfc34cd2a967aaa93271ef14a by m.eik michalke.
Committed on 28/11/2015 at 21:37.
Pushed by meikm into branch 'master'.

fixed ugly indentation of generated optionset JavaScript code

M  +1    -0    packages/rkwarddev/ChangeLog
M  +1    -1    packages/rkwarddev/R/js.R
M  +2    -2    packages/rkwarddev/R/rk-internal.R

http://commits.kde.org/rkward/403c955c984b2d9bfc34cd2a967aaa93271ef14a

diff --git a/packages/rkwarddev/ChangeLog b/packages/rkwarddev/ChangeLog
index 1f3c2a8..5076d5e 100644
--- a/packages/rkwarddev/ChangeLog
+++ b/packages/rkwarddev/ChangeLog
@@ -17,6 +17,7 @@ fixed:
   - pasting comments via rk.paste.JS() gained an extra space for subsequent
     lines
   - the "i18n" attribute in lists e.g. for rk.XML.radio() didn't really work
+  - improved indetation for rk.JS.oset objects
 added:
   - new methods plugin2script() to try to translate raw plugin XML into
     working rkwarddev script calls
diff --git a/packages/rkwarddev/R/js.R b/packages/rkwarddev/R/js.R
index ab4b9e2..7d713f9 100644
--- a/packages/rkwarddev/R/js.R
+++ b/packages/rkwarddev/R/js.R
@@ -94,7 +94,7 @@ js <- function(..., level=2, indent.by=rk.get.indent(), linebreaks=TRUE, empty.e
           return(this.part)
         } else {
           if(as.character(this.part[[1]]) %in% c("rk.comment", "tf", "rk.JS.optionset")){
-            return(rk.paste.JS(eval(this.part, envir=.rk.local.env), level=level, indent.by=indent.by, empty.e=empty.e))
+            return(trim(rk.paste.JS(eval(this.part, envir=.rk.local.env), level=level, indent.by=indent.by, empty.e=empty.e)))
           } else {}
           # replace JS operators
           return(do.call("replaceJSOperators", args=list(this.part)))
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 51f4419..121ea8d 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -1004,7 +1004,7 @@ paste.JS.options <- function(object, level=2, indent.by=rk.get.indent(), array=N
     } else {
       this.collapse <- ""
     }
-    paste.JS.ite(add.opts(thisIf, collapse=this.collapse, array=array), level=level+1, indent.by=indent.by)
+    paste.JS.ite(add.opts(thisIf, collapse=this.collapse, array=array), level=level, indent.by=indent.by)
   })
 
 #return(ifs.pasted)
@@ -1167,7 +1167,7 @@ paste.JS.optionsset <- function(object, level=2, indent.by=rk.get.indent()){
     for.head <- paste0(main.indent, "for (var ", loopvar, " = 0; ", loopvar, " < ", id(columns[[1]]), ".length; ++", loopvar, "){")
 
     paste.body <- sapply(body, function(bodyPart){
-        rk.paste.JS(bodyPart, level=level, indent.by=scnd.indent)
+        rk.paste.JS(bodyPart, level=level+1, indent.by=indent.by)
       })
     # replace the column IDs with indexed ones
     for (thisCol in sapply(columns, id)){



More information about the rkward-tracker mailing list