Software Freedom Law Center

Changeset 78

Show
Ignore:
Timestamp:
09/28/06 21:22:32 (2 years ago)
Author:
orion
Message:


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/stet-archived.js

    r77 r78  
    4545var firstLoad = "1"; 
    4646var noMatch =  0; 
     47 
    4748function initPage() { 
    4849  //  alert("starting initPage, supposedly DOM is loaded"); 
     
    8889// have to use an XMLHTTPRequest call. 
    8990function XpathSel() {  
    90   if (!readCookie('__ac')) { 
     91 
    9192    document.getElementById('login').setAttribute('style','color: red; font-weight: bold; font-size: 150%'); 
    9293    return; 
    9394  } 
    94   var textObj = ''; 
    95   var start = ''; 
    96   var end = ''; 
    97   if (window.getSelection) 
    98     { 
    99       textObj = window.getSelection(); 
    100     } 
    101   else if (document.getSelection) 
    102     { 
    103       textObj= document.getSelection(); 
    104     } 
    105   else if (document.selection) 
    106     { 
    107       textObj= document.selection.createRange().text; 
    108     } 
    109        if(textObj.length < 1) { 
    110          document.getElementById('selectsome').setAttribute('class','error'); 
    111          document.getElementById('login').innerHTML(textObj.length); 
    112          return; 
    113        } 
    114  
    115     try { var sn = textObj.anchorNode; } catch(e) {} 
    116     if (!sn) {  // lame getSelection object has no anchorNode 
    117        loadXMLDoc('/comments/rt/formxml.html','selection='+encodeURI(textObj.toString())); 
    118          
    119  
    120     } 
    121     else {  // good getSelection 
    122       try { var startNode = textObj.anchorNode; } catch(e) { } 
    123       if (startNode.parentNode.getAttribute && startNode.parentNode.getAttribute('class') && startNode.parentNode.getAttribute('class').match(/highlight/)) { 
    124         startNode = startNode.parentNode; 
    125       } 
    126       try { var startid = startNode.parentNode.id; } catch(e) { } 
    127       try { var start = startNode.parentNode.nodeName; } catch(e) { } 
    128       var endnode = textObj.focusNode.parentNode; 
    129       if (endnode.getAttribute && endnode.getAttribute('class') && endnode.getAttribute('class').match(/highlight/)) { 
    130         endnode = endnode.parentNode; 
    131       } 
    132       var endid = endnode.id; 
    133       var end = endnode.nodeName; 
    134       if (!readCookie('__ac')) { 
    135         // emphasizes that You need to log in to make comments. 
    136         document.getElementById('login').setAttribute('style','color: red; font-weight: bold; font-size: 150%'); 
    137       } 
    138       else { 
    139         // create the note form 
    140         var oStr = getDomPath(startNode); 
    141         createNoteDiv(startid); 
    142         var textString = textObj.toString(); 
    143         document.getElementById('DomPath').value = oStr; 
    144         document.getElementById('Selection').value = textString; 
    145         loadHTMLtoDiv('comment on: <strong>'+textString+'</strong>','SelectionTxt'); 
    146         document.getElementById('NoteSubj').value = 'Subject/summary [required]'; 
    147         document.getElementById('StartNodeId').value = startid; 
    148         // document.getElementById('EndNodeId').value = endid; 
    149         document.getElementById('NoteUrl').value = filename; 
    150         if ((i = navigator.userAgent.indexOf('MSIE')) >= 0) { 
    151           document.getElementById('SelectionTxt').innerHTML += "<br/>Comment submission isn't working on the copy of IE 6 we tested [if IE is really the browser you're using] but you're welcome to try.  If this box doesn't turn gray and then disappear when you click 'Submit', it probably didn't work: you can <a href=\"/comments/email.html\">email your comment</a> instead."; 
    152         } 
    153         if(startid != endid) { 
    154           noteErr('Your selection does not begin and end in the same sentence.  Please cancel and try again with a shorter selection.  If you want to comment on a whole section, please highlight the section title instead.  startid='+startid+', endid='+endid); 
    155         } 
    156         if((startid =='login') || (startid == undefined) || (textString == undefined) || (textString == '')) { 
    157           noteErr('You\'ve found a browser-compatibility bug that we\'re trying to fix; we would appreciate an email to stet@gplv3.fsf.org saying exactly what browser you\'re using (though we know about Safari).  For the moment the best way to send your comment would be via email: see http://gplv3.fsf.org/comments/email.html'); 
    158         } 
    159       } 
    160     } 
    161 
    162  
    163 function noteErr(msg) { 
    164   document.getElementById('NoteText').value = msg; 
    165   document.getElementById('submitNote').setAttribute('disabled','disabled'); 
    166   document.getElementById('NoteSubj').setAttribute('disabled','disabled'); 
    167 
    168  
    169 /* // not currently used: could invoke when calling submitComment();  
    170 function rmChildNotes(startid) { 
    171   node = document.getElementById(startid); 
    172   //  var oldChild; 
    173   if (node.hasChildNodes()) { 
    174     for (var nodeCt = 0; nodeCt < node.childNodes.length; nodeCt++) { 
    175       if (node.childNodes.item(nodeCt).getAttribute('class').match('notegroup')) {  
    176         //oldChild.appendChild( 
    177         node.removeChild(node.childNodes.item(nodeCt)); 
    178         // ) 
    179       } 
    180     } 
    181   } 
    182   } */ 
     95 
    18396function processDompath(response) { 
    18497  currently('asking server about your selection...'); 
     
    215128} 
    216129 
    217 function submitComment() { 
    218   // doesn't fire on IE, hmm. 
    219   if ((document.getElementById('NoteSubj').value == 'Subject/summary [required]') || (document.getElementById('NoteSubj').value == ' ')) { 
    220     loadHTMLtoDiv('<span class="error">Please enter a brief explanatory subject for this comment</span>','SelectionTxt'); 
    221   } 
    222   else { 
    223   var form = document.getElementById('noteify'); 
    224   //rmChildNotes(form.StartNodeId.value); 
    225   var noteText = form.NoteText.value; 
    226   loadHTMLtoDiv('Ok, submitting...','SelectionTxt'); 
    227   form.NoteText.style.background = '#aaa'; 
    228   form.NoteSubj.style.background = '#aaa'; 
    229   document.getElementById('submitNote').setAttribute('disabled','disabled'); 
    230   document.getElementById('cancel').setAttribute('disabled','disabled'); 
    231   form.style.background = '#aaa'; 
    232  
    233   var params = encodeURI('DomPath='+form.DomPath.value+'&amp;Selection='+encodeURIComponent(form.Selection.value)+'&amp;NoteSubj='+encodeURIComponent(form.NoteSubj.value)+'&amp;NoteText='+encodeURIComponent(noteText)+'&amp;StartNodeId='+form.StartNodeId.value+'&amp;NoteUrl='+location.href+'&amp;queue='+form.queue.value); 
    234  
    235   var theUrl = '/comments/rt/submitcomment-cachetoo.html';  
    236   loadXMLDoc(theUrl,params); 
    237   } 
    238 } 
    239130 
    240131// these are all too too slow, maybe cssQuery 
     
    365256    // only if "OK" or "not modified" 
    366257    if ((req.status == 200) || (req.status == 304)) { 
    367       cancelNote("noteify"); 
    368       cancelNote("loading"); 
    369258      var response  = req.responseXML.documentElement; 
    370259      var resp_arrN; 
     
    400289      } 
    401290      resp_arrA = response.getElementsByTagName("agreement"); 
    402       if(!!resp_arrN.length && (resp_arrN.length > 0)) { 
     291      if(!!resp_arrA.length && (resp_arrA.length > 0)) { 
    403292        processAgreement(response); 
    404293        did++; 
     
    628517          agreestr = agreestr.replace(/<\/?span>/g,''); 
    629518          agreestr = agreestr.replace(/<\/?b>/g,''); 
    630           if ((agreestr == "agree") || (agreestr == "unagree")) { 
    631             returnLink += ' | <a id="agree'+rtid+'" href="javascript:iAgree('+rtid+',\''+agreestr+'\')">'+agreestr+'</a> | '; 
    632           } 
    633           else { 
    634             returnLink += ' | <span id="agree'+rtid+'">'+agreestr+'</span> | '; 
    635           } 
    636519          if (agrtot > 0) { 
    637             returnLink += ' [<span id="agrtot'+rtid+'">'+agrtot+'</span> agree]'; 
     520            returnLink += ' [<span id="agrtot'+rtid+'">'+agrtot+'</span> agreed]'; 
    638521          } 
    639522          return returnLink; 
    640523} 
    641524 
    642  
    643  
    644 function processAgreement(response) { 
    645   currently('Indicating your agreement with this comment...'); 
    646         myId = response.getElementsByTagName("id")[0].firstChild.data; 
    647         myOpn = response.getElementsByTagName("b")[0].firstChild.data; 
    648         myLink = document.getElementById('agree'+myId); 
    649         opOpn = document.createElement('span'); 
    650         myOpn == "agree" ? opOpn.appendChild(document.createTextNode("unagree")) : opOpn.appendChild(document.createTextNode("agree")); 
    651         var agrcount = response.getElementsByTagName("ct")[0].firstChild.data; 
    652         loadHTMLtoDiv(agrcount,'agrtot'+myId); 
    653         ticketObj[myId].link = makeLinkObj(myId,getXMLNodeSerialisation(opOpn),agrcount); 
    654         showFull(myId); 
    655         myLink.href = 'javascript:iAgree('+myId+',\''+opOpn+'\')'; 
    656         currently('Ready.'); 
    657       } 
    658525 
    659526   
     
    677544} 
    678545 
    679 function cancelNote(div) { 
    680   if (cancelme = document.getElementById(div)) { 
    681     cancelme.parentNode.removeChild(cancelme); 
    682   } 
    683 } 
    684  
    685 function createNoteDiv(startid) { 
    686  
    687   // this would be a lot more readable and maintainable if it were 
    688   // just a string. 
    689  
    690 var noteifyDiv = document.createElement('form'); 
    691 noteifyDiv.setAttribute('action','/comments/rt/submitcomment-cachetoo.html'); 
    692 noteifyDiv.setAttribute('class','noteify'); 
    693 noteifyDiv.setAttribute('id','noteify'); 
    694 noteifyDiv.setAttribute('name','noteify'); 
    695 noteifyDiv.setAttribute('onblur','onNoteifyBlur()'); 
    696 // noteifyDiv.style.z-index = '100'; 
    697  
    698 var DomPathTxt = document.createElement('span'); 
    699 DomPathTxt.setAttribute('id','DomPathTxt'); 
    700 DomPathTxt.setAttribute('name','DomPathTxt'); 
    701  
    702 var DomPath = document.createElement('input'); 
    703 DomPath.setAttribute('id','DomPath'); 
    704 DomPath.setAttribute('name','DomPath'); 
    705 DomPath.setAttribute('type','hidden'); 
    706 DomPath.setAttribute('class','addnote'); 
    707  
    708 var SelectionTxt = document.createElement('span'); 
    709 SelectionTxt.setAttribute('id','SelectionTxt'); 
    710 SelectionTxt.setAttribute('name','SelectionTxt'); 
    711  
    712 var Selection = document.createElement('input'); 
    713 Selection.setAttribute('id','Selection'); 
    714 Selection.setAttribute('name','Selection'); 
    715 Selection.setAttribute('type','hidden'); 
    716  
    717 var NoteSubj = document.createElement('input'); 
    718 NoteSubj.setAttribute('id','NoteSubj'); 
    719 NoteSubj.setAttribute('name','NoteSubj'); 
    720 NoteSubj.setAttribute('type','text'); 
    721 NoteSubj.setAttribute('size','40'); 
    722 NoteSubj.setAttribute('onfocus','if(this.value=="Subject/summary [required]") {this.value="";}'); 
    723 NoteSubj.setAttribute('onblur','if(this.value==""){this.value="Subject/summary [required]";}'); 
    724 NoteSubj.setAttribute('class','addnote'); 
    725  
    726 var NoteText = document.createElement('textarea'); 
    727 NoteText.setAttribute('id','NoteText'); 
    728 NoteText.setAttribute('name','NoteText'); 
    729 NoteText.setAttribute('rows','10'); 
    730 NoteText.setAttribute('cols','40'); 
    731 NoteText.setAttribute('class','addnote'); 
    732  
    733 var StartNodeId = document.createElement('input'); 
    734 StartNodeId.setAttribute('id','StartNodeId'); 
    735 StartNodeId.setAttribute('name','StartNodeId'); 
    736 StartNodeId.setAttribute('type','hidden'); 
    737  
    738 var NoteUrl = document.createElement('input'); 
    739 NoteUrl.setAttribute('id','NoteUrl'); 
    740 NoteUrl.setAttribute('name','NoteUrl'); 
    741 NoteUrl.setAttribute('type','hidden'); 
    742  
    743 var cancel = document.createElement('input'); 
    744 cancel.setAttribute('type','button'); 
    745 cancel.setAttribute('id','cancel'); 
    746 cancel.setAttribute('name','cancel'); 
    747 cancel.setAttribute('value','cancel'); 
    748 cancel.setAttribute('onClick','cancelNote("noteify")'); 
    749 cancel.setAttribute('class','annoteButton'); 
    750 cancel.setAttribute('class','addnote'); 
    751  
    752 var theBR = document.createElement('br'); 
    753 var theBR1 = document.createElement('br'); 
    754 var theBR2 = document.createElement('br'); 
    755 var theBR3 = document.createElement('br'); 
    756 var theBR4 = document.createElement('br'); 
    757  
    758 var pickQueue; 
    759 if (drafter.match(/drafter/)) { 
    760 pickQueue = document.createElement('select'); 
    761 pickQueue.setAttribute('name','queue'); 
    762 pickQueue.setAttribute('id','queue'); 
    763  
    764 var optDrafter = document.createElement('option'); 
    765 optDrafter.setAttribute('value','Drafter'); 
    766 optDrafter.setAttribute('selected','selected'); 
    767 optDrafter.appendChild(document.createTextNode('Drafter')); 
    768  
    769 var optInbox = document.createElement('option'); 
    770 optInbox.setAttribute('value','Inbox'); 
    771 optInbox.appendChild(document.createTextNode('Inbox')); 
    772  
    773 var optIssues = document.createElement('option'); 
    774 optIssues.setAttribute('value','Issues'); 
    775 optIssues.appendChild(document.createTextNode('Issues')); 
    776  
    777 var optComA = document.createElement('option'); 
    778 optComA.setAttribute('value','CommitteeA'); 
    779 optComA.setAttribute('selected','selected'); 
    780 optComA.appendChild(document.createTextNode('CommitteeA')); 
    781  
    782 var optComB = document.createElement('option'); 
    783 optComB.setAttribute('value','CommitteeB'); 
    784 optComB.setAttribute('selected','selected'); 
    785 optComB.appendChild(document.createTextNode('CommitteeB')); 
    786  
    787 var optComC = document.createElement('option'); 
    788 optComC.setAttribute('value','CommitteeC'); 
    789 optComC.setAttribute('selected','selected'); 
    790 optComC.appendChild(document.createTextNode('CommitteeC')); 
    791  
    792 var optComD = document.createElement('option'); 
    793 optComD.setAttribute('value','CommitteeD'); 
    794 optComD.setAttribute('selected','selected'); 
    795 optComD.appendChild(document.createTextNode('CommitteeD')); 
    796  
    797 var optComT = document.createElement('option'); 
    798 optComT.setAttribute('value','CommitteeT'); 
    799 optComT.setAttribute('selected','selected'); 
    800 optComT.appendChild(document.createTextNode('CommitteeTest')); 
    801  
    802 pickQueue.appendChild(optDrafter); 
    803 pickQueue.appendChild(optInbox); 
    804 pickQueue.appendChild(optIssues); 
    805 pickQueue.appendChild(optComA); 
    806 pickQueue.appendChild(optComB); 
    807 pickQueue.appendChild(optComC); 
    808 pickQueue.appendChild(optComD); 
    809 pickQueue.appendChild(optComT); 
    810 } 
    811  
    812 else if (drafter.match(/Committee/)) { 
    813   var letray = drafter.match(/Committee(.)/); 
    814   var letter = letray[1]; 
    815  
    816   pickQueue = document.createElement('select'); 
    817   pickQueue.setAttribute('name','queue'); 
    818   pickQueue.setAttribute('id','queue'); 
    819    
    820   var optDrafter = document.createElement('option'); 
    821   optDrafter.setAttribute('value','Committee'+letter); 
    822   optDrafter.setAttribute('selected','selected'); 
    823   optDrafter.appendChild(document.createTextNode('Committee'+letter)); 
    824    
    825   var optInbox = document.createElement('option'); 
    826   optInbox.setAttribute('value','Inbox'); 
    827   optInbox.appendChild(document.createTextNode('Inbox')); 
    828    
    829   var optIssues = document.createElement('option'); 
    830   optIssues.setAttribute('value','Issues'); 
    831   optIssues.appendChild(document.createTextNode('Issues')); 
    832    
    833   pickQueue.appendChild(optDrafter); 
    834   pickQueue.appendChild(optInbox); 
    835   pickQueue.appendChild(optIssues); 
    836 } 
    837  
    838 else { 
    839 pickQueue = document.createElement('input'); 
    840 pickQueue.setAttribute('type','hidden'); 
    841 pickQueue.setAttribute('name','queue'); 
    842 pickQueue.setAttribute('value','Inbox'); 
    843 } 
    844 var submit = document.createElement('input'); 
    845 submit.setAttribute('type','button'); 
    846 submit.setAttribute('id','submitNote'); 
    847 submit.setAttribute('value','submit'); 
    848 submit.setAttribute('onClick','submitComment()'); 
    849 submit.setAttribute('class','annoteButton'); 
    850 submit.setAttribute('class','addnote'); 
    851  
    852 noteifyDiv.appendChild(DomPathTxt); 
    853 noteifyDiv.appendChild(DomPath); 
    854 noteifyDiv.appendChild(SelectionTxt); 
    855 noteifyDiv.appendChild(theBR1); 
    856 noteifyDiv.appendChild(Selection); 
    857 noteifyDiv.appendChild(NoteSubj); 
    858 noteifyDiv.appendChild(theBR3); 
    859 noteifyDiv.appendChild(NoteText); 
    860 noteifyDiv.appendChild(StartNodeId); 
    861 //noteifyDiv.appendChild(EndNodeId); 
    862 noteifyDiv.appendChild(NoteUrl); 
    863 //noteifyDiv.appendChild(DocRevision); 
    864 noteifyDiv.appendChild(theBR4); 
    865 noteifyDiv.appendChild(submit); 
    866 noteifyDiv.appendChild(cancel); 
    867  
    868 if (drafter) { 
    869 pickQueue && noteifyDiv.appendChild(document.createTextNode(' Queue: ')) && noteifyDiv.appendChild(pickQueue); 
    870 } 
    871 else { 
    872 pickQueue && noteifyDiv.appendChild(pickQueue); 
    873 } 
    874  
    875  thisNode = document.getElementById(startid); 
    876   
    877  if ((thisNode.previousSibling) && (thisNode.previousSibling.previousSibling) && (thisNode.previousSibling.previousSibling.appendChild)) { 
    878    thisNode.previousSibling.previousSibling.appendChild(noteifyDiv); 
    879  } 
    880  else  
    881    if ((thisNode.previousSibling) && (thisNode.previousSibling.appendChild)) { 
    882      thisNode.previousSibling.appendChild(noteifyDiv); 
    883    } 
    884    else { 
    885      thisNode.appendChild(noteifyDiv); 
    886    } 
    887 } 
    888546 
    889547function intense_annot(rootid,selections,rtids) { 
     
    1139797} 
    1140798 
    1141 function iAgree (rtid,opn) { 
    1142   myAgr = document.getElementById('agree'+rtid); 
    1143   myAgr.setAttribute('href','#'); 
    1144   loadHTMLtoDiv(myAgr.innerHTML+'ing...',myAgr.id); 
    1145   loadXMLDoc('/comments/rt/agree.html','rtid='+rtid+'&amp;opn='+opn); 
    1146 } 
    1147799 
    1148800function unOverlap(cls,gapDesired) { 
     
    1174826 
    1175827function loginbox() { 
    1176   if((!name) && (readCookie('__ac'))) { 
    1177         namepass = decodeBase64(readCookie('__ac')); 
    1178         var name = namepass.substr(0,namepass.indexOf(':')); 
    1179         loadHTMLtoDiv('you are '+name+': <a href="http://gplv3.fsf.org/logout">logout</a> <a href="http://gplv3.fsf.org/comments/source/stet-2006-03-14.tar.bz2">source</a> <a href=\"http://gplv3.fsf.org/comments/classic.html\">old interface</a><br/>\ 
    1180 <span id="selectsome" class="selectsome">select some text</span> and <a class="fakelink" onmousedown="javascript:XpathSel()">add a comment</a> | <a href="http://gplv3.fsf.org/comments/email.html">email your comment</a>','login'); 
    1181   } 
    1182   else { 
    1183     loadHTMLtoDiv('You need to <a href=\"http://gplv3.fsf.org/login_form?came_from='+location.pathname+'\">log in</a> to make comments. <a href=\"http://gplv3.fsf.org/comments/classic.html\">old interface</a>','login'); 
    1184   } 
     828    loadHTMLtoDiv('This license has been released; no further comments are being accepted.','login'); 
     829 
    1185830} 
    1186831function idLinks(cs) { 
     
    1239884    newMe.appendChild(lLnk); 
    1240885 
    1241 if (!filename.match(/lgpl-draft-1/)) { 
     886if ((!filename.match(/lgpl-draft-1/)) && (!filename.match(/gplv3-draft-3/)) && (!filename.match(/gplv3-draft-4/))) { 
    1242887    newMe.appendChild(document.createTextNode(' ')); 
    1243888    rat = document.createElement('a'); 

SFLC Main Page

[frdm] Support SFLC