start minimal reorganistaion, add shortcut/favicon

pull/3/merge
Michael Aschauer 2015-02-16 20:35:02 +01:00
rodzic df90429d44
commit 6dc9ed26ad
6 zmienionych plików z 686 dodań i 395 usunięć

Wyświetl plik

@ -2,7 +2,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>turtleStitch (based on Snap!) - Devlopment</title>
<title>TurtleStitch </title>
<link rel="shortcut icon" href="stitchcode/favicon.gif" type="image/gif">
<script type="text/javascript" src="morphic.js"></script>
<script type="text/javascript" src="widgets.js"></script>
<script type="text/javascript" src="blocks.js"></script>
@ -21,7 +23,9 @@
<script type="text/javascript" src="stitchcode/backend/js/jquery.js"></script>
<script type="text/javascript" src="stitchcode/backend/js/jquery.fileDownload.js"></script>
<script type="text/javascript" src="stitchcode/FileSaver.js"></script>
<script type="text/javascript" src="stitchcode/stitchcodeChangeSetDel.js"></script>
<script type="text/javascript" src="stitchcode/stitchcodeGUI.js"></script>
<script type="text/javascript" src="stitchcode/stitchcodeChangeSet.js"></script>
<script type="text/javascript">

Wyświetl plik

@ -0,0 +1,244 @@
/* FileSaver.js
* A saveAs() FileSaver implementation.
* 2015-01-04
*
* By Eli Grey, http://eligrey.com
* License: X11/MIT
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*/
/*global self */
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs = saveAs
// IE 10+ (native saveAs)
|| (typeof navigator !== "undefined" &&
navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
// Everyone else
|| (function(view) {
"use strict";
// IE <10 is explicitly unsupported
if (typeof navigator !== "undefined" &&
/MSIE [1-9]\./.test(navigator.userAgent)) {
return;
}
var
doc = view.document
// only get URL when necessary in case Blob.js hasn't overridden it yet
, get_URL = function() {
return view.URL || view.webkitURL || view;
}
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = "download" in save_link
, click = function(node) {
var event = doc.createEvent("MouseEvents");
event.initMouseEvent(
"click", true, false, view, 0, 0, 0, 0, 0
, false, false, false, false, 0, null
);
node.dispatchEvent(event);
}
, webkit_req_fs = view.webkitRequestFileSystem
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
, throw_outside = function(ex) {
(view.setImmediate || view.setTimeout)(function() {
throw ex;
}, 0);
}
, force_saveable_type = "application/octet-stream"
, fs_min_size = 0
// See https://code.google.com/p/chromium/issues/detail?id=375297#c7 and
// https://github.com/eligrey/FileSaver.js/commit/485930a#commitcomment-8768047
// for the reasoning behind the timeout and revocation flow
, arbitrary_revoke_timeout = 500 // in ms
, revoke = function(file) {
var revoker = function() {
if (typeof file === "string") { // file is an object URL
get_URL().revokeObjectURL(file);
} else { // file is a File
file.remove();
}
};
if (view.chrome) {
revoker();
} else {
setTimeout(revoker, arbitrary_revoke_timeout);
}
}
, dispatch = function(filesaver, event_types, event) {
event_types = [].concat(event_types);
var i = event_types.length;
while (i--) {
var listener = filesaver["on" + event_types[i]];
if (typeof listener === "function") {
try {
listener.call(filesaver, event || filesaver);
} catch (ex) {
throw_outside(ex);
}
}
}
}
, FileSaver = function(blob, name) {
// First try a.download, then web filesystem, then object URLs
var
filesaver = this
, type = blob.type
, blob_changed = false
, object_url
, target_view
, dispatch_all = function() {
dispatch(filesaver, "writestart progress write writeend".split(" "));
}
// on any filesys errors revert to saving with object URLs
, fs_error = function() {
// don't create more object URLs than needed
if (blob_changed || !object_url) {
object_url = get_URL().createObjectURL(blob);
}
if (target_view) {
target_view.location.href = object_url;
} else {
var new_tab = view.open(object_url, "_blank");
if (new_tab == undefined && typeof safari !== "undefined") {
//Apple do not allow window.open, see http://bit.ly/1kZffRI
view.location.href = object_url
}
}
filesaver.readyState = filesaver.DONE;
dispatch_all();
revoke(object_url);
}
, abortable = function(func) {
return function() {
if (filesaver.readyState !== filesaver.DONE) {
return func.apply(this, arguments);
}
};
}
, create_if_not_found = {create: true, exclusive: false}
, slice
;
filesaver.readyState = filesaver.INIT;
if (!name) {
name = "download";
}
if (can_use_save_link) {
object_url = get_URL().createObjectURL(blob);
save_link.href = object_url;
save_link.download = name;
click(save_link);
filesaver.readyState = filesaver.DONE;
dispatch_all();
revoke(object_url);
return;
}
// Object and web filesystem URLs have a problem saving in Google Chrome when
// viewed in a tab, so I force save with application/octet-stream
// http://code.google.com/p/chromium/issues/detail?id=91158
// Update: Google errantly closed 91158, I submitted it again:
// https://code.google.com/p/chromium/issues/detail?id=389642
if (view.chrome && type && type !== force_saveable_type) {
slice = blob.slice || blob.webkitSlice;
blob = slice.call(blob, 0, blob.size, force_saveable_type);
blob_changed = true;
}
// Since I can't be sure that the guessed media type will trigger a download
// in WebKit, I append .download to the filename.
// https://bugs.webkit.org/show_bug.cgi?id=65440
if (webkit_req_fs && name !== "download") {
name += ".download";
}
if (type === force_saveable_type || webkit_req_fs) {
target_view = view;
}
if (!req_fs) {
fs_error();
return;
}
fs_min_size += blob.size;
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
var save = function() {
dir.getFile(name, create_if_not_found, abortable(function(file) {
file.createWriter(abortable(function(writer) {
writer.onwriteend = function(event) {
target_view.location.href = file.toURL();
filesaver.readyState = filesaver.DONE;
dispatch(filesaver, "writeend", event);
revoke(file);
};
writer.onerror = function() {
var error = writer.error;
if (error.code !== error.ABORT_ERR) {
fs_error();
}
};
"writestart progress write abort".split(" ").forEach(function(event) {
writer["on" + event] = filesaver["on" + event];
});
writer.write(blob);
filesaver.abort = function() {
writer.abort();
filesaver.readyState = filesaver.DONE;
};
filesaver.readyState = filesaver.WRITING;
}), fs_error);
}), fs_error);
};
dir.getFile(name, {create: false}, abortable(function(file) {
// delete file if it already exists
file.remove();
save();
}), abortable(function(ex) {
if (ex.code === ex.NOT_FOUND_ERR) {
save();
} else {
fs_error();
}
}));
}), fs_error);
}), fs_error);
}
, FS_proto = FileSaver.prototype
, saveAs = function(blob, name) {
return new FileSaver(blob, name);
}
;
FS_proto.abort = function() {
var filesaver = this;
filesaver.readyState = filesaver.DONE;
dispatch(filesaver, "abort");
};
FS_proto.readyState = FS_proto.INIT = 0;
FS_proto.WRITING = 1;
FS_proto.DONE = 2;
FS_proto.error =
FS_proto.onwritestart =
FS_proto.onprogress =
FS_proto.onwrite =
FS_proto.onabort =
FS_proto.onerror =
FS_proto.onwriteend =
null;
return saveAs;
}(
typeof self !== "undefined" && self
|| typeof window !== "undefined" && window
|| this.content
));
// `self` is undefined in Firefox for Android content script context
// while `this` is nsIContentFrameMessageManager
// with an attribute `content` that corresponds to the window
if (typeof module !== "undefined" && module.exports) {
module.exports.saveAs = saveAs;
} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
define([], function() {
return saveAs;
});
}

