@Override public TextInJavaScriptEncoder append(char c, Appendable out) throws IOException { encodeTextInJavaScript(c, out); return this; }
public static void encodeTextInJavaScript(char[] cbuf, Writer out) throws IOException { encodeTextInJavaScript(cbuf, 0, cbuf.length, out); }
@Override public TextInJavaScriptEncoder append(CharSequence csq, Appendable out) throws IOException { encodeTextInJavaScript(csq==null ? "null" : csq, out); return this; }
@Override public TextInJavaScriptEncoder append(CharSequence csq, int start, int end, Appendable out) throws IOException { encodeTextInJavaScript(csq==null ? "null" : csq, start, end, out); return this; }
@Override public void write(int c, Writer out) throws IOException { encodeTextInJavaScript((char)c, out); }
@Override public void write(char cbuf[], Writer out) throws IOException { encodeTextInJavaScript(cbuf, out); }
@Override public void write(char[] cbuf, int off, int len, Writer out) throws IOException { encodeTextInJavaScript(cbuf, off, len, out); }
public static void encodeTextInJavaScript(CharSequence S, Appendable out) throws IOException { if(S!=null) { encodeTextInJavaScript(S, 0, S.length(), out); } }
@Override public void write(String str, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeTextInJavaScript(str, out); }
@Override public void write(String str, int off, int len, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeTextInJavaScript(str, off, off+len, out); }
/** * @see TextInJavaScriptEncoder#encodeTextInJavaScript(java.lang.String, Appendable) * * @deprecated */ @Deprecated public ChainWriter encodeJavaScriptString(String S) throws IOException { encodeTextInJavaScript(S, out); return this; }
public static void encodeTextInJavaScriptInXhtml(String text, Appendable out) throws IOException { StringBuilder javascript = new StringBuilder(text.length()); encodeTextInJavaScript(text, javascript); encodeJavaScriptInXhtml(javascript, out); }
public static void encodeTextInJavaScriptInXhtmlAttribute(String text, Appendable out) throws IOException { StringBuilder javascript = new StringBuilder(text.length()); encodeTextInJavaScript(text, javascript); encodeJavaScriptInXhtmlAttribute(javascript, out); }
@Override protected void writeSuffix(StringBuilder buffer, Appendable out) throws IOException { TextInJavaScriptEncoder.encodeTextInJavaScript( context.encodeURL(buffer.toString()), out ); out.append('"'); } }
@Override public void doComponent( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Writer out, View view, Page page, ComponentPosition position ) throws ServletException, IOException { if(position == ComponentPosition.HEAD_END) { out.write("<script type=\"text/javascript\">\n" + "// <![CDATA[\n" + "(function(i,s,o,g,r,a,m){i[\"GoogleAnalyticsObject\"]=r;i[r]=i[r]||function(){\n" + "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n" + "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n" + "})(window,document,\"script\",\"https://www.google-analytics.com/analytics.js\",\"ga\");\n" + "ga(\"create\",\""); TextInJavaScriptEncoder.encodeTextInJavaScript(trackingId, out); out.write("\",\"auto\");\n" + "ga(\"send\",\"pageview\");\n" + "// ]]>\n" + "</script>"); } } }
/** * Prints a JavaScript script that will preload the image at the provided URL. * * @param url This should be the URL-encoded URL, but with only a standalone ampersand (&) as parameter separator * (not &amp;) */ public static void writeHtmlImagePreloadJavaScript(String url, Appendable out) throws IOException { out.append("<script type='text/javascript'>\n" + " var img=new Image();\n" + " img.src=\""); // Escape for javascript StringBuilder javascript = new StringBuilder(url.length()); encodeTextInJavaScript(url, javascript); // Encode for XML attribute encodeJavaScriptInXhtmlAttribute(javascript, out); out.append("\";\n" + "</script>"); }
+ " \"item\": {\n" + " \"@id\": \""); encodeTextInJavaScript(view.getCanonicalUrl(servletContext, request, response, item), out); out.write("\",\n" + " \"name\": \""); encodeTextInJavaScript(PageUtils.getShortTitle(parentPageRef, item), out); out.write("\"\n" + " }\n"
encodeTextInJavaScript(release.getGroupId(), out); out.write(':'); encodeTextInJavaScript(release.getArtifactId(), out); out.write(":jar:"); encodeTextInJavaScript(release.getVersion(), out); out.write('\''); for(Release dependency : dependenciesList) { out.write(",\n'"); encodeTextInJavaScript(dependency.getGroupId(), out); out.write(':'); encodeTextInJavaScript(dependency.getArtifactId(), out); out.write(":jar:"); encodeTextInJavaScript(dependency.getVersion(), out); out.write('\''); "@Grapes(\n" + " @Grab(group='"); encodeTextInJavaScript(release.getGroupId(), out); out.write("', module='"); encodeTextInJavaScript(release.getArtifactId(), out); out.write("', version='"); encodeTextInJavaScript(release.getVersion(), out); out.write( "')\n"); for(Release dependency : dependenciesList) { out.write(" @Grab(group='"); encodeTextInJavaScript(dependency.getGroupId(), out); out.write("', module='"); encodeTextInJavaScript(dependency.getArtifactId(), out);
encodeTextInJavaScript(refId, out); out .append("\").src = document.getElementById(\"" + ALT_LINK_ID_PREFIX)