User:Proteins/quickdiffs.js: Difference between revisions

Content deleted Content added
Proteins (talk | contribs)
draft sketch of the routine
Proteins (talk | contribs)
add error messages
Line 54:
article_tables = body_content.getElementsByTagName("TABLE");
if (!article_tables) {
alert_string = "ERROR: This article has no TABLE elements.";
window.alert(alert_string);
return;
}
num_article_tables = article_tables.length;
if (!num_article_tables) {
alert_string = "ERROR: This article has no TABLE elements.";
window.alert(alert_string);
return;
}
Line 67 ⟶ 71:
} // closes loop searching for the diff table
if (num_diff_tables == 0) {
alert_string = "ERROR: This article has no TABLE elements belonging to the \"diff\" class.";
window.alert(alert_string);
return;
} else if (num_diff_tables != 1) {
alert_string = "ERROR: This article has " + num_diff_tables + " TABLE elements belonging to the \"diff\" class.";
alert_string += "An article should have at most one \"diff\" table.\n";
window.alert(alert_string);
return;
}
Line 75 ⟶ 84:
diff_table_bodies = diff_table.getElementsByTagName("TBODY");
if (!diff_table_bodies) {
alert_string = "ERROR: This article has no TBODY element within its \"diff\" table.";
 
window.alert(alert_string);
return;
}
num_diff_table_bodies = diff_table_bodies.length;
if (!num_diff_table_bodies) {
alert_string = "ERROR: This article has no TBODY element within its \"diff\" table.";
window.alert(alert_string);
return;
} else if (num_diff_table_bodies != 1) {
alert_string = "ERROR: This article has " + num_diff_table_bodies + " TBODY elements within its \"diff\" table.";
alert_string += "A \"diff\" table should have at most one TBODY element.\n";
window.alert(alert_string);
return;
}
Line 88 ⟶ 104:
diff_table_rows = diff_table_body.getElementsByTagName("TR");
if (!diff_table_rows) {
alert_string = "ERROR: This article has no TR elements within its \"diff\" table body.";
window.alert(alert_string);
return;
}
num_diff_table_rows = diff_table_rows.length;
if (!num_diff_table_rows) {
alert_string = "ERROR: This article has no TR elements within its \"diff\" table body.";
window.alert(alert_string);
return;
} else if (num_diff_table_rows < 3) {
alert_string = "ERROR: This article has " + num_diff_table_rows + " rows (TR elements) within its \"diff\" table body.";
alert_string += "A \"diff\" table body should have at least three rows.\n";
window.alert(alert_string);
return;
}