From abf4bd70a3dcd325befd207909a6339f826f9848 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 24 Aug 2016 12:16:09 +0200 Subject: [PATCH] Add loading path switcher --- test/dev-setup.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/dev-setup.js b/test/dev-setup.js index dddc2cf7..d8d6ccd5 100644 --- a/test/dev-setup.js +++ b/test/dev-setup.js @@ -39,6 +39,35 @@ Component.prototype.generateLoaderConfig = function(dest) { dest[this.modulePrefix] = this.getResolvedPath(); }; + Component.prototype.generateUrlForPath = function(pathName) { + var NEW_LOADER_OPTS = {}; + Object.keys(LOADER_OPTS).forEach(function(key) { + NEW_LOADER_OPTS[key] = (LOADER_OPTS[key] === 'npm' ? undefined : LOADER_OPTS[key]); + }); + NEW_LOADER_OPTS[this.name] = (pathName === 'npm' ? undefined : pathName); + + var search = Object.keys(NEW_LOADER_OPTS).map(function(key) { + var value = NEW_LOADER_OPTS[key]; + if (value) { + return key + '=' + value; + } + return ''; + }).filter(function(assignment) { return !!assignment; }).join('&'); + if (search.length > 0) { + search = '?' + search; + } + var result = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + window.location.pathname + search + window.location.hash; + // console.log(result); + return result; + }; + Component.prototype.renderLoadingOptions = function() { + return '' + this.name + ':   ' + Object.keys(this.paths).map(function(pathName) { + if (pathName === this.selectedPath) { + return '' + pathName + ''; + } + return '' + pathName + ''; + }.bind(this)).join('   '); + }; var RESOLVED_CORE = new Component('editor', 'vs', METADATA.CORE.paths); @@ -59,6 +88,22 @@ } + (function() { + var allComponents = [RESOLVED_CORE].concat(RESOLVED_PLUGINS); + + var div = document.createElement('div'); + div.style.position = 'fixed'; + div.style.top = 0; + div.style.right = 0; + div.style.background = 'lightgray'; + div.style.padding = '5px 20px 5px 5px'; + + div.innerHTML = ''; + + document.body.appendChild(div); + })(); + + self.loadEditor = function(callback, PATH_PREFIX) { PATH_PREFIX = PATH_PREFIX || '';