Clean up javascript indentation
authorMagnus Hagander <magnus@hagander.net>
Sun, 12 Jul 2020 12:03:03 +0000 (14:03 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 12 Jul 2020 12:09:25 +0000 (14:09 +0200)
Remove tabs from indentation, which was in about half the files, and
make everything 4-space indentation, which is what most of the rest
used.

media/js/featurematrix.js
media/js/forms.js
media/js/main.js
media/js/monospacefix.js
media/js/showdown_preview.js

index 735c9fca0d334a5c72d5654dfbf4baa3bc14cbd3..5c9bb9a41c0f1f340adcd89a18183d1dcccd81bc 100644 (file)
@@ -15,8 +15,8 @@ $(document).ready(function(){
         // Lastly, if at this point an entire row is obsolete, then hide
         $('tbody tr').each(function(i, el) {
             var $tr = $(el),
-            visible_count = $tr.find('td:not(.hidden)').length,
-            obsolete_count = $tr.find('td.fm_obs:not(.hidden)').length;
+                visible_count = $tr.find('td:not(.hidden)').length,
+                obsolete_count = $tr.find('td.fm_obs:not(.hidden)').length;
             // if visible count matches obsolete count, then hide this row
             $tr.toggle(visible_count !== obsolete_count);
         });
index cd91c8f2d434c5998ff5db84f8bd6e3524f0a563..f747ea120c98258c142cd9e3ecbf86aa67a10fe9 100644 (file)
@@ -1,13 +1,13 @@
 $(document).ready(function(){
     $('textarea.markdown-content').each(function(idx, e) {
-       attach_showdown_preview(e.id, 0);
+        attach_showdown_preview(e.id, 0);
     });
 
     $('input.toggle-checkbox').each(function(idx, e) {
-       $(this).change(function(e) {
-           update_form_toggles($(this));
-       });
-       update_form_toggles($(e));
+        $(this).change(function(e) {
+            update_form_toggles($(this));
+        });
+        update_form_toggles($(e));
     });
 
 });
@@ -17,14 +17,14 @@ function update_form_toggles(e) {
     var invert = e.data('toggle-invert');
     var show = e.is(':checked');
     if (invert) {
-       show = !show;
+        show = !show;
     }
     $.each(toggles, function(i, name) {
-       var e = $('#id_' + name);
-       if (show) {
-           $(e).parents('div.form-group').show();
-       } else {
-           $(e).parents('div.form-group').hide();
-       }
+        var e = $('#id_' + name);
+        if (show) {
+            $(e).parents('div.form-group').show();
+        } else {
+            $(e).parents('div.form-group').hide();
+        }
     });
 }
index ff2a87ffe8842a08f1204ee22529243338ed389f..0661c0655a1bbadba88ba51bb0f3c1762891ed7d 100644 (file)
@@ -79,13 +79,13 @@ function copyScript(trigger, elem) {
  * families on the Download page
  */
 function showDistros(btn, osDiv) {
-  // Disable everything
-  document.getElementById('btn-download-bsd').style.background = '#ffffff';
-  document.getElementById('download-subnav-bsd').style.display = 'none';
-  document.getElementById('btn-download-linux').style.background = '#ffffff';
-  document.getElementById('download-subnav-linux').style.display = 'none';
+    // Disable everything
+    document.getElementById('btn-download-bsd').style.background = '#ffffff';
+    document.getElementById('download-subnav-bsd').style.display = 'none';
+    document.getElementById('btn-download-linux').style.background = '#ffffff';
+    document.getElementById('download-subnav-linux').style.display = 'none';
 
-  // Enable the one we want
-  btn.style.background='#e7eae8';
-  document.getElementById(osDiv).style.display = 'block';
+    // Enable the one we want
+    btn.style.background='#e7eae8';
+    document.getElementById(osDiv).style.display = 'block';
 }
index e7f117e3ccb491c0c4f90ed3297ea53863441fef..205e81474557da0a98f3d2922755a7128dcfc02c 100644 (file)
@@ -1,12 +1,12 @@
 function display_default_font_size(id)
 {
-        var x = document.getElementById(id);
+    var x = document.getElementById(id);
 
-        if (x.currentStyle)
-                var y = x.currentStyle['fontSize'];
-        else if (window.getComputedStyle)
-                var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('font-size');
-        return y;
+    if (x.currentStyle)
+        var y = x.currentStyle['fontSize'];
+    else if (window.getComputedStyle)
+        var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('font-size');
+    return y;
 }
 
 document.write('<pre id="monotest" style="display: none;">&nbsp;</pre>');
@@ -17,11 +17,11 @@ var newMonoSize = propSize / monoSize;
 
 if (newMonoSize != 1)
 {
-        document.write('<style type="text/css" media="screen">'
-                                       + '#docContainer tt, #docContainer pre, #docContainer code'
-                                       + '{font-size: ' + newMonoSize.toFixed(1) + 'em;}\n'
-                                       /* prevent embedded code tags from changing font size */
-                                       + '#docContainer code code'
-                                       + '{font-size: 1em;}</style>\n');
+    document.write('<style type="text/css" media="screen">'
+                   + '#docContainer tt, #docContainer pre, #docContainer code'
+                   + '{font-size: ' + newMonoSize.toFixed(1) + 'em;}\n'
+                   /* prevent embedded code tags from changing font size */
+                   + '#docContainer code code'
+                   + '{font-size: 1em;}</style>\n');
 }
 
index cfca7101a7629084a3d8d2fa57a4a44f462cade5..7a43d163d976cc53d419190ba9cfa19271a50f5a 100644 (file)
@@ -4,53 +4,53 @@
 var converter = null;
 
 function attach_showdown_preview(objid, admin) {
-       if (!converter) {
-               converter = new Showdown.converter();
-       }
-       obj = document.getElementById(objid);
+    if (!converter) {
+        converter = new Showdown.converter();
+    }
+    obj = document.getElementById(objid);
 
-       if (!obj) {
-          alert('Could not locate object ' + objid + ' in DOM');
-          return;
-       }
+    if (!obj) {
+        alert('Could not locate object ' + objid + ' in DOM');
+        return;
+    }
 
-       newdiv = document.createElement('div');
-       newdiv.className = 'markdownpreview col-lg-12';
+    newdiv = document.createElement('div');
+    newdiv.className = 'markdownpreview col-lg-12';
 
-       if (admin) {
-               obj.style.cssFloat = 'left';
-               obj.style.marginRight = '10px';
-               obj.style.width = newdiv.style.width = "400px";
-               obj.style.height = newdiv.style.height = "200px";
-               newdiv.className = newdiv.className + ' adminmarkdownpreview';
-       }
+    if (admin) {
+        obj.style.cssFloat = 'left';
+        obj.style.marginRight = '10px';
+        obj.style.width = newdiv.style.width = "400px";
+        obj.style.height = newdiv.style.height = "200px";
+        newdiv.className = newdiv.className + ' adminmarkdownpreview';
+    }
 
-       obj.preview_div = newdiv;
+    obj.preview_div = newdiv;
 
-       obj.parentNode.insertBefore(newdiv, obj.nextSibling);
+    obj.parentNode.insertBefore(newdiv, obj.nextSibling);
 
-       obj.infospan_html_base = admin ? '' : 'This field supports <a href="http://daringfireball.net/projects/markdown/basics" target="_blank">markdown</a>. See below for a preview.';
+    obj.infospan_html_base = admin ? '' : 'This field supports <a href="http://daringfireball.net/projects/markdown/basics" target="_blank">markdown</a>. See below for a preview.';
 
-       obj.infospan = document.createElement('span');
-       obj.infospan.innerHTML = obj.infospan_html_base;
-       obj.parentNode.insertBefore(obj.infospan, newdiv);
+    obj.infospan = document.createElement('span');
+    obj.infospan.innerHTML = obj.infospan_html_base;
+    obj.parentNode.insertBefore(obj.infospan, newdiv);
 
-       update_markdown(obj, newdiv);
+    update_markdown(obj, newdiv);
 
-       window.onkeyup = function() {
-               /* Using a timer make sure we only update max 4 times / second */
-               if (obj.current_timeout) {
-                       clearTimeout(obj.current_timeout);
-               }
-               obj.current_timeout = setTimeout(function() {
-                       e = document.getElementsByTagName('textarea');
-                       for (i= 0; i < e.length; i++) {
-                               if (e[i].preview_div) {
-                                       update_markdown(e[i], e[i].preview_div);
-                               }
-                       }
-               }, 250);
-       };
+    window.onkeyup = function() {
+        /* Using a timer make sure we only update max 4 times / second */
+        if (obj.current_timeout) {
+            clearTimeout(obj.current_timeout);
+        }
+        obj.current_timeout = setTimeout(function() {
+            e = document.getElementsByTagName('textarea');
+            for (i= 0; i < e.length; i++) {
+                if (e[i].preview_div) {
+                    update_markdown(e[i], e[i].preview_div);
+                }
+            }
+        }, 250);
+    };
 }
 
 /*
@@ -62,21 +62,21 @@ function attach_showdown_preview(objid, admin) {
 var _update_markdown_reopen = new RegExp("<([^\s/][^>]*)>", "g");
 var _update_markdown_reclose = new RegExp("</([^>]+)>", "g");
 function update_markdown(src, dest) {
-       if (src.value != src.lastvalue) {
-               src.lastvalue = src.value;
-               if (_update_markdown_reclose.test(src.value) || _update_markdown_reopen.test(src.value)) {
-                   dest.innerHTML = converter.makeHtml(src.value.replace(_update_markdown_reopen, '[HTML REMOVED]').replace(_update_markdown_reclose,'[HTML REMOVED2]'));
-                   if (!src.last_had_html) {
-                       src.last_had_html = true;
-                       src.infospan.innerHTML = src.infospan_html_base + '<br/><span style="color: red;">You seem to be using HTML in your input - this will be filtered. Please use markdown instead!</span>';
-                   }
-               }
-               else {
-                   dest.innerHTML = converter.makeHtml(src.value);
-                   if (src.last_had_html) {
-                       src.last_had_html = false;
-                       src.infospan.innerHTML = src.infospan_html_base;
-                   }
-               }
-       }
+    if (src.value != src.lastvalue) {
+        src.lastvalue = src.value;
+        if (_update_markdown_reclose.test(src.value) || _update_markdown_reopen.test(src.value)) {
+            dest.innerHTML = converter.makeHtml(src.value.replace(_update_markdown_reopen, '[HTML REMOVED]').replace(_update_markdown_reclose,'[HTML REMOVED2]'));
+            if (!src.last_had_html) {
+                src.last_had_html = true;
+                src.infospan.innerHTML = src.infospan_html_base + '<br/><span style="color: red;">You seem to be using HTML in your input - this will be filtered. Please use markdown instead!</span>';
+            }
+        }
+        else {
+            dest.innerHTML = converter.makeHtml(src.value);
+            if (src.last_had_html) {
+                src.last_had_html = false;
+                src.infospan.innerHTML = src.infospan_html_base;
+            }
+        }
+    }
 }