User:Gryllida/assessmentHelper.js

// // ORIGINAL: User:Kaldari/assessmentHelper.js // THIS IS A FORK / DERIVATIVE WORK WITH MINOR CHANGES ONLY // Make sure we are on a talk page and in view or edit mode. If we are in edit // mode, make sure we are not editing a section. alert( mw.config.get( 'wgNamespaceNumber' )); //if ( mw.config.get( 'wgNamespaceNumber' ) === 1	// && ( mw.config.get( 'wgAction' ) === 'view' || ( mw.config.get( 'wgAction' ) === 'edit' && !$( 'input[name=wpSection]' ).val ) ) //) {

// This list should only include active WikiProjects with templates in // Category:WikiProject banners with quality assessment. // FIXME: Once mw.loader.using can load URLs, move this list to a separate // page that is loaded when the dialog is opened. alert('defining wikiproject list'); wikiProjectList = [ "", // empty initial option "24",		"A Song of Ice and Fire", "Abandoned Drafts", "Abkhazia", "Academic Journals", "Adoption, fostering, orphan care and displacement", "Aerosmith", "Afghanistan", "Africa", "African diaspora", "Agriculture", "Alabama", "Alaska", "Albania", "Albums", "Algae", "Algeria", "Alien", "Alternate History", "Alternative education", "Alternative medicine", "Alternative music", "Alternative Views", "Amateur radio", "American Football League", "American football", "Amphibians and Reptiles", "Amusement Parks", "Anatomy", "Ancient Egypt", "Ancient Germanic studies", "Ancient Near East", "Anglicanism", "Anglo-Saxon Kingdoms", "Animal anatomy", "Animal rights", "Animals in media", "Animals", "Animation", "Anime and manga", "Antarctica", "Anthropology", "Anthroponymy", "Anti-war", "Appalachia", "Apple Inc.", "Apps", "Aquarium Fishes", "Arab world", "Archaeology", "Architecture", "Archives of American Art", "Arctic", "Arena Football League", "Argentina", "Arizona", "Armenia", "Arminianism", "Arthropods", "Article Incubator", "Articles for creation (admin)", "Articles for creation", "Arts", "Asia", "Assyria", "Astrology", "Astronomy", "Atheism", "Athletics", "Atlantic Coast Conference", "Auckland", "Australia", "Australian Roads", "Australian rules football", "Austria", "Austria-Hungary", "Autism", "Automobiles", "Aviation", "Awake", "Awards and prizes", "Ayyavazhi", "Azawad", "Azerbaijan", "Babism", "Bacon", "Bahrain", "Bahá'í Faith", "Balboa Park", "Ballet", "Baltimore City College", "Bangladesh Premier League", "Bangladesh", "Bangladeshi Colleges", "Bangladeshi Universities", "Banksia", "Barack Obama", "Baseball", "Basic Income", "Basketball", "Bavaria", "BBC", "Beauty Pageants", "Bedfordshire", "Beer", "Beetles", "Belarus", "Belfast", "Belgium", "Belgrade", "Berbers", "Berkshire", "Beyoncé", "Bhutan", "Biathlon", "Bible", "Bibliographies", "Big 12 Conference", "Big Brother", "Biography", "Biology", "Biophysics", "Biota of Great Britain and Ireland", "Birds", "Birmingham", "Bivalves", "Björk", "Black Metal", "Blades", "Blogging", "Board and table games", "Bob Dylan", "Body Modification", "Bolivia", "Books", "Bosnia and Herzegovina", "Bowling", "Boxing", "Bradford", "Brands", "Brazil", "Breakfast", "Bridges", "Brigham Young University", "Brighton", "Bristol", "British and Irish hills", "British crime", "British Library", "British Museum", "British Overseas Territories", "British Royalty", "British TV channels", "British TV shows", "Britney Spears", "Buckethead task force", "Buckinghamshire", "Buddhism", "Buffyverse", "Bulgaria", "Burma (Myanmar)", "Buses", "Business", "C/C++", "Cal Poly Pomona", "California State University", "California", "Calvinism", "Cambodia", "Canada Roads", "Canada Streets", "Canada", "Canadian football", "Cannabis", "Cape Verde", "Capital District", "Capitalism", "Cardiff", "Caribbean", "Carnivorous plants", "Carrom", "Cartoon Network", "Catholicism", "Cats", "Caucasia", "Cell Signaling", "Celts", "Central America", "Central Asia", "Cephalopods", "Cetaceans", "Channel Islands", "Charts", "Chechnya", "Chemical and Bio Engineering", "Chemical Heritage Foundation", "Chemicals", "Chemistry", "Cheshire", "Chess", "Chicago Bears", "Chicago", "Children's literature", "Children's Museum of Indianapolis", "Chile", "China", "Christian Metal", "Christian music", "Christianity", "Christina Aguilera", "Chronicles of Narnia task force", "Circus", "Cities", "Civil engineering", "Clans of Scotland", "Classical Greece and Rome", "Classical League", "Cleveland", "Climbing", "Coca-Cola", "Cognitive science", "Cold War", "Coldplay", "Collections Care", "College Basketball", "College football", "Colombia", "Colonial Empires", "Color", "Columbia, Missouri", "Comedy", "Comics", "Community", "Companies", "Composers", "Computational Biology", "Computer graphics", "Computer science", "Computer Security", "Computer Vision", "Computing", "Concert Tours", "Connecticut", "Conservatism", "Constructed languages", "Containers", "Contract bridge", "Cooperatives", "Cornwall", "Coronation Street", "Correction and Detention Facilities", "Cosmology", "Costa Rica", "Countries", "Country Music", "Coventry", "Creationism", "Cricket", "Crime", "Criminal Biography", "Croatia", "Cryptography", "Cryptozoology", "CSI franchise", "Cuba", "Cue sports", "Cultural Heritage of Serbia", "Culture", "Curling", "Cycling", "Cyprus", "Czech Republic", "Dacia", "Dallas-Fort Worth", "Dams", "Dance", "Darts", "Databases", "Deaf", "Death", "Debating", "Degrassi", "Delaware Art Museum", "Denmark", "Dentistry", "Department of Fun", "Derby Museum and Art Gallery", "Derbyshire", "Devon", "Dietary Supplements", "Digital Preservation", "Dinosaurs", "Disability", "Disaster management", "Discographies", "Discrimination", "Disney", "Doctor Who", "Dogs", "Dorset", "Dravidian civilizations", "Dravidian languages", "Dravidian people", "Droughts and Fire Events", "Drug Policy", "Drum Corps", "Dungeons & Dragons", "Dyslexia", "Earthquakes", "East Anglia", "East Asia", "East Timor", "EastEnders", "Eastern Europe", "Eastern Orthodoxy", "Eclipses", "Ecology", "Economics", "Ecuador", "Edinburgh", "Editing trends", "Education in Nepal", "Education in New Jersey", "Education in the United Kingdom", "Education", "Egypt", "El Salvador", "Elections and Referendums", "Electrical engineering", "Electronic music", "Electronics", "Elements", "Elvis Presley", "Eminem", "Emmerdale", "Emo", "Endangered languages", "Energy", "Engineering", "England", "English Royalty", "Environment", "Equine", "Erie", "Espionage", "Estonia", "Ethiopia", "Ethnic groups", "Eurobeat", "Europe", "European history", "European Microstates", "European Union", "Eurovision", "Evanescence", "Event Venues", "Evolutionary biology", "Explosives", "Extinction", "Faroe Islands", "Fashion", "Feminism", "Fencing", "Festivals", "Fictional characters", "Figure Skating", "Fiji", "Film", "Finance", "Finland", "Fire Service", "Firearms", "Firefly", "Fisheries and Fishing", "Fishes", "Flight Simulation", "Floods", "Floorball", "Florida Gators", "Florida State University", "Florida", "Food and drink", "Football", "Forestry", "Former countries", "Formula One", "France", "Frank Zappa", "Fraternities and Sororities", "Free Software", "Freedom of speech", "Freemasonry", "Frisia", "Fungi", "Furry", "Futurama", "Futures studies", "G.I. Joe", "Gambling", "Game theory", "Games", "Gastropods", "Gemology and Jewelry", "Gender Studies", "Gene Wiki", "Genealogy", "Genetics", "Geocaching", "Geography", "Geology", "George Washington University", "Georgia (country)", "Georgia (U.S. state)", "Georgia Tech", "Germany", "Ghana", "Ghost towns", "Gibraltar", "GibraltarpediA", "Gilbert and Sullivan", "Glaciers", "Glass", "Globalization", "Gloucestershire", "Go", "Golf", "Google", "Graffiti", "Graphic design", "Greater Boston Public Transit", "Greater Manchester", "Greece", "Green Bay Packers", "Green Day", "Greenland", "Grenada", "Grey's Anatomy", "Guitarists", "Guyana", "Gymnastics", "Haiti", "Halloween", "Halo", "Hampshire", "Hanseatic League", "Hawaii", "Hazara", "Health and fitness", "Hello! Project", "Heraldry and vexillology", "Herbert Art Gallery and Museum", "Herefordshire", "Hertfordshire", "Highways", "Hiking Trails", "Hinduism", "Hip hop", "Historic sites", "History of photography", "History of Science", "History", "Holby", "Holidays", "Hollyoaks", "Home Living", "Homeschooling", "Hong Kong Roads", "Hong Kong", "HOPAU", "Horror", "Horse racing", "Horticulture and Gardening", "Hospitals", "Hotels", "House", "Houston", "Hudson Valley", "Human Computer Interaction", "Human Genetic History", "Human rights", "Hungary", "Ice Hockey", "Iceland", "Idol series", "Igbo", "Illinois", "Illyria", "India", "Indian Premier League", "Indian roads", "Indiana Historical Society", "Indiana Jones", "Indianapolis Colts", "Indigenous languages of California", "Indigenous peoples of North America", "Indigenous peoples of North America/Anishinaabe", "Indigenous peoples of the Americas", "Indonesia", "Industrial design", "Industrial", "Inheritance Cycle", "Insects", "Intelligent design", "International criminal law", "International development", "International relations", "Internet culture", "Internet", "Invention", "Investment", "iOS", "Iowa", "Iran", "Iraq", "IRC", "Ireland", "Irish music", "Irish Republicanism", "Islam", "Islands", "Isle of Man", "Israel Museum, Jerusalem", "Israel", "Italy", "Jacksonville", "Jainism", "James Bond", "Janet Jackson", "Japan", "Java", "Jazz", "Jennifer Lopez", "Jersey", "Jewish culture", "Jewish history", "Jewish Labour Bund Task Force", "JoburgpediA", "Johns Hopkins University", "Jordan", "Journalism", "Judaism", "Justin Timberlake", "Kabbalah", "Kansas City Chiefs", "Kansas City", "Kansas", "Karachi", "Katy Perry", "Kayaking", "Kelly Clarkson", "Kent", "Kilkenny", "King Arthur", "Korea", "Korn", "Kosovo", "Kurdistan", "Kuwait", "Kyrgyzstan", "Lacrosse", "Lady Gaga", "Lagos", "Lakes", "Lanark", "Lancashire and Cumbria", "Languages", "Latin America", "Latin music", "Latin", "Latter Day Saint movement", "Latvia", "Law Enforcement", "Law", "Lebanon", "Led Zeppelin", "Lego", "Lehigh Valley", "Leona Lewis", "Lepidoptera", "LGBT studies", "Libertarianism", "Libraries", "Library of Congress", "Life On Mars", "Lighthouses", "Lincolnshire", "Linguistics", "Linux", "Lists", "Literature", "Lithuania", "London Transport", "London", "Long Island", "Lost", "Lower Assam", "Lower Saxony", "Lucknow", "Lutheranism", "Luxembourg", "Macau", "Madonna", "Magazines", "Magic", "Magic: The Gathering", "Maine", "Malaysia", "Maldives", "Malta", "Mammals", "Maps", "Marching band", "Mariah Carey", "Marine life", "Maritime Trades", "Marketing & Advertising", "Mars", "Martial arts", "Maryland", "Mass spectrometry", "Mass surveillance", "Mathematics Competitions", "Mauritius", "Measurement", "Media franchises", "Media", "Medicine", "Medieval Scotland", "Melanesia", "Men's Issues", "Merge Copied", "Merseyside", "Mesoamerica", "Metal", "Metalworking", "Meteorology", "Mexico", "Miami", "Michael Jackson", "Michigan", "Microbiology", "Micronations", "Micronesia", "Microsoft Windows", "Microsoft", "Middle Ages", "Middle-earth", "Miley Cyrus", "Military history", "Mills", "Mining", "Minnesota", "Missouri", "Mithila", "Mixed martial arts", "Mizzou", "Moldova", "Molecular and Cellular Biology", "Mongols", "MonmouthpediA", "Montana", "Montenegro", "Montreal", "Monty Python", "Moon", "Morocco", "Motorcycling", "Motorsport", "Mountains", "Mozilla", "Multi-sport events", "Munich", "Museum of Modern Art", "Museums", "Music of the United Kingdom", "Music theory", "Music venues task force", "Music/Music genres task force", "Musical Instruments", "Musical Theatre", "Mythology", "NASCAR", "National Archives", "National Basketball Association", "National Basketball League of Canada", "National Football League", "National Railway Museum", "National Register of Historic Places", "Neopaganism", "Nepal", "Netball", "Netherlands", "Neuroscience", "Nevada", "New England Public Transit", "New Jersey", "New York City Public Transportation", "New York City", "New York Giants", "New York Jets", "New York", "New Zealand", "Newcomb Archives and Vorhoff Library", "Nickelodeon", "Nigeria", "Non-tropical storms", "Normandy", "Norse history and culture", "North America", "North East England", "North Korea", "Northamptonshire", "Northern Ireland", "Norway", "Nottinghamshire", "Novels", "Nudity", "Numismatics", "Nursing", "Objectivism", "Occult", "Occupations", "Oceania", "Oceans", "Ohio", "Okanagan", "Oklahoma", "Olympics", "Oman", "Open Access", "Open", "Opera", "Orders, Decorations, and Medals", "Oregon", "Organismal Biomechanics", "Organizations", "Organized Labour", "Oriental Orthodoxy", "Orienteering", "Osaka University", "Ottawa", "Ottoman Empire", "OWS", "Oz", "Paintball", "Pakistan", "Palaeontology", "Palestine", "Papua New Guinea", "Paraguay", "Paralympics", "Paranormal", "Parapsychology", "Parliamentary Procedure", "Pashtun", "Patna", "Pennsylvania", "Percussion", "Perl", "Peru", "Pharmacology", "Philadelphia Museum of Art", "Philadelphia", "Philately", "Philippine History", "Philosophy", "Photography", "Physics", "Physiology", "Pinball", "Pink Floyd", "Pipe Bands", "Pipe Organ", "Piracy", "Pirate Politics", "Pittsburgh Steelers", "Pittsburgh", "Plan 9", "Plants", "Podcasting", "Poetry", "Pokémon", "Poland", "Politics of the United Kingdom", "Politics", "Polynesia", "Pop music", "Popular Culture", "Pornography", "Ports", "Portugal", "Poultry", "Powderfinger", "Power in international relations", "Prem Rawat", "Primates", "Prison Break", "Professional sound production", "Professional wrestling", "Progressive Rock", "Protected areas", "Psychedelics, Dissociatives and Deliriants", "Psychology", "Psychopathic Records", "Public Art", "Puerto Rico", "Punjab", "Punk music", "Qatar", "Quakers", "Queen", "Queens of the Stone Age", "R&B and Soul Music", "Radio Stations", "Radio", "Rave", "Record Labels", "Record Production", "Reenactment", "Reggae", "Regional and national music", "Religion", "Religious texts", "Republic of Macedonia", "Requested articles (admin)", "Requested articles", "Retailing", "Richard Wagner", "Rihanna", "Rivers", "Robotics", "Rock music", "Rocketry", "Rocks and minerals", "Rodents", "Role-playing games", "Roman Curia", "Romance", "Romani people", "Romania", "Rome", "Roots music", "Rowing", "Rufus Wainwright", "Rugby league", "Rugby union", "Running", "Russia", "Sailing", "Saints", "San Diego", "San Francisco 49ers", "Sanitation", "Saudi Arabia", "Schools", "Science Fiction", "Science", "Scientology", "Scotland", "Scottish Castles", "Scottish Islands", "Scottish Royalty", "Scottish Television", "Scouting for Girls", "Scouting", "Scuba diving", "Seamounts", "Secret Societies", "Seinfeld", "Serbia", "Serial Killer task force", "Seventh-day Adventist Church", "Severe weather", "Sexuality", "Shakespeare", "Shakira", "Sharks", "Sheffield", "Ships", "Shipwrecks", "Shopping Centers", "Shropshire", "Sicily", "Sikhism", "Silesia", "Singapore", "Sinhalese Monarchy", "Skateboarding", "Skepticism", "Skiing and Snowboarding", "Skyscrapers", "Slayer", "Slipknot", "Slovakia", "Slovenia", "Smashing Pumpkins", "Smithsonian Institution", "Snooker", "Soap Operas", "Social Work", "Socialism", "Sociology", "Softball", "Software", "Solar System", "Somalia", "Somerset", "Songs", "South Africa", "South America", "South Asia", "South Dakota", "South Korea", "South Park", "South Sudan", "Southeast Asia", "Soviet Union", "Spaceflight", "Spain", "Spectroscopy", "Speed Skating", "Spiders", "Spirits", "Spirituality", "Spooks", "Sports Car Racing", "Sports facilities task force", "Sports", "Square Enix", "Squash", "Sri Lanka", "St. Louis Rams", "St. Louis", "Stagecraft", "Stamford", "Stanford University", "Star Trek", "Star Wars", "Stargate", "State University System of Florida", "Statistics", "Streetcars", "Sumo", "Surrey", "Sussex", "Swami Vivekananda", "Sweden", "Swimming", "Switzerland", "Syracuse, New York", "Syria", "Systems", "Taiwan", "Tajikistan", "Tambayan Philippines", "Tamil civilization", "Tamil Eelam", "Tampa Bay Buccaneers", "Tampa Bay", "Taoism", "Taxation", "Taylor Swift", "Technology", "Telecommunications", "Television Game Shows", "Television Stations", "Television", "Temperature extremes", "Tennessee", "Tennis", "Terrorism", "Textile Arts", "Teylers", "Thailand", "Thames", "The Apprentice UK", "The Beatles", "The Clash", "The Kinks", "The KLF", "The O.C. taskforce", "The Rolling Stones", "The Simpsons", "The Supremes", "The Twilight Zone", "The X Factor", "The X-Files", "Theatre", "Thelema", "Theology", "Three Kingdoms", "Tibet", "Tibetan Buddhism", "Tijuana", "Time", "Tirana", "Tokusatsu", "Tool", "Toronto", "Toys", "Trade", "Trains in Japan", "Trains", "Transcendental Meditation movement", "Transformers", "Transhumanism", "Transport in Scotland", "Transport", "Travel and Tourism", "Tree of Life", "Triathlon", "Trinidad and Tobago", "Tropical cyclones", "Trucks", "Tunisia", "Turkey", "Turkmenistan", "Turtles", "Typography", "U.S. Congress", "U.S. Roads", "U.S. Roads/U.S. Route 66", "U.S. Streets", "U.S. Supreme Court cases", "U2", "UK geography", "UK Roads", "UK Trams historical", "UK Trams modern", "UK Trams preserved", "UK Trams proposed", "UK Trams", "UK Waterways", "Ukraine", "Uniform Polytopes", "Unionism in Ireland", "United Arab Emirates", "United Kingdom", "United States Constitution", "United States courts and judges", "United States History", "United States Public Policy", "United States", "Universities", "University of Belgrade", "University of California Riverside Libraries", "University of California", "University of Cambridge", "University of Central Florida", "University of Connecticut", "University of Florida", "University of Houston", "University of Oxford", "University of Pennsylvania", "University of Pittsburgh", "University of Southern California", "University of the Philippines", "Urban studies and planning", "Uruguay", "Vancouver", "Vatican City", "Venezuela", "Vespidae", "Veterinary medicine", "Video games", "Vienna", "Vietnam", "Villages", "Virginia", "Viruses", "Visual arts", "Volcanoes", "Volleyball", "Wales", "Warhammer 40,000", "Warriors", "Warwickshire", "Washington Redskins", "Watches", "Water sports", "Water supply and sanitation", "Weather Data and Instrumentation", "Websites", "West Midlands", "Western Asia", "Western New York", "Westerns", "Wight", "Wikipedia", "Wikipedia-Books", "Wiltshire", "Wine", "Wisconsin", "Women artists", "Women scientists", "Women writers", "Women's Health", "Women's History", "Women's sport", "Woodworking", "Worcestershire", "World Heritage Sites", "World Rally", "World's Oldest People", "Writing systems", "Years", "Yemen", "Yoga", "York Museums Trust", "Yorkshire", "Yoruba", "Yu-Gi-Oh!", "Yugoslavia", "Zimbabwe", "Zoo", "Zoroastrianism" ];	alert('done defining wikiproject list'); // Script depends on jQuery UI dialog and jQuery cookie modules mw.loader.using( ['jquery.ui', 'mediawiki.cookie'], function {		alert('loaded jquery');		// Construct object (to prevent namespace conflicts)		wikiAssess = {

