User:Karl Dickman/airbuttons.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
//{{User:Karl Dickman/Subpages}} if(navigator.appName=='Netscape') { function infoBox(n,i,c,t,m,ms,d,f,introduced,r,s,p,u,pr,nb,uc,v) { insertTags('','','{{Infobox Aircraft\n'); insertTags('','',' |name=' + n + '\n'); insertTags('','',' |name=' + n + '\n'); insertTags('','',' |image=Image:' + i + '\n'); insertTags('','',' |image=Image:' + i + '\n'); insertTags('','',' |caption=' + c + '\n'); insertTags('','',' |caption=' + c + '\n'); insertTags('','',' |type=' + t + '\n'); insertTags('','',' |type=' + t + '\n'); insertTags('','',' |manufacturer=' + ms + '=' + m +'\n'); insertTags('','',' |manufacturer' + ms + '=' + m +'\n'); insertTags('','',' |designer=' + d + '\n'); insertTags('','',' |designer=' + d + '\n'); insertTags('','',' |first flight=' + f + '\n'); insertTags('','',' |first flight=' + f + '\n'); insertTags('','',' |introduced=' + introduced + '\n'); insertTags('','',' |introduced=' + introduced + '\n'); insertTags('','',' |retired=' + r + '\n'); insertTags('','',' |retired=' + r + '\n'); insertTags('','',' |status=' + s + '\n'); insertTags('','',' |status=' + s + '\n'); insertTags('','',' |primary user='+ p + '\n'); insertTags('','',' |primary user='+ p + '\n'); insertTags('','',' |more users=' + u + '\n'); insertTags('','',' |more users=' + u + '\n'); insertTags('','',' |produced=' + pr + '\n'); insertTags('','',' |produced=' + pr + '\n'); insertTags('','',' |number built=' + nb + '\n'); insertTags('','',' |number built=' + nb + '\n'); insertTags('','',' |unit cost=' + uc + '\n'); insertTags('','',' |unit cost=' + uc + '\n'); insertTags('','',' |variants with their own articles=' + v + '\n'); insertTags('','',' |variants with their own articles=' + v + '\n'); insertTags('','','}}\n'); insertTags('','','}}\n'); } function infoBoxRaw() { insertTags('','','{{Infobox Aircraft\n'); insertTags('','',' |name=\n'); insertTags('','',' |name=\n'); insertTags('','',' |image=\n'); insertTags('','',' |image=\n'); insertTags('','',' |caption=<!--image caption; if it isn\'t descriptive it should be left blank-->\n'); insertTags('','',' |caption=<!--image caption; if it isn\'t descriptive it should be left blank-->\n'); insertTags('','',' |type=\n'); insertTags('','',' |type=\n'); insertTags('','',' |manufacturer=\n'); insertTags('','',' |manufacturer=\n'); insertTags('','',' |designer=\n'); insertTags('','',' |designer=\n'); insertTags('','',' |first flight=\n'); insertTags('','',' |first flight=\n'); insertTags('','',' |introduced=\n'); insertTags('','',' |introduced=\n'); insertTags('','',' |retired=\n'); insertTags('','',' |retired=\n'); insertTags('','',' |status=\n'); insertTags('','',' |status=\n'); insertTags('','',' |primary user=<!--please list only one-->\n'); insertTags('','',' |primary user=<!--please list only one-->\n'); insertTags('','',' |more users=<!--up to three more. please separate with <br\/>.-->\n'); insertTags('','',' |more users=<!--up to three more. please separate with <br\/>.-->\n'); insertTags('','',' |produced=<!--years in production, e.g. 1970-1999, if still in active use but no longer built-->\n'); insertTags('','',' |produced=<!--years in production, e.g. 1970-1999, if still in active use but no longer built-->\n'); insertTags('','',' |number built=\n'); insertTags('','',' |number built=\n'); insertTags('','',' |unit cost=\n'); insertTags('','',' |unit cost=\n'); insertTags('','',' |variants with their own articles=\n'); insertTags('','',' |variants with their own articles=\n'); insertTags('','','}}\n'); insertTags('','','}}\n'); } function popupInfobox() { var popup = window.open('about:blank','WPtable','height="350",width="400",scrollbars="yes"'); javaCode = '<script type="text/javascript">function insertCode(){\n'; javaCode += 'var name = parseInt(document.paramForm.inputName.value);\n'; javaCode += 'var image = parseInt(document.paramForm.inputImage.value);\n'; javaCode += 'var caption = parseInt(document.paramForm.inputCaption.value);\n'; javaCode += 'var type = parseInt(document.paramForm.inputType.value);\n'; javaCode += 'var manufacturer = parseInt(document.paramForm.inputManufacturer.value);\n'; javaCode += 'var manufacturersIsPlural = document.paramForm.inputManufacturerPlurality.value;\n'; javaCode += 'var designer = parseInt(document.paramForm.inputDesigner.value);\n'; javaCode += 'var firstFlight = parseInt(document.paramForm.inputFirstFlight.value);\n'; javaCode += 'var introduced = parseInt(document.paramForm.inputIntroduced.value);\n'; javaCode += 'var retired = parseInt(document.paramForm.inputRetired.value);\n'; javaCode += 'var status = parseInt(document.paramForm.inputStatus.value);\n'; javaCode += 'var PUser = parseInt(document.paramForm.inputPUser.value);\n'; javaCode += 'var users = parseInt(document.paramForm.inputUsers.value);\n'; javaCode += 'var produced = parseInt(document.paramForm.inputProduced.value);\n'; javaCode += 'var numberBuilt = parseInt(document.paramForm.inputNB.value);\n'; javaCode += 'var unitCost = parseInt(document.paramForm.inputUnitCost.value);\n'; javaCode += 'var variants = parseInt(document.paramForm.inputVariants.value);\n'; javaCode += 'var inputHeader = document.paramForm.inputHeader.checked;\n'; javaCode += 'if((caption=="Please use a descriptive caption.")||(caption=="")) {caption="<!-- " + caption + " -->";}\n'; javaCode += 'if((PUser=="Please list only one.")||(PUser=="")) {PUser="<!-- " + PUser + " -->";}\n'; javaCode += 'if((users=="Up to three more. Please separate with <br/>.")||(users="")) {users="<!-- " + users + " -->";}\n'; javaCode += 'window.opener.infoBox(name,image,caption,type,manufacturer,manufacturersIsPlural,designer,firstFlight,introduced,retired,status,PUser,users,produced,numberBuilt,unitCost,variants);\n'; javaCode += 'window.close();\n' javaCode += '}\nfunction infoBoxRaw(){window.opener.infoBoxRaw();}\n</script>'; popup.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'); popup.document.write('<html><head><title>Insert infobox</title>\n'); popup.document.write('<script type="text/javascript" src="/skins-1.5/common/wikibits.js"><!-- wikibits js --></script>\n'); popup.document.write('<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/wikistandard/main.css?5"; /*]]>*/</style>\n'); popup.document.write('<style type=\'text/css\' media=\'screen,projection\'>/*<![CDATA[*/ @import \'http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&dontcountme=s?5\';/*]]>*/</style>\n'); popup.document.write(javaCode); popup.document.write('</head><body>\n'); popup.document.write('<form name="paramForm" action="">\n'); popup.document.write('<table class="wikitable">\n'); popup.document.write('<caption style="text-align: left;">Enter the infobox parameters below: </caption>\n'); popup.document.write('<tr><td>Name of aircraft:</td><td><input type="text" size="40" name="inputName"/></td></tr>\n'); popup.document.write('<tr><td>Image filename:</td><td><input type="text" size="40" name="inputImage"/></td></tr>\n'); popup.document.write('<tr><td>Caption of image:</td><td><input type="text" size="40" name="inputCaption" value="Please use a descriptive caption."/></td></tr>\n'); popup.document.write('<tr><td>Type of aircraft:</td><td><input type="text" size="40" name="inputType"/></td></tr>\n'); popup.document.write('<tr><td><input type="radio" value="" checked="checked" name="inputManufacturerPlurality"/> Manufacturer:<br/><input type="radio" value="s" name="inputManufacturerPlurality"/> Manufacturers:</td><td><input type="text" size="40" name="inputManufacturer"/></td></tr>\n'); popup.document.write('<tr><td>Designer:</td><td><input type="text" size="40" name="inputDesigner"/></td></tr>\n'); popup.document.write('<tr><td>Date of first flight:</td><td><input type="text" size="40" name="inputFirstFlight"/></td></tr>\n'); popup.document.write('<tr><td>Entered service:</td><td><input type="text" size="40" name="inputIntroduced"/></td></tr>\n'); popup.document.write('<tr><td>Retired from service:</td><td><input type="text" size="40" name="inputRetired"/></td></tr>\n'); popup.document.write('<tr><td>Status:</td><td><input type="text" size="40" name="inputStatus"/></td></tr>\n'); popup.document.write('<tr><td>Primary user:</td><td><input type="text" size="40" name="inputPUser" value="Please list only one."/></td></tr>\n'); popup.document.write('<tr><td>More users:</td><td><input type="text" size="40" name="inputUsers" value="Up to three more. Please separate with <br/>."/></td></tr>\n'); popup.document.write('<tr><td>Years in production:</td><td><input type="text" size="40" name="inputProduced"/></td></tr>\n'); popup.document.write('<tr><td>Number built:</td><td><input type="text" size="40" name="inputNB"/></td></tr>\n'); popup.document.write('<tr><td>Unit cost:</td><td><input type="text" size="40" name="inputUnitCost"/></td></tr>\n'); popup.document.write('<tr><td>Variants with their own articles:</td><td><input type="text" size="40" name="inputVariants"/></td></tr>\n'); popup.document.write('<tr><td colspan="2"><input type="checkbox" name="inputHeader"/>Include {{<a href="/wiki/Template:Wpairheader" title="Template:Wpairheader">wpairheader</a>}}</td></tr>'); popup.document.write('</table>\n'); popup.document.write('</form">\n'); popup.document.write('<p><a href="javascript:insertCode()">Insert infobox</a> | <a href="javascript:infoBoxRaw()">Insert raw infobox</a> |\n'); popup.document.write(' <a href="javascript:self.close()">Cancel</a></p>\n'); popup.document.write('<p>\n <a href="http://validator.w3.org/check?uri=referer"><img\n src="http://www.w3.org/Icons/valid-xhtml10"\n alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>\n </p>'); popup.document.write('</body></\html>\n'); popup.document.close(); } function specifications() { alert("Will be completed at a later date."); } function aircraftButton() { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/17/Button_aircraft.png", "speedTip": "Header", "tagOpen": "", "tagClose": "", "sampleText": "<!-- This article is a part of [[Wikipedia:WikiProject Aircraft]]. Please see [[Wikipedia:WikiProject Aircraft/page content]] for recommended layout. -->"} var toolbar=document.getElementById('toolbar'); if (!toolbar) return false; var textbox=document.getElementById('wpTextbox1'); if (!textbox) return false; if (!document.selection && textbox.selectionStart == null) return false; var image1=document.createElement("img"); image1.width = 23; image1.height = 22; image1.src = 'http://upload.wikimedia.org/wikipedia/commons/1/17/Button_aircraft.png'; image1.border = 0; image1.alt = 'Infobox'; image1.title = 'Insert WikiProject Aircraft infobox'; image1.style.cursor = "pointer"; image1.onclick = function() { popupInfobox(); return false; } var image2=document.createElement("img"); image2.width=23; image2.height=22; image2.src='http://upload.wikimedia.org/wikipedia/commons/1/17/Button_aircraft.png'; image2.border=0; image2.alt='Specs'; image2.title='Insert WikiProject Aircraft specifications section'; image2.style.cursor='pointer'; image2.onclick=function() { specifications(); return false; } toolbar.appendChild(image1); toolbar.appendChild(image2); } addOnloadHook(aircraftButton); }