Software Freedom Law Center

Changeset 5

Show
Ignore:
Timestamp:
11/23/05 09:42:04 (3 years ago)
Author:
orion
Message:


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rt-test.pl

    r4 r5  
    4040#my $Query= " Requestor.EmailAddress LIKE 'moglen' "; 
    4141my $Query; 
    42 # if(param()) { 
     42 if(param()) { 
    4343 
    44 #     $NoteUrl = param('NoteUrl'); 
     44     $NoteUrl = param('NoteUrl'); 
    4545#     $Query = " CustomFields.NoteUrl LIKE '$NoteUrl' "; 
    46 #
     46
    4747# else { 
    4848    $Query= " Requestor.EmailAddress LIKE 'moglen' "; 
     
    5252$TicketObj->FromSQL($Query); 
    5353$TicketObj->Query(); 
     54$TicketObj->LimitCustomField( 
     55     CUSTOMFIELD => 3, 
     56     VALUE => $NoteUrl, 
     57     OPERATOR => "=" 
     58); 
    5459$count = $TicketObj->CountAll(); 
    5560#print $TicketObj->loc("Found [quant,_1,annotation].\n",$count); 
     
    6873 
    6974    my $attachments = $Transaction->Attachments; 
    70     my $CustomFields = $item->QueueObj->TicketCustomFields(); 
     75    my $CustomFields = $item->QueueObj->TicketCustomFields(); 
    7176    $attachments->GotoFirstItem; 
    7277    my $message = $attachments->Next; 
     
    8691    $returnme .= " <i>" . $item->FirstCustomFieldValue('NoteStartNodeId') . "</i>\n"; 
    8792 
     93          $returnme .= " <id>" . $item->id . "</id>\n"; 
    8894    $returnme .= "</annotation>\n"; 
    8995 
  • trunk/searchhi.js

    r4 r5  
     1/* This is believed to be copyrighted by Stuart Langridge; the license is */ 
     2/* unkowning but we are clarifying with the author.  */ 
     3 
    14/* http://www.kryogenix.org/code/browser/searchhi/ */ 
    25/* Modified 20021006 to fix query string parsing and add case insensitivity */ 
    36 
    4 /* This is believed to be copyrighted by Stuart Langridge; the license is 
    5  * unkowning but we are clarifying with the author.  */ 
     7function highlightWord(node,word,tooltip,rtid,altClass) { 
     8  var haveHighlighted = false; 
     9  dump("doing highlightword of "+word+"\n"); 
     10  if (node.hasChildNodes) { 
     11    var iCN; 
     12    dump("this node has "+node.childNodes.length+" childNodes\n"); 
     13    for (iCN=0;iCN<node.childNodes.length;iCN++) { 
     14      dump("going in to "+node.childNodes[iCN].nodeName+"\nfor "+word+" iCN="+iCN+"\n"); 
     15      highlightWord(node.childNodes[iCN],word,tooltip,rtid); 
     16    } 
     17  } 
     18  if (node.nodeType == 3) { // text node 
     19      dump("node is "+node.nodeName+"\n"); 
     20    if (!haveHighlighted) { 
     21      dump("haven't highlighted\n"); 
     22    paragraph = node.parentNode.parentNode; 
     23    paragraphString = (new XMLSerializer).serializeToString(paragraph); 
     24    paragraphString.replace(/\s+/g,' '); 
     25    tempNodeVal = paragraphString; 
     26    tempWordVal = word; 
     27    tempWordVal = tempWordVal.replace(/\W+/g,'[\\W\\s]+(<[^>]+>)?'); 
    628 
    7 function highlightWord(node,word,tooltip,altClass) { 
    8     var haveHighlighted = false; 
     29        var re = new RegExp(tempWordVal, 'mi'); 
     30        //    var re = new RegExp("software", 'mig'); 
     31    dump("re is "+re+"\n"); 
     32            tooltipString = (new XMLSerializer).serializeToString(tooltip); 
     33            var ticketLink = rtid ? '<a href="/rt/Ticket/Display.html?id='+rtid+'">[+]</a>' : '[reload for ticket link]'; 
    934 
    10     // Iterate into this node's childNodes 
    11     if (!haveHighlighted) { 
    12     if (node.hasChildNodes) { 
    13       //      dump("iterating into child nodes\n"); 
    14       var hi_cn; 
    15       for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) { 
    16         //                dump("going in to "+node.childNodes[hi_cn].nodeName+"\nfor "+word+"\n"); 
    17         highlightWord(node.childNodes[hi_cn],word,tooltip); 
    18       } 
    19       //      dump("done with child nodes\n"); 
    20       } 
     35    paragraphString = paragraphString.replace(re,'<span class="highlight">$&<span class="annotation">'+tooltipString+ticketLink+' </span></span>'); 
     36    //     dump("replaced on "+$&+"\n"); 
     37    dump("pString is now "+paragraphString+"\n"); 
     38    node.parentNode.parentNode.innerHTML = paragraphString; 
     39     
     40    //    haveHighlighted=true; 
     41    } 
     42  } 
     43
    2144 
    22     } 
    23      
    24     // And do this node itself 
    25     if (node.nodeType == 3) { // text node 
    26       if (!haveHighlighted) { 
    27       //tempNodeVal = escape(node.nodeValue.toLowerCase()); 
    28       //tempWordVal = escape(word.toLowerCase()); 
    29       node.nodeValue = node.nodeValue.replace(/\s+/g,' '); 
    30        
    31       tempNodeVal = node.nodeValue; 
    32       tempWordVal = word; 
    33       tempWordVal = tempWordVal.replace(/\W+/g,'[\\W\\s]+'); 
    34       //tempWordVal = tempWordVal.replace(/\W+/g,' '); 
    35       //      dump('trying with\n'+escape(tempWordVal)+'\non\n'+escape(tempNodeVal)+"\n"); 
    36       var re = new RegExp(tempWordVal, 'mi'); 
    37       if ((ni = tempNodeVal.search(re)) && (ni != -1)) { 
     45/*      if ((ni = tempNodeVal.search(re)) && (ni != -1)) { 
    3846        //if (tempNodeVal.indexOf(tempWordVal) != -1) { 
    39         //    dump(tempWordVal+' matched!\n'); 
     47              dump(tempWordVal+' matched!\n'); 
    4048        pn = node.parentNode; 
    41         if (pn.className != "highlight") { 
     49        //     if (pn.className != "highlight") { 
    4250          // word has not already been highlighted! 
    4351          //                            nv = escape(node.nodeValue); 
    44           nv = node.nodeValue
     52          nv = paragraphString
    4553          //ni = tempNodeVal.indexOf(tempWordVal); 
    4654          // Create a load of replacement nodes 
     
    5058          hiwordtext = document.createTextNode(docWordVal); 
    5159          hiword = document.createElement("span"); 
    52           if (altClass) { dump("altClass is "+altClass+"\n"); } 
    53           hiword.className = altClass ? altClass : "highlight"; 
    54           hiword.title = tooltip; 
     60//        if (altClass) { dump("altClass is "+altClass+"\n"); } 
     61//        hiword.className = altClass ? altClass : "highlight"; 
     62          hiword.className = "highlight"; 
     63          //      tooltiptext = document.createTextNode(tooltip); 
     64            tooltipString = (new XMLSerializer).serializeToString(tooltip); 
     65          hiword.title = tooltipString; 
     66          //      dump('tooltiptext is '+tooltiptext.+"\n"); 
    5567          hiword.appendChild(hiwordtext); 
    5668          if (tooltip) { 
    5769            annote = document.createElement("span"); 
    5870            annote.className = "annotation"; 
    59             annoteText = document.createTextNode(tooltip); 
     71            linkToTkt = document.createElement("a"); 
     72            linkToTkt.href = '/rt/Ticket/Display.html?id='+rtid; 
     73            linkToTkt.appendChild(document.createTextNode('[+]')); 
     74            annoteText = document.createElement('span'); 
     75            annoteText.innerHTML = tooltipString; 
     76//          annoteText.appendChild(tooltiptext); 
    6077            annote.appendChild(annoteText); 
     78            //      annote.appendChild(tooltipString); 
     79            annote.appendChild(linkToTkt); 
    6180            hiword.appendChild(annote); 
    6281          } 
     82          dump(before); 
     83          //      pn.innerHTML=""; 
    6384          pn.insertBefore(before,node); 
    6485          pn.insertBefore(hiword,node); 
    6586          pn.insertBefore(after,node); 
    6687          pn.removeChild(node); 
     88      } 
    6789          haveHighlighted = true; 
     90 
     91          //    } 
     92          //    else if (pn.className == "noteLive") { 
     93          //      pn.setAttribute("class","highlight"); 
     94          //    } 
    6895        } 
    69         else if (pn.className == "noteLive") { 
    70           pn.setAttribute("class","highlight"); 
    71         } 
    72         } 
    73       } 
    74       /*                else { */ 
    75       /*                  highlightWord(node.parentNode,word,tooltip); */ 
    76       /*                } */ 
    77        
    78     } 
    79  
     96  } 
    8097} 
    8198 
    82 function XPointerHighlight() { 
    83 //      if (!document.createElement) return; 
    84 //      ref = document.referrer; 
    85 //      if (ref.indexOf('?') == -1) return; 
    86 //      qs = ref.substr(ref.indexOf('?')+1); 
    87 //      qsa = qs.split('&'); 
    88 //      for (i=0;i<qsa.length;i++) { 
    89 //              qsip = qsa[i].split('='); 
    90 //              if (qsip.length == 1) continue; 
    91 //              if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo 
     99*/ 
    92100 
    93 //              hardcoded = 'copying, distribution and modification'; 
    94 //              hardid = 'terms.0.p2.s1'; 
    95  
    96 //                      words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/); 
    97 //                      for (w=0;w<words.length;w++) { 
    98  
    99  
    100 //                              highlightWord(document.getElementsByTagName("body")[0],words[w]); 
    101 //                              highlightWord(document.getElementById(hardid),hardcoded); 
    102 //                              highlightWord(document.getElementsByTagName("body")[0],hardcoded); 
    103  
    104  
    105  
    106  //                     } 
    107 //              } 
    108 //      } 
    109 
    110  
    111 //window.onload = XPointerHighlight; 
    112 window.onload = loadXMLDoc('http://localhost/cgi-bin/rt-test.pl'); 
     101window.onload = loadXMLDoc('http://localhost/cgi-bin/rt-test.pl?NoteUrl='+location.href); 
  • trunk/selectxpath.xsl

    r4 r5  
    2727        <title><xsl:value-of select="/gpl/head/title"/></title> 
    2828        <script type="text/javascript" src="stet.js"/> 
    29         <script type="text/javascript" src="searchhi.js"/> 
    3029        <link rel="stylesheet" type="text/css" href="stet.css"/> 
    3130      </head> 
  • trunk/stet-submit.pl

    r4 r5  
    4848$returnme .= "<response>\n"; 
    4949 
    50     $returnme .= "<annotation>\n"; 
    51     $returnme .= " <n>$notetext</n>\n"; 
    52     $returnme .= " <e>$endid</e>\n"; 
    53     $returnme .= " <s>$selectedtext</s>\n";  
    54     $returnme .= " <i>$startid</i>\n"; 
     50$returnme .= "<annotation>\n"; 
     51$returnme .= " <n>$notetext</n>\n"; 
     52$returnme .= " <e>$endid</e>\n"; 
     53$returnme .= " <s>$selectedtext</s>\n";  
     54$returnme .= " <i>$startid</i>\n"; 
    5555 
    56     $returnme .= "</annotation>\n"; 
     56 
    5757 
    5858#    print Dumper($content); 
    5959 
    60    
     60
    6161 
    62 $returnme .= "</response>\n"; 
     62 
    6363 
    6464 
     
    9393  print STDERR $err . "\n" if $err; 
    9494 
     95$returnme .= " <id>$id</id>\n"; 
     96 
     97$returnme .= "</annotation>\n"; 
     98$returnme .= "</response>\n"; 
    9599print $returnme; 
  • trunk/stet.css

    r4 r5  
    7171margin-left: 100%; 
    7272//        border: 1px dotted #666; 
    73  
     73z-index: 100; 
    7474background: #f0ecb3; 
    7575 } 
     
    7777.annotation {  
    7878font-size: smaller; 
    79 position: absolute; 
    80 //float: right; 
     79//position: absolute; 
     80position: relative; 
     81float: right; 
    8182right: -200px; 
    8283width: 25%; 
    8384border: 1px dotted #666; 
    8485background: #f0ecb3; 
     86z-index: 10; 
    8587 } 
    8688 
  • trunk/stet.js

    r4 r5  
    5959        textString = textObj.toString(); 
    6060 
    61         //      highlightWord(startNode,textString,'','noteLive'); 
     61        //      highlightWord(startNode,textString,'','',''); 
    6262 
    6363        thisNode = document.getElementById(startid); 
     
    9292 
    9393function submitComment() { 
     94 
    9495var form = document.getElementById('noteify'); 
    95  
    96 var params = encodeURI('DomPath='+form.DomPath.value+'&amp;Selection='+form.Selection.value+'&amp;NoteText='+form.NoteText.value+'&amp;StartNode='+form.StartNode.value+'&amp;EndNode='+form.EndNode.value+'&amp;StartNodeId='+form.StartNodeId.value+'&amp;EndNodeId='+form.EndNodeId.value+'&amp;NoteUrl='+location.href); 
    97  
    98 var pyparams = encodeURI('custom_note_dom_path='+form.DomPath.value+'&amp;custom_note_selection='+form.Selection.value+'&amp;custom_start_node='+form.StartNode.value+'&amp;custom_end_node='+form.EndNode.value+'&amp;custom_note_start_node_id='+form.StartNodeId.value+'&amp;custom_note_end_node_id='+form.EndNodeId.value+'&amp;custom_note_url='+location.href+'&amp;description='+form.NoteText.value+'&amp;summary='+form.Selection.value+'&amp;reporter=moglen@columbia.edu&amp;mode=newticket&amp;action=create&amp;status=new&amp;component=component1&amp;severity=normal&amp;submit=create'); 
     96 var noteText = form.NoteText.value; 
     97 form.NoteText.value = "OK, submitting..."; 
     98 form.NoteText.style.background = '#aaa'; 
     99 form.style.background = '#aaa'; 
     100 
     101var params = encodeURI('DomPath='+form.DomPath.value+'&amp;Selection='+form.Selection.value+'&amp;NoteText='+noteText+'&amp;StartNode='+form.StartNode.value+'&amp;EndNode='+form.EndNode.value+'&amp;StartNodeId='+form.StartNodeId.value+'&amp;EndNodeId='+form.EndNodeId.value+'&amp;NoteUrl='+location.href); 
     102 
     103var pyparams = encodeURI('custom_note_dom_path='+form.DomPath.value+'&amp;custom_note_selection='+form.Selection.value+'&amp;custom_start_node='+form.StartNode.value+'&amp;custom_end_node='+form.EndNode.value+'&amp;custom_note_start_node_id='+form.StartNodeId.value+'&amp;custom_note_end_node_id='+form.EndNodeId.value+'&amp;custom_note_url='+location.href+'&amp;description='+noteText+'&amp;summary='+form.Selection.value+'&amp;reporter=moglen@columbia.edu&amp;mode=newticket&amp;action=create&amp;status=new&amp;component=component1&amp;severity=normal&amp;submit=create'); 
    99104 
    100105 
     
    103108//textObj = document.getElementById('Selection').value; 
    104109//startid = document.getElementById('NoteText').value; 
    105 //noteText = document.getElementById('StartNodeId').value; 
     110//noteSelection = document.getElementById('StartNodeId').value; 
    106111//endid = document.getElementById('EndNodeId').value; 
    107112//start = document.getElementById('StartNode').value; 
     
    114119var theUrl = 'http://localhost/cgi-bin/stet-submit.pl'+'?'+params; 
    115120 
    116 //loadXMLDoc(theUrl); 
     121//highlightWord(form.StartNode.value,form.Selection.value,noteText,''); 
     122loadXMLDoc(theUrl); 
    117123//cancelNote("noteify") 
    118124 
    119 window.location = 'http://trac.localdomain.org/trac.cgi'+'?'+pyparams; 
     125//window.location = 'http://trac.localdomain.org/trac.cgi'+'?'+pyparams; 
    120126} 
    121127 
     
    181187        // only if "OK" 
    182188        if (req.status == 200) { 
    183  
     189          cancelNote("noteify"); 
     190//      dump(req.responseText); 
    184191        response  = req.responseXML.documentElement; 
    185192        //foo_arr = response.getElementsByTagName("annotation"); 
     
    191198        startnodes_arr = response.getElementsByTagName("i"); 
    192199        annotations_arr = response.getElementsByTagName("n"); 
     200        rtids_arr = response.getElementsByTagName("id"); 
    193201        for (i = 0; i < selections_arr.length; i++) { 
     202//              dump("n "+i+"="+annotations_arr[i].firstChild.innerHTML+"\n"); 
    194203                startNode = startnodes_arr[i].firstChild.data; 
    195                 noteText = selections_arr[i].firstChild.data; 
    196                 annoteText = annotations_arr[i].firstChild.data; 
    197  
    198                 //                              dump("highlighting "+startNode+' '+noteText+' '+annoteText+"\n"); // debug 
    199                 highlightWord(document.getElementById(startNode),noteText,annoteText); 
     204                noteSelection = selections_arr[i].firstChild.data; 
     205                annoteText = annotations_arr[i]; 
     206//              if (annotations_arr[i].firstChild.nextSibling) { 
     207//              annoteText += annotations_arr[i].firstChild.toString(); 
     208//              } 
     209                 
     210                rtid = rtids_arr[i] ? rtids_arr[i].firstChild.data : ""; 
     211 
     212                //dump("highlighting "+startNode+' '+noteSelection+' '+annoteText+"\n"); // debug 
     213                highlightWord(document.getElementById(startNode),noteSelection,annoteText,rtid); 
     214 
    200215        //        eval(method + '(\'\', result)'); 
    201216        } 
     
    243258  } 
    244259} 
     260 
    245261function cancelNote(div) { 
    246 cancelme = document.getElementById(div); 
    247 cancelme.parentNode.removeChild(cancelme); 
     262  if (cancelme = document.getElementById(div)) { 
     263    cancelme.parentNode.removeChild(cancelme); 
     264  } 
    248265} 
    249266 
     
    255272noteifyDiv.setAttribute('id','noteify'); 
    256273noteifyDiv.setAttribute('name','noteify'); 
     274// noteifyDiv.style.z-index = '100'; 
    257275 
    258276var DomPathTxt = document.createElement('span'); 
     
    338356 
    339357} 
     358 
     359 
     360 
     361function highlightWord(node,word,tooltip,rtid,altClass) { 
     362 
     363/* this code is basically no longer descended from: */ 
     364/*                                                 */ 
     365/* http://www.kryogenix.org/code/browser/searchhi/ */ 
     366/*                             */ 
     367/* but it started out that way ... */ 
     368 
     369  var haveHighlighted = false; 
     370  //dump("doing highlightword of "+word+"\n"); 
     371  if (node.hasChildNodes) { 
     372    var iCN; 
     373    //dump("this node has "+node.childNodes.length+" childNodes\n"); 
     374    for (iCN=0;iCN<node.childNodes.length;iCN++) { 
     375      //dump("going in to "+node.childNodes[iCN].nodeName+"\nfor "+word+" iCN="+iCN+"\n"); 
     376      highlightWord(node.childNodes[iCN],word,tooltip,rtid); 
     377    } 
     378  } 
     379  if (node.nodeType == 3) { // text node 
     380    dump("node is "+node.parentNode.id+"\n"); 
     381    if (!haveHighlighted) { 
     382      //dump("haven't highlighted\n"); 
     383    paragraph = node.parentNode.parentNode; 
     384    paragraphString = (new XMLSerializer).serializeToString(paragraph); 
     385    paragraphString.replace(/\s+/g,' '); 
     386    tempNodeVal = paragraphString; 
     387    tempWordVal = word; 
     388    //tempWordVal = tempWordVal.replace(/\W+/g,'[\\W\\s]+(<[^>]+>)?'); 
     389    tempWordVal = tempWordVal.replace(/\W+/g,'[^<]*(<[^>]+>)*'); 
     390 
     391    var re = new RegExp(tempWordVal, 'mi'); 
     392        //    var re = new RegExp("software", 'mig'); 
     393    //dump("re is "+re+"\n"); 
     394    tooltipString = (new XMLSerializer).serializeToString(tooltip); 
     395    var ticketLink = rtid ? '<a href="/rt/Ticket/Display.html?id='+rtid+'">[+]</a>' : '[reload for ticket link]'; 
     396     
     397    paragraphString = paragraphString.replace(re,'<span class="highlight" id="note.'+rtid+'.'+node.parentNode.id+'">$&<span class="annotation">'+tooltipString+" "+ticketLink+' </span></span>'); 
     398    //     dump("replaced on "+$&+"\n"); 
     399    //dump("pString is now "+paragraphString+"\n"); 
     400    node.parentNode.parentNode.innerHTML = paragraphString; 
     401     
     402    //    haveHighlighted=true; 
     403    } 
     404  } 
     405} 
     406 
     407 
     408 
     409 
     410window.onload = loadXMLDoc('http://localhost/cgi-bin/rt-test.pl?NoteUrl='+location.href); 

SFLC Main Page

[frdm] Support SFLC