pageName: mw.config.get( 'wgPageName' ),

displayProgress: function( message ) { $( '#assessment-form div' ).hide; // remove everything else from the dialog box $( '#assessment-form' ).append ( $(' ').html( message+' ' ) ); },

displayError: function( error ) { $( '#assessment-form div' ).hide; // remove everything else from the dialog box $( '#assessment-form' ).append ( $(' ').html( 'Error: '+error ) ); },

addAssessment: function { var oldContent, newContent, selectedImportance, project = 'WikiProject ' + $( '#projectSelect' ).val, classRank = $( '#classSelect' ).val, importance = '', template;

wikiAssess.displayProgress( 'Adding assessment to article...' ); selectedImportance = $( "input[type='radio'][name='importance']:checked" ); if ( selectedImportance.length > 0 ) { importance = selectedImportance.val; }				if ( project !== 'WikiProject ' ) { mw.cookie.set( 'assessmentHelper', $('#projectSelect').val, { expires: 30 } ); template = ''; } else { wikiAssess.displayError( 'Invalid WikiProject selection.' ); return; }				if ( mw.config.get( 'wgAction' ) === 'view' ) { $.ajax({						url: mw.util.wikiScript( 'api' ),						data: {							action: 'query',							prop: 'revisions',							rvprop: 'content',							titles: wikiAssess.pageName,							formatversion: 2,							format: 'json'						},						dataType: 'json',						type: 'GET',						success: function( data ) {							if ( data.query !== undefined && data.query.pages[0] !== undefined && data.query.pages[0].revisions[0] !== undefined && typeof data.query.pages[0].revisions[0].content === 'string' ) {								oldContent = data.query.pages[0].revisions[0].content;								// Make sure there isn't already an assessment for this WikiProject.								// Note that this isn't foolproof due to template aliases.								if ( oldContent.search( '{{' + project ) !== -1 ) {									wikiAssess.displayError( 'Article already assessed for that project.' );									return;								}								// Insert the WikiProject template into the content								newContent = wikiAssess.insertTemplate( template, oldContent );								// Check for accidental content deletion								if ( newContent.length <= oldContent.length ) {									wikiAssess.displayError( 'Unknown error during template insertion.' );									return;								}								// Make the actual edit to the talk page								wikiAssess.editTalkPage( 'Adding template for ' + project + ' (via AssessmentHelper)', newContent );							} else {								wikiAssess.displayError( 'Failed to retrieve page content.' ); }						},						error: function( xhr ) { wikiAssess.displayError( 'Failed to retrieve page content.' ); }					});				} else if ( mw.config.get( 'wgAction' ) === 'edit' ) {					oldContent = $( '#wpTextbox1' ).val;					// Make sure there isn't already an assessment for this WikiProject					if ( oldContent.search( '{{' + project ) !== -1 ) {						wikiAssess.displayError( 'Article already assessed for that project.' );						return;					}					// Insert the WikiProject template into the content					newContent = wikiAssess.insertTemplate( template, oldContent );					// Check for accidental content deletion					if ( newContent.length <= oldContent.length ) {						wikiAssess.displayError( 'Unknown error during template insertion.' );						return;					}					// Replace the edit box contents with the new content					$( '#wpTextbox1' ).val( newContent );					// Close the dialog					$assessInterface.dialog( 'close' );				}			},			insertTemplate: function( template, oldContent ) {				var newContent, earliestPosition, testPosition1 = oldContent.search( /{{WikiProject(?!Banner)/ ), testPosition2 = oldContent.search( /{{WP(?!BS*\|)/ ); if ( testPosition1 === -1 && testPosition2 === -1 ) { // No existing assessments if ( oldContent.search( /^{{/ ) === 0 ) { newContent = template + "\n" + oldContent; } else { newContent = template + "\n\n" + oldContent; }				} else { // Talk page already includes assessments if ( testPosition1 > -1 ) { if ( testPosition2 > -1 ) { earliestPosition = Math.min( testPosition1, testPosition2 ); } else { earliestPosition = testPosition1; }					} else { earliestPosition = testPosition2; }					newContent = oldContent.substr( 0, earliestPosition ) + template + "\n" + oldContent.substr( earliestPosition ); }				return newContent; },

editTalkPage: function( summary, newContent ) { $.ajax({					url: mw.util.wikiScript( 'api' ),					data: {						action: 'edit',						title: wikiAssess.pageName,						summary: summary,						text: newContent,						format: 'json',						token: mw.user.tokens.get( 'csrfToken' ),					},					dataType: 'json',					type: 'POST',					success: function( data ) {						if ( data.edit !== undefined && data.edit.result == "Success" ) {							window.location.reload;						} else {							wikiAssess.displayError( 'Unknown result from API during edit attempt.' );						}					},					error: function( xhr ) {						wikiAssess.displayError( 'Edit failed.' );						//console.debug( xhr.responseText );					}				}); },

launchDialog: function { // Restore dialog to original state $assessInterface.find( '.assess-progress, .assess-error' ).remove; $assessInterface.find( 'div' ).show; // Open the dialog box $assessInterface.dialog( 'open' ); },

initialize: function { alert('started to initialize'); var classList = [ '',						'Stub', 'Start', 'C', 'B', 'GA', 'A', 'FA', 'List', 'FL', 'Disambig', 'NA' ];				alert('defining interface');

// Define assessment interface $assessInterface = $(' ') .append( $(' ').html( 'WikiProject: ' )						.append( $(' ') )					) .append( $(' ').html( 'Class: ' )						.append( $(' ') )					) .append( $(' ').html( 'Importance: ' )						.append( $('') ).append( ' Low ' )						.append( $('') ).append( ' Mid  ' )						.append( $('') ).append( ' High  ' )						.append( $('') ).append( ' Top  ' )					) .dialog({						width: 500,						autoOpen: false,						title: 'Assess this article',						modal: true,						buttons: { "Add assessment": wikiAssess.addAssessment }					}); alert('populating list');

// Populate WikiProject select list $.each( wikiProjectList, function(index, value) {					if ( mw.cookie.get( 'assessmentHelper' ) === value ) {						$('#projectSelect').append( $(' ').val(value).html(value).attr('selected', 'selected') );					} else {						$('#projectSelect').append( $('  ').val(value).html(value) );					}				}); alert('defining class select list');

// Populate class select list $.each( classList, function(index, value) { $('#classSelect').append( $(' ').val(value).html(value) ); }); alert('adding assess tab'); // Insert 'Assess' link into page interface $( document ).ready( function {					alert('hi');					$( '#ca-history' ).after( $( '' ).html( 'Assess') );					$( '#ca-history' ).after( "\n" );				}); alert('added assess tab');

} // close initialize function

} // close wikiAssess object alert('defined object'); wikiAssess.initialize; }) // close mw.loader //} // close if //