Changeset e2acc9f


Ignore:
Timestamp:
Mar 3, 2012 6:58:31 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b0a682f
Parents:
0e8d3d1
Message:
  • i2psnark:
    • CSS tweaks
    • Ajax fixes
    • Move js to console in prep for merging w/ homepage
Location:
apps
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/build.xml

    r0e8d3d1 re2acc9f  
    100100            <fileset dir="../icons/" />
    101101        </copy>
    102         <copy todir="build/js/.js" >
    103             <fileset dir="../js/" />
    104         </copy>
    105102        <war destfile="../i2psnark.war" webxml="../web.xml" >
    106103          <!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
    107104          <classes dir="./build/obj" includes="**/web/*.class" />
    108105            <fileset dir="build/icons/" />
    109             <fileset dir="build/js/" />
    110106            <manifest>
    111107                <attribute name="Implementation-Version" value="${full.version}" />
     
    120116    <target name="warUpToDate">
    121117        <uptodate property="war.uptodate" targetfile="../i2psnark.war" >
    122             <srcfiles dir= "." includes="build/obj/org/klomp/snark/web/*.class ../icons/* ../js/* ../web.xml" />
     118            <srcfiles dir= "." includes="build/obj/org/klomp/snark/web/*.class ../icons/* ../web.xml" />
    123119        </uptodate>
    124120    </target>
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r0e8d3d1 re2acc9f  
    159159            resp.setContentType("text/html; charset=UTF-8");
    160160            PrintWriter out = resp.getWriter();
     161            //if (_log.shouldLog(Log.DEBUG))
     162            //    _manager.addMessage((_context.clock().now() / 1000) + " xhr1 p=" + req.getParameter("p"));
    161163            writeMessages(out);
    162164            writeTorrents(out, req);
     
    205207        String peerParam = req.getParameter("p");
    206208        String peerString;
    207         if (peerParam == null || !_manager.util().connected()) {
     209        if (peerParam == null || (!_manager.util().connected()) ||
     210            peerParam.replaceAll("[a-zA-Z0-9~=-]", "").length() > 0) {  // XSS
    208211            peerString = "";
    209212        } else {
     
    224227        if (!isConfigure) {
    225228            delay = _manager.getRefreshDelaySeconds();
    226             if (delay > 0)
     229            if (delay > 0) {
    227230                //out.write("<meta http-equiv=\"refresh\" content=\"" + delay + ";/i2psnark/" + peerString + "\">\n");
    228                 out.write("<script src=\"/i2psnark/.js/i2psnark.js\" type=\"text/javascript\"></script>\n");
     231                out.write("<script src=\"/js/ajax.js\" type=\"text/javascript\"></script>\n" +
     232                          "<script type=\"text/javascript\">\n"  +
     233                          "function requestAjax1() { ajax(\"/i2psnark/.ajax/xhr1.html" + peerString + "\", \"mainsection\", " + (delay*1000) + "); }\n" +
     234                          "function initAjax(delayMs) { setTimeout(requestAjax1, " + (delay*1000) +");  }\n"  +
     235                          "</script>\n");
     236            }
    229237        }
    230238        out.write(HEADER_A + _themePath + HEADER_B + "</head>\n");
     
    232240            out.write("<body>");
    233241        else
    234             out.write("<body onload=\"initAjax(" + (delay * 1000) + ")\">");
     242            out.write("<body onload=\"initAjax()\">");
    235243        out.write("<center>");
    236244        if (isConfigure) {
     
    305313
    306314        List snarks = getSortedSnarks(req);
    307         String uri = req.getRequestURI();
    308315        boolean isForm = _manager.util().connected() || !snarks.isEmpty();
    309316        if (isForm) {
     
    419426        }
    420427        out.write("</th></tr></thead>\n");
     428        String uri = "/i2psnark/";
    421429        for (int i = 0; i < snarks.size(); i++) {
    422430            Snark snark = (Snark)snarks.get(i);
  • apps/routerconsole/jsp/js/ajax.js

    r0e8d3d1 re2acc9f  
    1 //var page = "home";
    2 function ajax(url,target) {
     1function ajax(url, target, refresh) {
    32  // native XMLHttpRequest object
    43  if (window.XMLHttpRequest) {
    54    req = new XMLHttpRequest();
    6     req.onreadystatechange = function() {ajaxDone(target);};
     5    req.onreadystatechange = function() {ajaxDone(url, target, refresh);};
    76    req.open("GET", url, true);
    87    req.send(null);
     
    1615    }
    1716  }
    18   //setTimeout("ajax(page,'scriptoutput')", 5000);
    1917}
    2018
    21 function ajaxDone(target) {
     19function ajaxDone(url, target, refresh) {
    2220  // only if req is "loaded"
    2321  if (req.readyState == 4) {
     
    3129      document.getElementById("lowersection").style.display="none";
    3230    }
     31    setTimeout(function() {ajax(url, target, refresh);}, refresh);
    3332  }
    3433}
    35 
    36 function requestAjax1() { ajax("/i2psnark/.ajax/xhr1.html", "mainsection"); }
    37 function initAjax(delayMs) { setInterval(requestAjax1, delayMs);  }
Note: See TracChangeset for help on using the changeset viewer.