User:Andrewds1021/global.js

console.log(test); function test { return $.when.then(function {return 6;}); }

/********************* this comment is 80 characters long *********************/

/* check for Internet Explorer if found: load CSS corrections

if (["MSIE", "Trident/7."].some(function (arg) { return (navigator.userAgent.indexOf(arg) >= 0); })) {   importArticles({        type: "style",        article: "u:w:User:Andrewds1021/IE11.css"    }); }

/* form edit modifications and additions

(function {

/* detect situation and call corresponding function

var fe_link = document.getElementById("ca-formedit"); var ce_link = document.getElementById("ca-edit"); var edit_link = $(".page-header__contribution-buttons .wds-button-group > a")[0]; // main button var link_list = $(".page-header__contribution-buttons ul")[0]; // dropdown list if (fe_link && (fe_link !== edit_link)) { moveFormEdit(getButtonTexts); } else if (ce_link && ce_link.getAttribute("href").match(/flow=create-page-create-button$/) && !document.getElementById("ca-formcreate")) { addCreateWithForm; } else if (document.body.classList.contains("mw-special-FormStart")) { // will not work in older browsers fillPageName; }

/* retrieve classic editor and VisualEditor edit button texts NOTE: in progress

function getButtonTexts { return mw.loader.using("mediawiki.api", function {        new mw.Api.get({ action: "query", meta: "allmessages", ammessages: "visualeditor-ca-classiceditor|visualeditor-ca-ve-edit" }).done(function (data) { return [data.query.allmessages[0]["*"], data.query.allmessages[1]["*"]]; });   }); }

/* check main button for either view source, classic editor, or VisualEditor if found: move main button action to top of dropdown move form edit to main button

function moveFormEdit(button_texts) { var ll_temp = ""; switch (edit_link.id) { case "ca-viewsource": ll_temp = fe_link.innerHTML; fe_link.innerHTML = edit_link.lastElementChild.innerHTML; edit_link.lastElementChild.innerHTML = ll_temp; break; case "ca-edit": fe_link.accessKey = edit_link.accessKey; edit_link.removeAttribute("accesskey"); fe_link.innerHTML = button_texts[0]; break; case "ca-ve-edit": fe_link.accessKey = edit_link.accessKey; edit_link.removeAttribute("accesskey"); fe_link.innerHTML = button_texts[1]; break; default: return; }   ll_temp = fe_link.id; fe_link.id = edit_link.id; edit_link.id = ll_temp; ll_temp = fe_link.getAttribute("data-tracking"); fe_link.setAttribute("data-tracking", edit_link.getAttribute("data-tracking")+"-dropdown"); edit_link.setAttribute("data-tracking", ll_temp.replace("-dropdown", "")); ll_temp = fe_link.getAttribute("href"); fe_link.setAttribute("href", edit_link.getAttribute("href")); edit_link.setAttribute("href", ll_temp); link_list.insertBefore(fe_link.parentElement, link_list.firstElementChild); }

/* check for both source editor and VisualEditor if found: add "Create with form" as 2nd in dropdown else: add "Create with form" to top of dropdown

function addCreateWithForm { var list_item = document.createElement("li"); var list_link = document.createElement("a"); var link_text = document.createTextNode("Create with form"); list_link.id = "ca-formcreate"; list_link.setAttribute("data-tracking", "ca-formcreate-dropdown"); list_link.setAttribute("href", "/wiki/Special:FormStart?tfl_formstart_pagename="       +encodeURIComponent(decodeURIComponent(location.pathname.substr(6)))); list_link.appendChild(link_text); list_item.appendChild(list_link); if (document.getElementById("ca-edit") && document.getElementById("ca-ve-edit")) { link_list.insertBefore(list_item, link_list.children[1]); } else { link_list.insertBefore(list_item, link_list.firstElementChild); } }

/* check for URL query parameter "tfl_formstart_pagename" if found: place value in field for "page_name"

function fillPageName { var params = location.search.substr(1).split(/[&=]/); var param_idx = params.indexOf("tfl_formstart_pagename"); var field = $("form input[name='page_name']")[0]; if (field && (param_idx != -1) && (param_idx < (params.length-1))) { field.value = decodeURIComponent(params[param_idx+1]); } }

});