Package freenet.support

Examples of freenet.support.HTMLNode


    private void start() throws FetchException {
      getter.start(clientContext);
    }

    public synchronized HTMLNode renderRow() {
      HTMLNode row = new HTMLNode("tr");
      row.addChild("td").addChild("p", filename.toString());
     
      if(uomFetcher != null)
        row.addChild("td").addChild("#", l10n("fetchingFromUOM"));
      else if(lastProgress == null)
        row.addChild(QueueToadlet.createProgressCell(false, true, COMPRESS_STATE.WORKING, 0, 0, 0, 0, 0, false, false));
      else
        row.addChild(QueueToadlet.createProgressCell(false,
            true, COMPRESS_STATE.WORKING, lastProgress.succeedBlocks, lastProgress.failedBlocks, lastProgress.fatallyFailedBlocks, lastProgress.minSuccessfulBlocks, lastProgress.totalBlocks, lastProgress.finalizedTotal, false));
      return row;
    }
View Full Code Here


    return getTitle();
  }

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode alertNode = new HTMLNode("div");
    alertNode.addChild("a", "href",
        "/?newbookmark=" + uri + "&desc=" + name + "&hasAnActivelink=" + hasAnActivelink)
        .addChild(
            "img",
            new String[] { "src", "alt", "title" },
            new String[] { "/static/icon/bookmark-new.png", l10n("addAsABookmark"),
                l10n("addAsABookmark") });
    alertNode.addChild("a", "href", "/freenet:" + uri.toString()).addChild("#", name);
    if (description != null && description.length() != 0) {
      String[] lines = description.split("\n");
      alertNode.addChild("br");
      alertNode.addChild("br");
      alertNode.addChild("#", l10n("bookmarkDescription"));
      alertNode.addChild("br");
      for (int i = 0; i < lines.length; i++) {
        alertNode.addChild("#", lines[i]);
        if (i != lines.length - 1)
          alertNode.addChild("br");
      }
    }
    return alertNode;
  }
View Full Code Here

    return NodeL10n.getBase().getString("NotEnoughNiceLevelsUserAlert.short");
  }

  @Override
  public HTMLNode getHTMLText() {
    return new HTMLNode("div", getText());
  }
View Full Code Here

  @Override
  public HTMLNode getHTMLText() {
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("ipAddressOverride");
   
    HTMLNode textNode = new HTMLNode("div");
    NodeL10n.getBase().addL10nSubstitution(textNode, "InvalidAddressOverrideUserAlert.unknownAddressWithConfigLink",
        new String[] { "link" },
        new HTMLNode[] { HTMLNode.link("/config/node")});
    HTMLNode formNode = textNode.addChild("form", new String[] { "action", "method" }, new String[] { "/config/node", "post" });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "subconfig", sc.getPrefix() });
    HTMLNode listNode = formNode.addChild("ul", "class", "config");
    HTMLNode itemNode = listNode.addChild("li");
    itemNode.addChild("span", "class", "configshortdesc", o.getLocalisedShortDesc()).addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", sc.getPrefix() + ".ipAddressOverride", o.getValueDisplayString() });
    itemNode.addChild("span", "class", "configlongdesc", o.getLocalisedLongDesc());
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "submit", NodeL10n.getBase().getString("UserAlert.apply") });
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "reset", NodeL10n.getBase().getString("UserAlert.reset") });
    return textNode;
  }
View Full Code Here

  @Override
  public HTMLNode getHTMLText() {
   
    UpdateThingy ut = createUpdateThingy();
   
    HTMLNode alertNode = new HTMLNode("div");
   
    alertNode.addChild("#", ut.firstBit);
   
    if(ut.formText != null) {
      alertNode.addChild("form", new String[] { "action", "method" }, new String[] { "/", "post" }).addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "update", ut.formText });
      alertNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", updater.node.clientCore.formPassword });
    }

    int version;
    if (updater.hasNewMainJar()) {
      version = updater.newMainJarVersion();
View Full Code Here

    return l10n("headerShort", "from", sourceNodeName);
  }

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode alertNode = new HTMLNode("div");
    alertNode.addChild("p", l10n("header", new String[] { "from",
        "composed", "sent", "received" }, new String[] {
        sourceNodeName,
        DateFormat.getInstance().format(new Date(composedTime)),
        DateFormat.getInstance().format(new Date(sentTime)),
        DateFormat.getInstance().format(new Date(receivedTime)) }));
    String[] lines = messageText.split("\n");
    for (int i = 0, c = lines.length; i < c; i++) {
      alertNode.addChild("#", lines[i]);
      if (i != lines.length - 1)
        alertNode.addChild("br");
    }
   
    DarknetPeerNode pn = (DarknetPeerNode) peerRef.get();
    if(pn != null)
      alertNode.addChild("p").addChild("a", "href",
          "/send_n2ntm/?peernode_hashcode=" + pn.hashCode(),
          l10n("reply"));
    return alertNode;
  }
