private void renderParameters( Element parent, SignatureInfo signatureInfo, Optional<Integer> activeParameter) { int end = signatureInfo.getLabel().length(); int idx; Element element; for (int i = signatureInfo.getParameters().get().size() - 1; i >= 0; i--) { ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(i); idx = signatureInfo.getLabel().lastIndexOf(parameterInfo.getLabel(), end); int signatureLabelOffset = 0; int signatureLabelEnd = 0; if (idx >= 0) { signatureLabelOffset = idx; signatureLabelEnd = idx + parameterInfo.getLabel().length(); } element = Elements.createSpanElement(); element.setTextContent(signatureInfo.getLabel().substring(signatureLabelEnd, end)); parent.insertBefore(element, parent.getFirstElementChild()); element = Elements.createSpanElement(resources.css().parameter()); if (activeParameter.isPresent() && i == activeParameter.get()) { Elements.addClassName(resources.css().active(), element); } element.setTextContent( signatureInfo.getLabel().substring(signatureLabelOffset, signatureLabelEnd)); parent.insertBefore(element, parent.getFirstElementChild()); end = signatureLabelOffset; } element = Elements.createSpanElement(); element.setTextContent(signatureInfo.getLabel().substring(0, end)); parent.insertBefore(element, parent.getFirstElementChild()); }
public static void injectJs(String js) { Element scriptElem = createElement("script"); scriptElem.setAttribute("language", "javascript"); scriptElem.setTextContent(js); getBody().appendChild(scriptElem); }