Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre>// Script to allow readers to see the derivations of mathematical results//// To use this script, add "importScript('User:Proteins/showmathderivations.js');" to your monobook.js subpage // under your user page, as you can see at User:Proteins/monobook.jsfunctionshowMathDerivations(){varalert_string="";varerror_string="";varderivation_string="";vardel_derivation_string="";varbody_content;varspan_nodes;vartemp_span_node;varnum_span_nodes=0;varspan_node_index=0;vartemp_derivation;vartemp_derivation_step;varmathematical_derivation_name="";varmathematical_derivation_list=newArray();varmathematical_derivation_step_list=newArray();varderivation_index=0;varnum_mathematical_derivations=0;varstep_index=0;varnum_derivation_steps=0;//****************// Initializations//****************num_mathematical_derivations=0;// Get the bodyContent nodebody_content=document.getElementById('bodyContent');if(!body_content){error_string="ERROR: There is no bodyContent node in this article.";window.alert(error_string);return;}span_nodes=body_content.getElementsByTagName("SPAN");if(!span_nodes){error_string="ERROR: This page has no SPAN nodes.\n";window.alert(error_string);return;}num_span_nodes=span_nodes.length;if(num_span_nodes<1){error_string="ERROR: This page has no SPAN nodes.\n";window.alert(error_string);return;}for(span_node_index=0;span_node_index<num_span_nodes;span_node_index++){temp_span_node=span_nodes[span_node_index];if(!temp_span_node){continue;}if(temp_span_node.className=="mathematical_derivation"){num_mathematical_derivations++;mathematical_derivation_list.push(temp_span_node);}}// closes loop over the SPAN nodes in the main articleif(num_mathematical_derivations<1){error_string="No mathematical derivations were found on this page.";window.alert(error_string);return;}elseif(num_mathematical_derivations==1){alert_string="This page has one mathematical derivation.\n\n";// window.alert(alert_string);}else{alert_string="This page has "+num_mathematical_derivations+" mathematical derivations.\n\n";alert_string+="These will be analyzed in individual pop-up windows.\n";// window.alert(alert_string);}//***************************************************// Loop over the mathematical derivations on the page//***************************************************for(derivation_index=1;derivation_index<=num_mathematical_derivations;derivation_index++){derivation_string="Derivation "+derivation_index+" (of "+num_mathematical_derivations+" on this page):\n\n";temp_derivation=mathematical_derivation_list[derivation_index-1];if(!temp_derivation){error_string="ERROR: Mathematical derivation "+derivation_index+" is undefined.\n";window.alert(error_string);continue;}// Get the name of the derivationmathematical_derivation_name=temp_derivation.title;if(!mathematical_derivation_name){error_string="ERROR: No name is defined for mathematical derivation "+derivation_index+".\n";window.alert(error_string);mathematical_derivation_name="UNNAMED REACTION";}derivation_string+=mathematical_derivation_name+"\n\n";// Find the number of steps in the derivationspan_nodes=temp_derivation.getElementsByTagName("SPAN");if(!span_nodes){error_string="ERROR: Mathematical derivation "+derivation_index+" has no SPAN nodes.\n";window.alert(error_string);return;}num_span_nodes=span_nodes.length;if(num_span_nodes<1){error_string="ERROR: Mathematical derivation "+derivation_index+" has zero SPAN nodes.\n";window.alert(error_string);return;}for(span_node_index=0;span_node_index<num_span_nodes;span_node_index++){temp_span_node=span_nodes[span_node_index];if(!temp_span_node){continue;}if(temp_span_node.className=="mathematical_derivation_step"){num_derivation_steps++;mathematical_derivation_step_list.push(temp_span_node);}}// closes loop over the SPAN nodes in this mathematical derivation// Loop over the steps of the derivationfor(step_index=0;step_index<num_derivation_steps;step_index++){temp_derivation_step=mathematical_derivation_step_list[step_index];if(!temp_derivation_step){error_string="ERROR: Step "+step_index+" in mathematical derivation "+derivation_index+" is undefined.\n";window.alert(error_string);continue;}derivation_string+=temp_derivation_step.title+": ";del_derivation_string=temp_derivation_step.innerHTML;del_derivation_string=del_derivation_string.replace(/<[^>]+>/,"");derivation_string+=del_derivation_string+"\n\n";}// closes loop over derivation stepsderivation_string+="Q. E. D.";// Print out the derivationwindow.alert(derivation_string);}// closes loop over mathematical derivations}// closes function showMathDerivations()$(function(){mw.util.addPortletLink('p-cactions','javascript:showMathDerivations()','D','ca-showmathderiv','Show derivations of mathematical results','','');});//</pre>