X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=blobdiff_plain;f=misc%2Fxgen%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fmisc%2Fxgen%2Fhtml%2FJSGen.java;h=5d9a507d56439ec5599757a7747b02361357c4a4;hp=537e9fc56931105f0bb15c7b8370006572301d19;hb=4b5a7d721d994a49057e9bfb403c7bff1b376660;hpb=824dc7b5fc0e1ccdf7f460479aff344727f0f01e diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java index 537e9fc5..5d9a507d 100644 --- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java @@ -31,174 +31,174 @@ import org.onap.aaf.misc.xgen.Mark; public class JSGen { - private HTMLGen htmlGen; - private IndentPrintWriter ipw; - private Mark mark; + private HTMLGen htmlGen; + private IndentPrintWriter ipw; + private Mark mark; - public JSGen(Mark mark, HTMLGen hg) { - this.mark = mark==null?new Mark():mark; - hg.incr(this.mark, "script", "language=javascript", "type=text/javascript"); - htmlGen = hg; - ipw = hg.getWriter(); - } + public JSGen(Mark mark, HTMLGen hg) { + this.mark = mark==null?new Mark():mark; + hg.incr(this.mark, "script", "language=javascript", "type=text/javascript"); + htmlGen = hg; + ipw = hg.getWriter(); + } - public JSGen inline(String filename, int tabstop) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(filename)); - int indent = htmlGen.getIndent(); - try { - boolean pretty = htmlGen.pretty; - String line, el; - int l, end; - while((line=br.readLine())!=null) { - if(pretty) { - String[] elements = line.split("\t"); - - for(int i=0; i0) ipw.print(' '); - ipw.print(el); - } - } - ipw.println(); - } else { - ipw.print(line.trim()); - } - } - } finally { - htmlGen.setIndent(indent); - try { - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return this; - } - - public JSGen pst(String ... lines) { - return pst(null, lines); - } - - public JSGen pst(Mark jm, String ... lines) { - if(lines.length>0) ipw.append(lines[0]); - ipw.append('('); - for(int i=1;i0) ipw.print(' '); + ipw.print(el); + } + } + ipw.println(); + } else { + ipw.print(line.trim()); + } + } + } finally { + htmlGen.setIndent(indent); + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return this; + } + + public JSGen pst(String ... lines) { + return pst(null, lines); + } + + public JSGen pst(Mark jm, String ... lines) { + if(lines.length>0) ipw.append(lines[0]); + ipw.append('('); + for(int i=1;i0)ipw.println(); - ipw.print(lines[i]); - } - ipw.setIndent(current); - ipw.append(';'); - if(htmlGen.pretty)ipw.println(); - return this; - } - - public JSGen text(String text) { - ipw.append(text); - if(htmlGen.pretty)ipw.println(); - return this; - } + if(htmlGen.pretty) { + back = new Back(");\n",false,false); + } else { + back = new Back(");",false,false); + } + int spot = htmlGen.pushBack(back); + if(jm!=null)jm.spot(spot); + return this; + } + + public JSGen li(String ... lines) { + int current = ipw.getIndent(); + for(int i=0;i0)ipw.println(); + ipw.print(lines[i]); + } + ipw.setIndent(current); + ipw.append(';'); + if(htmlGen.pretty)ipw.println(); + return this; + } + + public JSGen text(String text) { + ipw.append(text); + if(htmlGen.pretty)ipw.println(); + return this; + } - public JSGen function(String name, String ... params) { - return function(null, name, params); - } - - public JSGen jqfunc(Mark mark, String name, String ... params) { - pst(mark,"$").function(name, params); - return this; - } - - public JSGen function(Mark jm, String name, String ... params) { - ipw.print("function "); - ipw.print(name); - ipw.print('('); - for(int i=0;i0)ipw.println(); - ipw.print(lines[i]); - } - ipw.setIndent(current); - ipw.print('{'); - if(htmlGen.pretty) { - ipw.println(); - ipw.inc(); - } - int spot = htmlGen.pushBack(new Back("}",true,true)); - if(jm!=null)jm.spot(spot); - return this; + public JSGen cb(Mark jm, String ... lines) { + int current = ipw.getIndent(); + for(int i=0;i0)ipw.println(); + ipw.print(lines[i]); + } + ipw.setIndent(current); + ipw.print('{'); + if(htmlGen.pretty) { + ipw.println(); + ipw.inc(); + } + int spot = htmlGen.pushBack(new Back("}",true,true)); + if(jm!=null)jm.spot(spot); + return this; - } + } - - public JSGen comment(String ... lines) { - if(htmlGen.pretty) { - for(int i=0;i