From 36e0dae11dd96c1f5278f316fc7d3e5f238335b2 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 02:16:52 -0700 Subject: [PATCH 1/9] Start Refactoring of Resource Loading; Fix Typo in LIBRARIES This fixes a small typo in the LIBRARIES file, so that the leap motion lib will load correctly. This renames the getCostumesList() method to getMediaList() because its used for Costumes, Backgrounds, Sounds, and soon libraries. --- gui.js | 19 +++++++++++++++---- libraries/LIBRARIES | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gui.js b/gui.js index bc800696..d2fc9cb2 100644 --- a/gui.js +++ b/gui.js @@ -2601,7 +2601,7 @@ IDE_Morph.prototype.projectMenu = function () { localize(graphicsName) + '...', function () { var dir = graphicsName, - names = myself.getCostumesList(dir), + names = myself.getMediaList(dir), libMenu = new MenuMorph( myself, localize('Import') + ' ' + localize(dir) @@ -2633,7 +2633,7 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem( localize('Sounds') + '...', function () { - var names = this.getCostumesList('Sounds'), + var names = this.getMediaList('Sounds'), libMenu = new MenuMorph(this, 'Import sound'); function loadSound(name) { @@ -2660,7 +2660,7 @@ IDE_Morph.prototype.projectMenu = function () { menu.popup(world, pos); }; -IDE_Morph.prototype.getCostumesList = function (dirname) { +IDE_Morph.prototype.getMediaList = function (dirname) { var dir, costumes = []; @@ -2685,6 +2685,17 @@ IDE_Morph.prototype.getCostumesList = function (dirname) { return costumes; }; +// A Resource File lists all the files that could be loaded in a submenu +// Examples are libraries/LIBRARIES, Costumes/COSTUMES, etc +// A File is very simple: +// A "//" starts a comment line, that is ignored. +// All lines have 3 fields: file-name, Display Name, Help Text +// These fields are delimited by tabs. +IDE_Morph.prototype.parseResourceFile = function (text) { + +} + + // IDE_Morph menu actions IDE_Morph.prototype.aboutSnap = function () { @@ -4454,7 +4465,7 @@ IDE_Morph.prototype.setCloudURL = function () { ); }; -// IDE_Morph synchronous Http data fetching +// IDE_Morph synchronous HTTP data fetching IDE_Morph.prototype.getURL = function (url) { var request = new XMLHttpRequest(), diff --git a/libraries/LIBRARIES b/libraries/LIBRARIES index 8905553b..0656f724 100644 --- a/libraries/LIBRARIES +++ b/libraries/LIBRARIES @@ -4,4 +4,5 @@ stream-tools Streams (lazy lists) variadic-reporters Variadic reporters word-sentence Words, sentences cases Multi-branched conditional (switch) -leap-library LEAP Motion controller +leap-library LEAP Motion controller +TEST-TEST TEST-1234-45678 \ No newline at end of file From 2b69b91a4a22f4a66c2094ecda71341bd4c54462 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 02:21:35 -0700 Subject: [PATCH 2/9] Delete the getURLsSbeOrRelative(url) function This function was only used for tools.xml, and didnt even do its job... As of this writing, it simply prepended the `baseURL` variable, which is determined by the Snap! server, not s.b.e. If we want to have s.b.e as a permanent fallback source we should re-implement this in a way that is used for all Snap! media. --- gui.js | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/gui.js b/gui.js index d2fc9cb2..97ffbde2 100644 --- a/gui.js +++ b/gui.js @@ -2559,9 +2559,7 @@ IDE_Morph.prototype.projectMenu = function () { 'Import tools', function () { myself.droppedText( - myself.getURLsbeOrRelative( - 'tools.xml' - ), + myself.getURL('tools.xml'), 'tools' ); }, @@ -4483,22 +4481,6 @@ IDE_Morph.prototype.getURL = function (url) { } }; -IDE_Morph.prototype.getURLsbeOrRelative = function (url) { - var request = new XMLHttpRequest(), - myself = this; - try { - request.open('GET', baseURL + url, false); - request.send(); - if (request.status === 200) { - return request.responseText; - } - return myself.getURL(url); - } catch (err) { - myself.showMessage(err); - return; - } -}; - // IDE_Morph user dialog shortcuts IDE_Morph.prototype.showMessage = function (message, secs) { From b2c6b4319249676ce6fd13fabbc24edd8e373260 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 03:27:55 -0700 Subject: [PATCH 3/9] Cleanup LIBRARIES; Load Libraries using refactored code --- gui.js | 62 +++++++++++++++++++++++++++++++++------------ libraries/LIBRARIES | 15 +++++------ 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/gui.js b/gui.js index 97ffbde2..0951cc65 100644 --- a/gui.js +++ b/gui.js @@ -2569,25 +2569,24 @@ IDE_Morph.prototype.projectMenu = function () { 'Libraries...', function () { // read a list of libraries from an external file, - var libMenu = new MenuMorph(this, 'Import library'), - libUrl = baseURL + 'libraries/' + 'LIBRARIES'; + // TODO: Make menu name consistent, fix URL + var libs, + libMenu = new MenuMorph(this, 'Import library'), + libUrl = 'libraries/' + 'LIBRARIES'; - function loadLib(name) { - var url = baseURL + 'libraries/' + name + '.xml'; + function loadLib(file, name) { + // TODO: Consistent URL + var url = 'libraries/' + file; myself.droppedText(myself.getURL(url), name); } - myself.getURL(libUrl).split('\n').forEach(function (line) { - if (line.length > 0) { - libMenu.addItem( - line.substring(line.indexOf('\t') + 1), - function () { - loadLib( - line.substring(0, line.indexOf('\t')) - ); - } - ); - } + libs = myself.getURL(libUrl); + myself.parseResourceFile(libs).forEach(function (lib) { + libMenu.addItem( + lib.name, + function () { loadLib(lib.file, lib.name) }, + lib.help + ); }); libMenu.popup(world, pos); @@ -2606,6 +2605,7 @@ IDE_Morph.prototype.projectMenu = function () { ); function loadCostume(name) { + // TODO: Make this URL consistent var url = dir + '/' + name, img = new Image(); img.onload = function () { @@ -2632,9 +2632,11 @@ IDE_Morph.prototype.projectMenu = function () { localize('Sounds') + '...', function () { var names = this.getMediaList('Sounds'), + // TODO: Fix this menu name libMenu = new MenuMorph(this, 'Import sound'); function loadSound(name) { + // TODO: Refactor This URL var url = 'Sounds/' + name, audio = new Audio(); audio.src = url; @@ -2659,9 +2661,11 @@ IDE_Morph.prototype.projectMenu = function () { }; IDE_Morph.prototype.getMediaList = function (dirname) { + // TODO: Fix Variable Names var dir, costumes = []; + // TODO: have this load the /UPPERCASE name dir = this.getURL(dirname); dir.split('\n').forEach( function (line) { @@ -2690,8 +2694,34 @@ IDE_Morph.prototype.getMediaList = function (dirname) { // All lines have 3 fields: file-name, Display Name, Help Text // These fields are delimited by tabs. IDE_Morph.prototype.parseResourceFile = function (text) { + var parts, + items = [], + comment = '#', + delimter = '\t'; -} + text = text.split(/\n|\r\n/); + + text.map(function (line) { + return line.trim(); + }).filter(function (line) { + return line.length > 0 && line[0] !== comment; + }).forEach(function (line) { + parts = line.split(delimter); + parts = parts.map(function (str) { return str.trim() }); + + if (parts.length < 2) { + return; + } + + items.push({ + file: parts[0], + name: parts[1], + help: parts.length > 2 ? parts[2] : '' + }); + }); + + return items; +}; // IDE_Morph menu actions diff --git a/libraries/LIBRARIES b/libraries/LIBRARIES index 0656f724..441b0994 100644 --- a/libraries/LIBRARIES +++ b/libraries/LIBRARIES @@ -1,8 +1,7 @@ -iteration-composition Iteration, composition -list-utilities List utilities -stream-tools Streams (lazy lists) -variadic-reporters Variadic reporters -word-sentence Words, sentences -cases Multi-branched conditional (switch) -leap-library LEAP Motion controller -TEST-TEST TEST-1234-45678 \ No newline at end of file +iteration-composition.xml Iteration, composition +list-utilities.xml List utilities +stream-tools.xml Streams (lazy lists) +variadic-reporters.xml Variadic reporters +word-sentence.xml Words, sentences +cases.xml Multi-branched conditional (switch) +leap-library.xml LEAP Motion controller From 7b0fc4a17fa600578d9caea5dacd4c2c8f7e70d4 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 03:41:36 -0700 Subject: [PATCH 4/9] Add data lists for media! The display names are now much more readable, and will be translatable if wanted! --- Backgrounds/BACKGROUNDS | 12 ++++++++++++ Costumes/COSTUMES | 32 ++++++++++++++++++++++++++++++++ Examples/EXAMPLES | 10 ++++++++++ Sounds/SOUNDS | 12 ++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 Backgrounds/BACKGROUNDS create mode 100644 Costumes/COSTUMES create mode 100644 Examples/EXAMPLES create mode 100644 Sounds/SOUNDS diff --git a/Backgrounds/BACKGROUNDS b/Backgrounds/BACKGROUNDS new file mode 100644 index 00000000..9492cffc --- /dev/null +++ b/Backgrounds/BACKGROUNDS @@ -0,0 +1,12 @@ +atom-playground.jpg Atom Playground +bedroom1.gif Bedroom 1 +bedroom2.gif Bedroom 2 +berkeley-mural.jpg Berkeley Mural +brick-wall-and-stairs.jpg Brick Wall and Stairs +brick-wall1.jpg Brick Wall 1 +brick-wall2.jpg Brick Wall 2 +desert.gif Desert +night-city-with-street.gif Night City with Street +party-room.jpg Party Room +pathway.jpg Pathway +xy-grid.gif XY Grid diff --git a/Costumes/COSTUMES b/Costumes/COSTUMES new file mode 100644 index 00000000..1c303d77 --- /dev/null +++ b/Costumes/COSTUMES @@ -0,0 +1,32 @@ +alonzo.png Alonzo +bat1-a.png Bat 1a +bat1-b.png Bat 1b +bat2-a.png Bat 2a +bat2-b.png Bat 2b +boy1-standing.gif Boy 1 Standing +boy1-walking.gif Boy 1 Walking +boy2.gif Boy 2 +boy3.gif Boy 3 +cat2.gif Cat 2 +cat3.png Cat 3 +cat4.png Cat 4 +cat5.gif Cat 5 +dog1-a.png Dog 1a +dog1-b.png Dog 1b +dog2-a.png Dog 2a +dog2-b.png Dog 2b +dog2-c.png Dog 2c +dragon1-a.png Dragon 1a +dragon1-b.png Dragon 1b +dragon2.gif Dragon 2 +girl1-standing.gif Girl 1 Standing +girl1-walking.gif Girl 1 Walking +girl2-shouting.gif Girl 2 Shouting +girl2-standing.gif Girl 2 Standing +girl3-basketball.gif Girl 3 Basketball +girl3-running.gif Girl 3 Running +girl3-standing.gif Girl 3 Standing +marissa-crouching.gif Marissa Crouching +marissa-sitting.gif Marissa Sitting +marissa.gif Marissa +unicorn1.png Unicorn diff --git a/Examples/EXAMPLES b/Examples/EXAMPLES new file mode 100644 index 00000000..70b1ec53 --- /dev/null +++ b/Examples/EXAMPLES @@ -0,0 +1,10 @@ +animal-game.xml Animal Game +Codification.xml Codification +copter.xml Copter +count-change.xml Count Change +icecream-visual.xml Icecream Visual +JSfunctions.xml JSfunctions +live-tree.xml Live Tree +swimmer.xml Swimmer +tree.xml Tree +vee.xml Vee diff --git a/Sounds/SOUNDS b/Sounds/SOUNDS new file mode 100644 index 00000000..e5f538f5 --- /dev/null +++ b/Sounds/SOUNDS @@ -0,0 +1,12 @@ +Cat.mp3 Cat +Chord.wav Chord +Dog1.wav Dog 1 +Dog2.wav Dog 2 +FingerSnap.wav Finger Snap +Kitten.wav Kitten +Laugh-female.wav Laugh Female +Laugh-male1.wav Laugh Male 1 +Laugh-male2.wav Laugh Male 2 +Laugh-male3.mp3 Laugh Male 3 +Meow.wav Meow +Pop.wav Pop From c6b43bee12e9072f429e54a8d0ae77589f6e5d1e Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 04:23:30 -0700 Subject: [PATCH 5/9] Fix #867; All media has an index file that is being used to load files --- gui.js | 82 ++++++++++++++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/gui.js b/gui.js index 0951cc65..814ba4de 100644 --- a/gui.js +++ b/gui.js @@ -2570,21 +2570,18 @@ IDE_Morph.prototype.projectMenu = function () { function () { // read a list of libraries from an external file, // TODO: Make menu name consistent, fix URL - var libs, - libMenu = new MenuMorph(this, 'Import library'), - libUrl = 'libraries/' + 'LIBRARIES'; + var libMenu = new MenuMorph(this, 'Import library'), + libraries = this.getMediaList('libraries'); function loadLib(file, name) { - // TODO: Consistent URL - var url = 'libraries/' + file; + var url = myself.resourceURL('libraries', file); myself.droppedText(myself.getURL(url), name); } - libs = myself.getURL(libUrl); - myself.parseResourceFile(libs).forEach(function (lib) { + libraries.forEach(function (lib) { libMenu.addItem( lib.name, - function () { loadLib(lib.file, lib.name) }, + function () {loadLib(lib.file, lib.name) }, lib.help ); }); @@ -2605,8 +2602,7 @@ IDE_Morph.prototype.projectMenu = function () { ); function loadCostume(name) { - // TODO: Make this URL consistent - var url = dir + '/' + name, + var url = myself.resourceURL(dir, name), img = new Image(); img.onload = function () { var canvas = newCanvas(new Point(img.width, img.height)); @@ -2616,13 +2612,12 @@ IDE_Morph.prototype.projectMenu = function () { img.src = url; } - names.forEach(function (line) { - if (line.length > 0) { - libMenu.addItem( - line, - function () {loadCostume(line); } - ); - } + names.forEach(function (image) { + libMenu.addItem( + image.name, + function () {loadCostume(image.file); }, + image.help + ); }); libMenu.popup(world, pos); }, @@ -2636,21 +2631,19 @@ IDE_Morph.prototype.projectMenu = function () { libMenu = new MenuMorph(this, 'Import sound'); function loadSound(name) { - // TODO: Refactor This URL - var url = 'Sounds/' + name, + var url = myself.resourceURL('Sounds', name), audio = new Audio(); audio.src = url; audio.load(); myself.droppedAudio(audio, name); } - names.forEach(function (line) { - if (line.length > 0) { - libMenu.addItem( - line, - function () {loadSound(line); } - ); - } + names.forEach(function (sound) { + libMenu.addItem( + sound.name, + function () {loadSound(sound.file); }, + sound.help + ); }); libMenu.popup(world, pos); }, @@ -2660,31 +2653,24 @@ IDE_Morph.prototype.projectMenu = function () { menu.popup(world, pos); }; +// Give a path a file in subfolders. +// Method can be easily overridden if running in a custom location. +IDE_Morph.prototype.resourceURL = function (folder, file) { + return folder + '/' + file; +} + +// Return a list of files in a directory based on the contents file IDE_Morph.prototype.getMediaList = function (dirname) { - // TODO: Fix Variable Names - var dir, - costumes = []; + var url, data; - // TODO: have this load the /UPPERCASE name - dir = this.getURL(dirname); - dir.split('\n').forEach( - function (line) { - var startIdx = line.search(new RegExp('href="[^./?].*"')), - endIdx, - name; + url = this.resourceURL(dirname, dirname.toUpperCase()); + data = this.parseResourceFile(this.getURL(url)); - if (startIdx > 0) { - name = line.substring(startIdx + 6); - endIdx = name.search(new RegExp('"')); - name = name.substring(0, endIdx); - costumes.push(name); - } - } - ); - costumes.sort(function (x, y) { - return x < y ? -1 : 1; + data.sort(function (x, y) { + return x.name.toLowerCase() < y.name.toLowerCase() ? -1 : 1; }); - return costumes; + + return data; }; // A Resource File lists all the files that could be loaded in a submenu @@ -2696,7 +2682,7 @@ IDE_Morph.prototype.getMediaList = function (dirname) { IDE_Morph.prototype.parseResourceFile = function (text) { var parts, items = [], - comment = '#', + comment = '//', delimter = '\t'; text = text.split(/\n|\r\n/); From f9d62c1b7fc268838464c4d69f2145533021a78d Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 04:49:05 -0700 Subject: [PATCH 6/9] Refactor loading Example projects to be consistent. --- gui.js | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/gui.js b/gui.js index 814ba4de..e911bbf0 100644 --- a/gui.js +++ b/gui.js @@ -4918,7 +4918,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { } myself.edit(); }; - } else { // 'examples', 'cloud' is initialized elsewhere + } else { // 'examples'; 'cloud' is initialized elsewhere this.listField.action = function (item) { var src, xml; if (item === undefined) {return; } @@ -4926,7 +4926,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { myself.nameField.setContents(item.name || ''); } src = myself.ide.getURL( - baseURL + 'Examples/' + item.name + '.xml' + myself.ide.resourceURL('Examples', item.file) ); xml = myself.ide.serializer.parse(src); @@ -4978,33 +4978,7 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () { }; ProjectDialogMorph.prototype.getExamplesProjectList = function () { - var dir, - projects = []; - //alert(baseURL); - - dir = this.ide.getURL(baseURL + 'Examples/'); - dir.split('\n').forEach( - function (line) { - var startIdx = line.search(new RegExp('href=".*xml"')), - endIdx, - name, - dta; - if (startIdx > 0) { - endIdx = line.search(new RegExp('.xml')); - name = line.substring(startIdx + 6, endIdx); - dta = { - name: name, - thumb: null, - notes: null - }; - projects.push(dta); - } - } - ); - projects = projects.sort(function (x, y) { - return x.name.toLowerCase() < y.name.toLowerCase() ? -1 : 1; - }); - return projects; + return this.ide.getMediaList('Examples'); }; ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { @@ -5101,7 +5075,8 @@ ProjectDialogMorph.prototype.openProject = function () { if (this.source === 'cloud') { this.openCloudProject(proj); } else if (this.source === 'examples') { - src = this.ide.getURL(baseURL + 'Examples/' + proj.name + '.xml'); + // Note "file" is a property of the parseResourceFile function. + src = this.ide.getURL(this.ide.resourceURL('Examples', proj.file)); this.ide.openProjectString(src); this.destroy(); } else { // 'local' From 5452c2bfa7d53203775fb5073d04dc22b7d600bd Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 23:21:20 -0700 Subject: [PATCH 7/9] DRY out creation of Costumes/Sounds/etc submenus --- gui.js | 88 +++++++++++++++++++++++----------------------------------- 1 file changed, 34 insertions(+), 54 deletions(-) diff --git a/gui.js b/gui.js index e911bbf0..d101f352 100644 --- a/gui.js +++ b/gui.js @@ -2466,6 +2466,27 @@ IDE_Morph.prototype.projectMenu = function () { 'Costumes' : 'Backgrounds', shiftClicked = (world.currentKey === 16); + // Utility for creating Costumes, etc menus. + // loadFunction takes in two parameters: a file URL, and a canonical name + function createMediaMenu (mediaType, loadFunction) { + return function () { + var names = this.getMediaList(mediaType), + mediaMenu = new MenuMorph( + myself, + localize('Import') + ' ' + localize(mediaType) + ); + + names.forEach(function (item) { + mediaMenu.addItem( + item.name, + function () {loadFunction(item.file, item.name); }, + item.help + ); + }); + mediaMenu.popup(world, pos); + } + } + menu = new MenuMorph(this); menu.addItem('Project notes...', 'editProjectNotes'); menu.addLine(); @@ -2567,42 +2588,22 @@ IDE_Morph.prototype.projectMenu = function () { ); menu.addItem( 'Libraries...', - function () { - // read a list of libraries from an external file, - // TODO: Make menu name consistent, fix URL - var libMenu = new MenuMorph(this, 'Import library'), - libraries = this.getMediaList('libraries'); - + createMediaMenu( + 'libraries', function loadLib(file, name) { var url = myself.resourceURL('libraries', file); myself.droppedText(myself.getURL(url), name); } - - libraries.forEach(function (lib) { - libMenu.addItem( - lib.name, - function () {loadLib(lib.file, lib.name) }, - lib.help - ); - }); - - libMenu.popup(world, pos); - }, + ), 'Select categories of additional blocks to add to this project.' ); menu.addItem( localize(graphicsName) + '...', - function () { - var dir = graphicsName, - names = myself.getMediaList(dir), - libMenu = new MenuMorph( - myself, - localize('Import') + ' ' + localize(dir) - ); - - function loadCostume(name) { - var url = myself.resourceURL(dir, name), + createMediaMenu( + graphicsName, + function loadCostume(file, name) { + var url = myself.resourceURL(graphicsName, file), img = new Image(); img.onload = function () { var canvas = newCanvas(new Point(img.width, img.height)); @@ -2611,42 +2612,21 @@ IDE_Morph.prototype.projectMenu = function () { }; img.src = url; } - - names.forEach(function (image) { - libMenu.addItem( - image.name, - function () {loadCostume(image.file); }, - image.help - ); - }); - libMenu.popup(world, pos); - }, + ), 'Select a costume from the media library' ); menu.addItem( localize('Sounds') + '...', - function () { - var names = this.getMediaList('Sounds'), - // TODO: Fix this menu name - libMenu = new MenuMorph(this, 'Import sound'); - - function loadSound(name) { - var url = myself.resourceURL('Sounds', name), + createMediaMenu( + 'Sounds', + function loadSound(file, name) { + var url = myself.resourceURL('Sounds', file), audio = new Audio(); audio.src = url; audio.load(); myself.droppedAudio(audio, name); } - - names.forEach(function (sound) { - libMenu.addItem( - sound.name, - function () {loadSound(sound.file); }, - sound.help - ); - }); - libMenu.popup(world, pos); - }, + ), 'Select a sound from the media library' ); From cce37d817275fe6b4c2ef3c94b5f7ddcae9d46fd Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 7 Oct 2015 23:32:52 -0700 Subject: [PATCH 8/9] Use resourceURL() for items in help/ --- blocks.js | 3 ++- gui.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index f30b8e41..b678ed65 100644 --- a/blocks.js +++ b/blocks.js @@ -2559,6 +2559,7 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) { BlockMorph.prototype.showHelp = function () { var myself = this, + ide = this.parentThatIsA(IDE_Morph), pic = new Image(), help, comment, @@ -2596,7 +2597,7 @@ BlockMorph.prototype.showHelp = function () { block.fullImage() ); } else { - pic.src = 'help/' + spec + '.png'; + pic.src = ide.resourceURL('help', spec + '.png'); } }; diff --git a/gui.js b/gui.js index d101f352..e7e7f48b 100644 --- a/gui.js +++ b/gui.js @@ -2009,6 +2009,7 @@ IDE_Morph.prototype.userMenu = function () { IDE_Morph.prototype.snapMenu = function () { var menu, + myself = this, world = this.world(); menu = new MenuMorph(this); @@ -2017,7 +2018,8 @@ IDE_Morph.prototype.snapMenu = function () { menu.addItem( 'Reference manual', function () { - window.open('help/SnapManual.pdf', 'SnapReferenceManual'); + var url = myself.resourceURL('help', 'SnapManual.pdf'); + window.open(url, 'SnapReferenceManual'); } ); menu.addItem( From b9303422cab3280b1915e6a224ac047b70811d3b Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Tue, 27 Oct 2015 03:10:30 -0700 Subject: [PATCH 9/9] Delete baseURL code b/c it is not needed By making all loads relative to snap.html we eliminated the need for such a function. --- gui.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gui.js b/gui.js index e7e7f48b..e8570122 100644 --- a/gui.js +++ b/gui.js @@ -84,16 +84,6 @@ var SoundIconMorph; var JukeboxMorph; var StageHandleMorph; -// Get the full url without "snap.html" -var baseURL = (function getPath(location) { - var origin, path, slash; - path = location.pathname; // starts with a / - origin = location.origin; // has no trailing / - slash = path.lastIndexOf('/'); - path = path.slice(0, slash + 1); // keep a trailing / - return origin + path; -}(window.location)); - // IDE_Morph ///////////////////////////////////////////////////////////