User:Proteins/quickdiffs.js: Difference between revisions

Content deleted Content added
Proteins (talk | contribs)
add new variables
Proteins (talk | contribs)
draft sketch of the routine
Line 7:
 
var body_content;
var article_tables;
var num_diff_tables = 0;
 
var diff_table;
var diff_table_row;
Line 41 ⟶ 44:
var diff_change_line_numbers = new Array();
 
// Check that there areis anyexactly diffsone table on this page with the className "diff"
body_content = document.getElementById('bodyContent);
if (!body_content) {
alert_string = "ERROR: This article has no bodyContent element.";
window.alert(alert_string);
return;
}
 
article_tables = body_content.getElementsByTagName("TABLE");
// Acknowledgment string
if (!article_tables) {
alert_string = "This script added explanations for " + num_expanded_acronyms + " acronyms.\n\n";
return;
if (num_anomalous_acronyms) {
alert_string += "The following " + num_anomalous_acronyms + " acronyms were not identified:\n";
alert_string += anomalous_acronyms;
}
num_article_tables = article_tables.length;
if (!num_article_tables) {
return;
}
 
num_diff_tables = 0;
for (article_table_index=0; article_table_index<num_article_tables; article_table_index++) {
 
 
} // closes loop searching for the diff table
if (num_diff_tables == 0) {
return;
} else if (num_diff_tables != 1) {
return;
}
 
// Check that there is exactly one table body
diff_table_bodies = diff_table.getElementsByTagName("TBODY");
if (!diff_table_bodies) {
 
}
num_diff_table_bodies = diff_table_bodies.length;
if (!num_diff_table_bodies) {
return;
} else if (num_diff_table_bodies != 1) {
return;
}
diff_table_body = diff_table_bodies[0];
 
// Loop over the table rows in the table body
diff_table_rows = diff_table_body.getElementsByTagName("TR");
if (!diff_table_rows) {
return;
}
num_diff_table_rows = diff_table_rows.length;
if (!num_diff_table_rows) {
return;
} else if (num_diff_table_rows < 3) {
return;
}
 
for (table_row_index=0; table_row_index<num_diff_table_rows; table_row_index++) {
 
//MAIN LOGIC OF THE FUNCTION GOES HERE
 
} // closes loop over the table rows
 
// Report the results
alert_string = "This diff has " + num_additions + " additions, " + num_deletions + " deletions, and " + num_replacements + "replacements.\n\n";
window.alert(alert_string);
} // closes function quickDiffs()