[Codestriker-commits] CVS update: codestriker/lib/Codestriker/Http Response.pm
Brought to you by:
sits
|
From: <si...@us...> - 2005-05-22 04:34:08
|
Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=6346626&action=view User: sits Date: 05/05/21 21:33:39 Modified: . codestriker.conf doc codestriker.sgml edittopic.png html codestriker.js lib/Codestriker/Http Response.pm Log: Moved the add comment stuff back into an iframe, but still use XmlHttpRequest for sending and receiving the request so the tooltip can be disposed automatically if the comment was successfully added. This allows the tooltip window to be dragged around under all OS'es. Index: codestriker.conf =================================================================== RCS file: /cvsroot/codestriker/codestriker/codestriker.conf,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- codestriker.conf 21 Feb 2005 11:25:00 -0000 1.69 +++ codestriker.conf 22 May 2005 04:33:36 -0000 1.70 @@ -366,7 +366,7 @@ # default_value=>'Submitted' }, # { name=>'Type', values=>['Style', 'Minor', 'Major', 'Severe'] } # ]; -# + # Four metrics defined: Status, Level, Mode and Type. #$comment_state_metrics = # [ Index: codestriker.sgml =================================================================== RCS file: /cvsroot/codestriker/codestriker/doc/codestriker.sgml,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- codestriker.sgml 24 Nov 2004 20:40:00 -0000 1.45 +++ codestriker.sgml 22 May 2005 04:33:37 -0000 1.46 @@ -136,7 +136,10 @@ <listitem> <para>unpacking and configuring Codestriker.</para> </listitem> - </itemizedlist> + </itemizedlist> + Note for Win32 systems, only use Perl 5.6.X and Apache 1.X. + The more recent versions have problems which prevent Codestriker + working correctly. </para> <sect1 id="codestriker-database-creation"> @@ -982,6 +985,8 @@ Perl is available by default for all UNIX systems. For Windows, you can download it for free from <ulink url="http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl">http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl</ulink>. + Only use Perl 5.6.X, as Perl 5.8.X for Win32 has issues that + prevent Codestriker from working correctly. </para> <para> To run <filename>checksetup.pl</filename> under UNIX, do the @@ -1018,7 +1023,8 @@ url="http://httpd.apache.org">http://httpd.apache.org</ulink>), which is available for download for both UNIX and Window platforms. Apache should be already available for most UNIX - distributions. + distributions. Apache 1.X is recommended for Win32 systems, + as 2.X may have issues with running Codestriker. </para> <para> <emphasis>Note any Codestriker or Apache configuration changes Index: edittopic.png =================================================================== RCS file: /cvsroot/codestriker/codestriker/doc/edittopic.png,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 Binary files /tmp/cvs6G4FpZ and /tmp/cvsuoMgbC differ Index: codestriker.js =================================================================== RCS file: /cvsroot/codestriker/codestriker/html/codestriker.js,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- codestriker.js 5 May 2005 09:35:25 -0000 1.7 +++ codestriker.js 22 May 2005 04:33:38 -0000 1.8 @@ -2,6 +2,12 @@ ol_fgcolor = '#FFFFCC'; ol_textsize = '2'; +// Codestriker XMLHttpRequest object that is used. +var cs_request; + +// Reference to status element. +var cs_status_element; + // Handle to the popup window. var windowHandle = ''; @@ -63,16 +69,21 @@ function add_comment_html(file, line, new_value) { // Get the location of the codestriker URL. - var l = location; + var l = top.location; var url = l.protocol + '//' + l.host + l.pathname; // Create the hidden error span, and the initial form, with the // appropriate hidden fields. - var html = + var html = '<html><head>' + + '<link rel="stylesheet" type="text/css" ' + + ' href="' + cs_css + '"/>\n' + + '<script src="' + cs_xbdhtml_js + '" type="text/javascript"></script>\n' + + '</head>\n' + + '<body bgcolor="#eeeeee">\n' + '<span class="hidden" id="statusField"> </span>\n' + '<form name="add_comment" method="POST" ' + 'action="' + url + '" ' + - 'onSubmit="return verify();" ' + + 'onSubmit="return top.verify(document.add_comment, getElt(\'statusField\'));" ' + 'enctype="application/x-www-form-urlencoded">\n' + '<input type="hidden" name="action" value="submit_comment">\n' + '<input type="hidden" name="line" value="' + line + '">\n' + @@ -83,17 +94,17 @@ '</textarea>\n'; // Now add in the metric dropdowns. - if (cs_metric_data.length > 0) { + if (top.cs_metric_data.length > 0) { html += '<p><table>\n'; } - for (var i = 0; i < cs_metric_data.length; i++) { + for (var i = 0; i < top.cs_metric_data.length; i++) { if (i % 2 == 0) { html += '<tr>\n'; } - html += '<td align="right">' + cs_metric_data[i].name + ':</td>\n'; + html += '<td align="right">' + top.cs_metric_data[i].name + ':</td>\n'; html += '<td align="left">\n'; html += '<select name="comment_state_metric_' + - cs_metric_data[i].name + '">\n'; + top.cs_metric_data[i].name + '">\n'; // Check if a value has been selected for this metric. var key = file + '|' + line + '|' + new_value; @@ -102,18 +113,18 @@ if (comment_number != null && comment_metrics[comment_number] != null) { current_value = - comment_metrics[comment_number][cs_metric_data[i].name]; + comment_metrics[comment_number][top.cs_metric_data[i].name]; } if (current_value == null) { // If there is no default value defined, create an empty setting. - if (cs_metric_data[i].default_value == null) { + if (top.cs_metric_data[i].default_value == null) { html += '<option value="Select Value">' + '<Select Value></option>\n'; } - for (var j = 0; j < cs_metric_data[i].values.length; j++) { + for (var j = 0; j < top.cs_metric_data[i].values.length; j++) { html += '<option '; - var value = cs_metric_data[i].values[j]; - if (value == cs_metric_data[i].default_value) { + var value = top.cs_metric_data[i].values[j]; + if (value == top.cs_metric_data[i].default_value) { html += 'selected '; } html += 'value="' + value + '">' + value + '</option>\n'; @@ -122,8 +133,8 @@ else { // This metric does have a current value selected. var found_current_value = 0; - for (var j = 0; j < cs_metric_data[i].values.length; j++) { - var value = cs_metric_data[i].values[j]; + for (var j = 0; j < top.cs_metric_data[i].values.length; j++) { + var value = top.cs_metric_data[i].values[j]; if (value == current_value) { html += '<option selected value="' + value + '">' + value + '</option>\n'; @@ -145,11 +156,11 @@ } html += '</select>\n'; html += ' </td>\n'; - if (i % 2 == 1 || i == cs_metric_data.length-1) { + if (i % 2 == 1 || i == top.cs_metric_data.length-1) { html += '</tr>\n'; } } - if (cs_metric_data.length > 0) { + if (top.cs_metric_data.length > 0) { html += '</table>\n'; } @@ -161,23 +172,24 @@ 'value="' + cs_email + '">\n' + '</td><td></td></tr><tr>' + '<td>Cc: <font size="-1">' + - '<a href="javascript:add_other_reviewers();">' + + '<a href="javascript:top.add_other_reviewers(document.add_comment);">' + '(add other reviewers)</a></font> </td>' + '<td>' + '<input type="text" name="comment_cc" size="25" ' + 'maxlength="150"></td>\n' + '<td><input type="submit" name="submit" value="Submit"></td>' + - '</tr></table></form>\n'; + '</tr></table></form></body></html>\n'; // Return the generated html. return html; } // Verify that a comment is ready to be shipped out. -function verify() +function verify(comment_form, status_field) { - // Get a reference to the comment form. - var comment_form = document.add_comment; + // Set the global status element so it can be updated when + // the request is being sent and received. + top.cs_status_element = status_field; // Check that the comment field has a comment entered in it. if (comment_form.comments.value == '') { @@ -192,8 +204,8 @@ } // Check that the metrics have been set. - for (var i = 0; i < cs_metric_data.length; i++) { - var metric_name = cs_metric_data[i].name; + for (var i = 0; i < top.cs_metric_data.length; i++) { + var metric_name = top.cs_metric_data[i].name; var name = 'comment_state_metric_' + metric_name; var index = comment_form.elements[name].options.selectedIndex; if (index == -1) { @@ -221,9 +233,9 @@ params += '&comment_cc=' + escape(comment_form.comment_cc.value); params += '&format=xml'; - for (var i = 0; i < cs_metric_data.length; i++) { + for (var i = 0; i < top.cs_metric_data.length; i++) { var comment_param = - escape('comment_state_metric_' + cs_metric_data[i].name); + escape('comment_state_metric_' + top.cs_metric_data[i].name); params += '&' + comment_param + '=' + escape(eval('comment_form.' + comment_param + '.value')); } @@ -232,11 +244,8 @@ } // Add all the other reviews into the Cc field of the comment frame. -function add_other_reviewers() +function add_other_reviewers(comment_form) { - // Get a reference to the comment form. - var comment_form = document.add_comment; - // Find out who the reviewers are for this review. var reviewers = topic_reviewers.split(/[\s,]+/); @@ -274,18 +283,19 @@ { var html = '<a href="javascript:hideElt(getElt(\'overDiv\')); void(0);">' + 'Close</a><p>' + - add_comment_html(file,line,new_value); - overlib(html, STICKY, DRAGGABLE, CENTERPOPUP); + '<iframe width="480" height="300" name="comment_frame" ' + + 'src="javascript:top.add_comment_html(' + + file + ',' + line + ',' + new_value + ');">' + + 'Can\'t view iframe</iframe>'; + overlib(html, STICKY, DRAGGABLE, ALTCUT, CENTERPOPUP, WIDTH, 480, + HEIGHT, 300); } -// Codestriker XMLHttpRequest object that is used. -var cs_request; - // Function for posting to Codestriker using the XMLHttpRequest object. function postXMLDoc(params) { // Generate the basic Codestriker URL. - var l = location; + var l = top.location; var url = l.protocol + '//' + l.host + l.pathname; // Check for Mozilla/Safari. @@ -299,7 +309,7 @@ // If the request object was created, generate the request. if (cs_request) { - cs_request.onreadystatechange = processReqChange; + cs_request.onreadystatechange = top.processReqChange; cs_request.open("POST", url, true); cs_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -310,10 +320,9 @@ // Function for updating the status text in the add comment tooltip. function setStatusText(newStatusText) { - var statusElt = document.getElementById('statusField'); - statusElt.className = 'error'; + cs_status_element.className = 'error'; var newStatusTextNode = document.createTextNode(newStatusText); - statusElt.replaceChild(newStatusTextNode, statusElt.childNodes[0]); + cs_status_element.replaceChild(newStatusTextNode, cs_status_element.childNodes[0]); } // Function for handling state changes to the request object. @@ -322,7 +331,7 @@ // Only check for completed requests. if (cs_request.readyState == 4) { if (cs_request.status == 200) { - var response = cs_request.responseXML.documentElement; + var response = top.cs_request.responseXML.documentElement; result = response.getElementsByTagName('result')[0].firstChild.data; if (result == 'OK') { // Hide the popup if the comment was successful. Index: Response.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Response.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- Response.pm 5 May 2005 09:35:27 -0000 1.30 +++ Response.pm 22 May 2005 04:33:38 -0000 1.31 @@ -244,6 +244,8 @@ print " var cs_reload = $reload;\n"; print " var cs_topicid = $topic->{topicid};\n" if defined $topic; print " var cs_email = '$email';\n" if defined $email; + print " var cs_css = '$codestriker_css';\n"; + print " var cs_xbdhtml_js = '$xbdhtml_js';\n"; # Now output all of the comment metric information. print " var cs_metric_data = new Array();\n"; |