You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by hu...@apache.org on 2019/08/03 03:22:34 UTC

svn commit: r1864295 - in /comdev/reporter.apache.org/trunk/site/wizard/js: source/generators.js source/unified.js wizard.js

Author: humbedooh
Date: Sat Aug  3 03:22:34 2019
New Revision: 1864295

URL: http://svn.apache.org/viewvc?rev=1864295&view=rev
Log:
quicker method of checking reflow needs

Modified:
    comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js
    comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
    comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js?rev=1864295&r1=1864294&r2=1864295&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js Sat Aug  3 03:22:34 2019
@@ -246,6 +246,17 @@ function activity_tips(data) {
     return txt;
 }
 
+
+// Quick check for reflow needs
+function should_reflow(txt, chars) {
+  chars = chars || 80;
+  let lines = txt.split(/[\r\n]+/g);
+  for (var i = 0; i < lines.length; i++) {
+    if (lines[i].length > chars && lines[i].match(/\s/)) return true;
+  }
+  return false;
+}
+
 function reflow(txt, chars) {
   chars = chars || 80;
   let words = txt.match(/([\S+?]+\s*)/mg);

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js?rev=1864295&r1=1864294&r2=1864295&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js Sat Aug  3 03:22:34 2019
@@ -24,8 +24,7 @@ function UnifiedEditor_highlight_section
         // Check for overflow, offer reflowing
         let reflower = document.getElementById('unified-reflow');
         if (reflower) {
-            let stripped = additional_text.replace(/(^\s+|\s+$)/, '')
-            if (reflow(stripped) != stripped) {
+            if (should_reflow(additional_text)) {
                 color = 'red';
                 reflower.innerHTML = "SECTION IS OVERFLOWING 80 CHARACTERS!";
                 let btn = new HTML('button', {class: 'btn btn-success btn-sm'}, "Reflow section");

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js?rev=1864295&r1=1864294&r2=1864295&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Sat Aug  3 03:22:34 2019
@@ -1415,6 +1415,17 @@ function activity_tips(data) {
     return txt;
 }
 
+
+// Quick check for reflow needs
+function should_reflow(txt, chars) {
+  chars = chars || 80;
+  let lines = txt.split(/[\r\n]+/g);
+  for (var i = 0; i < lines.length; i++) {
+    if (lines[i].length > chars && lines[i].match(/\s/)) return true;
+  }
+  return false;
+}
+
 function reflow(txt, chars) {
   chars = chars || 80;
   let words = txt.match(/([\S+?]+\s*)/mg);
@@ -1924,8 +1935,7 @@ function UnifiedEditor_highlight_section
         // Check for overflow, offer reflowing
         let reflower = document.getElementById('unified-reflow');
         if (reflower) {
-            let stripped = additional_text.replace(/(^\s+|\s+$)/, '')
-            if (reflow(stripped) != stripped) {
+            if (should_reflow(additional_text)) {
                 color = 'red';
                 reflower.innerHTML = "SECTION IS OVERFLOWING 80 CHARACTERS!";
                 let btn = new HTML('button', {class: 'btn btn-success btn-sm'}, "Reflow section");