| 23 | | // Copyright (C) 2005 Software Freedom Law Center |
|---|
| 24 | | // Author: Orion Montoya <orion@mdcclv.com> |
|---|
| 25 | | |
|---|
| | 23 | /* Copyright (C) 2005 Software Freedom Law Center */ |
|---|
| | 24 | /* Author: Orion Montoya <orion@mdcclv.com> */ |
|---|
| | 25 | |
|---|
| | 26 | var ticketObj = new Object; |
|---|
| | 27 | ticketObj.rtidsBySn = new Object; |
|---|
| | 28 | var status = new Object; |
|---|
| | 29 | status.msg = new Array; |
|---|
| | 30 | status.last = last; |
|---|
| | 31 | |
|---|
| | 32 | var base64Chars = new Array( |
|---|
| | 33 | 'A','B','C','D','E','F','G','H', |
|---|
| | 34 | 'I','J','K','L','M','N','O','P', |
|---|
| | 35 | 'Q','R','S','T','U','V','W','X', |
|---|
| | 36 | 'Y','Z','a','b','c','d','e','f', |
|---|
| | 37 | 'g','h','i','j','k','l','m','n', |
|---|
| | 38 | 'o','p','q','r','s','t','u','v', |
|---|
| | 39 | 'w','x','y','z','0','1','2','3', |
|---|
| | 40 | '4','5','6','7','8','9','+','/' |
|---|
| | 41 | ); |
|---|
| | 42 | |
|---|
| | 43 | var reverseBase64Chars = new Array(); |
|---|
| | 44 | for (var i=0; i < base64Chars.length; i++){ |
|---|
| | 45 | reverseBase64Chars[base64Chars[i]] = i; |
|---|
| | 46 | } |
|---|
| | 47 | |
|---|
| | 48 | |
|---|
| | 49 | function initPage() { |
|---|
| | 50 | statusbox("Please wait while we load some comments."); |
|---|
| | 51 | var filename = location.pathname.substring(location.pathname.lastIndexOf('/')+1,location.pathname.length); |
|---|
| | 52 | if((!filename.length) || (filename.match(/index.html/))) { |
|---|
| | 53 | filename = 'gplv3-draft-1'; |
|---|
| | 54 | } |
|---|
| | 55 | |
|---|
| | 56 | if(window.location.search.length) { |
|---|
| | 57 | //dump('loadxmldoc /rt/NoAuth/xmlresults.html?'+window.location.search.substring(1)+'\n'); |
|---|
| | 58 | loadXMLDoc('/rt/NoAuth/xmlresults.html',window.location.search.substring(1)); |
|---|
| | 59 | } |
|---|
| | 60 | else { |
|---|
| | 61 | //dump('loadXMLDoc /rt/NoAuth/xmlresults.html?Query=+%27CF.NoteUrl%27+LIKE+%27'+filename+'%27+&RowsPerPage=25&Order=DESC'); |
|---|
| | 62 | loadXMLDoc('/rt/NoAuth/xmlresults.html','Query=+%27CF.NoteUrl%27+LIKE+%27'+filename+'%27+&RowsPerPage=25&Order=ASC'); |
|---|
| | 63 | } |
|---|
| | 64 | } |
|---|
| | 65 | |
|---|
| | 66 | window.onload = initPage(); |
|---|
| | 67 | |
|---|
| | 68 | |
|---|
| | 69 | // XpathSel adapted from http://www.quirksmode.org/js/selected.html |
|---|
| 52 | | |
|---|
| 53 | | |
|---|
| 54 | | for (var oStr='' ; startNode && startNode.nodeName != '#document'; startNode=startNode.parentNode) { |
|---|
| 55 | | if (startNode.nodeName!='#text') { |
|---|
| 56 | | oStr = startNode.nodeName |
|---|
| | 106 | |
|---|
| | 107 | if (!readCookie('__ac')) { |
|---|
| | 108 | document.getElementById('login').setAttribute('style','color: red; font-weight: bold; font-size: 150%'); |
|---|
| | 109 | } |
|---|
| | 110 | else { |
|---|
| | 111 | |
|---|
| | 112 | oStr = getDomPath(startNode); |
|---|
| | 113 | |
|---|
| | 114 | myNoteIfy = createNoteDiv(); |
|---|
| | 115 | textString = textObj.toString(); |
|---|
| | 116 | |
|---|
| | 117 | thisNode = document.getElementById(startid); |
|---|
| | 118 | |
|---|
| | 119 | if ((thisNode.previousSibling) && (thisNode.previousSibling.previousSibling) && (thisNode.previousSibling.previousSibling.appendChild)) { |
|---|
| | 120 | thisNode.previousSibling.previousSibling.appendChild(myNoteIfy); |
|---|
| | 121 | } |
|---|
| | 122 | else |
|---|
| | 123 | if ((thisNode.previousSibling) && (thisNode.previousSibling.appendChild)) { |
|---|
| | 124 | thisNode.previousSibling.appendChild(myNoteIfy); |
|---|
| | 125 | } |
|---|
| | 126 | else { |
|---|
| | 127 | thisNode.appendChild(myNoteIfy); |
|---|
| | 128 | } |
|---|
| | 129 | document.getElementById('DomPath').value = oStr; |
|---|
| | 130 | document.getElementById('Selection').value = textString; |
|---|
| | 131 | loadHTMLtoDiv('comment on: <strong>'+textString+'</strong>','SelectionTxt'); |
|---|
| | 132 | // document.getElementById('SelectionTxt').innerHTML = 'comment on: <strong>'+textString+'</strong>'; |
|---|
| | 133 | document.getElementById('NoteSubj').value = 'Subject/summary [required]'; |
|---|
| | 134 | document.getElementById('StartNodeId').value = startid; |
|---|
| | 135 | document.getElementById('EndNodeId').value = endid; |
|---|
| | 136 | document.getElementById('StartNode').value = start; |
|---|
| | 137 | document.getElementById('EndNode').value = end; |
|---|
| | 138 | document.getElementById('NoteUrl').value = location.href; |
|---|
| | 139 | |
|---|
| | 140 | if(startid != endid) { |
|---|
| | 141 | document.getElementById('NoteText').value = 'Your selection does not begin and end in the same sentence. Please cancel and try again with a shorter selection.'; |
|---|
| | 142 | document.getElementById('submitNote').setAttribute('disabled','disabled'); |
|---|
| | 143 | document.getElementById('NoteSubj').setAttribute('disabled','disabled'); |
|---|
| | 144 | //document.getElementById('NoteText').setAttribute('disabled','disabled'); |
|---|
| | 145 | } |
|---|
| | 146 | } |
|---|
| | 147 | } |
|---|
| | 148 | |
|---|
| | 149 | |
|---|
| | 150 | function getDomPath(startNode) { |
|---|
| | 151 | // helped here by http://www.howtocreate.co.uk/emails/FlorianSauvin.html |
|---|
| | 152 | for (var oStr='' ; startNode && startNode.nodeName != '#document'; startNode=startNode.parentNode) { |
|---|
| | 153 | if (startNode.nodeName!='#text') { |
|---|
| | 154 | oStr = startNode.nodeName |
|---|
| 59 | | } |
|---|
| 60 | | } |
|---|
| 61 | | myNoteIfy = createNoteDiv(); |
|---|
| 62 | | textString = textObj.toString(); |
|---|
| 63 | | |
|---|
| 64 | | // highlightWord(startNode,textString,'','',''); |
|---|
| 65 | | |
|---|
| 66 | | thisNode = document.getElementById(startid); |
|---|
| 67 | | |
|---|
| 68 | | if ((thisNode.previousSibling) && (thisNode.previousSibling.previousSibling) && (thisNode.previousSibling.previousSibling.appendChild)) { |
|---|
| 69 | | thisNode.previousSibling.previousSibling.appendChild(myNoteIfy); |
|---|
| 70 | | } |
|---|
| 71 | | else |
|---|
| 72 | | if ((thisNode.previousSibling) && (thisNode.previousSibling.appendChild)) { |
|---|
| 73 | | thisNode.previousSibling.appendChild(myNoteIfy); |
|---|
| 74 | | } |
|---|
| 75 | | else { |
|---|
| 76 | | thisNode.appendChild(myNoteIfy); |
|---|
| 77 | | } |
|---|
| 78 | | document.getElementById('DomPath').value = oStr; |
|---|
| 79 | | // document.getElementById('DomPathTxt').innerHTML = 'xpath: <strong>'+oStr+'</strong>'; |
|---|
| 80 | | document.getElementById('Selection').value = textString; |
|---|
| 81 | | document.getElementById('SelectionTxt').innerHTML = 'comment on: <strong>'+textString+'</strong>'; |
|---|
| 82 | | // document.getElementById('NoteText').value = startid; |
|---|
| 83 | | document.getElementById('StartNodeId').value = startid; |
|---|
| 84 | | document.getElementById('EndNodeId').value = endid; |
|---|
| 85 | | document.getElementById('StartNode').value = start; |
|---|
| 86 | | document.getElementById('EndNode').value = end; |
|---|
| 87 | | document.getElementById('NoteUrl').value = location.href; |
|---|
| 88 | | // document.getElementById('cancel').setAttribute('parent',startid); |
|---|
| 89 | | |
|---|
| 90 | | |
|---|
| 91 | | |
|---|
| 92 | | // location.href='http://localhost/cgi-bin/stet-submit.pl?url='+escape(location.href)+'&dompath='+oStr+'&selectedtext='+escape(textObj)+'&start='+escape(start)+'&startid='+escape(startid)+'&end='+escape(end)+'&endid='+escape(endid);; |
|---|
| 93 | | |
|---|
| | 157 | } |
|---|
| | 158 | } |
|---|
| 97 | | |
|---|
| 98 | | var form = document.getElementById('noteify'); |
|---|
| 99 | | var noteText = form.NoteText.value; |
|---|
| 100 | | form.NoteText.value = "OK, submitting..."; |
|---|
| 101 | | form.NoteText.style.background = '#aaa'; |
|---|
| 102 | | form.style.background = '#aaa'; |
|---|
| 103 | | |
|---|
| 104 | | 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); |
|---|
| 105 | | |
|---|
| 106 | | 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'); |
|---|
| 107 | | |
|---|
| 108 | | |
|---|
| 109 | | |
|---|
| 110 | | //oStr = document.getElementById('DomPath').value; |
|---|
| 111 | | //textObj = document.getElementById('Selection').value; |
|---|
| 112 | | //startid = document.getElementById('NoteText').value; |
|---|
| 113 | | //noteSelection = document.getElementById('StartNodeId').value; |
|---|
| 114 | | //endid = document.getElementById('EndNodeId').value; |
|---|
| 115 | | //start = document.getElementById('StartNode').value; |
|---|
| 116 | | //end = document.getElementById('EndNode').value; |
|---|
| 117 | | |
|---|
| 118 | | //http://localhost/cgi-bin/stet-submit.pl?DomPath=&Selection=&NoteText=&StartNode=&EndNode=&StartNodeId=&EndNodeId&NoteUrl= |
|---|
| 119 | | |
|---|
| 120 | | //var theUrl = 'http://localhost/cgi-bin/stet-submit.pl?NoteUrl='+escape(location.href)+'&DomPath='+oStr+'&Selection='+escape(textObj)+'&StartNode='+escape(start)+'&StartNodeId='+escape(startid)+'&EndNode='+escape(end)+'&EndNodeId='+escape(endid); |
|---|
| 121 | | //dump('would open '+theUrl+"\n"); |
|---|
| 122 | | var theUrl = 'http://localhost/cgi-bin/stet-submit.pl'+'?'+params; |
|---|
| 123 | | |
|---|
| 124 | | //highlightWord(form.StartNode.value,form.Selection.value,noteText,''); |
|---|
| 125 | | loadXMLDoc(theUrl); |
|---|
| 126 | | //cancelNote("noteify") |
|---|
| 127 | | |
|---|
| 128 | | //window.location = 'http://trac.localdomain.org/trac.cgi'+'?'+pyparams; |
|---|
| 129 | | } |
|---|
| 130 | | |
|---|
| 131 | | function toggle(myClass) { |
|---|
| 132 | | |
|---|
| 133 | | var toggleUs = getElementsByClass(myClass); |
|---|
| 134 | | for (var i=0; i < toggleUs.length; i++) { |
|---|
| 135 | | // if (toggleUs[i].style.display == 'inline') { |
|---|
| 136 | | toggleUs[i].style.display='none'; |
|---|
| 137 | | // } |
|---|
| 138 | | // else if (toggleUs[i].style.display == 'none') { |
|---|
| 139 | | // toggleUs[i].style.display='inline'; |
|---|
| 140 | | // } |
|---|
| 141 | | } |
|---|
| | 162 | |
|---|
| | 163 | if ((document.getElementById('NoteSubj').value == 'Subject/summary [required]') || (document.getElementById('NoteSubj').value == ' ')) { |
|---|
| | 164 | // document.getElementById('SelectionTxt').innerHTML = '<span class="error">Please enter a brief explanatory subject for this comment</span>'; |
|---|
| | 165 | |
|---|
| | 166 | loadHTMLtoDiv('<span class="error">Please enter a brief explanatory subject for this comment</span>','SelectionTxt'); |
|---|
| | 167 | } |
|---|
| | 168 | else { |
|---|
| | 169 | |
|---|
| | 170 | var form = document.getElementById('noteify'); |
|---|
| | 171 | var noteText = form.NoteText.value; |
|---|
| | 172 | loadHTMLtoDiv('Ok, submitting...','SelectionTxt'); |
|---|
| | 173 | form.NoteText.style.background = '#aaa'; |
|---|
| | 174 | form.NoteSubj.style.background = '#aaa'; |
|---|
| | 175 | document.getElementById('submitNote').setAttribute('disabled','disabled'); |
|---|
| | 176 | document.getElementById('cancel').setAttribute('disabled','disabled'); |
|---|
| | 177 | form.style.background = '#aaa'; |
|---|
| | 178 | |
|---|
| | 179 | var params = encodeURI('DomPath='+form.DomPath.value+'&Selection='+encodeURIComponent(form.Selection.value)+'&NoteSubj='+encodeURIComponent(form.NoteSubj.value)+'&NoteText='+encodeURIComponent(noteText)+'&StartNode='+form.StartNode.value+'&EndNode='+form.EndNode.value+'&StartNodeId='+form.StartNodeId.value+'&EndNodeId='+form.EndNodeId.value+'&NoteUrl='+location.href); |
|---|
| | 180 | |
|---|
| | 181 | |
|---|
| | 182 | |
|---|
| | 183 | var theUrl = 'stet-submit.pl'; |
|---|
| | 184 | //highlightWord(form.StartNode.value,form.Selection.value,noteText,''); |
|---|
| | 185 | loadXMLDoc(theUrl,params); |
|---|
| | 186 | } |
|---|
| 168 | | // branch for native XMLHttpRequest object |
|---|
| 169 | | if (window.XMLHttpRequest) { |
|---|
| 170 | | req = new XMLHttpRequest(); |
|---|
| 171 | | req.onreadystatechange = processReqChange; |
|---|
| 172 | | // netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); |
|---|
| 173 | | req.open("GET", url, true); // true = asynchronous |
|---|
| 174 | | req.send(null); |
|---|
| 175 | | // branch for IE/Windows ActiveX version |
|---|
| 176 | | } else if (window.ActiveXObject) { |
|---|
| 177 | | req = new ActiveXObject('Microsoft.XMLHTTP'); |
|---|
| 178 | | if (req) { |
|---|
| 179 | | req.onreadystatechange = processReqChange; |
|---|
| 180 | | req.open("GET", url, true); |
|---|
| 181 | | req.send(); |
|---|
| 182 | | } |
|---|
| 183 | | } |
|---|
| | 211 | dump('loading '+url+'?'+theData+'\n'); |
|---|
| | 212 | // branch for native XMLHttpRequest object |
|---|
| | 213 | if (window.XMLHttpRequest) { |
|---|
| | 214 | req = new XMLHttpRequest(); |
|---|
| | 215 | } else if (window.ActiveXObject) { |
|---|
| | 216 | req = new ActiveXObject('Microsoft.XMLHTTP'); |
|---|
| | 217 | } |
|---|
| | 218 | req.onreadystatechange = processReqChange; |
|---|
| | 219 | |
|---|
| | 220 | req.open("POST", url, true); |
|---|
| | 221 | // req.open("GET", url, false); |
|---|
| | 222 | req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); |
|---|
| | 223 | req.setRequestHeader('X-Referer',document.location); |
|---|
| | 224 | // theData = encodeURI(theData); |
|---|
| | 225 | req.send(theData); |
|---|
| | 226 | } |
|---|
| | 227 | |
|---|
| | 228 | function loadHTMLtoDiv(text,targetid,caller) { |
|---|
| | 229 | // this won't work in Safari so we need a Safari case: |
|---|
| | 230 | if(targetid) { |
|---|
| | 231 | dump('targetid is '+targetid); |
|---|
| | 232 | if(caller) { dump(', caller is '+caller);} |
|---|
| | 233 | dump('\n'); |
|---|
| | 234 | if (myElement = document.getElementById(targetid)) { |
|---|
| | 235 | // dump(e); |
|---|
| | 236 | try { |
|---|
| | 237 | myElement.innerHTML = text; |
|---|
| | 238 | } |
|---|
| | 239 | catch(e) { |
|---|
| | 240 | var newDiv = document.createElement('span'); |
|---|
| | 241 | newDiv.innerHTML = text; |
|---|
| | 242 | myElement.appendChild(newDiv); |
|---|
| | 243 | } |
|---|
| | 244 | } |
|---|
| | 245 | } |
|---|
| | 246 | } |
|---|
| | 247 | |
|---|
| | 248 | // thanks to http://www.mercurytide.com/knowledge/white-papers/issues-working-with-ajax |
|---|
| | 249 | function getXMLNodeSerialisation(xmlNode) { |
|---|
| | 250 | var text = false; |
|---|
| | 251 | try { |
|---|
| | 252 | // Gecko-based browsers, Safari, Opera. |
|---|
| | 253 | var serializer = new XMLSerializer(); |
|---|
| | 254 | text = serializer.serializeToString(xmlNode); |
|---|
| | 255 | } |
|---|
| | 256 | catch (e) { |
|---|
| | 257 | try { |
|---|
| | 258 | // Internet Explorer. |
|---|
| | 259 | text = xmlNode.xml; |
|---|
| | 260 | } |
|---|
| | 261 | catch (e) {} |
|---|
| | 262 | } |
|---|
| | 263 | return text; |
|---|
| | 264 | } |
|---|
| | 265 | |
|---|
| | 266 | function loadURLtoDiv(url,args,targetid) { |
|---|
| | 267 | // branch for native XMLHttpRequest object |
|---|
| | 268 | if (window.XMLHttpRequest) { |
|---|
| | 269 | req = new XMLHttpRequest(); |
|---|
| | 270 | } else if (window.ActiveXObject) { |
|---|
| | 271 | req = new ActiveXObject('Microsoft.XMLHTTP'); |
|---|
| | 272 | } |
|---|
| | 273 | req.open('GET',url,false); |
|---|
| | 274 | req.send(args); |
|---|
| | 275 | |
|---|
| | 276 | loadHTMLtoDiv(req.responseText,targetid,"loadurltodiv"); |
|---|
| | 277 | // document.getElementById(targetid).innerHTML = req.responseText; |
|---|
| | 278 | |
|---|
| | 279 | |
|---|
| 188 | | // only if req shows "complete" |
|---|
| 189 | | if (req.readyState == 4) { |
|---|
| 190 | | // only if "OK" |
|---|
| 191 | | if (req.status == 200) { |
|---|
| 192 | | cancelNote("noteify"); |
|---|
| 193 | | // dump(req.responseText); |
|---|
| 194 | | response = req.responseXML.documentElement; |
|---|
| 195 | | //foo_arr = response.getElementsByTagName("annotation"); |
|---|
| 196 | | // dump(req.responseXML+"\n"); |
|---|
| 197 | | // dump(foo_arr + ' ' + foo_arr.length + ' ' + foo_arr.item(1)+"\n"); |
|---|
| 198 | | |
|---|
| 199 | | selections_arr = response.getElementsByTagName("s"); |
|---|
| 200 | | // dump(selections_arr + ' ' + selections_arr.length + ' ' + selections_arr.item(0)+"\n"); |
|---|
| 201 | | startnodes_arr = response.getElementsByTagName("i"); |
|---|
| 202 | | annotations_arr = response.getElementsByTagName("n"); |
|---|
| 203 | | rtids_arr = response.getElementsByTagName("id"); |
|---|
| 204 | | for (i = 0; i < selections_arr.length; i++) { |
|---|
| 205 | | // dump("n "+i+"="+annotations_arr[i].firstChild.innerHTML+"\n"); |
|---|
| 206 | | startNode = startnodes_arr[i].firstChild.data; |
|---|
| 207 | | noteSelection = selections_arr[i].firstChild.data; |
|---|
| 208 | | annoteText = annotations_arr[i]; |
|---|
| 209 | | // if (annotations_arr[i].firstChild.nextSibling) { |
|---|
| 210 | | // annoteText += annotations_arr[i].firstChild.toString(); |
|---|
| 211 | | // } |
|---|
| 212 | | |
|---|
| 213 | | rtid = rtids_arr[i] ? rtids_arr[i].firstChild.data : ""; |
|---|
| 214 | | |
|---|
| 215 | | //dump("highlighting "+startNode+' '+noteSelection+' '+annoteText+"\n"); // debug |
|---|
| 216 | | highlightWord(document.getElementById(startNode),noteSelection,annoteText,rtid); |
|---|
| 217 | | |
|---|
| 218 | | // eval(method + '(\'\', result)'); |
|---|
| | 284 | |
|---|
| | 285 | // only if req shows "complete" |
|---|
| | 286 | if (req.readyState == 4) { |
|---|
| | 287 | // only if "OK" |
|---|
| | 288 | if (req.status == 200) { |
|---|
| | 289 | /* <jag> [Exception... "Component returned failure code: 0x80040111 |
|---|
| | 290 | (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: |
|---|
| | 291 | "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: |
|---|
| | 292 | http://gplv3.fsf.org/stet/stet.js :: processReqChange :: line 189" |
|---|
| | 293 | data: no] |
|---|
| | 294 | */ |
|---|
| | 295 | cancelNote("noteify"); |
|---|
| | 296 | //dump(req.responseText); |
|---|
| | 297 | response = req.responseXML.documentElement; |
|---|
| | 298 | dump("pre processAnnot\n"); |
|---|
| | 299 | var resp_arrN; |
|---|
| | 300 | var resp_arrA; |
|---|
| | 301 | var resp_arrF; |
|---|
| | 302 | cs = response.getElementsByTagName("cs"); |
|---|
| | 303 | statusbox(getXMLNodeSerialisation(cs[0])); |
|---|
| | 304 | |
|---|
| | 305 | resp_arrN = response.getElementsByTagName("annotation"); |
|---|
| | 306 | if(resp_arrN.length) { |
|---|
| | 307 | dump("processAnnot\n") |
|---|
| | 308 | processAnnotation(response); |
|---|
| | 309 | } |
|---|
| | 310 | |
|---|
| | 311 | else if (resp_arrF = response.getElementsByTagName("form")) { |
|---|
| | 312 | dump("pre processNQ\n") |
|---|
| | 313 | if(resp_arrF.length) { |
|---|
| | 314 | dump("processNQ\n") |
|---|
| | 315 | processNewQuery(response); |
|---|
| | 316 | } |
|---|
| | 317 | } |
|---|
| | 318 | else if (resp_arrA = response.getElementsByTagName("agreement")) { |
|---|
| | 319 | // dump("pre processAgree\n"+resp_arr[0].firstChild.data+"\n"); |
|---|
| | 320 | |
|---|
| | 321 | if(resp_arrA.length) { |
|---|
| | 322 | dump("processAgree\n"); |
|---|
| | 323 | processAgreement(response); |
|---|
| | 324 | } |
|---|
| | 325 | } |
|---|
| | 326 | else { |
|---|
| | 327 | statusbox("There was a problem retrieving the XML data:\n" + req.statusText+"\n"); //debug |
|---|
| | 328 | } |
|---|
| | 329 | } |
|---|
| | 330 | } |
|---|
| | 331 | // else { dump("readyState was "+req.readyState+"\n"); } // debug |
|---|
| | 332 | } |
|---|
| | 333 | |
|---|
| | 334 | function onNoteifyMouseover() { |
|---|
| | 335 | //this.onblur = onNoteifyBlur; |
|---|
| | 336 | |
|---|
| | 337 | } |
|---|
| | 338 | |
|---|
| | 339 | function processAnnotation(response) { |
|---|
| | 340 | // document.getElementById("statusbox").innerHTML = getXMLNodeSerialisation(cs[0]); |
|---|
| | 341 | // dump("got an annotation\n"); |
|---|
| | 342 | // dump(req.responseXML+"\n"); |
|---|
| | 343 | // responseStringSer = getXMLNodeSerialisation(req.responseXML); |
|---|
| | 344 | // dump(responseStringSer); |
|---|
| | 345 | // dump(resp_arr + ' ' + resp_arr.length + ' ' + resp_arr.item(1)+"\n"); |
|---|
| | 346 | |
|---|
| | 347 | selections_arr = response.getElementsByTagName("s"); |
|---|
| | 348 | // dump(selections_arr + ' ' + selections_arr.length + ' ' + selections_arr.item(0)+"\n"); |
|---|
| | 349 | startnodes_arr = response.getElementsByTagName("i"); |
|---|
| | 350 | annotations_arr = response.getElementsByTagName("n"); |
|---|
| | 351 | rtids_arr = response.getElementsByTagName("id"); |
|---|
| | 352 | users_arr = response.getElementsByTagName("u"); |
|---|
| | 353 | uagr_arr = response.getElementsByTagName("ua"); |
|---|
| | 354 | agrtot_arr = response.getElementsByTagName("at"); |
|---|
| | 355 | for (prI = 0; prI < selections_arr.length; prI++) { |
|---|
| | 356 | rtids_arr[prI].firstChild.data ? rtid = rtids_arr[prI].firstChild.data : rtid = "error"; |
|---|
| | 357 | tooltipString = getXMLNodeSerialisation(annotations_arr[prI]); |
|---|
| | 358 | tooltipString.length > 165 ? tooltipSubString = tooltipString.substr(0,199) + '...' : tooltipSubString = tooltipString; |
|---|
| | 359 | |
|---|
| | 360 | ticketObj[rtid] = new Object; |
|---|
| | 361 | |
|---|
| | 362 | ticketObj[rtid].link = rtid ? '<a href="/rt/NoAuth/readsay.html?id='+rtid+'">read/say more</a> ' : '[problem with ticket link]'; |
|---|
| | 363 | agreechild = uagr_arr[prI].firstChild.data |
|---|
| | 364 | agreestr = getXMLNodeSerialisation(uagr_arr[prI]); |
|---|
| | 365 | if ((agreechild == "agree") || (agreechild == "unagree")) { |
|---|
| | 366 | ticketObj[rtid].link += '<a id="agree'+rtid+'" href="javascript:iAgree(\''+rtid+'\',\''+agreechild+'\')">'+agreechild+'</a> | '; |
|---|
| | 367 | } |
|---|
| | 368 | else { |
|---|
| | 369 | ticketObj[rtid].link += ' '+agreestr+' | '; |
|---|
| | 370 | } |
|---|
| | 371 | if (agrtot_arr[prI].firstChild.data > 0) { |
|---|
| | 372 | ticketObj[rtid].link += ' ['+agrtot_arr[prI].firstChild.data+' agree]'; |
|---|
| | 373 | } |
|---|
| | 374 | ticketObj[rtid].full = tooltipString; |
|---|
| | 375 | ticketObj[rtid].excerpt = tooltipSubString; |
|---|
| | 376 | ticketObj[rtid].user = users_arr[prI].firstChild ? users_arr[prI].firstChild.data : ""; |
|---|
| | 377 | ticketObj[rtid].startnode = startnodes_arr[prI].firstChild.data; |
|---|
| | 378 | if(!ticketObj.rtidsBySn[ticketObj[rtid].startnode]) { |
|---|
| | 379 | ticketObj.rtidsBySn[ticketObj[rtid].startnode] = new Array(rtid); |
|---|
| | 380 | } |
|---|
| | 381 | else { |
|---|
| | 382 | ticketObj.rtidsBySn[ticketObj[rtid].startnode].push(rtid); |
|---|
| | 383 | } |
|---|
| | 384 | ticketObj[rtid].ua = getXMLNodeSerialisation(uagr_arr[prI]); |
|---|
| | 385 | startNode = startnodes_arr[prI].firstChild.data; |
|---|
| | 386 | startNode = startNode.replace(/note\.[0-9]+\./,''); |
|---|
| | 387 | noteSelection = selections_arr[prI].firstChild.data; |
|---|
| | 388 | // annoteText = users_arr[prI].firstChild.data+": "+ annotations_arr[prI].firstChild.data; |
|---|
| | 389 | annoteText = annotations_arr[prI]; |
|---|
| | 390 | // if (annotations_arr[prI].firstChild.nextSibling) { |
|---|
| | 391 | // annoteText += annotations_arr[prI].firstChild.toString(); |
|---|
| | 392 | // } |
|---|
| | 393 | |
|---|
| | 394 | rtid = rtids_arr[prI] ? rtids_arr[prI].firstChild.data : ""; |
|---|
| | 395 | user = users_arr[prI].firstChild ? users_arr[prI].firstChild.data : ""; |
|---|
| | 396 | // dump(users_arr[prI].firstChild.data); |
|---|
| | 397 | dump("\nhighlighting "+startNode+' '+noteSelection+' '+annoteText+' rt'+rtid+'\n'); |
|---|
| | 398 | highlightWord(document.getElementById(startNode),noteSelection,annoteText,rtid,user); |
|---|
| | 399 | |
|---|
| | 400 | // FIXME: couple bugs left in intense_annot, |
|---|
| | 401 | // new comments are not getting highlighted upon submission |
|---|
| | 402 | // and I want to sort out the rtidsBySn thing, so I can |
|---|
| | 403 | // annote one paragraph at a time. |
|---|
| | 404 | // also other distressing inconsistencies make the wack-ass |
|---|
| | 405 | // highlightWord() a better choice for the moment. |
|---|
| | 406 | |
|---|
| | 407 | // fixme: currently crashes browser :) |
|---|
| | 408 | |
|---|
| | 409 | //intense_annot(document.getElementById(startNode),noteSelection,rtid); |
|---|
| | 410 | |
|---|