Einzelnen Beitrag anzeigen
Alt 24.07.2003, 20:38   #1
gnagflow
knackiger Floh ;-)
 
Benutzerbild von gnagflow
 
Registriert seit: 15.01.2002
Ort: Wien
Alter: 58
Beiträge: 1.495

Mein Computer

Frage java - anfaengerfrage

hallo java-freaks!

habe als absolut blutiger anfaenger fuer meine hp das applet "searchtohtml" uebernommen bzw modifiziert, mit dem ich nicht sehr zufrieden bin.
bei der ausgabe der ergebnisse ist die option "match kontext" auf maximal 15 zeichen beschraenkt, das wuerde ich gerne aendern.
ausserdem stuerzen mozilla 1.2.1 und ie6sp1 bei mehrmaliger benutzung des applets ab.
wie kann ich diese schwaechen ausmaerzen bzw. gibt es fuer eine hp auf einem win2k-server eine andere alternative?


code der ausgabeseite:
Code:
...

<!--The query string has the following format (each entry is encoded so that it can
be transferred safely through the URL) :
"?"+[searchwords]+","+["y" if exact, else "n"]+["y" if HTML excluded, else "n"]+
[(match) [file name]+":"+[title]+":"+[anchor]+":"+[doc info]+":"+[match context]]+","...etc.

or in other words:

"?" (searchPhrase) "," ("y" | "n") ("y" | "n") ((matchURI) ":" (title)? ":" (anchor)? ":" 
(documentInfo)? ":" (matchContext)? ",")*
-->

<script language="JavaScript">
<!--
var targetFrame = "_self";
var noData_txt = "Es wurden noch keine Daten eingegeben!";
var yourSearch_txt = "Sie suchten nach";
var exactMatches_txt = "nur exakte Resultate";
var excludingHTML_txt = "ohne HTML";
var yielded_txt = "Versuchen Sie folgende Links:";
var closestAnchor_txt = "Wahrscheinlichster Link";
var docInfo_txt = "Dokumenten-Info";
var context_txt = "Zusammenhang";
var noMatches_txt = "Leider kein Treffer!";
var displayAnchor = true;
var displayDocInfo = true;
var displayContext = true;
var preferTitleOnly = false;
var anchorTheLink = false;
function writeResults() {
    var estr = this.location.toString();
    var index = estr.indexOf("?");
    if (index == -1) {
        document.writeln("" + noData_txt + "");
        return;
    }
    
    index++;
    estr = estr.substring(index, estr.length);
    index = estr.indexOf(",");
    document.writeln("<dl>");
    document.write("<dt>" + yourSearch_txt + " " + 
                    unescape(estr.substring(0, index)) + " ");
    estr = estr.substring(index + 1, estr.length);
    if (estr.substring(0, 1) == "y") 
        document.write(" (" + exactMatches_txt + ") ");
    if (estr.substring(1, 2) == "y") 
        document.write(" (" + excludingHTML_txt + ") "); 
    document.writeln(yielded_txt + ":

");
    estr = estr.substring(2, estr.length);
    index = -1;
    var numOfMatches = 0;
    var lastindex = 0; //colon
    var clastindex = 0; //comma
    var currdata = "";
    var myUrl = "";
    var myTitle = "";
    var myanchor = "";
    var colonindex = -1;
    var info = "";
    var context = "";
    var anchor = "";
    while ((index = estr.indexOf(",", index + 1)) != -1) {
        currdata = estr.substring(clastindex, index);
        clastindex = index + 1;
        colonindex = currdata.indexOf(":");
        if (colonindex != -1) {
            numOfMatches++;
        

            myUrl = unescape(currdata.substring(0, colonindex));
      
            lastindex = colonindex + 1;
            colonindex = currdata.indexOf(":", lastindex);
            
            myTitle = unescape(currdata.substring(lastindex, colonindex));
            
            
            lastindex = colonindex + 1;
            colonindex = currdata.indexOf(":", lastindex);
            anchor = unescape(currdata.substring(lastindex, colonindex));
            
            if (anchorTheLink && anchor.length > 0) {
                myUrl += "#" + anchor;
            }
            
            document.write("<dd><a href=\""+myUrl+"\" target=\"" + 
                            targetFrame + "\">" + myTitle + " ");
            if (!preferTitleOnly || myTitle.length == 0) {
                document.write("(" + myUrl + ")");
            }
                
            document.write("</a>");


            if (anchor.length > 0 && displayAnchor && !anchorTheLink) 
                document.write(" <a href=\""+myUrl+"#"+anchor+"\" target=\"" + targetFrame + "\">[" +     closestAnchor_txt +"]</a>");
            document.writeln("
");
      
            
            lastindex = colonindex + 1;
            colonindex = currdata.indexOf(":", lastindex);
            info = unescape(currdata.substring(lastindex, colonindex));
            document.write("");
            if (info.length > 0 && displayDocInfo) 
                document.write("" + docInfo_txt + ": "+info+"");
        
            //Get the match context
            lastindex = colonindex+1;
            context = unescape(currdata.substring(lastindex, currdata.length));
            if (context.length > 0 && displayContext) 
                document.writeln("" + context_txt + ": \""+context+"\"");
            document.write("");
            document.write("

");
        }
    }
    if (numOfMatches == 0)
        document.writeln("&lt;" + noMatches_txt + "&gt;");
    document.writeln("</dl>");
}

//-->
...
der hund muesste bei
Code:
... //Get the match context ...
begraben sein, oder?

danke fuer eure hilfe!
____________________________________
Danke für die Mitarbeit!
Wolfgang

Was du nicht willst, das man dir tu\', das füg\' auch keinem Andern zu! (aus dem Talmud)

Behandelt die Menschen so, wie ihr von den Menschen behandelt werden wollt! (Jesus im Neuen Testament)
Wer die Fehler anderer übernimmt, dessen Schuld ist größer als die Schuld desjenigen, der sie begeht. (Fernöstliche Weisheit)
gnagflow ist offline   Mit Zitat antworten