| 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 | |
|---|
| 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 | | } |
|---|