File diff suppressed because one or more lines are too long

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.2 KiB

Wyświetl plik

@ -2,22 +2,10 @@
// Stitchode's main changes and addtions to snap! go in here
// sorry it lacks proper documentation
// Force flat design
//IDE_Morph.prototype.setDefaultDesign = IDE_Morph.prototype.setFlatDesign;
// change logo
IDE_Morph.prototype.originalCreateLogo = IDE_Morph.prototype.createLogo;
IDE_Morph.prototype.createLogo = function () {
this.originalCreateLogo();
if (MorphicPreferences.isFlat) {
this.logo.texture = 'stitchcode/stitchcode_logo_small.png';
} else {
this.logo.texture = 'stitchcode/stitchcode_logo_small_black.png';
}
this.logo.drawNew();
}
var tStitch = {};
function debug_msg(st,clear) {
tStitch.debug_msg = function (st,clear) {
o = new String();
if (!clear) {
o = document.getElementById("bug").innerHTML;
@ -28,7 +16,12 @@ function debug_msg(st,clear) {
document.getElementById("bug").innerHTML = o;
}
var tStitch = {};
tStitch.getBaseURL = function () {
var url = location.href; // entire url including querystring - also: window.location.href;
var baseURL = url.substring(0, url.lastIndexOf('/'));
return baseURL + "/";
}
tStitch.debug = true;
tStitch.stitches = {};
tStitch.stitches.x = new Array();
@ -46,25 +39,20 @@ tStitch.addPoint = function (x,y,jump) {
s = s + "(" + x + "," + y;
if (jump) s = s + ",jump";
s+= ")";
debug_msg(s);
tStitch.debug_msg(s);
}
tStitch.stitches.x.push(x);
tStitch.stitches.y.push(y);
tStitch.stitches.jump.push(jump);
}
function getBaseURL() {
var url = location.href; // entire url including querystring - also: window.location.href;
var baseURL = url.substring(0, url.lastIndexOf('/'));
return baseURL + "/";
}
var baseUrl=getBaseURL()
tStitch.upload = function() {
debug_msg("uploading points... sending SAVE with num points= " + tStitch.stitches.x.length, true);
params = { "x[]": tStitch.stitches.x, "y[]":tStitch.stitches.y, "j[]":tStitch.stitches.jump };
//log("sending SAVE with num points= " + tStitch.stitches.x.length);
$.fileDownload(baseUrl+"stitchcode/backend/save.py", {
$.fileDownload(tStitch.getBaseUrl() +"stitchcode/backend/save.py", {
successCallback: function (html, url) {
alert("DSD");
},
@ -82,6 +70,9 @@ tStitch.upload = function() {
}
/* Sprite */
// modified SpriteMorph turtle functions
SpriteMorph.prototype.forward = function (steps) {
@ -108,7 +99,6 @@ SpriteMorph.prototype.forward = function (steps) {
};
SpriteMorph.prototype.gotoXY = function (x, y, justMe) {
var stage = this.parentThatIsA(StageMorph),
newX,
@ -133,7 +123,6 @@ SpriteMorph.prototype.gotoXY = function (x, y, justMe) {
tStitch.addPoint(tx,ty,tjump);
};
SpriteMorph.prototype.clear = function () {
this.parent.clearPenTrails();
tStitch.clearPoints();
@ -143,377 +132,37 @@ SpriteMorph.prototype.clear = function () {
};
// add buttons
/*
// Definition of new block categories
SpriteMorph.prototype.categories =
[
'motion',
'control',
'shapes',
'colors',
'sensing',
'operators',
'variables',
'lists',
'my blocks'
];
IDE_Morph.prototype.createControlBar = function () {
// assumes the logo has already been created
var padding = 5,
button,
stopButton,
pauseButton,
startButton,
projectButton,
settingsButton,
stageSizeButton,
appModeButton,
cloudButton,
upstitchButton,
x,
colors = [
this.groupColor,
this.frameColor.darker(50),
this.frameColor.darker(50)
],
myself = this;
if (this.controlBar) {
this.controlBar.destroy();
}
this.controlBar = new Morph();
this.controlBar.color = this.frameColor;
this.controlBar.setHeight(this.logo.height()); // height is fixed
this.controlBar.mouseClickLeft = function () {
this.world().fillPage();
};
this.add(this.controlBar);
//smallStageButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'toggleStageSize',
[
new SymbolMorph('smallStage', 14),
new SymbolMorph('normalStage', 14)
],
function () { // query
return myself.isSmallStage;
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stage size\nsmall & normal';
button.fixLayout();
button.refresh();
stageSizeButton = button;
this.controlBar.add(stageSizeButton);
this.controlBar.stageSizeButton = button; // for refreshing
//appModeButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'toggleAppMode',
[
new SymbolMorph('fullScreen', 14),
new SymbolMorph('normalScreen', 14)
],
function () { // query
return myself.isAppMode;
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'app & edit\nmodes';
button.fixLayout();
button.refresh();
appModeButton = button;
this.controlBar.add(appModeButton);
this.controlBar.appModeButton = appModeButton; // for refreshing
// upload StitchButton
button = new PushButtonMorph(
this,
'uploadStitches',
new SymbolMorph('arrowUp', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stop\nevery-\nthing';
button.fixLayout();
upstitchButton = button;
this.controlBar.add(upstitchButton);
// stopButton
button = new PushButtonMorph(
this,
'stopAllScripts',
new SymbolMorph('octagon', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(200, 0, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stop\nevery-\nthing';
button.fixLayout();
stopButton = button;
this.controlBar.add(stopButton);
//pauseButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'togglePauseResume',
[
new SymbolMorph('pause', 12),
new SymbolMorph('pointRight', 14)
],
function () { // query
return myself.isPaused();
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(255, 220, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'pause/resume\nall scripts';
button.fixLayout();
button.refresh();
pauseButton = button;
this.controlBar.add(pauseButton);
this.controlBar.pauseButton = pauseButton; // for refreshing
// startButton
button = new PushButtonMorph(
this,
'pressStart',
new SymbolMorph('flag', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(0, 200, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'start green\nflag scripts';
button.fixLayout();
startButton = button;
this.controlBar.add(startButton);
this.controlBar.startButton = startButton;
// projectButton
button = new PushButtonMorph(
this,
'projectMenu',
new SymbolMorph('file', 14)
//'\u270E'
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'open, save, & annotate project';
button.fixLayout();
projectButton = button;
this.controlBar.add(projectButton);
this.controlBar.projectButton = projectButton; // for menu positioning
// settingsButton
button = new PushButtonMorph(
this,
'settingsMenu',
new SymbolMorph('gears', 14)
//'\u2699'
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'edit settings';
button.fixLayout();
settingsButton = button;
this.controlBar.add(settingsButton);
this.controlBar.settingsButton = settingsButton; // for menu positioning
// cloudButton
button = new PushButtonMorph(
this,
'cloudMenu',
new SymbolMorph('cloud', 11)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'cloud operations';
button.fixLayout();
cloudButton = button;
this.controlBar.add(cloudButton);
this.controlBar.cloudButton = cloudButton; // for menu positioning
this.controlBar.fixLayout = function () {
x = this.right() - padding;
[stopButton, pauseButton, startButton].forEach(
function (button) {
button.setCenter(myself.controlBar.center());
button.setRight(x);
x -= button.width();
x -= padding;
}
);
x = Math.min(
startButton.left() - (3 * padding + 2 * stageSizeButton.width()),
myself.right() - StageMorph.prototype.dimensions.x *
(myself.isSmallStage ? myself.stageRatio : 1)
);
[stageSizeButton, appModeButton].forEach(
function (button) {
x += padding;
button.setCenter(myself.controlBar.center());
button.setLeft(x);
x += button.width();
}
);
upstitchButton.setCenter(myself.controlBar.center());
upstitchButton.setRight(stageSizeButton.left() - padding);
settingsButton.setCenter(myself.controlBar.center());
settingsButton.setLeft(this.left());
cloudButton.setCenter(myself.controlBar.center());
cloudButton.setRight(settingsButton.left() - padding);
projectButton.setCenter(myself.controlBar.center());
projectButton.setRight(cloudButton.left() - padding);
this.updateLabel();
};
this.controlBar.updateLabel = function () {
var suffix = myself.world().isDevMode ?
' - ' + localize('development mode') : '';
if (this.label) {
this.label.destroy();
}
if (myself.isAppMode) {
return;
}
this.label = new StringMorph(
(myself.projectName || localize('untitled')) + suffix,
14,
'sans-serif',
true,
false,
false,
MorphicPreferences.isFlat ? null : new Point(2, 1),
myself.frameColor.darker(myself.buttonContrast)
);
this.label.color = myself.buttonLabelColor;
this.label.drawNew();
this.add(this.label);
this.label.setCenter(this.center());
this.label.setLeft(this.settingsButton.right() + padding);
};
SpriteMorph.prototype.blockColor = {
motion : new Color(74, 108, 212),
shapes : new Color(143, 86, 227),
colors : new Color(207, 74, 217),
sound : new Color(207, 74, 217), // we need to keep this color for the zoom blocks dialog
control : new Color(230, 168, 34),
sensing : new Color(4, 148, 220),
operators : new Color(98, 194, 19),
variables : new Color(243, 118, 29),
lists : new Color(217, 77, 17),
other : new Color(150, 150, 150),
'my blocks': new Color(150, 150, 60),
};
// now move also "make a block to 'my blocks'
IDE_Morph.prototype.uploadStitches = function () {
tStitch.upload();
};
*/
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
var dir,
projects = [];
//dir = this.ide.getURL('http://snap.berkeley.edu/snapsource/Examples/');
dir = this.ide.getURL(getBaseURL() + '/stitchcode/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.sort(function (x, y) {
return x.name < y.name ? -1 : 1;
});
return projects;
};

Wyświetl plik

@ -0,0 +1,393 @@
// Force flat design
IDE_Morph.prototype.setDefaultDesign = IDE_Morph.prototype.setFlatDesign;
// change logo
IDE_Morph.prototype.originalCreateLogo = IDE_Morph.prototype.createLogo;
IDE_Morph.prototype.createLogo = function () {
this.originalCreateLogo();
if (MorphicPreferences.isFlat) {
this.logo.texture = 'stitchcode/stitchcode_logo_small.png';
} else {
this.logo.texture = 'stitchcode/stitchcode_logo_small_black.png';
}
this.logo.drawNew();
}
// add buttons
IDE_Morph.prototype.createControlBar = function () {
// assumes the logo has already been created
var padding = 5,
button,
stopButton,
pauseButton,
startButton,
projectButton,
settingsButton,
stageSizeButton,
appModeButton,
cloudButton,
upstitchButton,
x,
colors = [
this.groupColor,
this.frameColor.darker(50),
this.frameColor.darker(50)
],
myself = this;
if (this.controlBar) {
this.controlBar.destroy();
}
this.controlBar = new Morph();
this.controlBar.color = this.frameColor;
this.controlBar.setHeight(this.logo.height()); // height is fixed
this.controlBar.mouseClickLeft = function () {
this.world().fillPage();
};
this.add(this.controlBar);
//smallStageButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'toggleStageSize',
[
new SymbolMorph('smallStage', 14),
new SymbolMorph('normalStage', 14)
],
function () { // query
return myself.isSmallStage;
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stage size\nsmall & normal';
button.fixLayout();
button.refresh();
stageSizeButton = button;
this.controlBar.add(stageSizeButton);
this.controlBar.stageSizeButton = button; // for refreshing
//appModeButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'toggleAppMode',
[
new SymbolMorph('fullScreen', 14),
new SymbolMorph('normalScreen', 14)
],
function () { // query
return myself.isAppMode;
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'app & edit\nmodes';
button.fixLayout();
button.refresh();
appModeButton = button;
this.controlBar.add(appModeButton);
this.controlBar.appModeButton = appModeButton; // for refreshing
// upload StitchButton
button = new PushButtonMorph(
this,
'uploadStitches',
new SymbolMorph('arrowUp', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stop\nevery-\nthing';
button.fixLayout();
upstitchButton = button;
this.controlBar.add(upstitchButton);
// stopButton
button = new PushButtonMorph(
this,
'stopAllScripts',
new SymbolMorph('octagon', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(200, 0, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'stop\nevery-\nthing';
button.fixLayout();
stopButton = button;
this.controlBar.add(stopButton);
//pauseButton
button = new ToggleButtonMorph(
null, //colors,
myself, // the IDE is the target
'togglePauseResume',
[
new SymbolMorph('pause', 12),
new SymbolMorph('pointRight', 14)
],
function () { // query
return myself.isPaused();
}
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(255, 220, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'pause/resume\nall scripts';
button.fixLayout();
button.refresh();
pauseButton = button;
this.controlBar.add(pauseButton);
this.controlBar.pauseButton = pauseButton; // for refreshing
// startButton
button = new PushButtonMorph(
this,
'pressStart',
new SymbolMorph('flag', 14)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = new Color(0, 200, 0);
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'start green\nflag scripts';
button.fixLayout();
startButton = button;
this.controlBar.add(startButton);
this.controlBar.startButton = startButton;
// projectButton
button = new PushButtonMorph(
this,
'projectMenu',
new SymbolMorph('file', 14)
//'\u270E'
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'open, save, & annotate project';
button.fixLayout();
projectButton = button;
this.controlBar.add(projectButton);
this.controlBar.projectButton = projectButton; // for menu positioning
// settingsButton
button = new PushButtonMorph(
this,
'settingsMenu',
new SymbolMorph('gears', 14)
//'\u2699'
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'edit settings';
button.fixLayout();
settingsButton = button;
this.controlBar.add(settingsButton);
this.controlBar.settingsButton = settingsButton; // for menu positioning
// cloudButton
button = new PushButtonMorph(
this,
'cloudMenu',
new SymbolMorph('cloud', 11)
);
button.corner = 12;
button.color = colors[0];
button.highlightColor = colors[1];
button.pressColor = colors[2];
button.labelMinExtent = new Point(36, 18);
button.padding = 0;
button.labelShadowOffset = new Point(-1, -1);
button.labelShadowColor = colors[1];
button.labelColor = this.buttonLabelColor;
button.contrast = this.buttonContrast;
button.drawNew();
// button.hint = 'cloud operations';
button.fixLayout();
cloudButton = button;
this.controlBar.add(cloudButton);
this.controlBar.cloudButton = cloudButton; // for menu positioning
this.controlBar.fixLayout = function () {
x = this.right() - padding;
[stopButton, pauseButton, startButton].forEach(
function (button) {
button.setCenter(myself.controlBar.center());
button.setRight(x);
x -= button.width();
x -= padding;
}
);
x = Math.min(
startButton.left() - (3 * padding + 2 * stageSizeButton.width()),
myself.right() - StageMorph.prototype.dimensions.x *
(myself.isSmallStage ? myself.stageRatio : 1)
);
[stageSizeButton, appModeButton].forEach(
function (button) {
x += padding;
button.setCenter(myself.controlBar.center());
button.setLeft(x);
x += button.width();
}
);
upstitchButton.setCenter(myself.controlBar.center());
upstitchButton.setRight(stageSizeButton.left() - padding);
settingsButton.setCenter(myself.controlBar.center());
settingsButton.setLeft(this.left());
cloudButton.setCenter(myself.controlBar.center());
cloudButton.setRight(settingsButton.left() - padding);
projectButton.setCenter(myself.controlBar.center());
projectButton.setRight(cloudButton.left() - padding);
this.updateLabel();
};
this.controlBar.updateLabel = function () {
var suffix = myself.world().isDevMode ?
' - ' + localize('development mode') : '';
if (this.label) {
this.label.destroy();
}
if (myself.isAppMode) {
return;
}
this.label = new StringMorph(
(myself.projectName || localize('untitled')) + suffix,
14,
'sans-serif',
true,
false,
false,
MorphicPreferences.isFlat ? null : new Point(2, 1),
myself.frameColor.darker(myself.buttonContrast)
);
this.label.color = myself.buttonLabelColor;
this.label.drawNew();
this.add(this.label);
this.label.setCenter(this.center());
this.label.setLeft(this.settingsButton.right() + padding);
};
};
IDE_Morph.prototype.uploadStitches = function () {
tStitch.upload();
};
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
var dir,
projects = [];
//dir = this.ide.getURL('http://snap.berkeley.edu/snapsource/Examples/');
dir = this.ide.getURL(getBaseURL() + '/stitchcode/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.sort(function (x, y) {
return x.name < y.name ? -1 : 1;
});
return projects;
};