MediaWiki:UploadScript.js: Difference between revisions
From Halopedia, the Halo wiki
No edit summary |
mNo edit summary |
||
(44 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
var summary_input; | var summary_input; | ||
var nonhalo_input; | |||
var type_select; | var type_select; | ||
var mediatype_select; | |||
var media_select; | var media_select; | ||
var specific_media_text; | var specific_media_text; | ||
Line 22: | Line 24: | ||
var specific_source_text; | var specific_source_text; | ||
var filename_input; | var filename_input; | ||
var caption_input; | |||
var license_select; | var license_select; | ||
var final_textarea; | var final_textarea; | ||
var summary_tr; | var summary_tr; | ||
var nonhalo_tr; | |||
var type_tr; | var type_tr; | ||
var mediatype_tr; | |||
var media_tr; | var media_tr; | ||
var specific_media_span; | var specific_media_span; | ||
Line 44: | Line 49: | ||
var specific_source_span; | var specific_source_span; | ||
var filename_tr; | var filename_tr; | ||
var caption_tr; | |||
var license_tr; | var license_tr; | ||
var final_tr; | var final_tr; | ||
Line 49: | Line 55: | ||
var final_toggler_a; | var final_toggler_a; | ||
var has_nonhalo = false; | |||
var has_game = false; | var has_game = false; | ||
var has_subgame = false; | var has_subgame = false; | ||
Line 60: | Line 67: | ||
var has_source = false; | var has_source = false; | ||
var has_filename = false; | var has_filename = false; | ||
var has_caption = false; | |||
var has_license = false; | var has_license = false; | ||
var insert; | var insert; | ||
var ogFileName; | var ogFileName; | ||
function main() { | function main() { | ||
if(typeof(mw) === "undefined" || mw.config.get("wgCanonicalNamespace") != "Special" || mw.config.get("wgTitle") != "Upload") return; | if (typeof(mw) === "undefined" || mw.config.get("wgCanonicalNamespace") != "Special" || mw.config.get("wgTitle") != "Upload") return; | ||
if(window.location.href.indexOf("wpForReUpload=1") != -1) return; | if (window.location.href.indexOf("wpForReUpload=1") != -1) return; | ||
//Get the table with the upload fields. | //Get the table with the upload fields. | ||
var table; | |||
if (mw.config.get('wgMFMode')) | if (mw.config.get('wgMFMode')) | ||
table = document.getElementById("mw-htmlform-description"); | |||
else | else | ||
table = document.getElementById("mw-htmlform-description").firstChild; | |||
if(document.getElementById("wpUploadDescription") && document.getElementById("wpUploadDescription").value | if (document.getElementById("wpUploadDescription") && | ||
//Hold on, there's already text here! Chances are this is the warning page. | document.getElementById("wpUploadDescription").value != "{{file info\n|summary = \n|game = \n|type = \n|source = \n}}") { | ||
//Hold on, there's already custom text here! Chances are this is the warning page. | |||
//Let's just hide the license box and quit. | //Let's just hide the license box and quit. | ||
hide_license(table); | hide_license(table); | ||
Line 85: | Line 94: | ||
insert = 1; | insert = 1; | ||
ogFileName = ""; | ogFileName = ""; | ||
create_mediatype_list(table); | |||
create_nonhalo_input(table); | |||
create_media_list(table); | create_media_list(table); | ||
create_game_list(table); | create_game_list(table); | ||
Line 100: | Line 110: | ||
create_source_list(table); | create_source_list(table); | ||
create_filename_input(table); | create_filename_input(table); | ||
create_caption_input(table); | |||
create_license_list(table); | create_license_list(table); | ||
Line 106: | Line 117: | ||
handle_type_choice(); | handle_type_choice(); | ||
} | |||
function create_nonhalo_input(table) { | |||
nonhalo_input = document.createElement("input"); | |||
nonhalo_input.size = "60"; | |||
nonhalo_input.onchange = create_final_result; | |||
nonhalo_tr = add_field("Non-<i>Halo</i> title:", nonhalo_input, table); | |||
} | } | ||
Line 120: | Line 138: | ||
filename_input.onchange = create_final_result; | filename_input.onchange = create_final_result; | ||
filename_tr = add_field("Original filename:", filename_input, table); | filename_tr = add_field("Original filename:", filename_input, table); | ||
} | |||
function create_caption_input(table) { | |||
caption_input = document.createElement("input"); | |||
caption_input.size = "52"; | |||
caption_input.onchange = create_final_result; | |||
caption_tr = add_field("Source caption:", caption_input, table); | |||
} | } | ||
Line 133: | Line 158: | ||
add_option("logo", "Logo", type_select); | add_option("logo", "Logo", type_select); | ||
add_option("asset", "Raw asset", type_select); | add_option("asset", "Raw asset", type_select); | ||
add_option("page", " | add_option("page", "Book/comic page", type_select); | ||
add_option("document", " | add_option("designdoc", "Design documentation", type_select); | ||
add_option("document", "PDF document", type_select); | |||
add_option("audio", "Audio file", type_select); | add_option("audio", "Audio file", type_select); | ||
add_option("real", "Real-world image", type_select); | add_option("real", "Real-world image", type_select); | ||
Line 141: | Line 167: | ||
type_tr = add_field("File type:", type_select, table); | type_tr = add_field("File type:", type_select, table); | ||
} | |||
function create_mediatype_list(table) { | |||
var mediatype_span = document.createElement("span"); | |||
mediatype_select = document.createElement("select"); | |||
mediatype_select.name = "mediatype"; | |||
mediatype_select.onchange = handle_mediatype_choice; | |||
mediatype_span.appendChild(mediatype_select); | |||
add_option("halo", "Halo media", mediatype_select); | |||
add_option("nonhalo", "Non-Halo media", mediatype_select); | |||
mediatype_tr = add_field("Media type:", mediatype_span, table); | |||
} | } | ||
Line 154: | Line 194: | ||
add_option("film", "Film/series", media_select); | add_option("film", "Film/series", media_select); | ||
add_option("comic", "Comic/graphic novel", media_select); | add_option("comic", "Comic/graphic novel", media_select); | ||
add_option("book", " | add_option("book", "Novel/other book", media_select); | ||
add_option("album", "Album", media_select); | add_option("album", "Album", media_select); | ||
add_option("merch", "Merchandise", media_select); | add_option("merch", "Merchandise", media_select); | ||
add_option("marketing", "Marketing material", media_select); | add_option("marketing", "Marketing material", media_select); | ||
add_option("website", "Website", media_select); | add_option("website", "Website", media_select); | ||
add_option("other", "N/A", media_select); | add_option("other", "N/A", media_select); | ||
Line 166: | Line 205: | ||
specific_media_text = document.createElement("input"); | specific_media_text = document.createElement("input"); | ||
specific_media_text.size = " | specific_media_text.size = "46"; | ||
specific_media_text.onchange = update_fields; | specific_media_text.onchange = update_fields; | ||
specific_media_span.appendChild(document.createTextNode(" Please enter the book | specific_media_text.value = "Halo Encyclopedia (2022 edition)"; // recent big release | ||
specific_media_span.appendChild(document.createTextNode(" Please enter the book title exactly: ")); | |||
specific_media_span.appendChild(specific_media_text); | specific_media_span.appendChild(specific_media_text); | ||
Line 191: | Line 231: | ||
add_media("Halo 4", game_select); | add_media("Halo 4", game_select); | ||
add_media("Halo 5: Guardians", game_select); | add_media("Halo 5: Guardians", game_select); | ||
add_media("Halo Infinite", game_select); | add_media("Halo Infinite", game_select, 'selected'); | ||
add_media("Halo: The Master Chief Collection", game_select); | add_media("Halo: The Master Chief Collection", game_select); | ||
add_media("Halo Wars", game_select); | add_media("Halo Wars", game_select); | ||
Line 199: | Line 239: | ||
add_media("Halo: Fireteam Raven", game_select); | add_media("Halo: Fireteam Raven", game_select); | ||
add_media("Halo Online", game_select); | add_media("Halo Online", game_select); | ||
add_media("Other", game_select); | add_media("Other Halo game", game_select); | ||
specific_game_span = document.createElement("span"); | specific_game_span = document.createElement("span"); | ||
Line 205: | Line 245: | ||
specific_game_text = document.createElement("input"); | specific_game_text = document.createElement("input"); | ||
specific_game_text.size = " | specific_game_text.size = "32"; | ||
specific_game_text.onchange = update_fields; | specific_game_text.onchange = update_fields; | ||
specific_game_span.appendChild(document.createTextNode(" Please enter the game | specific_game_span.appendChild(document.createTextNode(" Please enter the game title exactly: ")); | ||
specific_game_span.appendChild(specific_game_text); | specific_game_span.appendChild(specific_game_text); | ||
Line 242: | Line 282: | ||
add_media("Halo 4: Forward Unto Dawn", film_select); | add_media("Halo 4: Forward Unto Dawn", film_select); | ||
add_media("Halo: Nightfall", film_select); | add_media("Halo: Nightfall", film_select); | ||
add_media("Halo: The Fall of Reach - The Animated Series", film_select); | |||
add_media("Halo: The Fall of Reach", film_select); | add_media("Halo: The Television Series", film_select, 'selected'); | ||
add_media("Halo: The | add_media("Other Halo film/series", film_select); | ||
add_media("Other", film_select); | |||
specific_film_span = document.createElement("span"); | specific_film_span = document.createElement("span"); | ||
Line 251: | Line 290: | ||
specific_film_text = document.createElement("input"); | specific_film_text = document.createElement("input"); | ||
specific_film_text.size = " | specific_film_text.size = "16"; | ||
specific_film_text.onchange = update_fields; | specific_film_text.onchange = update_fields; | ||
specific_film_span.appendChild(document.createTextNode(" Please enter the film/series | specific_film_span.appendChild(document.createTextNode(" Please enter the film/series title exactly: ")); | ||
specific_film_span.appendChild(specific_film_text); | specific_film_span.appendChild(specific_film_text); | ||
Line 276: | Line 315: | ||
add_media("Halo: Collateral Damage", comic_select); | add_media("Halo: Collateral Damage", comic_select); | ||
add_media("Halo: Lone Wolf", comic_select); | add_media("Halo: Lone Wolf", comic_select); | ||
add_media("Other/graphic novel", comic_select); | add_media("Halo Graphic Novel", comic_select, 'selected'); | ||
add_media("Halo: Tales from Slipspace", comic_select); | |||
add_media("Other Halo comic/graphic novel", comic_select); | |||
specific_comic_span = document.createElement("span"); | specific_comic_span = document.createElement("span"); | ||
Line 282: | Line 323: | ||
specific_comic_text = document.createElement("input"); | specific_comic_text = document.createElement("input"); | ||
specific_comic_text.size = " | specific_comic_text.size = "19"; | ||
specific_comic_text.onchange = update_fields; | specific_comic_text.onchange = update_fields; | ||
specific_comic_span.appendChild(document.createTextNode(" Please enter the comic series/graphic novel | specific_comic_span.appendChild(document.createTextNode(" Please enter the comic series/graphic novel title exactly: ")); | ||
specific_comic_span.appendChild(specific_comic_text); | specific_comic_span.appendChild(specific_comic_text); | ||
comic_tr = add_field(" | comic_tr = add_field("Series/title:", comic_span, table); | ||
} | } | ||
Line 295: | Line 336: | ||
screenshot_select.onchange = update_fields; | screenshot_select.onchange = update_fields; | ||
add_option("character", "Character or AI | add_option("character", "Character or AI", screenshot_select); | ||
add_option("multiplayer", "Multiplayer content", screenshot_select); | |||
add_option("weapon", "Weapon", screenshot_select); | add_option("weapon", "Weapon", screenshot_select); | ||
add_option("vehicle", "Vehicle", screenshot_select); | add_option("vehicle", "Vehicle", screenshot_select); | ||
add_option("menu", "Menu", screenshot_select); | add_option("menu", "Menu", screenshot_select); | ||
add_option("other", "Other", screenshot_select); | add_option("other", "Other", screenshot_select); | ||
Line 312: | Line 353: | ||
add_option("achievement", "Achievement", icon_select); | add_option("achievement", "Achievement", icon_select); | ||
add_option("medal", "Multiplayer medal", icon_select); | add_option("medal", "Multiplayer medal", icon_select); | ||
add_option("skull", "Skull | add_option("rank", "Rank insignia", icon_select); | ||
add_option("skull", "Skull icon", icon_select); | |||
add_option("menuicon", "Menu icon", icon_select); | |||
add_option("other", "Other", icon_select); | add_option("other", "Other", icon_select); | ||
Line 369: | Line 412: | ||
add_option("direct", "Direct rip from media files", source_select); | add_option("direct", "Direct rip from media files", source_select); | ||
add_option("unknown", "Unknown", source_select); | add_option("unknown", "Unknown", source_select); | ||
add_option("other", "N/A", source_select); | |||
specific_source_span = document.createElement("span"); | specific_source_span = document.createElement("span"); | ||
Line 374: | Line 418: | ||
specific_source_text = document.createElement("input"); | specific_source_text = document.createElement("input"); | ||
specific_source_text.size = " | specific_source_text.size = "51"; | ||
specific_source_text.onchange = create_final_result; | specific_source_text.onchange = create_final_result; | ||
specific_source_span.appendChild(document.createTextNode(" Please link to the page: ")); | specific_source_span.appendChild(document.createTextNode(" Please link to the page: ")); | ||
Line 399: | Line 443: | ||
function handle_type_choice() { | function handle_type_choice() { | ||
handle_mediatype_choice(); | |||
handle_media_choice(); | handle_media_choice(); | ||
handle_game_choice(); | handle_game_choice(); | ||
Line 405: | Line 450: | ||
handle_artist_choice(); | handle_artist_choice(); | ||
handle_source_choice(); | handle_source_choice(); | ||
update_fields(); | |||
} | |||
function handle_mediatype_choice() { | |||
var cur_mediatype = get_option(mediatype_select); | |||
update_fields(); | update_fields(); | ||
} | } | ||
Line 411: | Line 462: | ||
var cur_media = get_option(media_select); | var cur_media = get_option(media_select); | ||
if(cur_media == "book") { | if (cur_media == "book") { | ||
specific_media_span.style.display = "inline"; | specific_media_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 423: | Line 474: | ||
var cur_game = get_option(game_select); | var cur_game = get_option(game_select); | ||
if(cur_game == "Other") { | if (cur_game == "Other Halo game") { | ||
specific_game_span.style.display = "inline"; | specific_game_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 435: | Line 486: | ||
var cur_film = get_option(film_select); | var cur_film = get_option(film_select); | ||
if(cur_film == "Other") { | if (cur_film == "Other Halo film/series") { | ||
specific_film_span.style.display = "inline"; | specific_film_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 447: | Line 498: | ||
var cur_comic = get_option(comic_select); | var cur_comic = get_option(comic_select); | ||
if(cur_comic == "Other/graphic novel") { | if (cur_comic == "Other Halo comic/graphic novel") { | ||
specific_comic_span.style.display = "inline"; | specific_comic_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 459: | Line 510: | ||
var cur_artist = get_option(artist_select); | var cur_artist = get_option(artist_select); | ||
if(cur_artist == "known") { | if (cur_artist == "known") { | ||
specific_artist_span.style.display = "inline"; | specific_artist_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 471: | Line 522: | ||
var cur_source = get_option(source_select); | var cur_source = get_option(source_select); | ||
if(cur_source == "web") { | if (cur_source == "web") { | ||
specific_source_span.style.display = "inline"; | specific_source_span.style.display = "inline"; | ||
} else { | } else { | ||
Line 479: | Line 530: | ||
update_fields(); | update_fields(); | ||
} | } | ||
$("#wpUploadFile").change(function() { | |||
ogFileName = $("#wpUploadFile").val().split('\\').pop(); | |||
$('select[name="source"]').change(); | |||
}); | |||
$("#wpUploadFileURL").change(function() { | |||
ogFileName = $("#wpUploadFileURL").val().split('/').pop(); | |||
$('select[name="source"]').val('web').change(); | |||
}); | |||
function getAcronym(input) { | function getAcronym(input) { | ||
Line 486: | Line 547: | ||
function getGameAbbr(cur_game) { | function getGameAbbr(cur_game) { | ||
switch (cur_game) { | switch (cur_game) { | ||
case "Other": | case "Other Halo game": | ||
if (specific_game_text.value != "") | if (specific_game_text.value != "") | ||
return getAcronym(specific_game_text.value); | return getAcronym(specific_game_text.value); | ||
Line 500: | Line 561: | ||
function getFilmAbbr(cur_film) { | function getFilmAbbr(cur_film) { | ||
switch (cur_film) { | switch (cur_film) { | ||
case "Other": | case "Other Halo film/series": | ||
if (specific_film_text.value != "") | if (specific_film_text.value != "") | ||
return getAcronym(specific_film_text.value); | return getAcronym(specific_film_text.value); | ||
Line 510: | Line 571: | ||
function getComicAbbr(cur_comic) { | function getComicAbbr(cur_comic) { | ||
switch (cur_comic) { | switch (cur_comic) { | ||
case "Other/graphic novel": | case "Other Halo comic/graphic novel": | ||
if (specific_comic_text.value != "") | if (specific_comic_text.value != "") | ||
return getAcronym(specific_comic_text.value); | return getAcronym(specific_comic_text.value); | ||
Line 528: | Line 589: | ||
function update_fields() { | function update_fields() { | ||
var cur_type = get_option(type_select); | var cur_type = get_option(type_select); | ||
var cur_mediatype = get_option(mediatype_select); | |||
var cur_media = get_option(media_select); | var cur_media = get_option(media_select); | ||
var cur_game = get_option(game_select); | var cur_game = get_option(game_select); | ||
Line 539: | Line 601: | ||
var cur_source = get_option(source_select); | var cur_source = get_option(source_select); | ||
has_media = false; | |||
has_game = false; | has_game = false; | ||
has_nonhalo = false; | |||
has_subgame = false; | has_subgame = false; | ||
has_film = false; | has_film = false; | ||
Line 550: | Line 614: | ||
has_source = true; | has_source = true; | ||
has_filename = false; | has_filename = false; | ||
has_caption = false; | |||
has_license = true; | has_license = true; | ||
if( | if (cur_mediatype == "halo") { | ||
has_media = true; | |||
if (cur_media == "game") { | |||
has_game = true; | |||
} | |||
if(cur_media == "film") { | if (cur_media == "game" && cur_game == "Halo: The Master Chief Collection") { | ||
has_subgame = true; | |||
} | |||
if (cur_media == "film") { | |||
has_film = true; | |||
} | |||
if (cur_media == "comic") { | |||
has_comic = true; | |||
} | |||
if (cur_media == "book") { | |||
has_book = true; | |||
} | |||
if ((cur_media == "game" || cur_media == "film") && cur_type == "screenshot") { | |||
has_screenshot = true; | |||
} | |||
if (cur_media == "game" && cur_type == "icon") { | |||
has_icon = true; | |||
} | |||
} else if (cur_mediatype == "nonhalo") { | |||
has_nonhalo = true; | |||
} | } | ||
if(cur_type == "artwork") { | if (cur_type == "artwork") { | ||
has_artwork = true; | has_artwork = true; | ||
} | } | ||
if( | if ( | ||
cur_type == "artwork" || cur_type == "icon" || | cur_type == "artwork" || cur_type == "icon" || | ||
cur_type == "render" || cur_type == "logo" || | cur_type == "render" || cur_type == "logo" || | ||
cur_type == "asset" || cur_type == "page" || | cur_type == "asset" || cur_type == "page" || | ||
cur_type == "document" || cur_type == "audio" | cur_type == "designdoc" || cur_type == "document" || | ||
cur_type == "audio" || cur_type == "wiki" | |||
) { | ) { | ||
has_artist = true; | has_artist = true; | ||
Line 597: | Line 669: | ||
} | } | ||
if (has_source && cur_source | if (has_source && (cur_source == "web" || cur_source == "direct")) { | ||
has_filename = true; | has_filename = true; | ||
} | |||
if (has_source && cur_source == "web") { | |||
has_caption = true; | |||
} | } | ||
Line 606: | Line 682: | ||
var show = "table-row"; | var show = "table-row"; | ||
media_tr.style.display = show; | media_tr.style.display = | ||
has_media ? show : "none"; | |||
nonhalo_tr.style.display = | |||
has_nonhalo ? show : "none"; | |||
game_tr.style.display = | game_tr.style.display = | ||
has_game ? show : "none"; | has_game ? show : "none"; | ||
Line 627: | Line 706: | ||
filename_tr.style.display = | filename_tr.style.display = | ||
has_filename ? show : "none"; | has_filename ? show : "none"; | ||
caption_tr.style.display = | |||
has_caption ? show : "none"; | |||
license_tr.style.display = | license_tr.style.display = | ||
has_license ? show : "none"; | has_license ? show : "none"; | ||
if (ogFileName != "") { | if (ogFileName != "") { | ||
Line 646: | Line 715: | ||
var cur_icon = get_option(icon_select); | var cur_icon = get_option(icon_select); | ||
var cur_artwork = get_option(artwork_select); | var cur_artwork = get_option(artwork_select); | ||
if (has_icon && cur_icon != "other" ) { | if (has_icon && cur_icon != "other") { | ||
cur_type = cur_icon; | cur_type = cur_icon; | ||
} else if (has_artwork && cur_artwork != "other" ) { | } else if (has_artwork && cur_artwork != "other") { | ||
cur_type = cur_artwork; | cur_type = cur_artwork; | ||
} else if (has_screenshot && cur_screenshot != "other" ) { | } else if (has_screenshot && cur_screenshot != "other") { | ||
cur_type = cur_screenshot; | cur_type = cur_screenshot; | ||
} | } | ||
Line 668: | Line 737: | ||
abbr = capitalizeFirstLetter(cur_media); | abbr = capitalizeFirstLetter(cur_media); | ||
// $("#wpDestFile").val(abbr + " " + cur_type + " " + ogFileName); | filename_input.value = ogFileName; | ||
// $("#wpDestFile").val(abbr + " " + cur_type + " " + capitalizeFirstLetter(ogFileName)); | |||
} | } | ||
Line 676: | Line 746: | ||
function create_final_result() { | function create_final_result() { | ||
var t = ""; | var t = ""; | ||
var cur_mediatype = get_option(mediatype_select); | |||
var cur_media = get_option(media_select); | var cur_media = get_option(media_select); | ||
var cur_type = get_option(type_select); | var cur_type = get_option(type_select); | ||
Line 694: | Line 765: | ||
t += "|summary = " + summary_input.value + "\n"; | t += "|summary = " + summary_input.value + "\n"; | ||
if(cur_media == "book") { | if (has_media) { | ||
if (cur_media == "book") { | |||
if (specific_media_text.value != "") | |||
t += "|book = " + specific_media_text.value + "\n"; | |||
} else if (cur_media != "game" && cur_media != "film" && cur_media != "comic" && cur_media != "other") { | |||
} | t += "|media = " + cur_media + "\n"; | ||
} | |||
} else if (cur_mediatype == "nonhalo") { | |||
t += "|media = " + cur_mediatype + "\n"; | |||
if (nonhalo_input.value != "") | |||
t += "|title = " + nonhalo_input.value + "\n"; | |||
} | |||
if(has_game) { | if (has_game) { | ||
if (cur_game == "Other") { | if (cur_game == "Other Halo game") { | ||
if (specific_game_text.value != "") | if (specific_game_text.value != "") | ||
t += "|game = " + specific_game_text.value + "\n"; | t += "|game = " + specific_game_text.value + "\n"; | ||
Line 709: | Line 786: | ||
} | } | ||
if(has_subgame && cur_subgame != "N/A" ) { | if (has_subgame && cur_subgame != "N/A") { | ||
t += "|subgame = " + cur_subgame + "\n"; | t += "|subgame = " + cur_subgame + "\n"; | ||
} | } | ||
if(has_film) { | if (has_film) { | ||
if (cur_film == "Other") { | if (cur_film == "Other Halo film/series") { | ||
if (specific_film_text.value != "") | if (specific_film_text.value != "") | ||
t += "|film = " + specific_film_text.value + "\n"; | t += "|film = " + specific_film_text.value + "\n"; | ||
Line 721: | Line 798: | ||
} | } | ||
if(has_comic) { | if (has_comic) { | ||
if (cur_comic == "Other/graphic novel") { | if (cur_comic == "Other Halo comic/graphic novel") { | ||
if (specific_comic_text.value != "") | if (specific_comic_text.value != "") | ||
t += "|comic = " + specific_comic_text.value + "\n"; | t += "|comic = " + specific_comic_text.value + "\n"; | ||
Line 729: | Line 806: | ||
} | } | ||
if(has_icon && cur_icon != "other" ) { | if (has_icon && cur_icon != "other") { | ||
t += "|type = " + cur_icon + "\n"; | t += "|type = " + cur_icon + "\n"; | ||
} else if(has_artwork && cur_artwork != "other" ) { | } else if (has_artwork && cur_artwork != "other") { | ||
t += "|type = " + cur_artwork + "\n"; | t += "|type = " + cur_artwork + "\n"; | ||
} else { | } else { | ||
Line 737: | Line 814: | ||
} | } | ||
if(has_screenshot && cur_screenshot != "other" ) { | if (has_screenshot && cur_screenshot != "other") { | ||
t += "|subject = " + cur_screenshot + "\n"; | t += "|subject = " + cur_screenshot + "\n"; | ||
} | } | ||
if(has_artist) { | if (has_artist) { | ||
if(cur_artist == "known") { | if (cur_artist == "known") { | ||
if (specific_artist_text.value != "") | if (specific_artist_text.value != "") | ||
t += "|artist = " + specific_artist_text.value + "\n"; | t += "|artist = " + specific_artist_text.value + "\n"; | ||
} else if(cur_artist != "unknown") | } else if (cur_artist != "unknown") | ||
t += "|artist = " + cur_artist + "\n"; | t += "|artist = " + cur_artist + "\n"; | ||
} | } | ||
if(has_source) { | if (has_source && cur_source != "other") { | ||
if(cur_source == "web") { | if (cur_source == "web") { | ||
if (specific_source_text.value != "") | if (specific_source_text.value != "") | ||
t += "|source = " + specific_source_text.value + "\n"; | t += "|source = " + specific_source_text.value + "\n"; | ||
Line 757: | Line 834: | ||
} | } | ||
if (filename_input.value != "") | if (has_filename && filename_input.value != "") | ||
t += "|filename = " + filename_input.value + "\n"; | t += "|filename = " + filename_input.value + "\n"; | ||
if (has_caption && caption_input.value != "") | |||
t += "|caption = " + caption_input.value + "\n"; | |||
if(has_license && cur_license != "fairuse") { | if (has_license && cur_license != "fairuse") { | ||
t += "|license = " + cur_license + "\n"; | t += "|license = " + cur_license + "\n"; | ||
} | } | ||
Line 766: | Line 846: | ||
t += "}}\n\n" | t += "}}\n\n" | ||
if(t.substr(t.length - 2) == "\n\n") { | if (t.substr(t.length - 2) == "\n\n") { | ||
t = t.slice(0, t.length - 1); | t = t.slice(0, t.length - 1); | ||
} | } | ||
Line 779: | Line 859: | ||
function setup_final(table) { | function setup_final(table) { | ||
var final_toggler_div = document.createElement("div"); | var final_toggler_div = document.createElement("div"); | ||
final_toggler_div.id = "toggler"; | |||
final_toggler_a = document.createElement("a"); | final_toggler_a = document.createElement("a"); | ||
Line 786: | Line 867: | ||
final_toggler_div.appendChild(document.createTextNode("[")); | final_toggler_div.appendChild(document.createTextNode("[")); | ||
final_toggler_div.appendChild(final_toggler_a); | final_toggler_div.appendChild(final_toggler_a); | ||
final_toggler_div.appendChild(document.createTextNode("] summary result | final_toggler_div.appendChild(document.createTextNode("] summary result")); | ||
add_field("", final_toggler_div, table); | add_field("", final_toggler_div, table); | ||
Line 796: | Line 877: | ||
function toggle_final() { | function toggle_final() { | ||
if(final_tr.style.display == "none") { | if (final_tr.style.display == "none") { | ||
if (mw.config.get('wgMFMode')) | if (mw.config.get('wgMFMode')) | ||
var show = "block"; | var show = "block"; | ||
Line 825: | Line 906: | ||
opt.innerHTML = innerHTML; | opt.innerHTML = innerHTML; | ||
parent.appendChild(opt); | parent.appendChild(opt); | ||
if(typeof(selected) != "undefined") { | if (typeof(selected) != "undefined") { | ||
opt.setAttribute("selected", ""); | opt.setAttribute("selected", ""); | ||
} | } | ||
Line 836: | Line 917: | ||
opt.innerHTML = value; | opt.innerHTML = value; | ||
parent.appendChild(opt); | parent.appendChild(opt); | ||
if(typeof(selected) != "undefined") { | if (typeof(selected) != "undefined") { | ||
opt.setAttribute("selected", ""); | opt.setAttribute("selected", ""); | ||
} | } |
Latest revision as of 18:43, January 17, 2024
// <nowiki>
// Original script written by Espyo for Pikipedia
// https://www.pikminwiki.com/MediaWiki:PikipediaUpload.js
var summary_input;
var nonhalo_input;
var type_select;
var mediatype_select;
var media_select;
var specific_media_text;
var game_select;
var specific_game_text;
var subgame_select;
var film_select;
var specific_film_text;
var comic_select;
var specific_comic_text;
var screenshot_select;
var icon_select;
var artwork_select;
var artist_select;
var specific_artist_text;
var source_select;
var specific_source_text;
var filename_input;
var caption_input;
var license_select;
var final_textarea;
var summary_tr;
var nonhalo_tr;
var type_tr;
var mediatype_tr;
var media_tr;
var specific_media_span;
var game_tr;
var specific_game_span;
var subgame_tr;
var film_tr;
var specific_film_span;
var comic_tr;
var specific_comic_span;
var screenshot_tr;
var icon_tr;
var artwork_tr;
var artist_tr;
var specific_artist_span;
var source_tr;
var specific_source_span;
var filename_tr;
var caption_tr;
var license_tr;
var final_tr;
var final_toggler_a;
var has_nonhalo = false;
var has_game = false;
var has_subgame = false;
var has_film = false;
var has_comic = false;
var has_book = false;
var has_screenshot = false;
var has_icon = false;
var has_artwork = false;
var has_artist = false;
var has_source = false;
var has_filename = false;
var has_caption = false;
var has_license = false;
var insert;
var ogFileName;
function main() {
if (typeof(mw) === "undefined" || mw.config.get("wgCanonicalNamespace") != "Special" || mw.config.get("wgTitle") != "Upload") return;
if (window.location.href.indexOf("wpForReUpload=1") != -1) return;
//Get the table with the upload fields.
var table;
if (mw.config.get('wgMFMode'))
table = document.getElementById("mw-htmlform-description");
else
table = document.getElementById("mw-htmlform-description").firstChild;
if (document.getElementById("wpUploadDescription") &&
document.getElementById("wpUploadDescription").value != "{{file info\n|summary = \n|game = \n|type = \n|source = \n}}") {
//Hold on, there's already custom text here! Chances are this is the warning page.
//Let's just hide the license box and quit.
hide_license(table);
return;
}
insert = 1;
ogFileName = "";
create_mediatype_list(table);
create_nonhalo_input(table);
create_media_list(table);
create_game_list(table);
create_subgame_list(table);
create_film_list(table);
create_comic_list(table);
create_type_list(table);
create_screenshot_list(table);
create_icon_list(table);
create_artwork_list(table);
create_summary_input(table);
create_artist_list(table);
create_source_list(table);
create_filename_input(table);
create_caption_input(table);
create_license_list(table);
hide_license(table);
setup_final(table);
handle_type_choice();
}
function create_nonhalo_input(table) {
nonhalo_input = document.createElement("input");
nonhalo_input.size = "60";
nonhalo_input.onchange = create_final_result;
nonhalo_tr = add_field("Non-<i>Halo</i> title:", nonhalo_input, table);
}
function create_summary_input(table) {
summary_input = document.createElement("input");
summary_input.size = "60";
summary_input.onchange = create_final_result;
summary_tr = add_field("Summary:", summary_input, table);
}
function create_filename_input(table) {
filename_input = document.createElement("input");
filename_input.size = "52";
filename_input.onchange = create_final_result;
filename_tr = add_field("Original filename:", filename_input, table);
}
function create_caption_input(table) {
caption_input = document.createElement("input");
caption_input.size = "52";
caption_input.onchange = create_final_result;
caption_tr = add_field("Source caption:", caption_input, table);
}
function create_type_list(table) {
type_select = document.createElement("select");
type_select.name = "type";
type_select.onchange = handle_type_choice;
add_option("screenshot", "Screenshot", type_select);
add_option("icon", "Icon image", type_select);
add_option("artwork", "Artwork", type_select);
add_option("render", "Render", type_select);
add_option("logo", "Logo", type_select);
add_option("asset", "Raw asset", type_select);
add_option("page", "Book/comic page", type_select);
add_option("designdoc", "Design documentation", type_select);
add_option("document", "PDF document", type_select);
add_option("audio", "Audio file", type_select);
add_option("real", "Real-world image", type_select);
add_option("user", "Personal user image", type_select);
add_option("wiki", "Halopedia site image", type_select);
type_tr = add_field("File type:", type_select, table);
}
function create_mediatype_list(table) {
var mediatype_span = document.createElement("span");
mediatype_select = document.createElement("select");
mediatype_select.name = "mediatype";
mediatype_select.onchange = handle_mediatype_choice;
mediatype_span.appendChild(mediatype_select);
add_option("halo", "Halo media", mediatype_select);
add_option("nonhalo", "Non-Halo media", mediatype_select);
mediatype_tr = add_field("Media type:", mediatype_span, table);
}
function create_media_list(table) {
var media_span = document.createElement("span");
media_select = document.createElement("select");
media_select.name = "media";
media_select.onchange = handle_media_choice;
media_span.appendChild(media_select);
add_option("game", "Game", media_select);
add_option("film", "Film/series", media_select);
add_option("comic", "Comic/graphic novel", media_select);
add_option("book", "Novel/other book", media_select);
add_option("album", "Album", media_select);
add_option("merch", "Merchandise", media_select);
add_option("marketing", "Marketing material", media_select);
add_option("website", "Website", media_select);
add_option("other", "N/A", media_select);
specific_media_span = document.createElement("span");
media_span.appendChild(specific_media_span);
specific_media_text = document.createElement("input");
specific_media_text.size = "46";
specific_media_text.onchange = update_fields;
specific_media_text.value = "Halo Encyclopedia (2022 edition)"; // recent big release
specific_media_span.appendChild(document.createTextNode(" Please enter the book title exactly: "));
specific_media_span.appendChild(specific_media_text);
media_tr = add_field("<i>Halo</i> media:", media_span, table);
}
function create_game_list(table) {
var game_span = document.createElement("span");
game_select = document.createElement("select");
game_select.name = "game";
game_select.onchange = handle_game_choice;
game_span.appendChild(game_select);
add_media("Halo: Combat Evolved", game_select);
add_media("Halo: Combat Evolved Anniversary", game_select);
add_media("Halo 2", game_select);
add_media("Halo 2: Anniversary", game_select);
add_media("Halo 3", game_select);
add_media("Halo 3: ODST", game_select);
add_media("Halo: Reach", game_select);
add_media("Halo 4", game_select);
add_media("Halo 5: Guardians", game_select);
add_media("Halo Infinite", game_select, 'selected');
add_media("Halo: The Master Chief Collection", game_select);
add_media("Halo Wars", game_select);
add_media("Halo Wars 2", game_select);
add_media("Halo: Spartan Assault", game_select);
add_media("Halo: Spartan Strike", game_select);
add_media("Halo: Fireteam Raven", game_select);
add_media("Halo Online", game_select);
add_media("Other Halo game", game_select);
specific_game_span = document.createElement("span");
game_span.appendChild(specific_game_span);
specific_game_text = document.createElement("input");
specific_game_text.size = "32";
specific_game_text.onchange = update_fields;
specific_game_span.appendChild(document.createTextNode(" Please enter the game title exactly: "));
specific_game_span.appendChild(specific_game_text);
game_tr = add_field("Game:", game_span, table);
}
function create_subgame_list(table) {
subgame_select = document.createElement("select");
subgame_select.name = "subgame";
subgame_select.onchange = update_fields;
add_media("Halo: Combat Evolved", subgame_select);
add_media("Halo: Combat Evolved Anniversary", subgame_select);
add_media("Halo 2", subgame_select);
add_media("Halo 2: Anniversary", subgame_select);
add_media("Halo 3", subgame_select);
add_media("Halo 3: ODST", subgame_select);
add_media("Halo: Reach", subgame_select);
add_media("Halo 4", subgame_select);
add_media("N/A", subgame_select);
subgame_tr = add_field("Sub-game:", subgame_select, table);
}
function create_film_list(table) {
var film_span = document.createElement("span");
film_select = document.createElement("select");
film_select.name = "film";
film_select.onchange = handle_film_choice;
film_span.appendChild(film_select);
add_media("Halo Legends", film_select);
add_media("Halo 4: Forward Unto Dawn", film_select);
add_media("Halo: Nightfall", film_select);
add_media("Halo: The Fall of Reach - The Animated Series", film_select);
add_media("Halo: The Television Series", film_select, 'selected');
add_media("Other Halo film/series", film_select);
specific_film_span = document.createElement("span");
film_span.appendChild(specific_film_span);
specific_film_text = document.createElement("input");
specific_film_text.size = "16";
specific_film_text.onchange = update_fields;
specific_film_span.appendChild(document.createTextNode(" Please enter the film/series title exactly: "));
specific_film_span.appendChild(specific_film_text);
film_tr = add_field("Film/series:", film_span, table);
}
function create_comic_list(table) {
var comic_span = document.createElement("span");
comic_select = document.createElement("select");
comic_select.name = "comic";
comic_select.onchange = handle_comic_choice;
comic_span.appendChild(comic_select);
add_media("Halo: Uprising", comic_select);
add_media("Halo: Helljumper", comic_select);
add_media("Halo: Blood Line", comic_select);
add_media("Halo: Fall of Reach", comic_select);
add_media("Halo: Initiation", comic_select);
add_media("Halo: Escalation", comic_select);
add_media("Halo: Rise of Atriox", comic_select);
add_media("Halo: Collateral Damage", comic_select);
add_media("Halo: Lone Wolf", comic_select);
add_media("Halo Graphic Novel", comic_select, 'selected');
add_media("Halo: Tales from Slipspace", comic_select);
add_media("Other Halo comic/graphic novel", comic_select);
specific_comic_span = document.createElement("span");
comic_span.appendChild(specific_comic_span);
specific_comic_text = document.createElement("input");
specific_comic_text.size = "19";
specific_comic_text.onchange = update_fields;
specific_comic_span.appendChild(document.createTextNode(" Please enter the comic series/graphic novel title exactly: "));
specific_comic_span.appendChild(specific_comic_text);
comic_tr = add_field("Series/title:", comic_span, table);
}
function create_screenshot_list(table) {
screenshot_select = document.createElement("select");
screenshot_select.name = "screenshot";
screenshot_select.onchange = update_fields;
add_option("character", "Character or AI", screenshot_select);
add_option("multiplayer", "Multiplayer content", screenshot_select);
add_option("weapon", "Weapon", screenshot_select);
add_option("vehicle", "Vehicle", screenshot_select);
add_option("menu", "Menu", screenshot_select);
add_option("other", "Other", screenshot_select);
screenshot_tr = add_field("Subject:", screenshot_select, table);
}
function create_icon_list(table) {
icon_select = document.createElement("select");
icon_select.name = "icon";
icon_select.onchange = update_fields;
add_option("achievement", "Achievement", icon_select);
add_option("medal", "Multiplayer medal", icon_select);
add_option("rank", "Rank insignia", icon_select);
add_option("skull", "Skull icon", icon_select);
add_option("menuicon", "Menu icon", icon_select);
add_option("other", "Other", icon_select);
icon_tr = add_field("Icon type:", icon_select, table);
}
function create_artwork_list(table) {
artwork_select = document.createElement("select");
artwork_select.name = "artwork";
artwork_select.onchange = update_fields;
add_option("concept", "Concept art", artwork_select);
add_option("cover", "Cover art", artwork_select);
add_option("character", "Character", artwork_select);
add_option("storyboard", "Storyboard", artwork_select);
add_option("wallpaper", "Wallpaper", artwork_select);
add_option("other", "Other", artwork_select);
artwork_tr = add_field("Art type:", artwork_select, table);
}
function create_artist_list(table) {
var artist_span = document.createElement("span");
artist_select = document.createElement("select");
artist_select.name = "known";
artist_select.onchange = handle_artist_choice;
artist_span.appendChild(artist_select);
add_option("unknown", "Unknown", artist_select);
add_option("known", "Known artist", artist_select);
add_option("self", "I created it", artist_select);
specific_artist_span = document.createElement("span");
artist_span.appendChild(specific_artist_span);
specific_artist_text = document.createElement("input");
specific_artist_text.size = "58";
specific_artist_text.onchange = create_final_result;
specific_artist_span.appendChild(document.createTextNode(" Please enter the artist's name: "));
specific_artist_span.appendChild(specific_artist_text);
artist_tr = add_field("Artist:", artist_span, table);
}
function create_source_list(table) {
var source_span = document.createElement("span");
source_select = document.createElement("select");
source_select.name = "source";
source_select.onchange = handle_source_choice;
source_span.appendChild(source_select);
add_option("self", "I created the file myself", source_select);
add_option("web", "From a website", source_select);
add_option("direct", "Direct rip from media files", source_select);
add_option("unknown", "Unknown", source_select);
add_option("other", "N/A", source_select);
specific_source_span = document.createElement("span");
source_span.appendChild(specific_source_span);
specific_source_text = document.createElement("input");
specific_source_text.size = "51";
specific_source_text.onchange = create_final_result;
specific_source_span.appendChild(document.createTextNode(" Please link to the page: "));
specific_source_span.appendChild(specific_source_text);
source_tr = add_field("Source:", source_span, table);
}
function create_license_list(table) {
license_select = document.createElement("select");
license_select.name = "license";
license_select.onchange = create_final_result;
add_option("fairuse", "Fair use (most common)", license_select);
add_option("permission", "Used with permission", license_select);
add_option("freeuse", "Copyrighted free use", license_select);
add_option("pd", "Public domain", license_select);
add_option("gfdl", "GNU FDL", license_select);
add_option("cc-by-sa-3.0", "CC-BY-SA 3.0", license_select);
add_option("unknown", "I don't know", license_select);
license_tr = add_field("License:", license_select, table);
}
function handle_type_choice() {
handle_mediatype_choice();
handle_media_choice();
handle_game_choice();
handle_film_choice();
handle_comic_choice();
handle_artist_choice();
handle_source_choice();
update_fields();
}
function handle_mediatype_choice() {
var cur_mediatype = get_option(mediatype_select);
update_fields();
}
function handle_media_choice() {
var cur_media = get_option(media_select);
if (cur_media == "book") {
specific_media_span.style.display = "inline";
} else {
specific_media_span.style.display = "none";
}
update_fields();
}
function handle_game_choice() {
var cur_game = get_option(game_select);
if (cur_game == "Other Halo game") {
specific_game_span.style.display = "inline";
} else {
specific_game_span.style.display = "none";
}
update_fields();
}
function handle_film_choice() {
var cur_film = get_option(film_select);
if (cur_film == "Other Halo film/series") {
specific_film_span.style.display = "inline";
} else {
specific_film_span.style.display = "none";
}
update_fields();
}
function handle_comic_choice() {
var cur_comic = get_option(comic_select);
if (cur_comic == "Other Halo comic/graphic novel") {
specific_comic_span.style.display = "inline";
} else {
specific_comic_span.style.display = "none";
}
update_fields();
}
function handle_artist_choice() {
var cur_artist = get_option(artist_select);
if (cur_artist == "known") {
specific_artist_span.style.display = "inline";
} else {
specific_artist_span.style.display = "none";
}
update_fields();
}
function handle_source_choice() {
var cur_source = get_option(source_select);
if (cur_source == "web") {
specific_source_span.style.display = "inline";
} else {
specific_source_span.style.display = "none";
}
update_fields();
}
$("#wpUploadFile").change(function() {
ogFileName = $("#wpUploadFile").val().split('\\').pop();
$('select[name="source"]').change();
});
$("#wpUploadFileURL").change(function() {
ogFileName = $("#wpUploadFileURL").val().split('/').pop();
$('select[name="source"]').val('web').change();
});
function getAcronym(input) {
return input.split(' ').map(function(item){return item[0]}).join('').toUpperCase();
}
function getGameAbbr(cur_game) {
switch (cur_game) {
case "Other Halo game":
if (specific_game_text.value != "")
return getAcronym(specific_game_text.value);
return "Game";
case "Halo 3: ODST":
return "H3ODST";
case "Halo Infinite":
return "HINF";
}
return getAcronym(cur_game);
}
function getFilmAbbr(cur_film) {
switch (cur_film) {
case "Other Halo film/series":
if (specific_film_text.value != "")
return getAcronym(specific_film_text.value);
return "Film";
}
return getAcronym(cur_film);
}
function getComicAbbr(cur_comic) {
switch (cur_comic) {
case "Other Halo comic/graphic novel":
if (specific_comic_text.value != "")
return getAcronym(specific_comic_text.value);
return "Comic";
}
return getAcronym(cur_comic);
}
function capitalizeFirstLetter(input) {
var firstChar = input.substring(0,1);
firstChar = firstChar.toUpperCase();
var tail = input.substring(1);
input = firstChar + tail;
return input;
}
function update_fields() {
var cur_type = get_option(type_select);
var cur_mediatype = get_option(mediatype_select);
var cur_media = get_option(media_select);
var cur_game = get_option(game_select);
var cur_subgame = get_option(subgame_select);
var cur_film = get_option(film_select);
var cur_comic = get_option(comic_select);
var cur_screenshot = get_option(screenshot_select);
var cur_icon = get_option(icon_select);
var cur_artwork = get_option(artwork_select);
var cur_artist = get_option(artist_select);
var cur_source = get_option(source_select);
has_media = false;
has_game = false;
has_nonhalo = false;
has_subgame = false;
has_film = false;
has_comic = false;
has_book = false;
has_screenshot = false;
has_icon = false;
has_artwork = false;
has_artist = false;
has_source = true;
has_filename = false;
has_caption = false;
has_license = true;
if (cur_mediatype == "halo") {
has_media = true;
if (cur_media == "game") {
has_game = true;
}
if (cur_media == "game" && cur_game == "Halo: The Master Chief Collection") {
has_subgame = true;
}
if (cur_media == "film") {
has_film = true;
}
if (cur_media == "comic") {
has_comic = true;
}
if (cur_media == "book") {
has_book = true;
}
if ((cur_media == "game" || cur_media == "film") && cur_type == "screenshot") {
has_screenshot = true;
}
if (cur_media == "game" && cur_type == "icon") {
has_icon = true;
}
} else if (cur_mediatype == "nonhalo") {
has_nonhalo = true;
}
if (cur_type == "artwork") {
has_artwork = true;
}
if (
cur_type == "artwork" || cur_type == "icon" ||
cur_type == "render" || cur_type == "logo" ||
cur_type == "asset" || cur_type == "page" ||
cur_type == "designdoc" || cur_type == "document" ||
cur_type == "audio" || cur_type == "wiki"
) {
has_artist = true;
}
if (has_artist && cur_artist == "self") {
has_source = false;
}
if (has_source && (cur_source == "web" || cur_source == "direct")) {
has_filename = true;
}
if (has_source && cur_source == "web") {
has_caption = true;
}
if (mw.config.get('wgMFMode'))
var show = "block";
else
var show = "table-row";
media_tr.style.display =
has_media ? show : "none";
nonhalo_tr.style.display =
has_nonhalo ? show : "none";
game_tr.style.display =
has_game ? show : "none";
subgame_tr.style.display =
has_subgame ? show : "none";
film_tr.style.display =
has_film ? show : "none";
comic_tr.style.display =
has_comic ? show : "none";
screenshot_tr.style.display =
has_screenshot ? show : "none";
icon_tr.style.display =
has_icon ? show : "none";
artwork_tr.style.display =
has_artwork ? show : "none";
artist_tr.style.display =
has_artist ? show : "none";
source_tr.style.display =
has_source ? show : "none";
filename_tr.style.display =
has_filename ? show : "none";
caption_tr.style.display =
has_caption ? show : "none";
license_tr.style.display =
has_license ? show : "none";
if (ogFileName != "") {
var cur_type = get_option(type_select);
var cur_icon = get_option(icon_select);
var cur_artwork = get_option(artwork_select);
if (has_icon && cur_icon != "other") {
cur_type = cur_icon;
} else if (has_artwork && cur_artwork != "other") {
cur_type = cur_artwork;
} else if (has_screenshot && cur_screenshot != "other") {
cur_type = cur_screenshot;
}
cur_type = capitalizeFirstLetter(cur_type);
if (has_game) {
abbr = getGameAbbr(cur_game);
if (has_subgame && cur_subgame != "N/A")
abbr = abbr + " " + getGameAbbr(cur_subgame);
} else if (has_film)
abbr = getFilmAbbr(cur_film);
else if (has_comic)
abbr = getComicAbbr(cur_comic);
else if (has_book && specific_media_text.value != "")
abbr = getAcronym(specific_media_text.value);
else
abbr = capitalizeFirstLetter(cur_media);
filename_input.value = ogFileName;
// $("#wpDestFile").val(abbr + " " + cur_type + " " + capitalizeFirstLetter(ogFileName));
}
create_final_result();
}
function create_final_result() {
var t = "";
var cur_mediatype = get_option(mediatype_select);
var cur_media = get_option(media_select);
var cur_type = get_option(type_select);
var cur_game = get_option(game_select);
var cur_subgame = get_option(subgame_select);
var cur_film = get_option(film_select);
var cur_comic = get_option(comic_select);
var cur_screenshot = get_option(screenshot_select);
var cur_icon = get_option(icon_select);
var cur_artwork = get_option(artwork_select);
var cur_artist = get_option(artist_select);
var cur_source = get_option(source_select);
var cur_license = get_option(license_select);
t += "{{file info\n";
if (summary_input.value != "")
t += "|summary = " + summary_input.value + "\n";
if (has_media) {
if (cur_media == "book") {
if (specific_media_text.value != "")
t += "|book = " + specific_media_text.value + "\n";
} else if (cur_media != "game" && cur_media != "film" && cur_media != "comic" && cur_media != "other") {
t += "|media = " + cur_media + "\n";
}
} else if (cur_mediatype == "nonhalo") {
t += "|media = " + cur_mediatype + "\n";
if (nonhalo_input.value != "")
t += "|title = " + nonhalo_input.value + "\n";
}
if (has_game) {
if (cur_game == "Other Halo game") {
if (specific_game_text.value != "")
t += "|game = " + specific_game_text.value + "\n";
} else
t += "|game = " + cur_game + "\n";
}
if (has_subgame && cur_subgame != "N/A") {
t += "|subgame = " + cur_subgame + "\n";
}
if (has_film) {
if (cur_film == "Other Halo film/series") {
if (specific_film_text.value != "")
t += "|film = " + specific_film_text.value + "\n";
} else
t += "|film = " + cur_film + "\n";
}
if (has_comic) {
if (cur_comic == "Other Halo comic/graphic novel") {
if (specific_comic_text.value != "")
t += "|comic = " + specific_comic_text.value + "\n";
} else
t += "|comic = " + cur_comic + "\n";
}
if (has_icon && cur_icon != "other") {
t += "|type = " + cur_icon + "\n";
} else if (has_artwork && cur_artwork != "other") {
t += "|type = " + cur_artwork + "\n";
} else {
t += "|type = " + cur_type + "\n";
}
if (has_screenshot && cur_screenshot != "other") {
t += "|subject = " + cur_screenshot + "\n";
}
if (has_artist) {
if (cur_artist == "known") {
if (specific_artist_text.value != "")
t += "|artist = " + specific_artist_text.value + "\n";
} else if (cur_artist != "unknown")
t += "|artist = " + cur_artist + "\n";
}
if (has_source && cur_source != "other") {
if (cur_source == "web") {
if (specific_source_text.value != "")
t += "|source = " + specific_source_text.value + "\n";
} else
t += "|source = " + cur_source + "\n";
}
if (has_filename && filename_input.value != "")
t += "|filename = " + filename_input.value + "\n";
if (has_caption && caption_input.value != "")
t += "|caption = " + caption_input.value + "\n";
if (has_license && cur_license != "fairuse") {
t += "|license = " + cur_license + "\n";
}
t += "}}\n\n"
if (t.substr(t.length - 2) == "\n\n") {
t = t.slice(0, t.length - 1);
}
final_textarea.value = t;
}
function hide_license(table) {
document.getElementById("wpLicense").parentNode.parentNode.style.display = "none";
}
function setup_final(table) {
var final_toggler_div = document.createElement("div");
final_toggler_div.id = "toggler";
final_toggler_a = document.createElement("a");
final_toggler_a.href = "#";
final_toggler_a.innerHTML = "Show"
final_toggler_a.onclick = function(e) { e.preventDefault(); toggle_final(); };
final_toggler_div.appendChild(document.createTextNode("["));
final_toggler_div.appendChild(final_toggler_a);
final_toggler_div.appendChild(document.createTextNode("] summary result"));
add_field("", final_toggler_div, table);
final_tr = document.getElementById("wpUploadDescription").parentNode.parentNode;
final_textarea = final_tr.getElementsByTagName("textarea")[0];
final_tr.style.display = "none";
final_tr.parentNode.appendChild(final_tr); //Move to last row.
}
function toggle_final() {
if (final_tr.style.display == "none") {
if (mw.config.get('wgMFMode'))
var show = "block";
else
var show = "table-row";
final_tr.style.display = show;
final_toggler_a.innerHTML = "Hide";
} else {
final_tr.style.display = "none";
final_toggler_a.innerHTML = "Show";
}
}
function clear_el(el) {
while(el.firstChild){
el.removeChild(el.firstChild);
}
}
function get_option(sel) {
if (sel.options.length == 0) return null;
return sel.options[sel.selectedIndex].value;
}
function add_option(value, innerHTML, parent, selected) {
var opt = document.createElement("option");
opt.value = value;
opt.innerHTML = innerHTML;
parent.appendChild(opt);
if (typeof(selected) != "undefined") {
opt.setAttribute("selected", "");
}
return opt;
}
function add_media(value, parent, selected) {
var opt = document.createElement("option");
opt.value = value;
opt.innerHTML = value;
parent.appendChild(opt);
if (typeof(selected) != "undefined") {
opt.setAttribute("selected", "");
}
return opt;
}
function add_optgroup(label, parent) {
var optgroup = document.createElement("optgroup");
optgroup.label = label;
parent.appendChild(optgroup);
return optgroup;
}
function add_field(label, content, table) {
if (mw.config.get('wgMFMode')) {
var tr = document.createElement("div");
tr.className = "mw-htmlform-field-HTMLTextField";
var td1 = document.createElement("div");
td1.className = "mw-label";
td1.innerHTML = label;
tr.appendChild(td1);
var td2 = document.createElement("div");
td2.className = "mw-input";
td2.appendChild(content);
tr.appendChild(td2);
} else {
var tr = document.createElement("tr");
var td1 = document.createElement("td");
td1.className = "mw-label";
td1.innerHTML = label;
tr.appendChild(td1);
var td2 = document.createElement("td");
td2.className = "mw-input";
td2.appendChild(content);
tr.appendChild(td2);
}
if (label == "")
table.appendChild(tr);
else {
table.insertBefore(tr, table.childNodes[insert]);
insert++;
}
return tr;
}
main();
// </nowiki>