MediaWiki:UploadScript.js: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
 
(30 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 27: Line 29:


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 51: 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 79: Line 84:
     table = document.getElementById("mw-htmlform-description").firstChild;
     table = document.getElementById("mw-htmlform-description").firstChild;
    
    
   if (document.getElementById("wpUploadDescription") && document.getElementById("wpUploadDescription").value.length > 0) {
   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 89: Line 95:
   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 109: 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 143: 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", "Page scan", type_select);
   add_option("page", "Book/comic page", type_select);
   add_option("document", "Document", type_select);
   add_option("designdoc", "Design documentation", type_select);
   add_option("designdocument", "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 152: 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 165: 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", "Other book", media_select);
   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("nonhalo", "Non-Halo media", media_select);
   add_option("other", "N/A", media_select);
   add_option("other", "N/A", media_select);
    
    
Line 177: Line 205:
    
    
   specific_media_text = document.createElement("input");
   specific_media_text = document.createElement("input");
   specific_media_text.size = "44";
   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 name exactly: "));
  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 202: 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 210: 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 216: Line 245:
    
    
   specific_game_text = document.createElement("input");
   specific_game_text = document.createElement("input");
   specific_game_text.size = "30";
   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 name exactly: "));
   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 253: 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 Television Series", film_select);
   add_media("Halo: The Fall of Reach - The Animated Series", film_select);
   add_media("Halo: The Fall of Reach - The Animated Series", film_select);
   add_media("Halo: The Complete Video Collection", film_select);
   add_media("Halo: The Television Series", film_select, 'selected');
   add_media("Other", film_select);
   add_media("Other Halo film/series", film_select);
    
    
   specific_film_span = document.createElement("span");
   specific_film_span = document.createElement("span");
Line 262: Line 290:
    
    
   specific_film_text = document.createElement("input");
   specific_film_text = document.createElement("input");
   specific_film_text.size = "24";
   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 name exactly: "));
   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 287: 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 293: Line 323:
    
    
   specific_comic_text = document.createElement("input");
   specific_comic_text = document.createElement("input");
   specific_comic_text.size = "20";
   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 name exactly: "));
   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 series:", comic_span, table);
   comic_tr = add_field("Series/title:", comic_span, table);
}
}


Line 306: Line 336:
   screenshot_select.onchange = update_fields;
   screenshot_select.onchange = update_fields;
    
    
   add_option("character", "Character or AI unit", screenshot_select);
   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("multiplayer", "Multiplayer content", 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 323: 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("rank", "Rank image", icon_select);
   add_option("rank", "Rank insignia", icon_select);
   add_option("skull", "Skull image", icon_select);
   add_option("skull", "Skull icon", icon_select);
   add_option("menuicon", "Menu icon", icon_select);
   add_option("menuicon", "Menu icon", icon_select);
   add_option("other", "Other", icon_select);
   add_option("other", "Other", icon_select);
Line 382: 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 387: Line 418:
    
    
   specific_source_text = document.createElement("input");
   specific_source_text = document.createElement("input");
   specific_source_text.size = "52";
   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 412: 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 418: 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 436: 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 448: 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 460: 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 509: 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 523: 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 533: 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 551: 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 562: 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 576: Line 617:
   has_license = true;
   has_license = true;


   if (cur_media == "game") {
   if (cur_mediatype == "halo") {
     has_game = true;
     has_media = true;
  }


  if (cur_media == "game" && cur_game == "Halo: The Master Chief Collection") {
    if (cur_media == "game") {
    has_subgame = true;
      has_game = true;
  }
    }


   if (cur_media == "film") {
    if (cur_media == "game" && cur_game == "Halo: The Master Chief Collection") {
    has_film = true;
      has_subgame = true;
  }
    }
 
    
  if (cur_media == "comic") {
    if (cur_media == "film") {
    has_comic = true;
      has_film = true;
  }
    }
 
    if (cur_media == "comic") {
      has_comic = true;
    }


  if (cur_media == "book") {
    if (cur_media == "book") {
    has_book = true;
      has_book = true;
  }
    }


  if (cur_media == "game" && cur_type == "screenshot") {
    if ((cur_media == "game" || cur_media == "film") && cur_type == "screenshot") {
    has_screenshot = true;
      has_screenshot = true;
  }
    }


  if (cur_media == "game" && cur_type == "icon") {
    if (cur_media == "game" && cur_type == "icon") {
     has_icon = true;
      has_icon = true;
    }
  } else if (cur_mediatype == "nonhalo") {
     has_nonhalo = true;
   }
   }


Line 612: Line 659:
     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 == "designdocument" ||
     cur_type == "designdoc" || cur_type == "document" ||
     cur_type == "audio"
     cur_type == "audio" || cur_type == "wiki"
   ) {
   ) {
     has_artist = true;
     has_artist = true;
Line 622: Line 669:
   }
   }


   if (has_source && cur_source != "self" && cur_source != "unknown") {
   if (has_source && (cur_source == "web" || cur_source == "direct")) {
     has_filename = true;
     has_filename = true;
   }
   }
Line 635: 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 665: 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 696: 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 714: Line 765:
     t += "|summary = " + summary_input.value + "\n";
     t += "|summary = " + summary_input.value + "\n";
    
    
   if (cur_media == "book") {
   if (has_media) {
    if (specific_media_text.value != "")
    if (cur_media == "book") {
      t += "|book = " + specific_media_text.value + "\n";
      if (specific_media_text.value != "")
  } else if (cur_media != "game" && cur_media != "film" && cur_media != "comic" && cur_media != "other") {
        t += "|book = " + specific_media_text.value + "\n";
    t += "|media = " + cur_media + "\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 729: 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 742: Line 799:


   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 749: 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 757: Line 814:
   }
   }


   if (has_screenshot && cur_screenshot != "other" ) {
   if (has_screenshot && cur_screenshot != "other") {
     t += "|subject = " + cur_screenshot + "\n";
     t += "|subject = " + cur_screenshot + "\n";
   }
   }
Line 769: Line 826:
   }
   }


   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 != "")
Line 810: 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 (add categories below template)"));
   final_toggler_div.appendChild(document.createTextNode("] summary result"));
    
    
   add_field("", final_toggler_div, table);
   add_field("", final_toggler_div, table);