Renamed “http” block to “url”, use location.protocol (support https)

upd4.1
Jens Mönig 2017-09-05 11:24:57 +02:00
rodzic 01c22843f9
commit 37dbcad27f
3 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -3608,6 +3608,7 @@ Fixes:
170905 170905
------ ------
* German translation update * German translation update
* Threads, Objects: Renamed “http” block to “url”, use location.protocol (support https)
v4.1 Features: v4.1 Features:
@ -3633,6 +3634,7 @@ v4.1 Features:
* two-item lists as x-y coordinate arguments for "point towards”, "go to" and “distance to” primitives * two-item lists as x-y coordinate arguments for "point towards”, "go to" and “distance to” primitives
* Piano keyboard as drop-down menu for entering musical notes, Thanks, Michael! * Piano keyboard as drop-down menu for entering musical notes, Thanks, Michael!
* Basic “instruments” support: sine, square, sawtooth and triangle waves * Basic “instruments” support: sine, square, sawtooth and triangle waves
* Support https in “url” reporter
Fixes: Fixes:
* changed keyboard shortcut indicator for “find blocks” to “^” * changed keyboard shortcut indicator for “find blocks” to “^”

Wyświetl plik

@ -899,7 +899,7 @@ SpriteMorph.prototype.initBlocks = function () {
reportURL: { reportURL: {
type: 'reporter', type: 'reporter',
category: 'sensing', category: 'sensing',
spec: 'http:// %s', spec: 'url %s',
defaults: ['snap.berkeley.edu'] defaults: ['snap.berkeley.edu']
}, },
reportIsFastTracking: { reportIsFastTracking: {

Wyświetl plik

@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
TableFrameMorph, ColorSlotMorph, isSnapObject*/ TableFrameMorph, ColorSlotMorph, isSnapObject*/
modules.threads = '2017-September-01'; modules.threads = '2017-September-05';
var ThreadManager; var ThreadManager;
var Process; var Process;
@ -2265,10 +2265,19 @@ Process.prototype.reportLastAnswer = function () {
// Process URI retrieval (interpolated) // Process URI retrieval (interpolated)
Process.prototype.reportURL = function (url) { Process.prototype.reportURL = function (url) {
var response; var idx, protocol, hostname, response;
if (!this.httpRequest) { if (!this.httpRequest) {
// use the location protocol unless the user specifies otherwise
idx = url.indexOf('://');
if (idx < 0) {
protocol = location.protocol + '//';
hostname = url;
} else {
protocol = url.slice(0, idx) + '://';
hostname = url.slice(idx + 3, url.length);
}
this.httpRequest = new XMLHttpRequest(); this.httpRequest = new XMLHttpRequest();
this.httpRequest.open("GET", 'http://' + url, true); this.httpRequest.open("GET", protocol + hostname, true);
this.httpRequest.send(null); this.httpRequest.send(null);
} else if (this.httpRequest.readyState === 4) { } else if (this.httpRequest.readyState === 4) {
response = this.httpRequest.responseText; response = this.httpRequest.responseText;