View Full Code Here

    return sb.toString();
  }
 
  @Override
  public HTMLNode getHTMLText() {
    HTMLNode alertNode = new HTMLNode("div");
   
    synchronized(this) {
      if(isOutdated)
        // Arguably we should provide a button to turn on auto-update,
        // but very few users will turn off auto-update completely.
        // This is useful to not lose those who do however.
        alertNode.addChild("#", l10n("outdatedUpdate"));
      else if (peers == 0 && !isOpennetEnabled) {
        alertNode.addChild("#", l10n("noPeersDarknet"));
      } else if(conns < 3 && clockProblem > MIN_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("clockProblem", "count", Integer.toString(clockProblem)));
      } else if(conns < 3 && connError > MIN_CONN_ERROR_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("connError", "count", Integer.toString(connError)));
      } else if (conns == 0 && !isOpennetEnabled) {
        alertNode.addChild("#", l10n("noConns"));
      } else if (conns == 1 && !isOpennetEnabled) {
        alertNode.addChild("#", l10n("oneConn"));
      } else if (conns == 2 && !isOpennetEnabled) {
        alertNode.addChild("#", l10n("twoConns"));
      } else if (bwlimitDelayAlertRelevant && (bwlimitDelayTime > NodeStats.MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD)) {
        alertNode.addChild("#", l10n("tooHighBwlimitDelayTime", new String[] { "delay", "max" },
            new String[] { Integer.toString(bwlimitDelayTime), Long.toString(NodeStats.MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD)}));
      } else if (nodeAveragePingAlertRelevant && (nodeAveragePingTime > NodeStats.MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD)) {
        alertNode.addChild("#", l10n("tooHighPingTime", new String[] { "ping", "max" },
            new String[] { Integer.toString(nodeAveragePingTime), Long.toString(NodeStats.MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD) }));
      } else if (clockProblem > MIN_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("clockProblem", "count", Integer.toString(clockProblem)));
      } else if (neverConn > MAX_NEVER_CONNECTED_PEER_ALERT_THRESHOLD) {
        NodeL10n.getBase().addL10nSubstitution(alertNode, "PeerManagerUserAlert.tooManyNeverConnectedWithLink",
            new String[] { "link", "count" },
            new HTMLNode[] { HTMLNode.link("/friends/myref.fref"), HTMLNode.text(neverConn) });
      } else if(connError > MIN_CONN_ERROR_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("connError", "count", Integer.toString(connError)));
      } else if (disconnDarknetPeers > MAX_DISCONN_PEER_ALERT_THRESHOLD && !darknetDefinitelyPortForwarded && !darknetAssumeNAT) {
        alertNode.addChild("#", l10n("tooManyDisconnected", new String[] { "count", "max" }, new String[] { Integer.toString(disconnDarknetPeers), Integer.toString(MAX_DISCONN_PEER_ALERT_THRESHOLD)}));
      } else if (darknetConns > MAX_DARKNET_CONN_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("tooManyConns", new String[] { "count", "max" },
            new String[] { Integer.toString(conns), Integer.toString(MAX_DARKNET_CONN_ALERT_THRESHOLD)}));
      } else if (oldestNeverConnectedPeerAge > MAX_OLDEST_NEVER_CONNECTED_PEER_AGE_ALERT_THRESHOLD) {
        alertNode.addChild("#", l10n("tooOldNeverConnectedPeers"));
      } else throw new IllegalArgumentException("not valid");
    }
    return alertNode;
  }
View Full Code Here

    }
    return s.toString();
  }

  public void fillRemoteRequestHTLsBox(HTMLNode html) {
    HTMLNode table = html.addChild("table");
    HTMLNode row = table.addChild("tr");
    row.addChild("th", "HTL");
    row.addChild("th", "CHKs");
    row.addChild("th", "SSKs");
    row = table.addChild("tr");
    char nbsp = (char)160;
    int totalCHKLS = 0;
    int totalCHKRS = 0;
    int totalCHKT = 0;
    int totalSSKLS = 0;
    int totalSSKRS = 0;
    int totalSSKT = 0;
    synchronized(this) {
      for(int htl = byHTL.length - 1; htl >= 0; htl--) {
        row = table.addChild("tr");
        row.addChild("td", Integer.toString(htl));
        StatsLine line = byHTL[htl];
        int chkLS = (int)line.chkLocalSuccess.countReports();
        int chkRS = (int)line.chkRemoteSuccess.countReports();
        int chkF = (int)line.chkFailure.countReports();
        int chkT = chkLS + chkRS + chkF;
        int sskLS = (int)line.sskLocalSuccess.countReports();
        int sskRS = (int)line.sskRemoteSuccess.countReports();
        int sskF = (int)line.sskFailure.countReports();
        int sskT = sskLS + sskRS + sskF;
       
        double locdiffCHK = line.locDiffCHK.currentValue();
        locdiffCHK = Math.pow(2.0, locdiffCHK);
        double locdiffSSK = line.locDiffSSK.currentValue();
        locdiffSSK = Math.pow(2.0, locdiffSSK);

        double chkRate = 0.;
        double sskRate = 0.;
        if (chkT > 0) chkRate = ((double)(chkLS + chkRS)) / (chkT);
        if (sskT > 0) sskRate = ((double)(sskLS + sskRS)) / (sskT);

        row.addChild("td", fix3p3pct.format(chkRate) + nbsp + "(" + chkLS + "," + chkRS + "," + chkT + ")"+nbsp+"("+fix4p.format(locdiffCHK)+")");
        row.addChild("td", fix3p3pct.format(sskRate) + nbsp + "(" + sskLS + "," + sskRS + "," + sskT + ")"+nbsp+"("+fix4p.format(locdiffSSK)+")");

        totalCHKLS += chkLS;
        totalCHKRS+= chkRS;
        totalCHKT += chkT;
        totalSSKLS += sskLS;
        totalSSKRS += sskRS;
        totalSSKT += sskT;
      }
      double totalCHKRate = 0.0;
      double totalSSKRate = 0.0;
      if (totalCHKT > 0) totalCHKRate = ((double)(totalCHKLS + totalCHKRS)) / totalCHKT;
      if (totalSSKT > 0) totalSSKRate = ((double)(totalSSKLS + totalSSKRS)) / totalSSKT;

      row = table.addChild("tr");
      row.addChild("td", "Total");
      row.addChild("td", fix3p3pct.format(totalCHKRate) + nbsp + "("+ totalCHKLS + "," + totalCHKRS + "," + totalCHKT + ")");
      row.addChild("td", fix3p3pct.format(totalSSKRate) + nbsp + "("+ totalSSKLS + "," + totalSSKRS + "," + totalSSKT + ")");
    }
  }
View Full Code Here

    return l10n("shortText");
  }

  @Override
  public HTMLNode getHTMLText() {
    return new HTMLNode("div", getText());
  }
View Full Code Here

  /**
   * Write the alerts as HTML.
   */
  public HTMLNode createAlerts(boolean showOnlyErrors) {
    HTMLNode alertsNode = new HTMLNode("div");
    int totalNumber = 0;
    for (UserAlert alert: getAlerts()) {
      if(showOnlyErrors && alert.getPriorityClass() > UserAlert.ERROR)
        continue;
      if (!alert.isValid())
        continue;
      totalNumber++;
      alertsNode.addChild("a", "name", alert.anchor());
      if(showOnlyErrors) {
        // Paranoia. Don't break the web interface no matter what.
        try {
          alertsNode.addChild(renderAlert(alert));
        } catch (Throwable t) {
          Logger.error(this, "FAILED TO RENDER ALERT: "+alert+" : "+t, t);
        }
      } else {
        // Alerts toadlet itself can error, that's OK.
        alertsNode.addChild(renderAlert(alert));
      }
    }
    if (totalNumber == 0) {
      return new HTMLNode("#", "");
    }
    return alertsNode;
  }
View Full Code Here

TOP

Related Classes of freenet.support.HTMLNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.