Google Answers Logo
View Question
 
Q: Fix HTML Javascript that works on PC to work on PocketPC (2002 or 2003 OS) ( No Answer,   0 Comments )
Question  
Subject: Fix HTML Javascript that works on PC to work on PocketPC (2002 or 2003 OS)
Category: Computers > Software
Asked by: ken3141-ga
List Price: $150.00
Posted: 29 Jun 2003 23:21 PDT
Expires: 02 Jul 2003 05:54 PDT
Question ID: 223370
This is an extension to a previously asked and answered (well
answered, I might add) question regarding writing a javascript-enabled
webpage that would search hidden contents on the page and produce a
table of results.  Really neat, but then again, I'm easily amused. 
The original question, comments, history, and answer are here: 
http://answers.google.com/answers/main?cmd=threadview&id=222748

It does not, however, work (offline) on a PocketPC, which is
ultimately where it would need to work.  Below I've copied and pasted
two things: 1. A simple javascript HTML page that simply highlights
words on a page in red that works on a PPC (iPaq 3955 running 2002 OS,
thus proving that SOME form of Javascript will work). 2. The tweaked
version of what j_philipp-ga wrote up (I changed the item separator to
a comma from a semicolon, tweaked one cell width, and removed the
copyright).  And, I've noted what it shows and does wrong on a PPC.

THE QUESION: Can someone make it work (correctly, as it does on a PC)
on a PPC?  If so, you rock.  If instead that's too risky (as it might
not ever work), then I'd probably reduce the Price a fair amount to
just have someone play around with it.  It's not worth the full $150
to me if it won't work. Make sense?  OK, see code as follows:

----------------------------
The Simple Javascript That Works on a PPC
----------------------------

<html><body> 
JavaScript hilite demo -- Credit goes to a guy named Tim from a PPC
User Group<br>
<form method="get"> 
  <input name="search" type="text"><input type="submit"> 
</form> 

<script language='javascript'> 
var tmp = document.location.href; 
var search = ''; 

if (tmp.indexOf('search=') >= 0) { 
  tmp = tmp.substring(tmp.indexOf('search=')+'search='.length); 
  tmp = tmp.substring(0,(tmp.indexOf('&') > 0 ? tmp.indexOf('&') :
tmp.indexOf('#') > 0 ? tmp.indexOf('#') : tmp.length));
  search = tmp.replace('+',' '); 
} 

var str = ''; 

str += '<p>\nIs there a plug in or upgrade (I\'ve looked and'; 
str += ' can\'t find any) for Pocket IE that would allow on'; 
str += 'e to search within a webpage for text, like you ca'; 
str += 'n in regular IE by doing a &ctr&F. \nWe coul'; 
str += 'd really use that functionality for searching for '; 
str += 'information on our units. The webpages are all off'; 
str += '-line (on the actual iPaqs); perhaps there\'s some '; 
str += 'way we can embed an internal search function in th'; 
str += 'e HTML??? \nI\'m not optimistic, but if anyone know'; 
str += 's of an upgrade or way to do this, it\'d be great. '; 
str += '\nThanks! \nKen\n</p>\n'; 
str += ''; 

