preload.js 1.6 KB
Newer Older
M
Matt Bierner 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

(function() {
	function getConfig() {
		const queryParams = window.location.search.substring(1).split('&');
		for (var i = 0; i < queryParams.length; i++) {
			var kv = queryParams[i].split('=');
			if (kv[0] === 'config' && kv[1]) {
				return JSON.parse(decodeURIComponent(kv[1]));
			}
		}
		return {};
	}
	try {
		const config = getConfig();
		const document = window.document;

		// sets the base theme class ('vs', 'vs-dark', 'hc-black')
		const baseTheme = config.baseTheme || 'vs';
		document.body.className = 'monaco-shell ' + baseTheme;

		// adds a stylesheet with the backgrdound color
R
Ryan Adolf 已提交
27 28 29 30
		// var backgroundColor = config.backgroundColor;
		// if (!backgroundColor) {
		// 	backgroundColor = baseTheme === 'hc-black' ? '#000000' : (baseTheme === 'vs' ? '#FFFFFF' : '#1E1E1E');
		// }
R
Ryan Adolf 已提交
31
		var backgroundColor = 'rgba(100, 0, 0, 0)';
M
Matt Bierner 已提交
32 33
		const foregroundColor = baseTheme === 'hc-black' ? '#FFFFFF' : (baseTheme === 'vs' ? '#6C6C6C' : '#CCCCCC');
		const style = document.createElement('style');
R
Ryan Adolf 已提交
34
		style.innerHTML = '.monaco-shell { background-color:' + backgroundColor + '; color:' + foregroundColor + '; } .monaco-workbench { background-color: transparent !important; }';
M
Matt Bierner 已提交
35 36 37 38 39
		document.head.appendChild(style);

	} catch (error) {
		console.error(error);
	}
R
Ryan Adolf 已提交
40
})();