community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1864295 - in /comdev/reporter.apache.org/trunk/site/wizard/js: source/generators.js source/unified.js wizard.js
Date Sat, 03 Aug 2019 03:22:34 GMT
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");



Mime
View raw message