if (search) { 
  var strtmp = ''; 
  while (""+strtmp != ""+str) { 
    strtmp = str; 
    str = str.replace(' '+search,' <font
color=red><i><b>'+search.substring(0,1)+'</b><b>'+search.substring(1)+'</b></i></font>');
  } 
} 
document.write(str); 
</script> 
</body></html> 

-------------------------------
2. This is the Code that I'd love to work on a PPC, but doesn't.
When inserted, here are the visual and functional issues:
a. after the "your query", it gives TWO input boxes, one above the
other
b. Before anything is entered, the "new search" link is shown
c. None of the 'hidden text' is hidden, it's all there as text on the
bottom.
d. when i put in a search item in the box (upper or lower or both),
and tap search, nothing happens; the text stays in the box, but the
rest of the rest of the page stays the same.
Here's the code:
--------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
<title>CSV Search</title>  
  
<style><!--  
  
body  
{  
    background-color: white;  
    color: black;  
    font-family: arial, helvetica, sans-serif;  
}  
  
/* The result-found highlight style for  
   a matching string, can be changed.  
   For example, you could give it a yellow  
   background-color (see comment).  
*/  
  
.hilite  
{  
    color: red;  
    /* background-color: yellow; */  
    font-weight: bold;  
}  
 
/* Define column width; 
   Leave out specific column 
   for auto-sizing depending 
   on cell-contents: 
*/ 
 
.column1 
{ 
    width: 100px; 
} 
 
.column2 
{ 
    width: 150px; 
} 

.column3 
{ 
    width: 150px; 
} 
  
table  
{  
    border-collapse: collapse;  
    border: 1px solid black;  
}  
  
td  
{  
    text-align: left;  
    vertical-align: top;  
    padding: 6px;  
    border: 1px solid black;  
}  
  
/* Two row background-colors  
   to seperate rows; can be changed:  
*/  
  
tr td  
{  
    background-color: #eee;  
}  
  
tr.alternateRow td  
{  
    background-color: #ccc;  
}  
  
#excel  
{  
    display: none;  
}  
  
--></style>  
  
<script type="text/javascript"><!--  
  
// Row and column separator  
// characters, can be changed:  
  
var rowSeparator = "~";  
var columnSeparator = ",";  
  
var resultsI = 0;  
  
function searchData()  
{  
    var data = getData();  
    var search = document.getElementById("searchString").value;  
    var arrRows = data.split(rowSeparator);  
    var rowsLength = arrRows.length; 
  
    var s = "";  
  
    search = replaceStr(search, "  ", " ");  
    var phraseSearch = ( search.indexOf("\"") >= 0 );  
 
    arrHeader = arrRows[0].split(columnSeparator); 
    headerLength = arrHeader.length; 
    header = "";  
    for (var i = 0; i < headerLength; i++) 
    { 
     header += "<th>" + arrHeader[i] + "</th>"; 
    } 
    header = "<tr>" + header + "</tr>"; 
 
    if (phraseSearch)  
    {  
        resultsI = 0;  
        search = replaceStr(search, "\"", "");  
        s += getMatchingRows(arrRows, search);  
  
        if (s != "")  
        {  
            s = "<p>" + resultsI +  
                    " results found for phrase \"" +  
                    search + "\":</p> " +  
                    "<table>" + header + s + "</table>";  
        }  
  
    }  
    else  
    {  
        var searchWords = search.split(" ");  
        var wordsLength = searchWords.length;  
        for (var i = 0; i < wordsLength; i++)  
        {  
            resultsI = 0;  
            if (searchWords[i] != "")  
            {  
                var thisS = getMatchingRows(arrRows,  
                        searchWords[i]);  
                if (thisS != "")  
                {  
                    thisS = "<p>" + resultsI +  
                            " results found for \"" +  
                            searchWords[i] + "\":</p> " +  
                            "<table>" + header + thisS + "</table>";
                    s += thisS;  
                }  
            }  
        }  
    }  
  
    if (resultsI < 1)  
    {  
        // No results output  
        s = "<p><em>No results matching \"" +  
                search + "\" were found.</em></p>";  
    }  
  
    var outputLayer = document.getElementById("dataOutput");  
    outputLayer.innerHTML = s;  
  
    document.getElementById("h1data").innerHTML = "Results";  
    searchForm.style.display = "none";  
    newSearchLink.style.display = "block";  
}  
  
function newSearch()  
{  
    var outputLayer = document.getElementById("dataOutput");  
    outputLayer.innerHTML = "";  
    searchForm.style.display = "block";  
    newSearchLink.style.display = "none";  
    document.getElementById("h1data").innerHTML = "Search Data";  
}  
  
function getMatchingRows(arrRows, search)  
{  
    var sRow = "";  
    var isAlternate = false;  
    var rowsLength = arrRows.length;  
    var lowSearch = search.toLowerCase();  
    for (var i = 1; i < rowsLength; i++)  
    {  
        var row = arrRows[i];  
        if ( row.toLowerCase().indexOf(lowSearch) >= 0 )  
        {  
            // Construct a table row with matches  
            // to display later:  
  
            var classString = (isAlternate) ?  
                    " class=\"alternateRow\"" : "";  
            sRow += "<tr" + classString + ">"; 
 
            arrColumns = row.split(columnSeparator); 
            var columnLength = arrColumns.length; 
            for (var j = 0; j < columnLength; j++)  
            { 
                var column = arrColumns[j]; 
                sRow += "<td class=\"column" + (j + 1) + "\">"; 
                var rowDisplay = replaceStr(column, 
                    search,  
                    "<span class=\"hilite\">" + search +  
                    "</span>"); 
                sRow += rowDisplay; 
                sRow += "</td>"; 
            } 
            sRow += "</tr>";  
  
            isAlternate = !isAlternate;  
            resultsI++;  
        }  
    }  
    return sRow;  
}  
  
function getData()  
{  
    var excelLayer = document.getElementById("excel");  
    return excelLayer.firstChild.data;  
}  
  
function replaceStr(str, oldStr, newStr)  
{  
    regExp = new RegExp(oldStr, "gi"); 
    results = str.replace(regExp, newStr); 
    return results; 
}  
  
// --></script>  
</head>  
<body>  
  
<h1 id="h1data">Search Data</h1>  
  
<form id="searchForm">  
    <p>  
    Your query:  
    <input type="text" size="20"  
        name="searchString" id="searchString" />  
    <input type="text" name="suppressReturn"  
            style="display: none;" />  
    <input type="button" onclick="searchData()"  
        value="Search" />  
    </p>  
</form>  
  
<div id="dataOutput">  
&nbsp;  
</div>  
  
<div id="newSearchLink" style="display: none;">  
<p>[<a href="javascript:newSearch()">New search ...</a>]</p>  
</div>  
  
<div id="excel">   
Owner,Position,Comments,Photo?
~Lawrence Welk,Singer,VIN #A23493839ki; Reg no: 74893gh6, no
~Julia Childs,Cook and Generally Annoying TV Personality, VIN#:
93823820j89383; Lic no 483820383B, yes
~Scooby Doo,Large Talking Dog, Mystery Machine VIN#: 89439292H8300,YES
~Gumby,Giant Green Guy,VIN#: Pokey,No
</div>   
  
  
</body>  
</html>

Clarification of Question by ken3141-ga on 30 Jun 2003 04:48 PDT
OK, I dug up a little more info that might help (since I personally
know NOTHING about Java, Javascript, and all that stuff)

http://www.pswebcode.com/psw_resources.htm   Go down the page, and it
states what PIE supports in the 2002 OS.  Bunch of techie stuff that
is WAY above me, but I think it will answer any compatibility issues
for the 2003 OS.  I know the 2003 OS supports CSS (but 2002 doesn't),
so it may have other updated support as well, but I haven't found any
listing of all the tech stuff yet.

Following a lot of links, I got to
http://www.esmertec.com/products/jeode_pda.shtm which allegedly can
allow PIE to use Java Aplets, but I'm not really sure. I wouldn't
bother with this link if I were you; I'll keep plugging at it.

I'm trying to sift through the Microsoft Knowledge Base and user
groups to see if I can find the real, under the skin, difference
between the PIE versions.

[note: right now we're running the 2003

Clarification of Question by ken3141-ga on 30 Jun 2003 04:51 PDT
.... continuing the previous clarification that posted too soon....

Right now we're running the 2002 version on iPaq 3955s.  However, we
CAN, if it helps, upgrade to the 2003 OS, so leave that as an option
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy