ElEditors, Interface administrators, Administrators
70,888
edits
mNo edit summary |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
$(function() { | $(function() { | ||
//variables that are preserved between function calls | //variables that are preserved between function calls | ||
var wpTextbox0; | var wpTextbox0; | ||
Line 556: | Line 542: | ||
window.syntaxHighlighterSiteConfig = window.syntaxHighlighterSiteConfig || {}; | window.syntaxHighlighterSiteConfig = window.syntaxHighlighterSiteConfig || {}; | ||
window.syntaxHighlighterConfig = window.syntaxHighlighterConfig || {}; | window.syntaxHighlighterConfig = window.syntaxHighlighterConfig || {}; | ||
var tone6 = getComputedStyle(document.body).getPropertyValue('--theme-tone-6'); | |||
//use 3-digit colors instead of 6-digit colors for performance | //use 3-digit colors instead of 6-digit colors for performance | ||
configureColor("backgroundColor", "#FFF", false); //white | if ($('body').hasClass('dark-mode')) { | ||
configureColor("backgroundColor", tone6, false); //white | |||
configureColor("foregroundColor", "#FFF", false); //black | |||
configureColor("boldOrItalicColor", "#444", true); //gray | |||
configureColor("commentColor", "#4d745d", true); //green | |||
configureColor("entityColor", "#556c55", true); //green | |||
configureColor("externalLinkColor", "#485959", true); //cyan | |||
configureColor("headingColor", "#444", true); //gray | |||
configureColor("hrColor", "#444", true); //gray | |||
configureColor("listOrIndentColor", "#4d745d", true); //green | |||
configureColor("parameterColor", "#6e5e36", true); //orange | |||
configureColor("signatureColor", "#6e5e36", true); //orange | |||
configureColor("tagColor", "#4f364f", true); //pink | |||
configureColor("tableColor", "#3f3f31", true); //yellow | |||
configureColor("templateColor", "#3f3f31", true); //yellow | |||
configureColor("wikilinkColor", "#5d5d6c", true); //blue | |||
} else { | |||
configureColor("backgroundColor", "#FFF", false); //white | |||
configureColor("foregroundColor", "#000", false); //black | |||
configureColor("boldOrItalicColor", "#EEE", true); //gray | |||
configureColor("commentColor", "#EFE", true); //green | |||
configureColor("entityColor", "#DFD", true); //green | |||
configureColor("externalLinkColor", "#EFF", true); //cyan | |||
configureColor("headingColor", "#EEE", true); //gray | |||
configureColor("hrColor", "#EEE", true); //gray | |||
configureColor("listOrIndentColor", "#EFE", true); //green | |||
configureColor("parameterColor", "#FC6", true); //orange | |||
configureColor("signatureColor", "#FC6", true); //orange | |||
configureColor("tagColor", "#FEF", true); //pink | |||
configureColor("tableColor", "#FFC", true); //yellow | |||
configureColor("templateColor", "#FFC", true); //yellow | |||
configureColor("wikilinkColor", "#EEF", true); //blue | |||
} | |||
//tag lists are ordered from most common to least common | //tag lists are ordered from most common to least common | ||
Line 605: | Line 612: | ||
wpTextbox0.style.fontFamily = wpTextbox1Style.fontFamily; | wpTextbox0.style.fontFamily = wpTextbox1Style.fontFamily; | ||
wpTextbox0.style.fontSize = wpTextbox1Style.fontSize; | wpTextbox0.style.fontSize = wpTextbox1Style.fontSize; | ||
wpTextbox0.style.lineHeight = " | wpTextbox0.style.lineHeight = "normal"; | ||
wpTextbox0.style.marginBottom = "0"; | wpTextbox0.style.marginBottom = "0"; | ||
wpTextbox0.style.marginLeft = "0"; | wpTextbox0.style.marginLeft = "0"; | ||
Line 623: | Line 630: | ||
wpTextbox1.style.color = syntaxHighlighterConfig.foregroundColor; | wpTextbox1.style.color = syntaxHighlighterConfig.foregroundColor; | ||
wpTextbox1.style.fontSize = wpTextbox1Style.fontSize; //resolves alignment problems on mobile chrome | wpTextbox1.style.fontSize = wpTextbox1Style.fontSize; //resolves alignment problems on mobile chrome | ||
wpTextbox1.style.lineHeight = " | wpTextbox1.style.lineHeight = "normal"; | ||
wpTextbox1.style.marginBottom = wpTextbox1Style.marginBottom; //lock to pixel value because the top margin was also locked to a pixel value when it was moved to wpTextbox0 | wpTextbox1.style.marginBottom = wpTextbox1Style.marginBottom; //lock to pixel value because the top margin was also locked to a pixel value when it was moved to wpTextbox0 | ||
wpTextbox1.style.marginLeft = "0"; | wpTextbox1.style.marginLeft = "0"; | ||
Line 652: | Line 659: | ||
highlightSyntaxIfNeededIntervalID = setInterval(highlightSyntaxIfNeeded, 500); | highlightSyntaxIfNeededIntervalID = setInterval(highlightSyntaxIfNeeded, 500); | ||
highlightSyntax(); | highlightSyntax(); | ||
} | |||
//enable the highlighter only when editing wikitext pages | |||
//in the future a separate parser could be added for CSS and JS pages | |||
//blacklist Internet Explorer and Edge, they're just too broken | |||
var wgAction = mw.config.get("wgAction"); | |||
var layoutEngine = $.client.profile().layout; | |||
if ((wgAction == "edit" || wgAction == "submit") && mw.config.get("wgPageContentModel") == "wikitext" && layoutEngine != "trident" && layoutEngine != "edge") | |||
{ | |||
setup(); | |||
} | |||
else | |||
{ | |||
return; | |||
} | } | ||
}); | }); |