Clean up javascript indentation

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.
This commit is contained in:
Magnus Hagander
2020-07-12 14:03:03 +02:00
parent af78101784
commit 6464c68d6a
5 changed files with 89 additions and 89 deletions

View 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);
});

View 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();
}
});
}

View 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';
}

View 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');
}

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