Changeset 5
- Timestamp:
- 11/23/05 09:42:04 (3 years ago)
- Files:
-
- trunk/rt-test.pl (modified) (4 diffs)
- trunk/searchhi.js (modified) (2 diffs)
- trunk/selectxpath.xsl (modified) (1 diff)
- trunk/stet-submit.pl (modified) (2 diffs)
- trunk/stet.css (modified) (2 diffs)
- trunk/stet.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rt-test.pl
r4 r5 40 40 #my $Query= " Requestor.EmailAddress LIKE 'moglen' "; 41 41 my $Query; 42 #if(param()) {42 if(param()) { 43 43 44 #$NoteUrl = param('NoteUrl');44 $NoteUrl = param('NoteUrl'); 45 45 # $Query = " CustomFields.NoteUrl LIKE '$NoteUrl' "; 46 #}46 } 47 47 # else { 48 48 $Query= " Requestor.EmailAddress LIKE 'moglen' "; … … 52 52 $TicketObj->FromSQL($Query); 53 53 $TicketObj->Query(); 54 $TicketObj->LimitCustomField( 55 CUSTOMFIELD => 3, 56 VALUE => $NoteUrl, 57 OPERATOR => "=" 58 ); 54 59 $count = $TicketObj->CountAll(); 55 60 #print $TicketObj->loc("Found [quant,_1,annotation].\n",$count); … … 68 73 69 74 my $attachments = $Transaction->Attachments; 70 my $CustomFields = $item->QueueObj->TicketCustomFields();75 my $CustomFields = $item->QueueObj->TicketCustomFields(); 71 76 $attachments->GotoFirstItem; 72 77 my $message = $attachments->Next; … … 86 91 $returnme .= " <i>" . $item->FirstCustomFieldValue('NoteStartNodeId') . "</i>\n"; 87 92 93 $returnme .= " <id>" . $item->id . "</id>\n"; 88 94 $returnme .= "</annotation>\n"; 89 95 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 1 4 /* http://www.kryogenix.org/code/browser/searchhi/ */ 2 5 /* Modified 20021006 to fix query string parsing and add case insensitivity */ 3 6 4 /* This is believed to be copyrighted by Stuart Langridge; the license is 5 * unkowning but we are clarifying with the author. */ 7 function 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]+(<[^>]+>)?'); 6 28 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]'; 9 34 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 } 21 44 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)) { 38 46 //if (tempNodeVal.indexOf(tempWordVal) != -1) { 39 //dump(tempWordVal+' matched!\n');47 dump(tempWordVal+' matched!\n'); 40 48 pn = node.parentNode; 41 if (pn.className != "highlight") {49 // if (pn.className != "highlight") { 42 50 // word has not already been highlighted! 43 51 // nv = escape(node.nodeValue); 44 nv = node.nodeValue;52 nv = paragraphString; 45 53 //ni = tempNodeVal.indexOf(tempWordVal); 46 54 // Create a load of replacement nodes … … 50 58 hiwordtext = document.createTextNode(docWordVal); 51 59 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"); 55 67 hiword.appendChild(hiwordtext); 56 68 if (tooltip) { 57 69 annote = document.createElement("span"); 58 70 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); 60 77 annote.appendChild(annoteText); 78 // annote.appendChild(tooltipString); 79 annote.appendChild(linkToTkt); 61 80 hiword.appendChild(annote); 62 81 } 82 dump(before); 83 // pn.innerHTML=""; 63 84 pn.insertBefore(before,node); 64 85 pn.insertBefore(hiword,node); 65 86 pn.insertBefore(after,node); 66 87 pn.removeChild(node); 88 } 67 89 haveHighlighted = true; 90 91 // } 92 // else if (pn.className == "noteLive") { 93 // pn.setAttribute("class","highlight"); 94 // } 68 95 } 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 } 80 97 } 81 98 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 */ 92 100 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'); 101 window.onload = loadXMLDoc('http://localhost/cgi-bin/rt-test.pl?NoteUrl='+location.href); trunk/selectxpath.xsl
r4 r5 27 27 <title><xsl:value-of select="/gpl/head/title"/></title> 28 28 <script type="text/javascript" src="stet.js"/> 29 <script type="text/javascript" src="searchhi.js"/>30 29 <link rel="stylesheet" type="text/css" href="stet.css"/> 31 30 </head> trunk/stet-submit.pl
r4 r5 48 48 $returnme .= "<response>\n"; 49 49 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"; 55 55 56 $returnme .= "</annotation>\n"; 56 57 57 58 58 # print Dumper($content); 59 59 60 }60 } 61 61 62 $returnme .= "</response>\n"; 62 63 63 64 64 … … 93 93 print STDERR $err . "\n" if $err; 94 94 95 $returnme .= " <id>$id</id>\n"; 96 97 $returnme .= "</annotation>\n"; 98 $returnme .= "</response>\n"; 95 99 print $returnme; trunk/stet.css
r4 r5 71 71 margin-left: 100%; 72 72 // border: 1px dotted #666; 73 73 z-index: 100; 74 74 background: #f0ecb3; 75 75 } … … 77 77 .annotation { 78 78 font-size: smaller; 79 position: absolute; 80 //float: right; 79 //position: absolute; 80 position: relative; 81 float: right; 81 82 right: -200px; 82 83 width: 25%; 83 84 border: 1px dotted #666; 84 85 background: #f0ecb3; 86 z-index: 10; 85 87 } 86 88 trunk/stet.js
r4 r5 59 59 textString = textObj.toString(); 60 60 61 // highlightWord(startNode,textString,'',' noteLive');61 // highlightWord(startNode,textString,'','',''); 62 62 63 63 thisNode = document.getElementById(startid); … … 92 92 93 93 function submitComment() { 94 94 95 var form = document.getElementById('noteify'); 95 96 var params = encodeURI('DomPath='+form.DomPath.value+'&Selection='+form.Selection.value+'&NoteText='+form.NoteText.value+'&StartNode='+form.StartNode.value+'&EndNode='+form.EndNode.value+'&StartNodeId='+form.StartNodeId.value+'&EndNodeId='+form.EndNodeId.value+'&NoteUrl='+location.href); 97 98 var pyparams = encodeURI('custom_note_dom_path='+form.DomPath.value+'&custom_note_selection='+form.Selection.value+'&custom_start_node='+form.StartNode.value+'&custom_end_node='+form.EndNode.value+'&custom_note_start_node_id='+form.StartNodeId.value+'&custom_note_end_node_id='+form.EndNodeId.value+'&custom_note_url='+location.href+'&description='+form.NoteText.value+'&summary='+form.Selection.value+'&reporter=moglen@columbia.edu&mode=newticket&action=create&status=new&component=component1&severity=normal&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 101 var params = encodeURI('DomPath='+form.DomPath.value+'&Selection='+form.Selection.value+'&NoteText='+noteText+'&StartNode='+form.StartNode.value+'&EndNode='+form.EndNode.value+'&StartNodeId='+form.StartNodeId.value+'&EndNodeId='+form.EndNodeId.value+'&NoteUrl='+location.href); 102 103 var pyparams = encodeURI('custom_note_dom_path='+form.DomPath.value+'&custom_note_selection='+form.Selection.value+'&custom_start_node='+form.StartNode.value+'&custom_end_node='+form.EndNode.value+'&custom_note_start_node_id='+form.StartNodeId.value+'&custom_note_end_node_id='+form.EndNodeId.value+'&custom_note_url='+location.href+'&description='+noteText+'&summary='+form.Selection.value+'&reporter=moglen@columbia.edu&mode=newticket&action=create&status=new&component=component1&severity=normal&submit=create'); 99 104 100 105 … … 103 108 //textObj = document.getElementById('Selection').value; 104 109 //startid = document.getElementById('NoteText').value; 105 //note Text= document.getElementById('StartNodeId').value;110 //noteSelection = document.getElementById('StartNodeId').value; 106 111 //endid = document.getElementById('EndNodeId').value; 107 112 //start = document.getElementById('StartNode').value; … … 114 119 var theUrl = 'http://localhost/cgi-bin/stet-submit.pl'+'?'+params; 115 120 116 //loadXMLDoc(theUrl); 121 //highlightWord(form.StartNode.value,form.Selection.value,noteText,''); 122 loadXMLDoc(theUrl); 117 123 //cancelNote("noteify") 118 124 119 window.location = 'http://trac.localdomain.org/trac.cgi'+'?'+pyparams;125 //window.location = 'http://trac.localdomain.org/trac.cgi'+'?'+pyparams; 120 126 } 121 127 … … 181 187 // only if "OK" 182 188 if (req.status == 200) { 183 189 cancelNote("noteify"); 190 // dump(req.responseText); 184 191 response = req.responseXML.documentElement; 185 192 //foo_arr = response.getElementsByTagName("annotation"); … … 191 198 startnodes_arr = response.getElementsByTagName("i"); 192 199 annotations_arr = response.getElementsByTagName("n"); 200 rtids_arr = response.getElementsByTagName("id"); 193 201 for (i = 0; i < selections_arr.length; i++) { 202 // dump("n "+i+"="+annotations_arr[i].firstChild.innerHTML+"\n"); 194 203 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 200 215 // eval(method + '(\'\', result)'); 201 216 } … … 243 258 } 244 259 } 260 245 261 function cancelNote(div) { 246 cancelme = document.getElementById(div); 247 cancelme.parentNode.removeChild(cancelme); 262 if (cancelme = document.getElementById(div)) { 263 cancelme.parentNode.removeChild(cancelme); 264 } 248 265 } 249 266 … … 255 272 noteifyDiv.setAttribute('id','noteify'); 256 273 noteifyDiv.setAttribute('name','noteify'); 274 // noteifyDiv.style.z-index = '100'; 257 275 258 276 var DomPathTxt = document.createElement('span'); … … 338 356 339 357 } 358 359 360 361 function 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 410 window.onload = loadXMLDoc('http://localhost/cgi-bin/rt-test.pl?NoteUrl='+location.href);