diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-03-08 09:54:57 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-03-08 09:54:57 +0100 |
| commit | 526a595c5e00f171eb814f063e58a6c18c5784d4 (patch) | |
| tree | 7043e1fe7a6d2434fc6e2072961948bb2c3e44dd | |
| parent | 1ed98c27ff3c1a825e75783481a4e739fb610bdb (diff) | |
| parent | b6d846444e44d41842e253b7276cd590d7163349 (diff) | |
| download | snap-526a595c5e00f171eb814f063e58a6c18c5784d4.tar.gz snap-526a595c5e00f171eb814f063e58a6c18c5784d4.zip | |
Merge branch 'development' into gh-pages
| -rwxr-xr-x | binary.sh | 50 | ||||
| -rw-r--r-- | blocks.js | 67 | ||||
| -rw-r--r-- | byob.js | 14 | ||||
| -rw-r--r-- | gui.js | 114 | ||||
| -rw-r--r-- | help/receiveInteraction.png (renamed from help/receiveClick.png) | bin | 49453 -> 49453 bytes | |||
| -rwxr-xr-x | history.txt | 40 | ||||
| -rwxr-xr-x | index.html | 1 | ||||
| -rw-r--r-- | lang-de.js | 34 | ||||
| -rw-r--r-- | lang-ml.js | 1282 | ||||
| -rw-r--r-- | lang-ta.js | 1283 | ||||
| -rw-r--r-- | lang-te.js | 1283 | ||||
| -rw-r--r-- | locale.js | 40 | ||||
| -rwxr-xr-x | mobile.sh | 43 | ||||
| -rw-r--r-- | objects.js | 217 | ||||
| -rw-r--r-- | peer.js | 2711 | ||||
| -rw-r--r-- | store.js | 11 | ||||
| -rw-r--r-- | threads.js | 54 |
17 files changed, 7156 insertions, 88 deletions
@@ -17,7 +17,15 @@ then echo " Mobile amazon-fireos android blackberry10 firefoxos ios ubuntu wp8 win8 tizen" echo " Desktop win32 win64 osx linux32 linux64" echo "" - echo "If FILE/URL is given, it will be #open-ed inside Snap\! immediately. URL will be loaded at runtime." + echo "If FILE/URL is given, it will be #open-ed inside Snap! immediately. URL will be loaded at runtime." + echo "" + echo "" + echo "The following environment variables will be used, if available:" + echo " snapsource Path or URL to the Snap! git repository. This repository must contain the branch" + echo " mobileapp with the configuration files! Default: https://github.com/Gubolin/snap.git" + echo " crosswalk Path to a crosswalk-cordova directory. Download \"Cordova Android\" here:" + echo " https://crosswalk-project.org/documentation/downloads.html" + echo " If omitted, standard cordova will be used." exit 0 fi @@ -28,7 +36,6 @@ scriptdir=$(readlink -e ".") # UglifyJS2 (https://github.com/mishoo/UglifyJS2) ide=true -url=false platform=$2 # presentation mode @@ -37,16 +44,6 @@ then ide=false fi -if [ $ide == false ] -then - if [ -f "$3" ] - then - content="'$(cat $3)'" - else - url=true - fi -fi - buildsource=$(mktemp -d) git clone $snapsource $buildsource cd "$buildsource" @@ -57,36 +54,33 @@ rm -rf .git/ if [ $ide == false ] then # minimize everything - rm lang* ypr.js paint.js cloud.js gui.js - rm -r help/ + rm lang* ypr.js paint.js cloud.js gui.js *.sh *.pdf *.txt + rm -r help/ Costumes/ Backgrounds/ Sounds/ sed -i '/paint\.js"/d' snap.html sed -i '/cloud\.js"/d' snap.html sed -i 's/gui\.js"/binary\.js"/' snap.html - # load custom project from file or url - if [ $url == false ] + # if a file was given, move it to "project.xml" + # it will be loaded like an URL then + if [ -f "$3" ] then - sed -i '/sha512\.js"/a\ - <script type="text/javascript" src="code.js"></script> ' snap.html - - echo "var code =" > code.js - echo "$content" >> code.js - echo ";" >> code.js - - sed -i "/ide\.openIn/a\ - ide.droppedText(code); " snap.html + cp "$3" "project.xml" + url="project.xml" else - sed -i "/ide\.openIn/a\ - ide.droppedText(ide.getURL('$3')); " snap.html + url=$3 fi + # load custom project from url + sed -i "/ide\.openIn/a\ + ide.droppedText(ide.getURL('$url')); " snap.html + else rm binary.js fi # compress all js files -find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c +find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c 2> /dev/null # return to the directory where the script was called from cd "$scriptdir" @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2014 by Jens Mönig + Copyright (C) 2015 by Jens Mönig This file is part of Snap!. @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-November-21'; +modules.blocks = '2015-March-06'; var SyntaxElementMorph; @@ -340,6 +340,7 @@ SyntaxElementMorph.prototype.setScale = function (num) { }; SyntaxElementMorph.prototype.setScale(1); +SyntaxElementMorph.prototype.isCachingInputs = true; // SyntaxElementMorph instance creation: @@ -356,6 +357,7 @@ SyntaxElementMorph.prototype.init = function () { SyntaxElementMorph.uber.init.call(this); this.defaults = []; + this.cachedInputs = null; }; // SyntaxElementMorph accessing: @@ -375,10 +377,35 @@ SyntaxElementMorph.prototype.parts = function () { SyntaxElementMorph.prototype.inputs = function () { // answer my arguments and nested reporters - return this.parts().filter(function (part) { - return part instanceof SyntaxElementMorph; - }); + if (isNil(this.cachedInputs) || !this.isCachingInputs) { + this.cachedInputs = this.parts().filter(function (part) { + return part instanceof SyntaxElementMorph; + }); + } + // this.debugCachedInputs(); + return this.cachedInputs; +}; +SyntaxElementMorph.prototype.debugCachedInputs = function () { + // private - only used for manually debugging inputs caching + var realInputs, i; + if (!isNil(this.cachedInputs)) { + realInputs = this.parts().filter(function (part) { + return part instanceof SyntaxElementMorph; + }); + } + if (this.cachedInputs.length !== realInputs.length) { + throw new Error('cached inputs size do not match: ' + + this.constructor.name); + } + for (i = 0; i < realInputs.length; i += 1) { + if (this.cachedInputs[i] !== realInputs[i]) { + throw new Error('cached input does not match ' + + this.constructor.name + + ' ' + + i); + } + } }; SyntaxElementMorph.prototype.allInputs = function () { @@ -494,6 +521,7 @@ SyntaxElementMorph.prototype.replaceInput = function (oldArg, newArg) { replacement.drawNew(); this.fixLayout(); } + this.cachedInputs = null; this.endLayout(); }; @@ -529,6 +557,7 @@ SyntaxElementMorph.prototype.silentReplaceInput = function (oldArg, newArg) { replacement.drawNew(); this.fixLayout(); } + this.cachedInputs = null; }; SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) { @@ -571,6 +600,7 @@ SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) { } else if (deflt instanceof RingMorph) { deflt.fixBlockColor(); } + this.cachedInputs = null; }; SyntaxElementMorph.prototype.isLocked = function () { @@ -848,6 +878,20 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { true // read-only ); break; + case '%interaction': + part = new InputSlotMorph( + null, // text + false, // numeric? + { + 'clicked' : ['clicked'], + 'pressed' : ['pressed'], + 'dropped' : ['dropped'], + 'mouse-entered' : ['mouse-entered'], + 'mouse-departed' : ['mouse-departed'] + }, + true // read-only + ); + break; case '%dates': part = new InputSlotMorph( null, // text @@ -1949,6 +1993,7 @@ BlockMorph.prototype.init = function () { BlockMorph.uber.init.call(this); this.color = new Color(0, 17, 173); + this.cashedInputs = null; }; BlockMorph.prototype.receiver = function () { @@ -2054,6 +2099,7 @@ BlockMorph.prototype.setSpec = function (spec) { }); this.blockSpec = spec; this.fixLayout(); + this.cachedInputs = null; }; BlockMorph.prototype.buildSpec = function () { @@ -2446,6 +2492,7 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) { } i += 1; }); + this.cachedInputs = null; }; BlockMorph.prototype.showHelp = function () { @@ -3041,6 +3088,7 @@ BlockMorph.prototype.fullCopy = function () { //block.comment = null; }); + ans.cachedInputs = null; return ans; }; @@ -4610,6 +4658,7 @@ RingMorph.uber = ReporterBlockMorph.prototype; // RingMorph preferences settings: +RingMorph.prototype.isCachingInputs = false; // RingMorph.prototype.edge = 2; // RingMorph.prototype.rounding = 9; // RingMorph.prototype.alpha = 0.8; @@ -9227,6 +9276,10 @@ MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; +// MultiArgMorph preferences settings + +MultiArgMorph.prototype.isCachingInputs = false; + // MultiArgMorph instance creation: function MultiArgMorph( @@ -9657,6 +9710,10 @@ ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; +// ArgLabelMorph preferences settings + +ArgLabelMorph.prototype.isCachingInputs = false; + // MultiArgMorph instance creation: function ArgLabelMorph(argMorph, labelTxt) { @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-January-21'; +modules.byob = '2015-March-02'; // Declarations @@ -429,6 +429,7 @@ CustomCommandBlockMorph.prototype.refresh = function () { // find unnahmed upvars and label them // to their internal definition (default) + this.cachedInputs = null; this.inputs().forEach(function (inp, idx) { if (inp instanceof TemplateSlotMorph && inp.contents() === '\u2191') { inp.setContents(def.inputNames()[idx]); @@ -443,6 +444,7 @@ CustomCommandBlockMorph.prototype.restoreInputs = function (oldInputs) { myself = this; if (this.isPrototype) {return; } + this.cachedInputs = null; this.inputs().forEach(function (inp) { old = oldInputs[i]; if (old instanceof ReporterBlockMorph && @@ -460,6 +462,7 @@ CustomCommandBlockMorph.prototype.restoreInputs = function (oldInputs) { } i += 1; }); + this.cachedInputs = null; }; CustomCommandBlockMorph.prototype.refreshDefaults = function () { @@ -472,6 +475,7 @@ CustomCommandBlockMorph.prototype.refreshDefaults = function () { } idx += 1; }); + this.cachedInputs = null; }; CustomCommandBlockMorph.prototype.refreshPrototype = function () { @@ -924,6 +928,9 @@ CustomReporterBlockMorph.prototype.refresh = function () { if (!this.isPrototype) { this.isPredicate = (this.definition.type === 'predicate'); } + if (this.parent instanceof SyntaxElementMorph) { + this.parent.cachedInputs = null; + } this.drawNew(); }; @@ -1865,6 +1872,9 @@ BlockEditorMorph.prototype.context = function (prototypeHat) { if (topBlock === null) { return null; } + topBlock.allChildren().forEach(function (c) { + if (c instanceof BlockMorph) {c.cachedInputs = null; } + }); stackFrame = Process.prototype.reify.call( null, topBlock, @@ -2974,7 +2984,7 @@ InputSlotDialogMorph.prototype.editSlotOptions = function () { new DialogBoxMorph( myself, function (options) { - myself.fragment.options = options; + myself.fragment.options = options.trim(); }, myself ).promptCode( @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-January-21'; +modules.gui = '2015-February-28'; // Declarations @@ -201,7 +201,8 @@ IDE_Morph.prototype.init = function (isAutoFill) { MorphicPreferences.globalFontFamily = 'Helvetica, Arial'; // restore saved user preferences - this.userLanguage = null; + this.userLanguage = null; // user language preference for startup + this.projectsInURLs = false; this.applySavedSettings(); // additional properties: @@ -249,6 +250,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.color = this.backgroundColor; setInterval(this.save, 1000 * 60 * 60 * 5); // every 5 minutes + window.peers = []; }; IDE_Morph.prototype.openIn = function (world) { @@ -436,7 +438,7 @@ IDE_Morph.prototype.openIn = function (world) { myself.parentCommitSha = pcSha; myself.lastCommit = code; myself.rawOpenCloudDataString(code); - myself.hasChangedMedia = true; + myself.hasChangedMedia = true; }, function () { myself.shield.destroy(); @@ -445,10 +447,50 @@ IDE_Morph.prototype.openIn = function (world) { myself.toggleAppMode(true); myself.runScripts(); } - ]); + ]); }, this.githubError() ); + } else if (location.hash.substr(0, 7) === '#cloud:') { + this.shield = new Morph(); + this.shield.alpha = 0; + this.shield.setExtent(this.parent.extent()); + this.parent.add(this.shield); + myself.showMessage('Fetching project\nfrom the cloud...'); + + // make sure to lowercase the username + dict = SnapCloud.parseDict(location.hash.substr(7)); + dict.Username = dict.Username.toLowerCase(); + + SnapCloud.getPublicProject( + SnapCloud.encodeDict(dict), + function (projectData) { + var msg; + myself.nextSteps([ + function () { + msg = myself.showMessage('Opening project...'); + }, + function () {nop(); }, // yield (bug in Chrome) + function () { + if (projectData.indexOf('<snapdata') === 0) { + myself.rawOpenCloudDataString(projectData); + } else if ( + projectData.indexOf('<project') === 0 + ) { + myself.rawOpenProjectString(projectData); + } + myself.hasChangedMedia = true; + }, + function () { + myself.shield.destroy(); + myself.shield = null; + msg.destroy(); + myself.toggleAppMode(false); + } + ]); + }, + this.cloudError() + ); } else if (location.hash.substr(0, 6) === '#lang:') { urlLanguage = location.hash.substr(6); this.setLanguage(urlLanguage); @@ -1836,6 +1878,7 @@ IDE_Morph.prototype.applySavedSettings = function () { language = this.getSetting('language'), click = this.getSetting('click'), longform = this.getSetting('longform'), + longurls = this.getSetting('longurls'), plainprototype = this.getSetting('plainprototype'); // design @@ -1869,6 +1912,13 @@ IDE_Morph.prototype.applySavedSettings = function () { InputSlotDialogMorph.prototype.isLaunchingExpanded = true; } + // project data in URLs + if (longurls) { + this.projectsInURLs = true; + } else { + this.projectsInURLs = false; + } + // plain prototype labels if (plainprototype) { BlockLabelPlaceHolderMorph.prototype.plainLabel = true; @@ -2327,6 +2377,17 @@ IDE_Morph.prototype.settingsMenu = function () { 'check to prioritize\nscript execution' ); addPreference( + 'Cache Inputs', + function () { + SyntaxElementMorph.prototype.isCachingInputs = + !SyntaxElementMorph.prototype.isCachingInputs; + }, + SyntaxElementMorph.prototype.isCachingInputs, + 'uncheck to stop caching\ninputs (for debugging the evaluator)', + 'check to cache inputs\nboosts recursion', + true + ); + addPreference( 'Rasterize SVGs', function () { MorphicPreferences.rasterizeSVGs = @@ -2351,6 +2412,21 @@ IDE_Morph.prototype.settingsMenu = function () { false ); addPreference( + 'Project URLs', + function () { + myself.projectsInURLs = !myself.projectsInURLs; + if (myself.projectsInURLs) { + myself.saveSetting('longurls', true); + } else { + myself.removeSetting('longurls'); + } + }, + myself.projectsInURLs, + 'uncheck to disable\nproject data in URLs', + 'check to enable\nproject data in URLs', + true + ); + addPreference( 'Sprite Nesting', function () { SpriteMorph.prototype.enableNesting = @@ -2421,14 +2497,12 @@ IDE_Morph.prototype.projectMenu = function () { if (GitHub.username) { menu.addItem('Save with commit message', 'commitProjectToGitHub'); } - if (shiftClicked) { - menu.addItem( - 'Save to disk', - 'saveProjectToDisk', - 'experimental - store this project\nin your downloads folder', - new Color(100, 0, 0) - ); - } + menu.addItem( + 'Save to disk', + 'saveProjectToDisk', + 'store this project\nin the downloads folder\n' + + '(in supporting browsers)' + ); menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); menu.addItem( @@ -2902,7 +2976,7 @@ IDE_Morph.prototype.rawSaveProject = function (name) { try { localStorage['-snap-project-' + name] = str = this.serializer.serialize(this.stage); - location.hash = '#open:' + str; + this.setURL('#open:' + str); this.showMessage('Saved!', 1); } catch (err) { this.showMessage('Save failed: ' + err); @@ -2910,7 +2984,7 @@ IDE_Morph.prototype.rawSaveProject = function (name) { } else { localStorage['-snap-project-' + name] = str = this.serializer.serialize(this.stage); - location.hash = '#open:' + str; + this.setURL('#open:' + str); this.showMessage('Saved!', 1); } } @@ -2951,7 +3025,7 @@ IDE_Morph.prototype.exportProject = function (name, plain) { str = encodeURIComponent( this.serializer.serialize(this.stage) ); - location.hash = '#open:' + str; + this.setURL('#open:' + str); window.open('data:text/' + (plain ? 'plain,' + str : 'xml,' + str)); menu.destroy(); @@ -2964,7 +3038,7 @@ IDE_Morph.prototype.exportProject = function (name, plain) { str = encodeURIComponent( this.serializer.serialize(this.stage) ); - location.hash = '#open:' + str; + this.setURL('#open:' + str); window.open('data:text/' + (plain ? 'plain,' + str : 'xml,' + str)); menu.destroy(); @@ -3238,7 +3312,13 @@ IDE_Morph.prototype.openProject = function (name) { this.setProjectName(name); str = localStorage['-snap-project-' + name]; this.openProjectString(str); - location.hash = '#open:' + str; + this.setURL('#open:' + str); + } +}; + +IDE_Morph.prototype.setURL = function (str) { + if (this.projectsInURLs) { + location.hash = str; } }; diff --git a/help/receiveClick.png b/help/receiveInteraction.png Binary files differindex 6ace2e3..6ace2e3 100644 --- a/help/receiveClick.png +++ b/help/receiveInteraction.png diff --git a/history.txt b/history.txt index deb76a6..d042af4 100755 --- a/history.txt +++ b/history.txt @@ -2426,3 +2426,43 @@ ______ * GUI: Fix Zoom Dialog’s sample background in “flat” design * Updated Korean and Catalan translations, thanks, Yunjae Jang and Bernat Romagosa! * Objects: Fix speech bubbles of dragged nested sprites + +150128 +------ +* Objects: Fixed #710 + +150206 +------ +* GUI: Added url switch #cloud: to open a shared project in edit mode + +150220 +------ +* Malayam, Tamil and Telagu translations, thanks, Vinay Kumar!! +* Un-hide “Save to disk” feature (currently supported by both Chrome and Firefox, but not by Safari) +* Update German translation +* GUI: Make “project data in URLs” a hidden dev option (prevent long urls per default) + +150223 +------ +* Blocks, Objects: Add user-interaction choices to the “When I am ...” hat block +* Update German translation +* Store: Avoid incompatibility warning for very old (pre-earmarked) projects + +150224 +------ +* Store: fixed #725 + +150228 +------ +* Blocks, Store, GUI: Cache inputs, accelerates evaluating recursive reporters and warped / turbo recursive commands by up to 40% +* Objects: slightly optimize warped / turbo execution +* Threads: fixed #715 +* BYOB: fixed #716 + +150302 +------ +* BYOB: fixed #730 + +150306 +------ +* Blocks: fixed #736 @@ -24,6 +24,7 @@ <script type="text/javascript" src="Snapin8r/snapin8r.min.js"></script> <script type="text/javascript" src="vkBeautify/vkbeautify.js"></script> <script type="text/javascript" src="diff-merge/dist/diff.js"></script> + <script type="text/javascript" src="peer.js"></script> <script type="text/javascript"> var world; window.onload = function () { @@ -185,7 +185,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', // optional 'last_changed': - '2014-07-29', // this, too, will appear in the Translators tab + '2015-02-23', // this, too, will appear in the Translators tab // GUI // control bar: @@ -417,8 +417,18 @@ SnapTranslator.dict.de = { 'Wenn %greenflag angeklickt', 'when %keyHat key pressed': 'Wenn Taste %keyHat gedr\u00fcckt', - 'when I am clicked': - 'Wenn ich angeklickt werde', + 'when I am %interaction': + 'Wenn ich %interaction werde', + 'clicked': + 'angeklickt', + 'pressed': + 'gedr\u00fcckt', + 'dropped': + 'abgestellt', + 'mouse-entered': + 'vom Mauszeiger betreten', + 'mouse-departed': + 'vom Mauszeiger verlassen', 'when I receive %msgHat': 'Wenn ich %msgHat empfange', 'broadcast %msg': @@ -615,6 +625,19 @@ SnapTranslator.dict.de = { 'replace item %idx of %l with %s': 'ersetze Element %idx in %l durch %s', + // peer to peer communication + 'when I receive %upvar from %upvar': + 'Wenn ich %upvar von %upvar empfange', + 'peer': + 'Peer', + 'send %s to %s': + 'sende %s an %s', + 'my peer id': + 'meine Peer-ID', + 'peers online': + 'verbundene Peers', + + // other 'Make a block': 'Neuer Block', @@ -647,6 +670,11 @@ SnapTranslator.dict.de = { '\u00d6ffnen...', 'Save': 'Sichern', + 'Save to disk': + 'Abpeichern', + 'store this project\nin the downloads folder\n(in supporting browsers)': + 'dieses Projekt herunterladen\nund lokal speichern\n' + + '(nicht von allen Browsern unters\u00fctzt)', 'Save As...': 'Sichern als...', 'Import...': diff --git a/lang-ml.js b/lang-ml.js new file mode 100644 index 0000000..415a280 --- /dev/null +++ b/lang-ml.js @@ -0,0 +1,1282 @@ +/*
+
+ lang-de.js
+
+ German translation for SNAP!
+
+ written by Jens Mönig
+
+ Copyright (C) 2014 by Jens Mönig
+
+ This file is part of Snap!.
+
+ Snap! is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+ Note to Translators:
+ --------------------
+ At this stage of development, Snap! can be translated to any LTR language
+ maintaining the current order of inputs (formal parameters in blocks).
+
+ Translating Snap! is easy:
+
+
+ 1. Download
+
+ Download the sources and extract them into a local folder on your
+ computer:
+
+ <http://snap.berkeley.edu/snapsource/snap.zip>
+
+ Use the German translation file (named 'lang-de.js') as template for your
+ own translations. Start with editing the original file, because that way
+ you will be able to immediately check the results in your browsers while
+ you're working on your translation (keep the local copy of snap.html open
+ in your web browser, and refresh it as you progress with your
+ translation).
+
+
+ 2. Edit
+
+ Edit the translation file with a regular text editor, or with your
+ favorite JavaScript editor.
+
+ In the first non-commented line (the one right below this
+ note) replace "de" with the two-letter ISO 639-1 code for your language,
+ e.g.
+
+ fr - French => SnapTranslator.dict.fr = {
+ it - Italian => SnapTranslator.dict.it = {
+ pl - Polish => SnapTranslator.dict.pl = {
+ pt - Portuguese => SnapTranslator.dict.pt = {
+ es - Spanish => SnapTranslator.dict.es = {
+ el - Greek => => SnapTranslator.dict.el = {
+
+ etc. (see <http://en.wikipedia.org/wiki/ISO_639-1>)
+
+
+ 3. Translate
+
+ Then work through the dictionary, replacing the German strings against
+ your translations. The dictionary is a straight-forward JavaScript ad-hoc
+ object, for review purposes it should be formatted as follows:
+
+ {
+ 'English string':
+ 'Translation string',
+ 'last key':
+ } 'last value'
+
+ and you only edit the indented value strings. Note that each key-value
+ pair needs to be delimited by a comma, but that there shouldn't be a comma
+ after the last pair (again, just overwrite the template file and you'll be
+ fine).
+
+ If something doesn't work, or if you're unsure about the formalities you
+ should check your file with
+
+ <http://JSLint.com>
+
+ This will inform you about any missed commas etc.
+
+
+ 4. Accented characters
+
+ Depending on which text editor and which file encoding you use you can
+ directly enter special characters (e.g. Umlaut, accented characters) on
+ your keyboard. However, I've noticed that some browsers may not display
+ special characters correctly, even if other browsers do. So it's best to
+ check your results in several browsers. If you want to be on the safe
+ side, it's even better to escape these characters using Unicode.
+
+ see: <http://0xcc.net/jsescape/>
+
+
+ 5. Block specs:
+
+ At this time your translation of block specs will only work
+ correctly, if the order of formal parameters and their types
+ are unchanged. Placeholders for inputs (formal parameters) are
+ indicated by a preceding % prefix and followed by a type
+ abbreviation.
+
+ For example:
+
+ 'say %s for %n secs'
+
+ can currently not be changed into
+
+ 'say %n secs long %s'
+
+ and still work as intended.
+
+ Similarly
+
+ 'point towards %dst'
+
+ cannot be changed into
+
+ 'point towards %cst'
+
+ without breaking its functionality.
+
+
+ 6. Submit
+
+ When you're done, rename the edited file by replacing the "de" part of the
+ filename with the two-letter ISO 639-1 code for your language, e.g.
+
+ fr - French => lang-fr.js
+ it - Italian => lang-it.js
+ pl - Polish => lang-pl.js
+ pt - Portuguese => lang-pt.js
+ es - Spanish => lang-es.js
+ el - Greek => => lang-el.js
+
+ and send it to me for inclusion in the official Snap! distribution.
+ Once your translation has been included, Your name will the shown in the
+ "Translators" tab in the "About Snap!" dialog box, and you will be able to
+ directly launch a translated version of Snap! in your browser by appending
+
+ lang:xx
+
+ to the URL, xx representing your translations two-letter code.
+
+
+ 7. Known issues
+
+ In some browsers accents or ornaments located in typographic ascenders
+ above the cap height are currently (partially) cut-off.
+
+ Enjoy!
+ -Jens
+*/
+
+/*global SnapTranslator*/
+
+SnapTranslator.dict.ml = {
+
+/*
+ Special characters: (see <http://0xcc.net/jsescape/>)
+
+ Ä, ä \u00c4, \u00e4
+ Ö, ö \u00d6, \u00f6
+ Ü, ü \u00dc, \u00fc
+ ß \u00df
+*/
+
+ // translations meta information
+ 'language_name':
+ 'Malayalam', // the name as it should appear in the language menu
+ 'language_translator':
+ 'vinayakumar R', // your name for the Translators tab
+ 'translator_e-mail':
+ 'vnkmr7620@gmail.com', // optional
+ 'last_changed':
+ '2015-02-20', // this, too, will appear in the Translators tab
+
+ // GUI
+ // control bar:
+ 'untitled':
+ 'തലക്കെട്ടില്ലാത്ത',
+ 'development mode':
+ 'വികസനം സമ്പ്രദായം',
+
+ // categories:
+ 'Motion':
+ 'ചലനം',
+ 'Looks':
+ 'കാഴ്ച',
+ 'Sound':
+ 'ശബ്ദം',
+ 'Pen':
+ 'പേന',
+ 'Control':
+ 'നിയന്ത്രണം',
+ 'Sensing':
+ 'ഗ്രഹണം',
+ 'Operators':
+ 'ക്രിയകള്',
+ 'Variables':
+ 'ചരങ്ങള്',
+ 'Lists':
+ 'പട്ടിക',
+ 'Other':
+ 'വേറൊന്ന്',
+
+ // editor:
+ 'draggable':
+ 'വലിച്ചിഴയ്ക്കുക',
+
+ // tabs:
+ 'Scripts':
+ 'ലിപികള്',
+ 'Costumes':
+ 'വേഷം',
+ 'Sounds':
+ 'ശബ്ദകള്',
+
+ // names:
+ 'Sprite':
+ 'ദേവത',
+ 'Stage':
+ 'നില',
+
+ // rotation styles:
+ 'don\'t rotate':
+ 'തിരികരുത്',
+ 'can rotate':
+ 'തിരിക്കാന് കഴിയും',
+ 'only face left/right':
+ 'മാത്രം നോകുക ഇടത്/വലത്ത്',
+
+ // new sprite button:
+ 'add a new sprite':
+ 'പുതിയ ദേവത ചേര്ക്കുക',
+
+ // tab help
+ 'costumes tab help':
+ 'വേഷം ലഘുപട്ടിക സഹായം',
+ 'import a sound from your computer\nby dragging it into here':
+ 'കമ്പ്യൂട്ടറില് നിന്നും ശബ്തം ഇറക്കുമതി\n ഇവിടെ വലിച്ചിട്ടുക',
+
+ // primitive blocks:
+
+ /*
+ Attention Translators:
+ ----------------------
+ At this time your translation of block specs will only work
+ correctly, if the order of formal parameters and their types
+ are unchanged. Placeholders for inputs (formal parameters) are
+ indicated by a preceding % prefix and followed by a type
+ abbreviation.
+
+ For example:
+
+ 'say %s for %n secs'
+
+ can currently not be changed into
+
+ 'say %n secs long %s'
+
+ and still work as intended.
+
+ Similarly
+
+ 'point towards %dst'
+
+ cannot be changed into
+
+ 'point towards %cst'
+
+ without breaking its functionality.
+ */
+
+ // motion:
+ 'Stage selected:\nno motion primitives':
+ 'B\u00fchne ausgew\u00e4hlt:\nkeine Standardbewegungsbl\u00f6cke\n'
+ + 'vorhanden',
+
+ 'move %n steps':
+ 'ചലിക്കുക %n പടികള്',
+ 'turn %clockwise %n degrees':
+ 'drehe %clockwise %n Grad',
+ 'turn %counterclockwise %n degrees':
+ 'drehe %counterclockwise %n Grad',
+ 'point in direction %dir':
+ 'ലേക്ക് തിരിയുക %dir',
+ 'point towards %dst':
+ 'ലേക്ക് തിരിയുക %dst',
+ 'go to x: %n y: %n':
+ 'ലേക്ക് പോവുക x: %n y: %n',
+ 'go to %dst':
+ 'ലേക്ക് പോവുക %dst',
+ 'glide %n secs to x: %n y: %n':
+ 'സെകന്റില് %n ലേക്ക് നീങ്ങുക x: %n y: %n',
+ 'change x by %n':
+ 'xനെ %n കൊണ്ട് മാറ്റുക',
+ 'set x to %n':
+ 'xനെ %n ആക്കുക',
+ 'change y by %n':
+ 'yനെ %n കൊണ്ട് മാറ്റുക',
+ 'set y to %n':
+ 'yനെ %n ആക്കുക',
+ 'if on edge, bounce':
+ 'അറ്റത്താണെങ്കില് തിരിച്ചു നടക്കുക',
+ 'x position':
+ 'xസ്ഥാന',
+ 'y position':
+ 'yസ്ഥാനം',
+ 'direction':
+ 'ദിശ',
+
+ // looks:
+ 'switch to costume %cst':
+ 'മത്തെ രൂപമാക്കുക %cst',
+ 'next costume':
+ 'അടുത്ത രൂപം',
+ 'costume #':
+ 'രൂപ #',
+ 'say %s for %n secs':
+ '%s %n സെകന്റ് പറയുക',
+ 'say %s':
+ '%s പറയുക',
+ 'think %s for %n secs':
+ '%n സെകന്റ് %s ചിന്തിക്കുക',
+ 'think %s':
+ '%s ചിന്തിക്കുക',
+ 'Hello!':
+ 'ഹലോ!',
+ 'Hmm...':
+ 'ഹ് മ് മും...',
+ 'change %eff effect by %n':
+ '%eff നെ %n കൊണ്ട് മാറ്റുക',
+ 'set %eff effect to %n':
+ '%eff എന്ന സ്പെഷല് എഫെക്റ്റ് %n ആക്കുക',
+ 'clear graphic effects':
+ 'ഗ്രാഫിക് ഇഫെക്റ്റ്സ് മാറ്റുക',
+ 'change size by %n':
+ 'വലിപ്പം %n കൊണ്ട് മാറ്റുക',
+ 'set size to %n %':
+ 'വലിപ്പം %n % ആക്കുക',
+ 'size':
+ 'വലിപ്',
+ 'show':
+ 'പ്രത്യക്ഷമാവുക',
+ 'hide':
+ 'ഒളിക്കുക',
+ 'go to front':
+ 'ഉപരിതലത്തിലോട്ടു വരിക',
+ 'go back %n layers':
+ '%n പാളി അകത്തേക്ക് പോവുക',
+
+ 'development mode \ndebugging primitives:':
+ 'Hackermodus \nDebugging-Bl\u00f6cke',
+ 'console log %mult%s':
+ 'schreibe in die Konsole: %mult%s',
+ 'alert %mult%s':
+ 'Pop-up: %mult%s',
+
+ // sound:
+ 'play sound %snd':
+ '%snd ശബ്ദമുണ്ടാക്കുക',
+ 'play sound %snd until done':
+ 'തീരുന്നതു വരെ %snd ശബ്ദമുണ്ടാക്കുക',
+ 'stop all sounds':
+ 'stoppe alle Kl\u00e4nge',
+ 'rest for %n beats':
+ '%n ബീറ്റ് സമയം കാത്തിരിക്കുക',
+ 'play note %n for %n beats':
+ '%n മത്തെ സ്വരം %n ബീറ്റ്സ് അവതരിപ്പിക്കുക',
+ 'change tempo by %n':
+ 'ടെംപോ %n കൊണ്ട് മാറ്റുക',
+ 'set tempo to %n bpm':
+ 'ടെംപോ %n ബീറ്റ്സ്/മിനിറ്റ് ആക്കുക',
+ 'tempo':
+ 'ടെംപ',
+
+ // pen:
+ 'clear':
+ 'മായ്ക്കുക',
+ 'pen down':
+ 'വരയ്ക്കാന് തുടങ്ങുക',
+ 'pen up':
+ 'വരയുന്നത് നിര്ത്തുക',
+ 'set pen color to %clr':
+ 'പേനയുടെ നിറം %clr ആക്കുക',
+ 'change pen color by %n':
+ 'പേനയുടെ നിറം %n കൊണ്ട് മാറ്റുക',
+ 'set pen color to %n':
+ 'പേനയുടെ നിറം %n ആക്കുക',
+ 'change pen shade by %n':
+ 'പേനയുടെ ഷേഡ് %n കൊണ്ട് മാറ്റുക',
+ 'set pen shade to %n':
+ 'പേനയുടെ ഷേഡ് %n ആക്കുക',
+ 'change pen size by %n':
+ 'പേനയുടെ വലിപ്പം %n കൊണ്ട് മാറ്റുക',
+ 'set pen size to %n':
+ 'പേനയുടെ വലിപ്പം %n ആക്കുക',
+ 'stamp':
+ 'ഒട്ടിക്കുക',
+
+ // control:
+ 'when %greenflag clicked':
+ '%greenflag ക്ലിക്ക് ചെയ്യുമ്പോള്',
+ 'when %keyHat key pressed':
+ '%keyHat കീ അമര്ത്തുമ്പോള്',
+ 'when I am clicked':
+ 'Wenn ich angeklickt werde',
+ 'when I receive %msgHat':
+ 'ഞാന് %msgHat സ്വീകരിക്കുമ്പോള്',
+ 'broadcast %msg':
+ '%msg വിളംബരം ചെയ്യുക',
+ 'broadcast %msg and wait':
+ '%msg വിളംബരം ചെയ്തു കാത്തിരിക്കുക',
+ 'Message name':
+ 'സന്ദേശത്തിന്റെ പേര്',
+ 'message':
+ 'സന്ദേശത്തിന്റ',
+ 'any message':
+ 'eine beliebige Nachricht',
+ 'wait %n secs':
+ '%n സെകന്റ് കാത്തിരിക്കുക',
+ 'wait until %b':
+ '%b ആവുന്നത് വരെ കാത്തിരിക്കുക',
+ 'forever %c':
+ 'എല്ലായ്പ്പോഴു %c',
+ 'repeat %n %c':
+ 'തവണ ആവര്ത്തിക്കുക %n %c',
+ 'repeat until %b %c':
+ '%b %c ആവുന്നത് വരെ ആവര്ത്തിക്കുക',
+ 'if %b %c':
+ '%b %c ആണെങ്കില്',
+ 'if %b %c else %c':
+ '%b %c ആണെങ്കില് അല്ലെങ്കില് %c',
+ 'report %s':
+ 'berichte %s',
+ 'stop %stopChoices':
+ 'നിര്ത്തുക %stopChoices',
+ 'all':
+ 'എല്ലാ',
+ 'this script':
+ 'ഈ സീരിയല് ',
+ 'this block':
+ 'ഈ ബ്ലോക്കുകള്',
+ 'stop %stopOthersChoices':
+ 'നിര്ത്തുക %stopOthersChoices',
+ 'all but this script':
+ 'alles au\u00dfer diesem Skript',
+ 'other scripts in sprite':
+ 'andere Skripte in diesem Objekt',
+ 'pause all %pause':
+ 'pausiere alles %pause',
+ 'run %cmdRing %inputs':
+ 'f\u00fchre %cmdRing aus %inputs',
+ 'launch %cmdRing %inputs':
+ 'starte %cmdRing %inputs',
+ 'call %repRing %inputs':
+ 'rufe %repRing auf %inputs',
+ 'run %cmdRing w/continuation':
+ 'f\u00fchre %cmdRing mit Continuation aus',
+ 'call %cmdRing w/continuation':
+ 'rufe %cmdRing mit Continuation auf',
+ 'warp %c':
+ 'Warp %c',
+ 'when I start as a clone':
+ 'Wenn ich geklont werde',
+ 'create a clone of %cln':
+ 'klone %cln',
+ 'myself':
+ 'mich',
+ 'delete this clone':
+ 'entferne diesen Klon',
+
+ // sensing:
+ 'touching %col ?':
+ '%col തൊടുന്നുണ്ടോ?',
+ 'touching %clr ?':
+ '%clr തൊടുന്നുണ്ടോ?',
+ 'color %clr is touching %clr ?':
+ '%clr കളര് %clr നെ തൊടുന്നുണ്ടോ?',
+ 'ask %s and wait':
+ '%s ചോദിച്ചു കാത്തിരിക്കുക',
+ 'what\'s your name?':
+ 'താങ്കളുടെ പേര് എന്താണ്?',
+ 'answer':
+ 'ഉത്തര',
+ 'mouse x':
+ 'മൗസിന്റെ x സ്ഥാന',
+ 'mouse y':
+ 'മൗസിന്റെ y സ്ഥാന',
+ 'mouse down?':
+ 'മൗസ് താഴെയാണോ?',
+ 'key %key pressed?':
+ '%key കീ അമര്ത്തിയോ?',
+ 'distance to %dst':
+ '%dst ലേക്കുള്ള ദൂരം',
+ 'reset timer':
+ 'ടൈമര് വീണ്ടും തുടങ്ങുക',
+ 'timer':
+ 'ടൈമര്',
+ '%att of %spr':
+ '%att ന്റ %spr',
+ 'http:// %s':
+ 'http:// %s',
+ 'turbo mode?':
+ 'Turbomodus?',
+ 'set turbo mode to %b':
+ 'setze Turbomodus auf %b',
+
+ 'filtered for %clr':
+ 'nach %clr gefiltert',
+ 'stack size':
+ 'Stapelgr\u00f6\u00dfe',
+ 'frames':
+ 'Rahmenz\u00e4hler',
+
+ // operators:
+ '%n mod %n':
+ '%n ശിഷ് %n',
+ 'round %n':
+ '%n റൗണ്ട് ചെയ്യുക',
+ '%fun of %n':
+ '%fun ന്റ %n',
+ 'pick random %n to %n':
+ '%n മുതല് %n വരെയുള്ള ഏതെങ്കിലും സംഖ്യ എടുക്കുക',
+ '%b and %b':
+ '%b കൂടാത %b',
+ '%b or %b':
+ '%b അഥവ %b',
+ 'not %b':
+ '%b അല്ല',
+ 'true':
+ 'ശര',
+ 'false':
+ 'തെറ്റ്',
+ 'join %words':
+ 'മായി യോജിപ്പിക്കുക %words',
+ 'split %s by %delim':
+ 'trenne %s nach %delim',
+ 'hello':
+ 'ഹലോ',
+ 'world':
+ 'ലോകം',
+ 'letter %n of %s':
+ '%s ന്റെ %n മത്തെ അക്ഷരം',
+ 'length of %s':
+ '%s ന്റെ നീള',
+ 'unicode of %s':
+ 'Unicode Wert von %s',
+ 'unicode %n as letter':
+ 'Unicode %n als Buchstabe',
+ 'is %s a %typ ?':
+ 'ist %s ein(e) %typ ?',
+ 'is %s identical to %s ?':
+ 'ist %s identisch mit %s ?',
+
+ 'type of %s':
+ 'Typ von %s',
+
+ // variables:
+ 'Make a variable':
+ 'ഒരു ചരം ഉണ്ടാക്കുക',
+ 'Variable name':
+ 'ചരത്തിന്റെ പേര്',
+ 'Script variable name':
+ 'കോഡ് ചരത്തിന്റെ പേര്',
+ 'Delete a variable':
+ 'ഒരു ചരം ഡിലീറ്റ് ചെയ്യുക',
+
+ 'set %var to %s':
+ '%var നെ %s ആക്കി മാറ്റുക',
+ 'change %var by %n':
+ '%var നെ %n കൊണ്ട് മാറ്റുക',
+ 'show variable %var':
+ '%var എന്ന ചരം കാണിക്കുക',
+ 'hide variable %var':
+ '%var എന്ന ചരത്തെ ഒളിപ്പിച്ചു വയ്ക്കുക',
+ 'script variables %scriptVars':
+ 'Skriptvariablen %scriptVars',
+
+ // lists:
+ 'list %exp':
+ 'Liste %exp',
+ '%s in front of %l':
+ '%s am Anfang von %l',
+ 'item %idx of %l':
+ 'Element %idx von %l',
+ 'all but first of %l':
+ 'alles au\u00dfer dem ersten von %l',
+ 'length of %l':
+ 'L\u00e4nge von %l',
+ '%l contains %s':
+ '%l enth\u00e4lt %s',
+ 'thing':
+ 'etwas',
+ 'add %s to %l':
+ 'f\u00fcge %s zu %l hinzu',
+ 'delete %ida of %l':
+ 'entferne %ida aus %l',
+ 'insert %s at %idx of %l':
+ 'f\u00fcge %s als %idx in %l ein',
+ 'replace item %idx of %l with %s':
+ 'ersetze Element %idx in %l durch %s',
+
+ // other
+ 'Make a block':
+ 'Neuer Block',
+
+ // menus
+ // snap menu
+ 'About...':
+ '\u00dcber Snap!...',
+ 'Reference manual':
+ 'Handbuch lesen',
+ 'Snap! website':
+ 'Snap! Webseite',
+ 'Download source':
+ 'Quellcode runterladen',
+ 'Switch back to user mode':
+ 'zur\u00fcck zum Benutzermodus',
+ 'disable deep-Morphic\ncontext menus\nand show user-friendly ones':
+ 'verl\u00e4sst Morphic',
+ 'Switch to dev mode':
+ 'zum Hackermodus wechseln',
+ 'enable Morphic\ncontext menus\nand inspectors,\nnot user-friendly!':
+ 'erm\u00f6glicht Morphic Funktionen',
+
+ // project menu
+ 'Project notes...':
+ 'പ്രോജെക്റ്റ് കുറിപ്പുകള്....',
+ 'New':
+ 'പുതിയ',
+ 'Open...':
+ 'ഓപ്പണ് ചെയ്യുക...',
+ 'Save':
+ 'സേവ് ചെയ്യുക',
+ 'Save As...':
+ 'എന്ന് സേവ് ചെയ്യുക...',
+ 'Import...':
+ 'കൊണ്ടുവരിക...',
+ 'file menu import hint':
+ 'l\u00e4dt ein exportiertes Projekt,\neine Bibliothek mit '
+ + 'Bl\u00f6cken\n'
+ + 'ein Kost\u00fcm oder einen Klang',
+ 'Export project as plain text...':
+ 'Projekt als normalen Text exportieren...',
+ 'Export project...':
+ 'Projekt exportieren...',
+ 'show project data as XML\nin a new browser window':
+ 'zeigt das Projekt als XML\nin einem neuen Browserfenster an',
+ 'Export blocks...':
+ 'Bl\u00f6cke exportieren...',
+ 'show global custom block definitions as XML\nin a new browser window':
+ 'zeigt globale Benutzerblockdefinitionen\nals XML im Browser an',
+ 'Import tools':
+ 'Tools laden',
+ 'load the official library of\npowerful blocks':
+ 'das offizielle Modul mit\nm\u00e4chtigen Bl\u00f6cken laden',
+ 'Libraries...':
+ 'Module...',
+ 'Import library':
+ 'Modul laden',
+
+ // cloud menu
+ 'Login...':
+ 'Anmelden...',
+ 'Signup...':
+ 'Benutzerkonto einrichten...',
+
+ // settings menu
+ 'Language...':
+ 'ഭാഷ...',
+ 'Zoom blocks...':
+ 'Bl\u00f6cke vergr\u00f6\u00dfern...',
+ 'Stage size...':
+ 'സ്റ്റേജ് വലിപ്...',
+ 'Stage size':
+ 'സ്റ്റേജ് വലിപ്',
+ 'Stage width':
+ 'B\u00fchnenbreite',
+ 'Stage height':
+ 'B\u00fchnenh\u00f6he',
+ 'Default':
+ 'Normal',
+ 'Blurred shadows':
+ 'Weiche Schatten',
+ 'uncheck to use solid drop\nshadows and highlights':
+ 'abschalten f\u00fcr harte Schatten\nund Beleuchtung',
+ 'check to use blurred drop\nshadows and highlights':
+ 'einschalten f\u00fcr harte Schatten\nund Beleuchtung',
+ 'Zebra coloring':
+ 'Zebrafarben',
+ 'check to enable alternating\ncolors for nested blocks':
+ 'einschalten \u00fcr abwechselnde Farbnuancen\nin Bl\u00f6cken',
+ 'uncheck to disable alternating\ncolors for nested block':
+ 'ausschalten verhindert abwechselnde\nFarbnuancen in Bl\u00f6cken',
+ 'Dynamic input labels':
+ 'Eingabenbeschriftung',
+ 'uncheck to disable dynamic\nlabels for variadic inputs':
+ 'ausschalten verhindert Beschriftung\nvon Mehrfacheingaben',
+ 'check to enable dynamic\nlabels for variadic inputs':
+ 'einschalten um Mehrfacheingabefelder\nautomatisch zu beschriften',
+ 'Prefer empty slot drops':
+ 'Leere Platzhalter bevorzugen',
+ 'settings menu prefer empty slots hint':
+ 'einschalten um leere Platzhalter\nbeim Platzieren von Bl\u00f6cken'
+ + 'zu bevorzugen',
+ 'uncheck to allow dropped\nreporters to kick out others':
+ 'ausschalten um das "Rauskicken"\nvon platzierten Bl\u00f6cken\n'
+ + 'zu erm\u00f6glichen',
+ 'Long form input dialog':
+ 'Ausf\u00fchrlicher Input-Dialog',
+ 'Plain prototype labels':
+ 'Einfache Prototyp-Beschriftung',
+ 'uncheck to always show (+) symbols\nin block prototype labels':
+ 'ausschalten, um (+) Zeichen\nim Blockeditor zu verbergen',
+ 'check to hide (+) symbols\nin block prototype labels':
+ 'einschalten, um (+) Zeichen\nim Blockeditor immer anzuzeigen',
+ 'check to always show slot\ntypes in the input dialog':
+ 'einschalten, um immer die Datentypen\nim Input-Dialog zu sehen',
+ 'uncheck to use the input\ndialog in short form':
+ 'ausschalten f\u00fcr kurzen\nInput-Dialog',
+ 'Virtual keyboard':
+ 'Virtuelle Tastatur',
+ 'uncheck to disable\nvirtual keyboard support\nfor mobile devices':
+ 'ausschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n'
+ + 'zu sperren',
+ 'check to enable\nvirtual keyboard support\nfor mobile devices':
+ 'einschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n'
+ + 'zu erm\u00f6glichen',
+ 'Input sliders':
+ 'Eingabeschieber',
+ 'uncheck to disable\ninput sliders for\nentry fields':
+ 'ausschalten um Schieber\nin Eingabefeldern zu verhindern',
+ 'check to enable\ninput sliders for\nentry fields':
+ 'einschalten um Schieber\nin Eingabefeldern zu aktivieren',
+ 'Clicking sound':
+ 'Akustisches Klicken',
+ 'uncheck to turn\nblock clicking\nsound off':
+ 'ausschalten um akustisches\nKlicken zu deaktivieren',
+ 'check to turn\nblock clicking\nsound on':
+ 'einschalten um akustisches\nKlicken zu aktivieren',
+ 'Animations':
+ 'Animationen',
+ 'uncheck to disable\nIDE animations':
+ 'ausschalten um IDE-\nAnimationen zu verhindern',
+ 'Turbo mode':
+ 'Turbomodus',
+ 'check to prioritize\nscript execution':
+ 'einschalten, um Skripte\nzu priorisieren',
+ 'uncheck to run scripts\nat normal speed':
+ 'ausschalten, um Skripte\nnormal auszuf\u00fchren',
+ 'check to enable\nIDE animations':
+ 'einschalten um IDE-\nAnimationen zu erlauben',
+ 'Thread safe scripts':
+ 'Threadsicherheit',
+ 'uncheck to allow\nscript reentrance':
+ 'verhindert, dass unvollendete\nSkripte erneut gestartet werden',
+ 'check to disallow\nscript reentrance':
+ 'verhindert, dass unvollendete\nSkripte erneut gestartet werden',
+ 'Prefer smooth animations':
+ 'Fixe Framerate',
+ 'uncheck for greater speed\nat variable frame rates':
+ 'ausschalten, um Animationen \ndynamischer auszuf\u00fchren',
+ 'check for smooth, predictable\nanimations across computers':
+ 'einschalten, damit Animationen\n\u00fcberall gleich laufen',
+ 'Flat line ends':
+ 'Flache Pinselstriche',
+ 'check for flat ends of lines':
+ 'einschalten f\u00fcr flache\nPinselstrichenden',
+ 'uncheck for round ends of lines':
+ 'auschalten f\u00fcr runde\nPinselstrichenden',
+
+ // inputs
+ 'with inputs':
+ 'mit Eingaben',
+ 'input names:':
+ 'Eingaben:',
+ 'Input Names:':
+ 'Eingaben:',
+ 'input list:':
+ 'Eingabeliste:',
+
+ // context menus:
+ 'help':
+ 'സഹായ',
+
+ // palette:
+ 'hide primitives':
+ 'Basisbl\u00f6cke ausblenden',
+ 'show primitives':
+ 'Basisbl\u00f6cke anzeigen',
+
+ // blocks:
+ 'help...':
+ 'സഹായ...',
+ 'relabel...':
+ 'Umbenennen...',
+ 'duplicate':
+ 'ഡ്യൂപ്ലിക്കേറ്റ്',
+ 'make a copy\nand pick it up':
+ 'eine Kopie aufnehmen',
+ 'only duplicate this block':
+ 'nur diesen Block duplizieren',
+ 'delete':
+ 'ഡിലീറ്റ് ചെയ്യുക',
+ 'script pic...':
+ 'Skriptbild...',
+ 'open a new window\nwith a picture of this script':
+ 'ein neues Browserfenster mit einem\nBild dieses Skripts \u00f6ffnen',
+ 'ringify':
+ 'Umringen',
+ 'unringify':
+ 'Entringen',
+
+ // custom blocks:
+ 'delete block definition...':
+ 'Blockdefinition l\u00f6schen',
+ 'edit...':
+ 'Bearbeiten...',
+
+ // sprites:
+ 'edit':
+ 'എഡിറ്റ്',
+ 'move':
+ 'നീങ്ങുക',
+ 'detach from':
+ 'Abtrennen von',
+ 'detach all parts':
+ 'Alle Teile abtrennen',
+ 'export...':
+ 'കൊടുത്തയയ്ക്കുക...',
+
+ // stage:
+ 'show all':
+ 'Alles zeigen',
+ 'pic...':
+ 'Bild exportieren...',
+ 'open a new window\nwith a picture of the stage':
+ 'ein neues Browserfenster mit einem\nBild der B\u00fchne \u00f6ffnen',
+
+ // scripting area
+ 'clean up':
+ 'Aufr\u00e4umen',
+ 'arrange scripts\nvertically':
+ 'Skripte der Reihe nach\nanordnen',
+ 'add comment':
+ 'Anmerkung hinzuf\u00fcgen',
+ 'undrop':
+ 'R\u00fcckg\u00e4ngig',
+ 'undo the last\nblock drop\nin this pane':
+ 'Setzen des letzten Blocks\nwiderrufen',
+ 'scripts pic...':
+ 'Bild aller Scripte...',
+ 'open a new window\nwith a picture of all scripts':
+ 'ein neues Browserfenster mit einem\nBild aller Skripte \u00f6ffnen',
+ 'make a block...':
+ 'Neuen Block bauen...',
+
+ // costumes
+ 'rename':
+ 'Umbenennen',
+ 'export':
+ 'കൊടുത്തയയ്ക്കുക',
+ 'rename costume':
+ 'Kost\u00fcm umbenennen',
+
+ // sounds
+ 'Play sound':
+ 'ശബ്ദമുണ്ടാക്കുക',
+ 'Stop sound':
+ 'Klang\nanhalten',
+ 'Stop':
+ 'Halt',
+ 'Play':
+ 'തുടങ്ങുക',
+ 'rename sound':
+ 'Klang umbenennen',
+
+ // dialogs
+ // buttons
+ 'OK':
+ 'ഓക',
+ 'Ok':
+ 'ഓക',
+ 'Cancel':
+ 'ക്യാന്സല് ചെയ്യുക',
+ 'Yes':
+ 'അതെ',
+ 'No':
+ 'അല്ല',
+
+ // help
+ 'Help':
+ 'സഹായ',
+
+ // zoom blocks
+ 'Zoom blocks':
+ 'Bl\u00f6cke vergr\u00f6\u00dfern',
+ 'build':
+ 'baue',
+ 'your own':
+ 'eigene',
+ 'blocks':
+ 'Bl\u00f6cke',
+ 'normal (1x)':
+ 'normal (1x)',
+ 'demo (1.2x)':
+ 'Demo (1.2x)',
+ 'presentation (1.4x)':
+ 'Pr\u00e4sentation (1.4x)',
+ 'big (2x)':
+ 'gro\u00df (2x)',
+ 'huge (4x)':
+ 'riesig (4x)',
+ 'giant (8x)':
+ 'gigantisch (8x)',
+ 'monstrous (10x)':
+ 'ungeheuerlich (10x)',
+
+ // Project Manager
+ 'Untitled':
+ 'Unbenannt',
+ 'Open Project':
+ 'പ്രോജെക്റ്റ് ഓപ്പണ് ചെയ്യുക',
+ '(empty)':
+ '(leer)',
+ 'Saved!':
+ 'Gesichert!',
+ 'Delete Project':
+ 'Projekt l\u00f6schen',
+ 'Are you sure you want to delete':
+ 'Wirklich l\u00f6schen?',
+ 'rename...':
+ 'Umbenennen...',
+
+ // costume editor
+ 'Costume Editor':
+ 'Kost\u00fcmeditor',
+ 'click or drag crosshairs to move the rotation center':
+ 'Fadenkreuz anklicken oder bewegen um den Drehpunkt zu setzen',
+
+ // project notes
+ 'Project Notes':
+ 'പ്രോജെക്റ്റ് കുറിപ്പുകള്',
+
+ // new project
+ 'New Project':
+ 'Neues Projekt',
+ 'Replace the current project with a new one?':
+ 'Das aktuelle Projekt durch ein neues ersetzen?',
+
+ // save project
+ 'Save Project As...':
+ 'Projekt Sichern Als...',
+
+ // export blocks
+ 'Export blocks':
+ 'Bl\u00f6cke exportieren',
+ 'Import blocks':
+ 'Bl\u00f6cke importieren',
+ 'this project doesn\'t have any\ncustom global blocks yet':
+ 'in diesem Projekt gibt es noch keine\nglobalen Bl\u00f6cke',
+ 'select':
+ 'ausw\u00e4hlen',
+ 'none':
+ 'nichts',
+
+ // variable dialog
+ 'for all sprites':
+ 'f\u00fcr alle',
+ 'for this sprite only':
+ 'nur f\u00fcr dieses Objekt',
+
+ // block dialog
+ 'Change block':
+ 'Block ver\u00e4ndern',
+ 'Command':
+ 'Befehl',
+ 'Reporter':
+ 'Funktion',
+ 'Predicate':
+ 'Pr\u00e4dikat',
+
+ // block editor
+ 'Block Editor':
+ 'Blockeditor',
+ 'Apply':
+ 'Anwenden',
+
+ // block deletion dialog
+ 'Delete Custom Block':
+ 'Block L\u00f6schen',
+ 'block deletion dialog text':
+ 'Soll dieser Block mit allen seinen Exemplare\n' +
+ 'wirklich gel\u00f6scht werden?',
+
+ // input dialog
+ 'Create input name':
+ 'Eingabe erstellen',
+ 'Edit input name':
+ 'Eingabe bearbeiten',
+ 'Edit label fragment':
+ 'Beschriftung bearbeiten',
+ 'Title text':
+ 'Beschriftung',
+ 'Input name':
+ 'Eingabe',
+ 'Delete':
+ 'L\u00f6schen',
+ 'Object':
+ 'Objekt',
+ 'Number':
+ 'Zahl',
+ 'Text':
+ 'Text',
+ 'List':
+ 'Liste',
+ 'Any type':
+ 'Beliebig',
+ 'Boolean (T/F)':
+ 'Boolsch (W/F)',
+ 'Command\n(inline)':
+ 'Befehl',
+ 'Command\n(C-shape)':
+ 'Befehl\n(C-Form)',
+ 'Any\n(unevaluated)':
+ 'Beliebig\n(zitiert)',
+ 'Boolean\n(unevaluated)':
+ 'Boolsch\n(zitiert)',
+ 'Single input.':
+ 'Einzeleingabe.',
+ 'Default Value:':
+ 'Standardwert:',
+ 'Multiple inputs (value is list of inputs)':
+ 'Mehrere Eingaben (als Liste)',
+ 'Upvar - make internal variable visible to caller':
+ 'Interne Variable au\u00dfen sichtbar machen',
+
+ // About Snap
+ 'About Snap':
+ '\u00dcber Snap',
+ 'Back...':
+ 'Zur\u00fcck...',
+ 'License...':
+ 'Lizenz...',
+ 'Modules...':
+ 'Komponenten...',
+ 'Credits...':
+ 'Mitwirkende...',
+ 'Translators...':
+ '\u00dcbersetzer',
+ 'License':
+ 'Lizenz',
+ 'current module versions:':
+ 'Komponenten-Versionen',
+ 'Contributors':
+ 'Mitwirkende',
+ 'Translations':
+ '\u00dcbersetzungen',
+
+ // variable watchers
+ 'normal':
+ 'normal',
+ 'large':
+ 'gro\u00df',
+ 'slider':
+ 'Regler',
+ 'slider min...':
+ 'Minimalwert...',
+ 'slider max...':
+ 'Maximalwert...',
+ 'import...':
+ 'Importieren...',
+ 'Slider minimum value':
+ 'Minimalwert des Reglers',
+ 'Slider maximum value':
+ 'Maximalwert des Reglers',
+
+ // list watchers
+ 'length: ':
+ 'L\u00e4nge: ',
+
+ // coments
+ 'add comment here...':
+ 'Anmerkung hier hinzuf\u00fcgen',
+
+ // drow downs
+ // directions
+ '(90) right':
+ '(90) rechts',
+ '(-90) left':
+ '(-90) links',
+ '(0) up':
+ '(0) oben',
+ '(180) down':
+ '(180) unten',
+
+ // collision detection
+ 'mouse-pointer':
+ 'Mauszeiger',
+ 'edge':
+ 'Kante',
+ 'pen trails':
+ 'Malspuren',
+
+ // costumes
+ 'Turtle':
+ 'Richtungszeiger',
+ 'Empty':
+ 'Leer',
+
+ // graphical effects
+ 'brightness':
+ 'Helligeit',
+ 'ghost':
+ 'Durchsichtigkeit',
+ 'negative':
+ 'Farbumkehr',
+ 'comic':
+ 'Moire',
+ 'confetti':
+ 'Farbverschiebung',
+
+ // keys
+ 'space':
+ 'Leertaste',
+ 'up arrow':
+ 'Pfeil nach oben',
+ 'down arrow':
+ 'Pfeil nach unten',
+ 'right arrow':
+ 'Pfeil nach rechts',
+ 'left arrow':
+ 'Pfeil nach links',
+ 'a':
+ 'a',
+ 'b':
+ 'b',
+ 'c':
+ 'c',
+ 'd':
+ 'd',
+ 'e':
+ 'e',
+ 'f':
+ 'f',
+ 'g':
+ 'g',
+ 'h':
+ 'h',
+ 'i':
+ 'i',
+ 'j':
+ 'j',
+ 'k':
+ 'k',
+ 'l':
+ 'l',
+ 'm':
+ 'm',
+ 'n':
+ 'n',
+ 'o':
+ 'o',
+ 'p':
+ 'p',
+ 'q':
+ 'q',
+ 'r':
+ 'r',
+ 's':
+ 's',
+ 't':
+ 't',
+ 'u':
+ 'u',
+ 'v':
+ 'v',
+ 'w':
+ 'w',
+ 'x':
+ 'x',
+ 'y':
+ 'y',
+ 'z':
+ 'z',
+ '0':
+ '0',
+ '1':
+ '1',
+ '2':
+ '2',
+ '3':
+ '3',
+ '4':
+ '4',
+ '5':
+ '5',
+ '6':
+ '6',
+ '7':
+ '7',
+ '8':
+ '8',
+ '9':
+ '9',
+
+ // messages
+ 'new...':
+ 'Neu...',
+
+ // math functions
+ 'abs':
+ 'Betrag',
+ 'floor':
+ 'Abgerundet',
+ 'sqrt':
+ 'Wurzel',
+ 'sin':
+ 'sin',
+ 'cos':
+ 'cos',
+ 'tan':
+ 'tan',
+ 'asin':
+ 'asin',
+ 'acos':
+ 'acos',
+ 'atan':
+ 'atan',
+ 'ln':
+ 'ln',
+ 'e^':
+ 'e^',
+
+ // delimiters
+ 'letter':
+ 'Buchstabe',
+ 'whitespace':
+ 'Leerraum',
+ 'line':
+ 'Zeilenvorschub',
+ 'tab':
+ 'Tabulator',
+ 'cr':
+ 'Wagenr\u00fccklauf',
+
+ // data types
+ 'number':
+ 'Zahl',
+ 'text':
+ 'Text',
+ 'Boolean':
+ 'Boole',
+ 'list':
+ 'Liste',
+ 'command':
+ 'Befehlsblock',
+ 'reporter':
+ 'Funktionsblock',
+ 'predicate':
+ 'Pr\u00e4dikat',
+
+ // list indices
+ 'last':
+ 'letztes',
+ 'any':
+ 'beliebiges'
+};
diff --git a/lang-ta.js b/lang-ta.js new file mode 100644 index 0000000..c672e91 --- /dev/null +++ b/lang-ta.js @@ -0,0 +1,1283 @@ +/* + + lang-de.js + + German translation for SNAP! + + written by Jens Mönig + + Copyright (C) 2014 by Jens Mönig + + This file is part of Snap!. + + Snap! is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + + + Note to Translators: + -------------------- + At this stage of development, Snap! can be translated to any LTR language + maintaining the current order of inputs (formal parameters in blocks). + + Translating Snap! is easy: + + + 1. Download + + Download the sources and extract them into a local folder on your + computer: + + <http://snap.berkeley.edu/snapsource/snap.zip> + + Use the German translation file (named 'lang-de.js') as template for your + own translations. Start with editing the original file, because that way + you will be able to immediately check the results in your browsers while + you're working on your translation (keep the local copy of snap.html open + in your web browser, and refresh it as you progress with your + translation). + + + 2. Edit + + Edit the translation file with a regular text editor, or with your + favorite JavaScript editor. + + In the first non-commented line (the one right below this + note) replace "de" with the two-letter ISO 639-1 code for your language, + e.g. + + fr - French => SnapTranslator.dict.fr = { + it - Italian => SnapTranslator.dict.it = { + pl - Polish => SnapTranslator.dict.pl = { + pt - Portuguese => SnapTranslator.dict.pt = { + es - Spanish => SnapTranslator.dict.es = { + el - Greek => => SnapTranslator.dict.el = { + + etc. (see <http://en.wikipedia.org/wiki/ISO_639-1>) + + + 3. Translate + + Then work through the dictionary, replacing the German strings against + your translations. The dictionary is a straight-forward JavaScript ad-hoc + object, for review purposes it should be formatted as follows: + + { + 'English string': + 'Translation string', + 'last key': + } 'last value' + + and you only edit the indented value strings. Note that each key-value + pair needs to be delimited by a comma, but that there shouldn't be a comma + after the last pair (again, just overwrite the template file and you'll be + fine). + + If something doesn't work, or if you're unsure about the formalities you + should check your file with + + <http://JSLint.com> + + This will inform you about any missed commas etc. + + + 4. Accented characters + + Depending on which text editor and which file encoding you use you can + directly enter special characters (e.g. Umlaut, accented characters) on + your keyboard. However, I've noticed that some browsers may not display + special characters correctly, even if other browsers do. So it's best to + check your results in several browsers. If you want to be on the safe + side, it's even better to escape these characters using Unicode. + + see: <http://0xcc.net/jsescape/> + + + 5. Block specs: + + At this time your translation of block specs will only work + correctly, if the order of formal parameters and their types + are unchanged. Placeholders for inputs (formal parameters) are + indicated by a preceding % prefix and followed by a type + abbreviation. + + For example: + + 'say %s for %n secs' + + can currently not be changed into + + 'say %n secs long %s' + + and still work as intended. + + Similarly + + 'point towards %dst' + + cannot be changed into + + 'point towards %cst' + + without breaking its functionality. + + + 6. Submit + + When you're done, rename the edited file by replacing the "de" part of the + filename with the two-letter ISO 639-1 code for your language, e.g. + + fr - French => lang-fr.js + it - Italian => lang-it.js + pl - Polish => lang-pl.js + pt - Portuguese => lang-pt.js + es - Spanish => lang-es.js + el - Greek => => lang-el.js + + and send it to me for inclusion in the official Snap! distribution. + Once your translation has been included, Your name will the shown in the + "Translators" tab in the "About Snap!" dialog box, and you will be able to + directly launch a translated version of Snap! in your browser by appending + + lang:xx + + to the URL, xx representing your translations two-letter code. + + + 7. Known issues + + In some browsers accents or ornaments located in typographic ascenders + above the cap height are currently (partially) cut-off. + + Enjoy! + -Jens +*/ + +/*global SnapTranslator*/ + +SnapTranslator.dict.ta = { + +/* + Special characters: (see <http://0xcc.net/jsescape/>) + + Ä, ä \u00c4, \u00e4 + Ö, ö \u00d6, \u00f6 + Ü, ü \u00dc, \u00fc + ß \u00df +*/ + + // translations meta information + 'language_name': + 'Tamil', // the name as it should appear in the language menu + 'language_translator': + 'vinayakumar R', // your name for the Translators tab + 'translator_e-mail': + 'vnkmr7620@gmail.com', // optional + 'last_changed': + '2015-02-20', // this, too, will appear in the Translators tab + + // GUI + // control bar: + 'untitled': + 'Unbenannt', + 'development mode': + 'Hackermodus', + + // categories: + 'Motion': + 'நகர்ச்ச', + 'Looks': + 'தோற்றம்', + 'Sound': + 'ஒல', + 'Pen': + 'பேனா', + 'Control': + 'கன்ட்ரொல்', + 'Sensing': + 'உணருதல்', + 'Operators': + 'ஆபரேட்டர்கள்', + 'Variables': + 'வேரியபில்கள்', + 'Lists': + 'பட்டியல்', + 'Other': + 'Andere', + + // editor: + 'draggable': + 'greifbar', + + // tabs: + 'Scripts': + 'Skripte', + 'Costumes': + 'உடைகள்', + 'Sounds': + 'ஒலஒல', + + // names: + 'Sprite': + 'Objekt', + 'Stage': + 'மேட', + + // rotation styles: + 'don\'t rotate': + 'சுழற்றாத', + 'can rotate': + 'சுழற்ற முடியும்', + 'only face left/right': + 'kann sich nur nach\nlinks/rechts drehen', + + // new sprite button: + 'add a new sprite': + 'ein neues Objekt\nhinzuf\u00fcgen', + + // tab help + 'costumes tab help': + 'Bilder durch hereinziehen von einer anderen\n' + + 'Webseite or vom Computer importieren', + 'import a sound from your computer\nby dragging it into here': + 'Kl\u00e4nge durch hereinziehen importieren', + + // primitive blocks: + + /* + Attention Translators: + ---------------------- + At this time your translation of block specs will only work + correctly, if the order of formal parameters and their types + are unchanged. Placeholders for inputs (formal parameters) are + indicated by a preceding % prefix and followed by a type + abbreviation. + + For example: + + 'say %s for %n secs' + + can currently not be changed into + + 'say %n secs long %s' + + and still work as intended. + + Similarly + + 'point towards %dst' + + cannot be changed into + + 'point towards %cst' + + without breaking its functionality. + */ + + // motion: + 'Stage selected:\nno motion primitives': + 'B\u00fchne ausgew\u00e4hlt:\nkeine Standardbewegungsbl\u00f6cke\n' + + 'vorhanden', + + 'move %n steps': + '%n அடிகள் நகரவும்', + 'turn %clockwise %n degrees': + 'drehe %clockwise %n Grad', + 'turn %counterclockwise %n degrees': + 'drehe %counterclockwise %n Grad', + 'point in direction %dir': + '%dir திசையை சுட்டிக்கட்டவும்', + 'point towards %dst': + '%dst நோக்கி சுட்டிக்கட்டவும்', + 'go to x: %n y: %n': + 'x: %n y: %n க்கு செல்லவும்', + 'go to %dst': + '%dst க்கு செல்லவும்', + 'glide %n secs to x: %n y: %n': + 'gleite %n Sek. zu x: %n y: %n', + 'change x by %n': + 'x %n அளவு மாற்றவும்', + 'set x to %n': + 'x %n ஆக்கவும்', + 'change y by %n': + 'y %n அளவு மாற்றவும்', + 'set y to %n': + 'y %n ஆக்கவும்', + 'if on edge, bounce': + 'pralle vom Rand ab', + 'x position': + 'x இடம்', + 'y position': + 'y இடம்', + 'direction': + 'திச', + + // looks: + 'switch to costume %cst': + '%cst உடைக்கு மாற்ற', + 'next costume': + 'அடுத்த உட', + 'costume #': + 'உட #', + 'say %s for %n secs': + '%n விநாடிகள் %s சொல்', + 'say %s': + '%s சொல்', + 'think %s for %n secs': + '%n விநாடிகள் %s யோச', + 'think %s': + '%s யோச', + 'Hello!': + 'வணக்கம்!', + 'Hmm...': + 'Hmm...', + 'change %eff effect by %n': + '\u00e4ndere %eff -Effekt um %n', + 'set %eff effect to %n': + 'setze %eff -Effekt auf %n', + 'clear graphic effects': + 'க்ராபிக்ஸ் எபெக்ட்டை அழித்து விடு', + 'change size by %n': + 'கன அளவை %n அளவு மாற்றவும்', + 'set size to %n %': + 'கனம் %n % ஆக்கவும்', + 'size': + 'பரிமாணம்', + 'show': + 'காண்ப', + 'hide': + 'மறைக்கவும்', + 'go to front': + 'முன் செல்லவும்', + 'go back %n layers': + '%n அடுக்குகள் பின்னால் செல்லவும்', + + 'development mode \ndebugging primitives:': + 'Hackermodus \nDebugging-Bl\u00f6cke', + 'console log %mult%s': + 'schreibe in die Konsole: %mult%s', + 'alert %mult%s': + 'Pop-up: %mult%s', + + // sound: + 'play sound %snd': + '%snd ஒலிக்கவும்', + 'play sound %snd until done': + 'நிற்க்கும் வரை %snd ஒலிக்கவும்', + 'stop all sounds': + 'எல்லா ஒலிகளையும் நிருத்த', + 'rest for %n beats': + '%n தாள தட்டு காத்திருக்கவும்', + 'play note %n for %n beats': + '%n ஸ்வரம் %n தாள தட்டு வாசிக்கவும்', + 'change tempo by %n': + '%n அளவு தாளத்தை மாற்றவும்', + 'set tempo to %n bpm': + 'தாளம் %n bpm ஆக்கவும்', + 'tempo': + 'தாளம்', + + // pen: + 'clear': + 'அழ', + 'pen down': + 'பேனா கீழே', + 'pen up': + 'பேனா மேல', + 'set pen color to %clr': + 'பேனா நிரம் %clr ஆக்கவும்', + 'change pen color by %n': + 'பேனா நிறத்தை %n அளவு மாற்றவும்', + 'set pen color to %n': + 'பேனா நிரம் %n ஆக்கவும்', + 'change pen shade by %n': + 'பேனா ஷெடை %n அளவு மாற்றவும்', + 'set pen shade to %n': + 'பேனா ஷேட் %n ஆக்கவும்', + 'change pen size by %n': + 'பேனா கன அளவை %n அளவு மாற்றவும்', + 'set pen size to %n': + 'பேனா கனம் %n ஆக்கவும்', + 'stamp': + 'அச்சு', + + // control: + 'when %greenflag clicked': + '%greenflag அழுத்தும்பொழுது', + 'when %keyHat key pressed': + '%keyHat கீ அழுத்தும்பொழுது', + 'when I am clicked': + 'Wenn ich angeklickt werde', + 'when I receive %msgHat': + '%msgHat பெறுகையில்', + 'broadcast %msg': + '%msg செலித்தி', + 'broadcast %msg and wait': + '%msg செலித்தி காத்திருக்கவும்', + 'Message name': + 'Nachricht', + 'message': + 'Nachricht', + 'any message': + 'eine beliebige Nachricht', + 'wait %n secs': + '%n விநாடிகள் காத்திருக்கவும்', + 'wait until %b': + '%b வரை காத்திருக்கவும்', + 'forever %c': + 'எப்போதும் %c', + 'repeat %n %c': + 'திரும்பச்செய் %n %c', + 'repeat until %b %c': + '%b %c வரை திரும்பச்செய்', + 'if %b %c': + '%b %c என்றால்', + 'if %b %c else %c': + '%b என்றால் அல்லது %c', + 'report %s': + 'berichte %s', + 'stop %stopChoices': + 'நிருத்து %stopChoices', + 'all': + 'alles', + 'this script': + 'இந்த ச்கிரிப்ட்ட', + 'this block': + 'diesen Block', + 'stop %stopOthersChoices': + 'stoppe %stopOthersChoices', + 'all but this script': + 'alles au\u00dfer diesem Skript', + 'other scripts in sprite': + 'andere Skripte in diesem Objekt', + 'pause all %pause': + 'pausiere alles %pause', + 'run %cmdRing %inputs': + 'f\u00fchre %cmdRing aus %inputs', + 'launch %cmdRing %inputs': + 'starte %cmdRing %inputs', + 'call %repRing %inputs': + 'rufe %repRing auf %inputs', + 'run %cmdRing w/continuation': + 'f\u00fchre %cmdRing mit Continuation aus', + 'call %cmdRing w/continuation': + 'rufe %cmdRing mit Continuation auf', + 'warp %c': + 'Warp %c', + 'when I start as a clone': + 'Wenn ich geklont werde', + 'create a clone of %cln': + 'klone %cln', + 'myself': + 'mich', + 'delete this clone': + 'entferne diesen Klon', + + // sensing: + 'touching %col ?': + 'தொடுகிரதா %col ?', + 'touching %clr ?': + 'தொடுகிரதா %clr ?', + 'color %clr is touching %clr ?': + '%clr கலர் %clr யை தொடுகிரதா?', + 'ask %s and wait': + '%s காத்திருக்க சொல்', + 'what\'s your name?': + 'உங்கள் பெயர் என்ன ?', + 'answer': + 'பதில்', + 'mouse x': + 'மவுஸ் x', + 'mouse y': + 'மவுஸ் y', + 'mouse down?': + 'Maustaste gedr\u00fcckt?', + 'key %key pressed?': + '%key கீ அழுத்தி இருக்கிரதா', + 'distance to %dst': + '%dst வரை தூரம்', + 'reset timer': + 'டைமெர் ரீசெட்', + 'timer': + 'டைமெர்', + '%att of %spr': + '%att von %spr', + 'http:// %s': + 'http:// %s', + 'turbo mode?': + 'Turbomodus?', + 'set turbo mode to %b': + 'setze Turbomodus auf %b', + + 'filtered for %clr': + 'nach %clr gefiltert', + 'stack size': + 'Stapelgr\u00f6\u00dfe', + 'frames': + 'Rahmenz\u00e4hler', + + // operators: + '%n mod %n': + '%n மாட் %n', + 'round %n': + '%n gerundet', + '%fun of %n': + '%fun ன் %n', + 'pick random %n to %n': + 'Zufallszahl von %n bis %n', + '%b and %b': + '%b மற்றும் %b', + '%b or %b': + '%b அல்லத %b', + 'not %b': + 'இல்ல %b', + 'true': + 'சர', + 'false': + 'தவறு', + 'join %words': + 'சேர்க்கவும் %words', + 'split %s by %delim': + 'trenne %s nach %delim', + 'hello': + 'வணக்கம்', + 'world': + 'உலகம்', + 'letter %n of %s': + '%s ன் %n வது எழுத்து', + 'length of %s': + '%s ன் நீளம்', + 'unicode of %s': + 'Unicode Wert von %s', + 'unicode %n as letter': + 'Unicode %n als Buchstabe', + 'is %s a %typ ?': + 'ist %s ein(e) %typ ?', + 'is %s identical to %s ?': + 'ist %s identisch mit %s ?', + + 'type of %s': + 'Typ von %s', + + // variables: + 'Make a variable': + 'வேரியபில் செய்', + 'Variable name': + 'மாறிழியின் பெயர்', + 'Script variable name': + 'ச்கிரிப்ட்ட மாறிழியின் பெயர்', + 'Delete a variable': + 'வேரியபில் அழி', + + 'set %var to %s': + '%var %n ஆக்கவும்', + 'change %var by %n': + '%var %n அளவு மாற்றவும்', + 'show variable %var': + '%var வேரியபிலை காண்பி', + 'hide variable %var': + '%var வேரியபிலை மறைக்கவும்', + 'script variables %scriptVars': + 'Skriptvariablen %scriptVars', + + // lists: + 'list %exp': + 'Liste %exp', + '%s in front of %l': + '%s am Anfang von %l', + 'item %idx of %l': + 'Element %idx von %l', + 'all but first of %l': + 'alles au\u00dfer dem ersten von %l', + 'length of %l': + 'L\u00e4nge von %l', + '%l contains %s': + '%l enth\u00e4lt %s', + 'thing': + 'etwas', + 'add %s to %l': + 'f\u00fcge %s zu %l hinzu', + 'delete %ida of %l': + 'entferne %ida aus %l', + 'insert %s at %idx of %l': + 'f\u00fcge %s als %idx in %l ein', + 'replace item %idx of %l with %s': + 'ersetze Element %idx in %l durch %s', + + // other + 'Make a block': + 'Neuer Block', + + // menus + // snap menu + 'About...': + '\u00dcber Snap!...', + 'Reference manual': + 'Handbuch lesen', + 'Snap! website': + 'Snap! Webseite', + 'Download source': + 'Quellcode runterladen', + 'Switch back to user mode': + 'zur\u00fcck zum Benutzermodus', + 'disable deep-Morphic\ncontext menus\nand show user-friendly ones': + 'verl\u00e4sst Morphic', + 'Switch to dev mode': + 'zum Hackermodus wechseln', + 'enable Morphic\ncontext menus\nand inspectors,\nnot user-friendly!': + 'erm\u00f6glicht Morphic Funktionen', + + // project menu + 'Project notes...': + 'Projektanmerkungen...', + 'New': + 'புதிய புதிய பின்னணி', + 'Open...': + 'திறக்க...', + 'Save': + 'சேம', + 'Save As...': + 'எனச் சேம...', + 'Import...': + 'Importieren...', + 'file menu import hint': + 'l\u00e4dt ein exportiertes Projekt,\neine Bibliothek mit ' + + 'Bl\u00f6cken\n' + + 'ein Kost\u00fcm oder einen Klang', + 'Export project as plain text...': + 'Projekt als normalen Text exportieren...', + 'Export project...': + 'Projekt exportieren...', + 'show project data as XML\nin a new browser window': + 'zeigt das Projekt als XML\nin einem neuen Browserfenster an', + 'Export blocks...': + 'Bl\u00f6cke exportieren...', + 'show global custom block definitions as XML\nin a new browser window': + 'zeigt globale Benutzerblockdefinitionen\nals XML im Browser an', + 'Import tools': + 'Tools laden', + 'load the official library of\npowerful blocks': + 'das offizielle Modul mit\nm\u00e4chtigen Bl\u00f6cken laden', + 'Libraries...': + 'Module...', + 'Import library': + 'Modul laden', + + // cloud menu + 'Login...': + 'Anmelden...', + 'Signup...': + 'Benutzerkonto einrichten...', + + // settings menu + 'Language...': + 'மொழ...', + 'Zoom blocks...': + 'Bl\u00f6cke vergr\u00f6\u00dfern...', + 'Stage size...': + 'B\u00fchnengr\u00f6\u00dfe...', + 'Stage size': + 'B\u00fchnengr\u00f6\u00dfe', + 'Stage width': + 'B\u00fchnenbreite', + 'Stage height': + 'B\u00fchnenh\u00f6he', + 'Default': + 'Normal', + 'Blurred shadows': + 'Weiche Schatten', + 'uncheck to use solid drop\nshadows and highlights': + 'abschalten f\u00fcr harte Schatten\nund Beleuchtung', + 'check to use blurred drop\nshadows and highlights': + 'einschalten f\u00fcr harte Schatten\nund Beleuchtung', + 'Zebra coloring': + 'Zebrafarben', + 'check to enable alternating\ncolors for nested blocks': + 'einschalten \u00fcr abwechselnde Farbnuancen\nin Bl\u00f6cken', + 'uncheck to disable alternating\ncolors for nested block': + 'ausschalten verhindert abwechselnde\nFarbnuancen in Bl\u00f6cken', + 'Dynamic input labels': + 'Eingabenbeschriftung', + 'uncheck to disable dynamic\nlabels for variadic inputs': + 'ausschalten verhindert Beschriftung\nvon Mehrfacheingaben', + 'check to enable dynamic\nlabels for variadic inputs': + 'einschalten um Mehrfacheingabefelder\nautomatisch zu beschriften', + 'Prefer empty slot drops': + 'Leere Platzhalter bevorzugen', + 'settings menu prefer empty slots hint': + 'einschalten um leere Platzhalter\nbeim Platzieren von Bl\u00f6cken' + + 'zu bevorzugen', + 'uncheck to allow dropped\nreporters to kick out others': + 'ausschalten um das "Rauskicken"\nvon platzierten Bl\u00f6cken\n' + + 'zu erm\u00f6glichen', + 'Long form input dialog': + 'Ausf\u00fchrlicher Input-Dialog', + 'Plain prototype labels': + 'Einfache Prototyp-Beschriftung', + 'uncheck to always show (+) symbols\nin block prototype labels': + 'ausschalten, um (+) Zeichen\nim Blockeditor zu verbergen', + 'check to hide (+) symbols\nin block prototype labels': + 'einschalten, um (+) Zeichen\nim Blockeditor immer anzuzeigen', + 'check to always show slot\ntypes in the input dialog': + 'einschalten, um immer die Datentypen\nim Input-Dialog zu sehen', + 'uncheck to use the input\ndialog in short form': + 'ausschalten f\u00fcr kurzen\nInput-Dialog', + 'Virtual keyboard': + 'Virtuelle Tastatur', + 'uncheck to disable\nvirtual keyboard support\nfor mobile devices': + 'ausschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n' + + 'zu sperren', + 'check to enable\nvirtual keyboard support\nfor mobile devices': + 'einschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n' + + 'zu erm\u00f6glichen', + 'Input sliders': + 'Eingabeschieber', + 'uncheck to disable\ninput sliders for\nentry fields': + 'ausschalten um Schieber\nin Eingabefeldern zu verhindern', + 'check to enable\ninput sliders for\nentry fields': + 'einschalten um Schieber\nin Eingabefeldern zu aktivieren', + 'Clicking sound': + 'Akustisches Klicken', + 'uncheck to turn\nblock clicking\nsound off': + 'ausschalten um akustisches\nKlicken zu deaktivieren', + 'check to turn\nblock clicking\nsound on': + 'einschalten um akustisches\nKlicken zu aktivieren', + 'Animations': + 'Animationen', + 'uncheck to disable\nIDE animations': + 'ausschalten um IDE-\nAnimationen zu verhindern', + 'Turbo mode': + 'Turbomodus', + 'check to prioritize\nscript execution': + 'einschalten, um Skripte\nzu priorisieren', + 'uncheck to run scripts\nat normal speed': + 'ausschalten, um Skripte\nnormal auszuf\u00fchren', + 'check to enable\nIDE animations': + 'einschalten um IDE-\nAnimationen zu erlauben', + 'Thread safe scripts': + 'Threadsicherheit', + 'uncheck to allow\nscript reentrance': + 'verhindert, dass unvollendete\nSkripte erneut gestartet werden', + 'check to disallow\nscript reentrance': + 'verhindert, dass unvollendete\nSkripte erneut gestartet werden', + 'Prefer smooth animations': + 'Fixe Framerate', + 'uncheck for greater speed\nat variable frame rates': + 'ausschalten, um Animationen \ndynamischer auszuf\u00fchren', + 'check for smooth, predictable\nanimations across computers': + 'einschalten, damit Animationen\n\u00fcberall gleich laufen', + 'Flat line ends': + 'Flache Pinselstriche', + 'check for flat ends of lines': + 'einschalten f\u00fcr flache\nPinselstrichenden', + 'uncheck for round ends of lines': + 'auschalten f\u00fcr runde\nPinselstrichenden', + + // inputs + 'with inputs': + 'mit Eingaben', + 'input names:': + 'Eingaben:', + 'Input Names:': + 'Eingaben:', + 'input list:': + 'Eingabeliste:', + + // context menus: + 'help': + 'Hilfe', + + // palette: + 'hide primitives': + 'Basisbl\u00f6cke ausblenden', + 'show primitives': + 'Basisbl\u00f6cke anzeigen', + + // blocks: + 'help...': + 'உதவ...', + 'relabel...': + 'Umbenennen...', + 'duplicate': + 'நகல் செய்', + 'make a copy\nand pick it up': + 'eine Kopie aufnehmen', + 'only duplicate this block': + 'nur diesen Block duplizieren', + 'delete': + 'அழ', + 'script pic...': + 'Skriptbild...', + 'open a new window\nwith a picture of this script': + 'ein neues Browserfenster mit einem\nBild dieses Skripts \u00f6ffnen', + 'ringify': + 'Umringen', + 'unringify': + 'Entringen', + + // custom blocks: + 'delete block definition...': + 'Blockdefinition l\u00f6schen', + 'edit...': + 'Bearbeiten...', + + // sprites: + 'edit': + 'திருத்த', + 'move': + 'நகர்த்து', + 'detach from': + 'Abtrennen von', + 'detach all parts': + 'Alle Teile abtrennen', + 'export...': + 'Exportieren...', + + // stage: + 'show all': + 'Alles zeigen', + 'pic...': + 'Bild exportieren...', + 'open a new window\nwith a picture of the stage': + 'ein neues Browserfenster mit einem\nBild der B\u00fchne \u00f6ffnen', + + // scripting area + 'clean up': + 'சுத்தம் செய்', + 'arrange scripts\nvertically': + 'Skripte der Reihe nach\nanordnen', + 'add comment': + 'Anmerkung hinzuf\u00fcgen', + 'undrop': + 'R\u00fcckg\u00e4ngig', + 'undo the last\nblock drop\nin this pane': + 'Setzen des letzten Blocks\nwiderrufen', + 'scripts pic...': + 'Bild aller Scripte...', + 'open a new window\nwith a picture of all scripts': + 'ein neues Browserfenster mit einem\nBild aller Skripte \u00f6ffnen', + 'make a block...': + 'Neuen Block bauen...', + + // costumes + 'rename': + 'Umbenennen', + 'export': + 'Exportieren', + 'rename costume': + 'Kost\u00fcm umbenennen', + + // sounds + 'Play sound': + 'Klang\nabspielen', + 'Stop sound': + 'Klang\nanhalten', + 'Stop': + 'நிறுத்த', + 'Play': + 'Los', + 'rename sound': + 'Klang umbenennen', + + // dialogs + // buttons + 'OK': + 'சர', + 'Ok': + 'சர', + 'Cancel': + 'கென்செல்', + 'Yes': + 'ஆம்', + 'No': + 'இல்ல', + + // help + 'Help': + 'உதவ', + + // zoom blocks + 'Zoom blocks': + 'Bl\u00f6cke vergr\u00f6\u00dfern', + 'build': + 'baue', + 'your own': + 'eigene', + 'blocks': + 'Bl\u00f6cke', + 'normal (1x)': + 'normal (1x)', + 'demo (1.2x)': + 'Demo (1.2x)', + 'presentation (1.4x)': + 'Pr\u00e4sentation (1.4x)', + 'big (2x)': + 'gro\u00df (2x)', + 'huge (4x)': + 'riesig (4x)', + 'giant (8x)': + 'gigantisch (8x)', + 'monstrous (10x)': + 'ungeheuerlich (10x)', + + // Project Manager + 'Untitled': + 'Unbenannt', + 'Open Project': + 'Project \u00f6ffnen', + '(empty)': + '(leer)', + 'Saved!': + 'Gesichert!', + 'Delete Project': + 'Projekt l\u00f6schen', + 'Are you sure you want to delete': + 'Wirklich l\u00f6schen?', + 'rename...': + 'Umbenennen...', + + // costume editor + 'Costume Editor': + 'Kost\u00fcmeditor', + 'click or drag crosshairs to move the rotation center': + 'Fadenkreuz anklicken oder bewegen um den Drehpunkt zu setzen', + + // project notes + 'Project Notes': + 'Projektanmerkungen', + + // new project + 'New Project': + 'Neues Projekt', + 'Replace the current project with a new one?': + 'Das aktuelle Projekt durch ein neues ersetzen?', + + // save project + 'Save Project As...': + 'Projekt Sichern Als...', + + // export blocks + 'Export blocks': + 'Bl\u00f6cke exportieren', + 'Import blocks': + 'Bl\u00f6cke importieren', + 'this project doesn\'t have any\ncustom global blocks yet': + 'in diesem Projekt gibt es noch keine\nglobalen Bl\u00f6cke', + 'select': + 'ausw\u00e4hlen', + 'none': + 'nichts', + + // variable dialog + 'for all sprites': + 'f\u00fcr alle', + 'for this sprite only': + 'nur f\u00fcr dieses Objekt', + + // block dialog + 'Change block': + 'Block ver\u00e4ndern', + 'Command': + 'Befehl', + 'Reporter': + 'Funktion', + 'Predicate': + 'Pr\u00e4dikat', + + // block editor + 'Block Editor': + 'Blockeditor', + 'Apply': + 'Anwenden', + + // block deletion dialog + 'Delete Custom Block': + 'Block L\u00f6schen', + 'block deletion dialog text': + 'Soll dieser Block mit allen seinen Exemplare\n' + + 'wirklich gel\u00f6scht werden?', + + // input dialog + 'Create input name': + 'Eingabe erstellen', + 'Edit input name': + 'Eingabe bearbeiten', + 'Edit label fragment': + 'Beschriftung bearbeiten', + 'Title text': + 'Beschriftung', + 'Input name': + 'Eingabe', + 'Delete': + 'L\u00f6schen', + 'Object': + 'Objekt', + 'Number': + 'Zahl', + 'Text': + 'Text', + 'List': + 'Liste', + 'Any type': + 'Beliebig', + 'Boolean (T/F)': + 'Boolsch (W/F)', + 'Command\n(inline)': + 'Befehl', + 'Command\n(C-shape)': + 'Befehl\n(C-Form)', + 'Any\n(unevaluated)': + 'Beliebig\n(zitiert)', + 'Boolean\n(unevaluated)': + 'Boolsch\n(zitiert)', + 'Single input.': + 'Einzeleingabe.', + 'Default Value:': + 'Standardwert:', + 'Multiple inputs (value is list of inputs)': + 'Mehrere Eingaben (als Liste)', + 'Upvar - make internal variable visible to caller': + 'Interne Variable au\u00dfen sichtbar machen', + + // About Snap + 'About Snap': + '\u00dcber Snap', + 'Back...': + 'Zur\u00fcck...', + 'License...': + 'Lizenz...', + 'Modules...': + 'Komponenten...', + 'Credits...': + 'Mitwirkende...', + 'Translators...': + '\u00dcbersetzer', + 'License': + 'Lizenz', + 'current module versions:': + 'Komponenten-Versionen', + 'Contributors': + 'Mitwirkende', + 'Translations': + '\u00dcbersetzungen', + + // variable watchers + 'normal': + 'normal', + 'large': + 'gro\u00df', + 'slider': + 'Regler', + 'slider min...': + 'Minimalwert...', + 'slider max...': + 'Maximalwert...', + 'import...': + 'Importieren...', + 'Slider minimum value': + 'Minimalwert des Reglers', + 'Slider maximum value': + 'Maximalwert des Reglers', + + // list watchers + 'length: ': + 'L\u00e4nge: ', + + // coments + 'add comment here...': + 'Anmerkung hier hinzuf\u00fcgen', + + // drow downs + // directions + '(90) right': + '(90) rechts', + '(-90) left': + '(-90) links', + '(0) up': + '(0) oben', + '(180) down': + '(180) unten', + + // collision detection + 'mouse-pointer': + 'Mauszeiger', + 'edge': + 'Kante', + 'pen trails': + 'Malspuren', + + // costumes + 'Turtle': + 'Richtungszeiger', + 'Empty': + 'Leer', + + // graphical effects + 'brightness': + 'Helligeit', + 'ghost': + 'Durchsichtigkeit', + 'negative': + 'Farbumkehr', + 'comic': + 'Moire', + 'confetti': + 'Farbverschiebung', + + // keys + 'space': + 'இடைவெள', + 'up arrow': + 'மேல் அம்புக்குற', + 'down arrow': + 'Pfeil nach unten', + 'right arrow': + 'வலது அம்புக்குற', + 'left arrow': + 'Pfeil nach links', + 'a': + 'a', + 'b': + 'b', + 'c': + 'c', + 'd': + 'd', + 'e': + 'e', + 'f': + 'f', + 'g': + 'g', + 'h': + 'h', + 'i': + 'i', + 'j': + 'j', + 'k': + 'k', + 'l': + 'l', + 'm': + 'm', + 'n': + 'n', + 'o': + 'o', + 'p': + 'p', + 'q': + 'q', + 'r': + 'r', + 's': + 's', + 't': + 't', + 'u': + 'u', + 'v': + 'v', + 'w': + 'w', + 'x': + 'x', + 'y': + 'y', + 'z': + 'z', + '0': + '0', + '1': + '1', + '2': + '2', + '3': + '3', + '4': + '4', + '5': + '5', + '6': + '6', + '7': + '7', + '8': + '8', + '9': + '9', + + // messages + 'new...': + 'Neu...', + + // math functions + 'abs': + 'Betrag', + 'floor': + 'Abgerundet', + 'sqrt': + 'Wurzel', + 'sin': + 'sin', + 'cos': + 'cos', + 'tan': + 'tan', + 'asin': + 'asin', + 'acos': + 'acos', + 'atan': + 'atan', + 'ln': + 'ln', + 'e^': + 'e^', + + // delimiters + 'letter': + 'Buchstabe', + 'whitespace': + 'Leerraum', + 'line': + 'Zeilenvorschub', + 'tab': + 'Tabulator', + 'cr': + 'Wagenr\u00fccklauf', + + // data types + 'number': + 'Zahl', + 'text': + 'Text', + 'Boolean': + 'Boole', + 'list': + 'Liste', + 'command': + 'Befehlsblock', + 'reporter': + 'Funktionsblock', + 'predicate': + 'Pr\u00e4dikat', + + // list indices + 'last': + 'letztes', + 'any': + 'beliebiges' +}; diff --git a/lang-te.js b/lang-te.js new file mode 100644 index 0000000..bd1c5dd --- /dev/null +++ b/lang-te.js @@ -0,0 +1,1283 @@ +/* + + lang-de.js + + German translation for SNAP! + + written by Jens Mönig + + Copyright (C) 2014 by Jens Mönig + + This file is part of Snap!. + + Snap! is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + + + Note to Translators: + -------------------- + At this stage of development, Snap! can be translated to any LTR language + maintaining the current order of inputs (formal parameters in blocks). + + Translating Snap! is easy: + + + 1. Download + + Download the sources and extract them into a local folder on your + computer: + + <http://snap.berkeley.edu/snapsource/snap.zip> + + Use the German translation file (named 'lang-de.js') as template for your + own translations. Start with editing the original file, because that way + you will be able to immediately check the results in your browsers while + you're working on your translation (keep the local copy of snap.html open + in your web browser, and refresh it as you progress with your + translation). + + + 2. Edit + + Edit the translation file with a regular text editor, or with your + favorite JavaScript editor. + + In the first non-commented line (the one right below this + note) replace "de" with the two-letter ISO 639-1 code for your language, + e.g. + + fr - French => SnapTranslator.dict.fr = { + it - Italian => SnapTranslator.dict.it = { + pl - Polish => SnapTranslator.dict.pl = { + pt - Portuguese => SnapTranslator.dict.pt = { + es - Spanish => SnapTranslator.dict.es = { + el - Greek => => SnapTranslator.dict.el = { + + etc. (see <http://en.wikipedia.org/wiki/ISO_639-1>) + + + 3. Translate + + Then work through the dictionary, replacing the German strings against + your translations. The dictionary is a straight-forward JavaScript ad-hoc + object, for review purposes it should be formatted as follows: + + { + 'English string': + 'Translation string', + 'last key': + } 'last value' + + and you only edit the indented value strings. Note that each key-value + pair needs to be delimited by a comma, but that there shouldn't be a comma + after the last pair (again, just overwrite the template file and you'll be + fine). + + If something doesn't work, or if you're unsure about the formalities you + should check your file with + + <http://JSLint.com> + + This will inform you about any missed commas etc. + + + 4. Accented characters + + Depending on which text editor and which file encoding you use you can + directly enter special characters (e.g. Umlaut, accented characters) on + your keyboard. However, I've noticed that some browsers may not display + special characters correctly, even if other browsers do. So it's best to + check your results in several browsers. If you want to be on the safe + side, it's even better to escape these characters using Unicode. + + see: <http://0xcc.net/jsescape/> + + + 5. Block specs: + + At this time your translation of block specs will only work + correctly, if the order of formal parameters and their types + are unchanged. Placeholders for inputs (formal parameters) are + indicated by a preceding % prefix and followed by a type + abbreviation. + + For example: + + 'say %s for %n secs' + + can currently not be changed into + + 'say %n secs long %s' + + and still work as intended. + + Similarly + + 'point towards %dst' + + cannot be changed into + + 'point towards %cst' + + without breaking its functionality. + + + 6. Submit + + When you're done, rename the edited file by replacing the "de" part of the + filename with the two-letter ISO 639-1 code for your language, e.g. + + fr - French => lang-fr.js + it - Italian => lang-it.js + pl - Polish => lang-pl.js + pt - Portuguese => lang-pt.js + es - Spanish => lang-es.js + el - Greek => => lang-el.js + + and send it to me for inclusion in the official Snap! distribution. + Once your translation has been included, Your name will the shown in the + "Translators" tab in the "About Snap!" dialog box, and you will be able to + directly launch a translated version of Snap! in your browser by appending + + lang:xx + + to the URL, xx representing your translations two-letter code. + + + 7. Known issues + + In some browsers accents or ornaments located in typographic ascenders + above the cap height are currently (partially) cut-off. + + Enjoy! + -Jens +*/ + +/*global SnapTranslator*/ + +SnapTranslator.dict.te = { + +/* + Special characters: (see <http://0xcc.net/jsescape/>) + + Ä, ä \u00c4, \u00e4 + Ö, ö \u00d6, \u00f6 + Ü, ü \u00dc, \u00fc + ß \u00df +*/ + + // translations meta information + 'language_name': + 'Telagu', // the name as it should appear in the language menu + 'language_translator': + 'vinayakumar R', // your name for the Translators tab + 'translator_e-mail': + 'vnkmr7620@gmail.com', // optional + 'last_changed': + '2015-02-20', // this, too, will appear in the Translators tab + + // GUI + // control bar: + 'untitled': + 'Unbenannt', + 'development mode': + 'Hackermodus', + + // categories: + 'Motion': + 'చలన', + 'Looks': + 'కనబడ', + 'Sound': + 'శబ్దమ', + 'Pen': + 'పెన్', + 'Control': + 'నియంత్రణ', + 'Sensing': + 'స్పర్శించుట', + 'Operators': + 'చేసేవి', + 'Variables': + 'చరరాశులు', + 'Lists': + 'జాబితా', + 'Other': + 'Andere', + + // editor: + 'draggable': + 'greifbar', + + // tabs: + 'Scripts': + 'ఆజ్ఞ', + 'Costumes': + 'వేషధారణ', + 'Sounds': + 'శబ్దాల', + + // names: + 'Sprite': + 'రూపమ', + 'Stage': + 'వేదిక', + + // rotation styles: + 'don\'t rotate': + 'తిరుగవద్', + 'can rotate': + 'తిరుగ గలద', + 'only face left/right': + 'ముఖం ఎడమ-కుడి వైపు మాత్రమే', + + // new sprite button: + 'add a new sprite': + 'ein neues Objekt\nhinzuf\u00fcgen', + + // tab help + 'costumes tab help': + 'Bilder durch hereinziehen von einer anderen\n' + + 'Webseite or vom Computer importieren', + 'import a sound from your computer\nby dragging it into here': + 'Kl\u00e4nge durch hereinziehen importieren', + + // primitive blocks: + + /* + Attention Translators: + ---------------------- + At this time your translation of block specs will only work + correctly, if the order of formal parameters and their types + are unchanged. Placeholders for inputs (formal parameters) are + indicated by a preceding % prefix and followed by a type + abbreviation. + + For example: + + 'say %s for %n secs' + + can currently not be changed into + + 'say %n secs long %s' + + and still work as intended. + + Similarly + + 'point towards %dst' + + cannot be changed into + + 'point towards %cst' + + without breaking its functionality. + */ + + // motion: + 'Stage selected:\nno motion primitives': + 'B\u00fchne ausgew\u00e4hlt:\nkeine Standardbewegungsbl\u00f6cke\n' + + 'vorhanden', + + 'move %n steps': + '%n అడుగులు జరుగ', + 'turn %clockwise %n degrees': + 'drehe %clockwise %n Grad', + 'turn %counterclockwise %n degrees': + 'drehe %counterclockwise %n Grad', + 'point in direction %dir': + 'బిందువు %dir దిశలో', + 'point towards %dst': + 'బిందువు %dst వైపునక', + 'go to x: %n y: %n': + 'x: %n y: %n కు వెళ్', + 'go to %dst': + '%dst కు వెళ్', + 'glide %n secs to x: %n y: %n': + '%n సెకన్లకు x: %n y: %n జరుగున', + 'change x by %n': + 'x విలువ %n కి మార్', + 'set x to %n': + 'x విలువకు %n పెట్', + 'change y by %n': + 'y విలువ %n కి మార్', + 'set y to %n': + 'y విలువకు %n పెట్', + 'if on edge, bounce': + 'అంచున ఉంటే, దూక', + 'x position': + 'x స్థానం', + 'y position': + 'y స్థానం', + 'direction': + 'దిక్', + + // looks: + 'switch to costume %cst': + 'వేషధారణ %cst కు బదలాయించు', + 'next costume': + 'తదుపరి వేషధారణ', + 'costume #': + 'వేషధారణ #', + 'say %s for %n secs': + '%n సెకన్ల కోసం %s అని చెప్', + 'say %s': + '%s అని చెప్', + 'think %s for %n secs': + '%n సెకన్ల కోసం %s ఆలోచించ', + 'think %s': + '%s ఆలోచించ', + 'Hello!': + '"హలో!', + 'Hmm...': + 'హమ్.మ్..', + 'change %eff effect by %n': + '%n ప్రభావంతో %eff మారున', + 'set %eff effect to %n': + '%n ప్రయోజనంతో %eff పెట్', + 'clear graphic effects': + 'గ్రాఫిక్ ప్రయోజనాలు తొలగించుట', + 'change size by %n': + 'పరిమాణంను %n కి మార్', + 'set size to %n %': + '%n % కు పరిమాణాన్ని పెట్', + 'size': + 'Gr\u00f6\u00dfe', + 'show': + 'చూపించ', + 'hide': + 'దాచిపెట్', + 'go to front': + 'ముందుకు వెళ్', + 'go back %n layers': + '%n లేయర్లు తిరిగి వెళ్ళుట', + + 'development mode \ndebugging primitives:': + 'Hackermodus \nDebugging-Bl\u00f6cke', + 'console log %mult%s': + 'schreibe in die Konsole: %mult%s', + 'alert %mult%s': + 'Pop-up: %mult%s', + + // sound: + 'play sound %snd': + '%snd శబ్దం వాయించ', + 'play sound %snd until done': + '%snd ఆగువరకు శబ్దం వాయించ', + 'stop all sounds': + 'అన్నీ శబ్దాలు నిలుప', + 'rest for %n beats': + 'spiele Pause f\u00fcr %n Schl\u00e4ge', + 'play note %n for %n beats': + '%n సంజ్ఞను వాయించు %n బీట్స్ కోస', + 'change tempo by %n': + 'కదలికలోని తీవ్రతను %n మార్', + 'set tempo to %n bpm': + '%n బి.పి.యం.కు కదలికలోని తీవ్రతను పెట్', + 'tempo': + 'కదలికలోని తీవ్రత', + + // pen: + 'clear': + 'తొలగించుట', + 'pen down': + 'పెన్ను క్రిందకి', + 'pen up': + 'పెన్ను పైకి', + 'set pen color to %clr': + 'పెన్ను రంగును %clr కు పెట్', + 'change pen color by %n': + 'పెన్ను రంగు %n కు మార్', + 'set pen color to %n': + 'పెన్ను రంగును %n కు పెట్', + 'change pen shade by %n': + 'పెన్ను రంగు షేడ్ %n కు మార్', + 'set pen shade to %n': + 'పెన్ను రంగు షేడ్ %n కు పెట్', + 'change pen size by %n': + 'న్ను పరిమాణం మార్చేందుకు %n', + 'set pen size to %n': + 'పెన్ను పరిమాణం %n కు పెట్టు', + 'stamp': + 'ముద్', + + // control: + 'when %greenflag clicked': + '%greenflag ఒత్తినప్పుడ', + 'when %keyHat key pressed': + '%keyHat కీ ఒత్తినప్పుడ', + 'when I am clicked': + 'Wenn ich angeklickt werde', + 'when I receive %msgHat': + '%msgHat నేను స్వీకరించినప్పుడు', + 'broadcast %msg': + 'ప్రసార %msg', + 'broadcast %msg and wait': + '%msg ని ప్రసారం చేసి, వేచివుండు', + 'Message name': + 'సందేశం పేర', + 'message': + 'సందేశ', + 'any message': + 'ఏదైనా సందేశ', + 'wait %n secs': + '%n సెకన్లు వేచియుండ', + 'wait until %b': + '%b వరకూ వేచియుండ', + 'forever %c': + 'ఎప్పటికి %c', + 'repeat %n %c': + '%n %c పునరావృత', + 'repeat until %b %c': + '%b %c పునరావృతం అయ్యేంతవరక', + 'if %b %c': + 'ఒకవేళ %b %c', + 'if %b %c else %c': + 'ఒకవేళ %b %c ఇంకా %c', + 'report %s': + 'berichte %s', + 'stop %stopChoices': + 'నిలుపు %stopChoices', + 'all': + 'అన్', + 'this script': + 'ఈ ఆజ్', + 'this block': + 'diesen Block', + 'stop %stopOthersChoices': + 'నిలుప %stopOthersChoices', + 'all but this script': + 'alles au\u00dfer diesem Skript', + 'other scripts in sprite': + 'andere Skripte in diesem Objekt', + 'pause all %pause': + 'pausiere alles %pause', + 'run %cmdRing %inputs': + 'f\u00fchre %cmdRing aus %inputs', + 'launch %cmdRing %inputs': + 'starte %cmdRing %inputs', + 'call %repRing %inputs': + 'rufe %repRing auf %inputs', + 'run %cmdRing w/continuation': + 'f\u00fchre %cmdRing mit Continuation aus', + 'call %cmdRing w/continuation': + 'rufe %cmdRing mit Continuation auf', + 'warp %c': + 'Warp %c', + 'when I start as a clone': + 'Wenn ich geklont werde', + 'create a clone of %cln': + 'klone %cln', + 'myself': + 'mich', + 'delete this clone': + 'entferne diesen Klon', + + // sensing: + 'touching %col ?': + '%col తాకుతుందా?', + 'touching %clr ?': + '%clr రంగును తాకుతుందా?', + 'color %clr is touching %clr ?': + '%clr రంగు %clr తాకుతుందా?', + 'ask %s and wait': + '%s అడిగి, వేచియుండ', + 'what\'s your name?': + 'నీ పేరు ఏమిటి?', + 'answer': + 'సమాధాన', + 'mouse x': + 'మౌస్ x', + 'mouse y': + 'మౌస్ y', + 'mouse down?': + 'మౌస్ ఒత్తారా?', + 'key %key pressed?': + '%key కీ ఒత్తారా?', + 'distance to %dst': + '%dst కు దూరం', + 'reset timer': + 'సమయసూచిని మళ్ళీ పెట్', + 'timer': + 'సమయసూచి', + '%att of %spr': + '%att లో %spr', + 'http:// %s': + 'http:// %s', + 'turbo mode?': + 'Turbomodus?', + 'set turbo mode to %b': + 'setze Turbomodus auf %b', + + 'filtered for %clr': + 'nach %clr gefiltert', + 'stack size': + 'Stapelgr\u00f6\u00dfe', + 'frames': + 'Rahmenz\u00e4hler', + + // operators: + '%n mod %n': + '%n శేష %n', + 'round %n': + '%n గుండ్రమ', + '%fun of %n': + '%fun లో %n', + 'pick random %n to %n': + '%n నుండి %n ను యాదృచ్ఛికంగా ఎంచుకోండి', + '%b and %b': + '%b మరియ %b', + '%b or %b': + '%b లేదా %b', + 'not %b': + 'లేద %b', + 'true': + 'సత్', + 'false': + 'తప్', + 'join %words': + 'కలుప %words', + 'split %s by %delim': + 'trenne %s nach %delim', + 'hello': + 'హలో', + 'world': + 'ప్రపంచం', + 'letter %n of %s': + 'Zeichen %n von %s', + 'length of %s': + 'L\u00e4nge von %s', + 'unicode of %s': + 'Unicode Wert von %s', + 'unicode %n as letter': + 'Unicode %n als Buchstabe', + 'is %s a %typ ?': + 'ist %s ein(e) %typ ?', + 'is %s identical to %s ?': + 'ist %s identisch mit %s ?', + + 'type of %s': + 'Typ von %s', + + // variables: + 'Make a variable': + 'చరరాశిని కల్పించు', + 'Variable name': + 'చరరాశి పేరు ?', + 'Script variable name': + 'Skriptvariablenname', + 'Delete a variable': + 'చరరాశిని తొలగించ', + + 'set %var to %s': + '%var లో %s ను పెట్', + 'change %var by %n': + '%var మార్చడానికి %n', + 'show variable %var': + 'చరరాశి %var ను చూప', + 'hide variable %var': + '%var చరరాశిని దాచు', + 'script variables %scriptVars': + 'Skriptvariablen %scriptVars', + + // lists: + 'list %exp': + 'Liste %exp', + '%s in front of %l': + '%s am Anfang von %l', + 'item %idx of %l': + 'Element %idx von %l', + 'all but first of %l': + 'alles au\u00dfer dem ersten von %l', + 'length of %l': + 'L\u00e4nge von %l', + '%l contains %s': + '%l enth\u00e4lt %s', + 'thing': + 'etwas', + 'add %s to %l': + 'f\u00fcge %s zu %l hinzu', + 'delete %ida of %l': + 'entferne %ida aus %l', + 'insert %s at %idx of %l': + 'f\u00fcge %s als %idx in %l ein', + 'replace item %idx of %l with %s': + 'ersetze Element %idx in %l durch %s', + + // other + 'Make a block': + 'Neuer Block', + + // menus + // snap menu + 'About...': + '\u00dcber Snap!...', + 'Reference manual': + 'Handbuch lesen', + 'Snap! website': + 'Snap! Webseite', + 'Download source': + 'Quellcode runterladen', + 'Switch back to user mode': + 'zur\u00fcck zum Benutzermodus', + 'disable deep-Morphic\ncontext menus\nand show user-friendly ones': + 'verl\u00e4sst Morphic', + 'Switch to dev mode': + 'zum Hackermodus wechseln', + 'enable Morphic\ncontext menus\nand inspectors,\nnot user-friendly!': + 'erm\u00f6glicht Morphic Funktionen', + + // project menu + 'Project notes...': + 'రాజెక్ట్ గమనికల...', + 'New': + 'కొత్', + 'Open...': + 'తెరువ...', + 'Save': + 'సేవ్ చేయ', + 'Save As...': + 'వదిలేయడానికి ముందు మార్పులను సేవ్ చేయ...', + 'Import...': + 'దిగుమతి...', + 'file menu import hint': + 'l\u00e4dt ein exportiertes Projekt,\neine Bibliothek mit ' + + 'Bl\u00f6cken\n' + + 'ein Kost\u00fcm oder einen Klang', + 'Export project as plain text...': + 'Projekt als normalen Text exportieren...', + 'Export project...': + 'Projekt exportieren...', + 'show project data as XML\nin a new browser window': + 'zeigt das Projekt als XML\nin einem neuen Browserfenster an', + 'Export blocks...': + 'Bl\u00f6cke exportieren...', + 'show global custom block definitions as XML\nin a new browser window': + 'zeigt globale Benutzerblockdefinitionen\nals XML im Browser an', + 'Import tools': + 'Tools laden', + 'load the official library of\npowerful blocks': + 'das offizielle Modul mit\nm\u00e4chtigen Bl\u00f6cken laden', + 'Libraries...': + 'Module...', + 'Import library': + 'Modul laden', + + // cloud menu + 'Login...': + 'Anmelden...', + 'Signup...': + 'Benutzerkonto einrichten...', + + // settings menu + 'Language...': + 'భాష...', + 'Zoom blocks...': + 'Bl\u00f6cke vergr\u00f6\u00dfern...', + 'Stage size...': + 'B\u00fchnengr\u00f6\u00dfe...', + 'Stage size': + 'B\u00fchnengr\u00f6\u00dfe', + 'Stage width': + 'B\u00fchnenbreite', + 'Stage height': + 'B\u00fchnenh\u00f6he', + 'Default': + 'Normal', + 'Blurred shadows': + 'Weiche Schatten', + 'uncheck to use solid drop\nshadows and highlights': + 'abschalten f\u00fcr harte Schatten\nund Beleuchtung', + 'check to use blurred drop\nshadows and highlights': + 'einschalten f\u00fcr harte Schatten\nund Beleuchtung', + 'Zebra coloring': + 'Zebrafarben', + 'check to enable alternating\ncolors for nested blocks': + 'einschalten \u00fcr abwechselnde Farbnuancen\nin Bl\u00f6cken', + 'uncheck to disable alternating\ncolors for nested block': + 'ausschalten verhindert abwechselnde\nFarbnuancen in Bl\u00f6cken', + 'Dynamic input labels': + 'Eingabenbeschriftung', + 'uncheck to disable dynamic\nlabels for variadic inputs': + 'ausschalten verhindert Beschriftung\nvon Mehrfacheingaben', + 'check to enable dynamic\nlabels for variadic inputs': + 'einschalten um Mehrfacheingabefelder\nautomatisch zu beschriften', + 'Prefer empty slot drops': + 'Leere Platzhalter bevorzugen', + 'settings menu prefer empty slots hint': + 'einschalten um leere Platzhalter\nbeim Platzieren von Bl\u00f6cken' + + 'zu bevorzugen', + 'uncheck to allow dropped\nreporters to kick out others': + 'ausschalten um das "Rauskicken"\nvon platzierten Bl\u00f6cken\n' + + 'zu erm\u00f6glichen', + 'Long form input dialog': + 'Ausf\u00fchrlicher Input-Dialog', + 'Plain prototype labels': + 'Einfache Prototyp-Beschriftung', + 'uncheck to always show (+) symbols\nin block prototype labels': + 'ausschalten, um (+) Zeichen\nim Blockeditor zu verbergen', + 'check to hide (+) symbols\nin block prototype labels': + 'einschalten, um (+) Zeichen\nim Blockeditor immer anzuzeigen', + 'check to always show slot\ntypes in the input dialog': + 'einschalten, um immer die Datentypen\nim Input-Dialog zu sehen', + 'uncheck to use the input\ndialog in short form': + 'ausschalten f\u00fcr kurzen\nInput-Dialog', + 'Virtual keyboard': + 'Virtuelle Tastatur', + 'uncheck to disable\nvirtual keyboard support\nfor mobile devices': + 'ausschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n' + + 'zu sperren', + 'check to enable\nvirtual keyboard support\nfor mobile devices': + 'einschalten um die virtuelle\nTastatur auf mobilen Ger\u00e4ten\n' + + 'zu erm\u00f6glichen', + 'Input sliders': + 'Eingabeschieber', + 'uncheck to disable\ninput sliders for\nentry fields': + 'ausschalten um Schieber\nin Eingabefeldern zu verhindern', + 'check to enable\ninput sliders for\nentry fields': + 'einschalten um Schieber\nin Eingabefeldern zu aktivieren', + 'Clicking sound': + 'Akustisches Klicken', + 'uncheck to turn\nblock clicking\nsound off': + 'ausschalten um akustisches\nKlicken zu deaktivieren', + 'check to turn\nblock clicking\nsound on': + 'einschalten um akustisches\nKlicken zu aktivieren', + 'Animations': + 'ఆనిమేషన్ (సజీవత్వము)', + 'uncheck to disable\nIDE animations': + 'ausschalten um IDE-\nAnimationen zu verhindern', + 'Turbo mode': + 'Turbomodus', + 'check to prioritize\nscript execution': + 'einschalten, um Skripte\nzu priorisieren', + 'uncheck to run scripts\nat normal speed': + 'ausschalten, um Skripte\nnormal auszuf\u00fchren', + 'check to enable\nIDE animations': + 'einschalten um IDE-\nAnimationen zu erlauben', + 'Thread safe scripts': + 'Threadsicherheit', + 'uncheck to allow\nscript reentrance': + 'verhindert, dass unvollendete\nSkripte erneut gestartet werden', + 'check to disallow\nscript reentrance': + 'verhindert, dass unvollendete\nSkripte erneut gestartet werden', + 'Prefer smooth animations': + 'Fixe Framerate', + 'uncheck for greater speed\nat variable frame rates': + 'ausschalten, um Animationen \ndynamischer auszuf\u00fchren', + 'check for smooth, predictable\nanimations across computers': + 'einschalten, damit Animationen\n\u00fcberall gleich laufen', + 'Flat line ends': + 'Flache Pinselstriche', + 'check for flat ends of lines': + 'einschalten f\u00fcr flache\nPinselstrichenden', + 'uncheck for round ends of lines': + 'auschalten f\u00fcr runde\nPinselstrichenden', + + // inputs + 'with inputs': + 'mit Eingaben', + 'input names:': + 'Eingaben:', + 'Input Names:': + 'Eingaben:', + 'input list:': + 'Eingabeliste:', + + // context menus: + 'help': + 'సహాయ', + + // palette: + 'hide primitives': + 'Basisbl\u00f6cke ausblenden', + 'show primitives': + 'Basisbl\u00f6cke anzeigen', + + // blocks: + 'help...': + 'సహాయ...', + 'relabel...': + 'Umbenennen...', + 'duplicate': + 'నకల', + 'make a copy\nand pick it up': + 'eine Kopie aufnehmen', + 'only duplicate this block': + 'nur diesen Block duplizieren', + 'delete': + 'తొలగించ', + 'script pic...': + 'Skriptbild...', + 'open a new window\nwith a picture of this script': + 'ein neues Browserfenster mit einem\nBild dieses Skripts \u00f6ffnen', + 'ringify': + 'Umringen', + 'unringify': + 'Entringen', + + // custom blocks: + 'delete block definition...': + 'Blockdefinition l\u00f6schen', + 'edit...': + 'సవరించ...', + + // sprites: + 'edit': + 'సవరించ', + 'move': + 'జరుగ', + 'detach from': + 'Abtrennen von', + 'detach all parts': + 'Alle Teile abtrennen', + 'export...': + 'ఎగుమతి...', + + // stage: + 'show all': + 'Alles zeigen', + 'pic...': + 'Bild exportieren...', + 'open a new window\nwith a picture of the stage': + 'ein neues Browserfenster mit einem\nBild der B\u00fchne \u00f6ffnen', + + // scripting area + 'clean up': + 'శుభ్రం చేయ', + 'arrange scripts\nvertically': + 'Skripte der Reihe nach\nanordnen', + 'add comment': + 'వ్యాఖ్యానించ', + 'undrop': + 'R\u00fcckg\u00e4ngig', + 'undo the last\nblock drop\nin this pane': + 'Setzen des letzten Blocks\nwiderrufen', + 'scripts pic...': + 'Bild aller Scripte...', + 'open a new window\nwith a picture of all scripts': + 'ein neues Browserfenster mit einem\nBild aller Skripte \u00f6ffnen', + 'make a block...': + 'Neuen Block bauen...', + + // costumes + 'rename': + 'Umbenennen', + 'export': + 'ఎగుమతి', + 'rename costume': + 'Kost\u00fcm umbenennen', + + // sounds + 'Play sound': + 'శబ్దం వాయించ', + 'Stop sound': + 'Klang\nanhalten', + 'Stop': + 'ఆప', + 'Play': + 'ఆడ', + 'rename sound': + 'Klang umbenennen', + + // dialogs + // buttons + 'OK': + 'సరే', + 'Ok': + 'సరే', + 'Cancel': + 'రద్', + 'Yes': + 'అవున', + 'No': + 'లేద', + + // help + 'Help': + 'సహాయ', + + // zoom blocks + 'Zoom blocks': + 'Bl\u00f6cke vergr\u00f6\u00dfern', + 'build': + 'baue', + 'your own': + 'eigene', + 'blocks': + 'Bl\u00f6cke', + 'normal (1x)': + 'normal (1x)', + 'demo (1.2x)': + 'Demo (1.2x)', + 'presentation (1.4x)': + 'Pr\u00e4sentation (1.4x)', + 'big (2x)': + 'gro\u00df (2x)', + 'huge (4x)': + 'riesig (4x)', + 'giant (8x)': + 'gigantisch (8x)', + 'monstrous (10x)': + 'ungeheuerlich (10x)', + + // Project Manager + 'Untitled': + 'Unbenannt', + 'Open Project': + 'Project \u00f6ffnen', + '(empty)': + '(leer)', + 'Saved!': + 'Gesichert!', + 'Delete Project': + 'Projekt l\u00f6schen', + 'Are you sure you want to delete': + 'Wirklich l\u00f6schen?', + 'rename...': + 'Umbenennen...', + + // costume editor + 'Costume Editor': + 'Kost\u00fcmeditor', + 'click or drag crosshairs to move the rotation center': + 'Fadenkreuz anklicken oder bewegen um den Drehpunkt zu setzen', + + // project notes + 'Project Notes': + '"ప్రాజెక్ట్ గమనికల', + + // new project + 'New Project': + 'Neues Projekt', + 'Replace the current project with a new one?': + 'Das aktuelle Projekt durch ein neues ersetzen?', + + // save project + 'Save Project As...': + 'Projekt Sichern Als...', + + // export blocks + 'Export blocks': + 'Bl\u00f6cke exportieren', + 'Import blocks': + 'Bl\u00f6cke importieren', + 'this project doesn\'t have any\ncustom global blocks yet': + 'in diesem Projekt gibt es noch keine\nglobalen Bl\u00f6cke', + 'select': + 'ausw\u00e4hlen', + 'none': + 'nichts', + + // variable dialog + 'for all sprites': + 'f\u00fcr alle', + 'for this sprite only': + 'nur f\u00fcr dieses Objekt', + + // block dialog + 'Change block': + 'Block ver\u00e4ndern', + 'Command': + 'Befehl', + 'Reporter': + 'Funktion', + 'Predicate': + 'Pr\u00e4dikat', + + // block editor + 'Block Editor': + 'Blockeditor', + 'Apply': + 'Anwenden', + + // block deletion dialog + 'Delete Custom Block': + 'Block L\u00f6schen', + 'block deletion dialog text': + 'Soll dieser Block mit allen seinen Exemplare\n' + + 'wirklich gel\u00f6scht werden?', + + // input dialog + 'Create input name': + 'Eingabe erstellen', + 'Edit input name': + 'Eingabe bearbeiten', + 'Edit label fragment': + 'Beschriftung bearbeiten', + 'Title text': + 'Beschriftung', + 'Input name': + 'Eingabe', + 'Delete': + 'L\u00f6schen', + 'Object': + 'Objekt', + 'Number': + 'Zahl', + 'Text': + 'Text', + 'List': + 'Liste', + 'Any type': + 'Beliebig', + 'Boolean (T/F)': + 'Boolsch (W/F)', + 'Command\n(inline)': + 'Befehl', + 'Command\n(C-shape)': + 'Befehl\n(C-Form)', + 'Any\n(unevaluated)': + 'Beliebig\n(zitiert)', + 'Boolean\n(unevaluated)': + 'Boolsch\n(zitiert)', + 'Single input.': + 'Einzeleingabe.', + 'Default Value:': + 'Standardwert:', + 'Multiple inputs (value is list of inputs)': + 'Mehrere Eingaben (als Liste)', + 'Upvar - make internal variable visible to caller': + 'Interne Variable au\u00dfen sichtbar machen', + + // About Snap + 'About Snap': + '\u00dcber Snap', + 'Back...': + 'Zur\u00fcck...', + 'License...': + 'Lizenz...', + 'Modules...': + 'Komponenten...', + 'Credits...': + 'Mitwirkende...', + 'Translators...': + '\u00dcbersetzer', + 'License': + 'Lizenz', + 'current module versions:': + 'Komponenten-Versionen', + 'Contributors': + 'Mitwirkende', + 'Translations': + '\u00dcbersetzungen', + + // variable watchers + 'normal': + 'normal', + 'large': + 'gro\u00df', + 'slider': + 'Regler', + 'slider min...': + 'Minimalwert...', + 'slider max...': + 'Maximalwert...', + 'import...': + 'Importieren...', + 'Slider minimum value': + 'Minimalwert des Reglers', + 'Slider maximum value': + 'Maximalwert des Reglers', + + // list watchers + 'length: ': + 'L\u00e4nge: ', + + // coments + 'add comment here...': + 'Anmerkung hier hinzuf\u00fcgen', + + // drow downs + // directions + '(90) right': + '(90) rechts', + '(-90) left': + '(-90) links', + '(0) up': + '(0) oben', + '(180) down': + '(180) unten', + + // collision detection + 'mouse-pointer': + 'Mauszeiger', + 'edge': + 'Kante', + 'pen trails': + 'Malspuren', + + // costumes + 'Turtle': + 'Richtungszeiger', + 'Empty': + 'Leer', + + // graphical effects + 'brightness': + 'Helligeit', + 'ghost': + 'Durchsichtigkeit', + 'negative': + 'Farbumkehr', + 'comic': + 'Moire', + 'confetti': + 'Farbverschiebung', + + // keys + 'space': + 'Leertaste', + 'up arrow': + 'Pfeil nach oben', + 'down arrow': + 'Pfeil nach unten', + 'right arrow': + 'Pfeil nach rechts', + 'left arrow': + 'Pfeil nach links', + 'a': + 'a', + 'b': + 'b', + 'c': + 'c', + 'd': + 'd', + 'e': + 'e', + 'f': + 'f', + 'g': + 'g', + 'h': + 'h', + 'i': + 'i', + 'j': + 'j', + 'k': + 'k', + 'l': + 'l', + 'm': + 'm', + 'n': + 'n', + 'o': + 'o', + 'p': + 'p', + 'q': + 'q', + 'r': + 'r', + 's': + 's', + 't': + 't', + 'u': + 'u', + 'v': + 'v', + 'w': + 'w', + 'x': + 'x', + 'y': + 'y', + 'z': + 'z', + '0': + '0', + '1': + '1', + '2': + '2', + '3': + '3', + '4': + '4', + '5': + '5', + '6': + '6', + '7': + '7', + '8': + '8', + '9': + '9', + + // messages + 'new...': + 'Neu...', + + // math functions + 'abs': + 'Betrag', + 'floor': + 'Abgerundet', + 'sqrt': + 'Wurzel', + 'sin': + 'sin', + 'cos': + 'cos', + 'tan': + 'tan', + 'asin': + 'asin', + 'acos': + 'acos', + 'atan': + 'atan', + 'ln': + 'ln', + 'e^': + 'e^', + + // delimiters + 'letter': + 'Buchstabe', + 'whitespace': + 'Leerraum', + 'line': + 'Zeilenvorschub', + 'tab': + 'Tabulator', + 'cr': + 'Wagenr\u00fccklauf', + + // data types + 'number': + 'Zahl', + 'text': + 'Text', + 'Boolean': + 'Boole', + 'list': + 'Liste', + 'command': + 'Befehlsblock', + 'reporter': + 'Funktionsblock', + 'predicate': + 'Pr\u00e4dikat', + + // list indices + 'last': + 'letztes', + 'any': + 'beliebiges' +}; @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2015-January-21'; +modules.locale = '2015-February-23'; // Global stuff @@ -149,7 +149,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', 'last_changed': - '2014-07-29' + '2015-02-23' }; SnapTranslator.dict.it = { @@ -439,3 +439,39 @@ SnapTranslator.dict.kn = { 'last_changed': '2014-12-02' }; + +SnapTranslator.dict.ml = { + // translations meta information + 'language_name': + 'Malayalam', + 'language_translator': + 'vinayakumar R', + 'translator_e-mail': + 'vnkmr7620@gmail.com', + 'last_changed': + '2015-02-20' +}; + +SnapTranslator.dict.ta = { + // translations meta information + 'language_name': + 'Tamil', + 'language_translator': + 'vinayakumar R', + 'translator_e-mail': + 'vnkmr7620@gmail.com', + 'last_changed': + '2015-02-20' +}; + +SnapTranslator.dict.te = { + // translations meta information + 'language_name': + 'Telagu', // the name as it should appear in the language menu + 'language_translator': + 'vinayakumar R', // your name for the Translators tab + 'translator_e-mail': + 'vnkmr7620@gmail.com', // optional + 'last_changed': + '2015-02-20' +}; @@ -16,6 +16,7 @@ scriptdir=$(readlink -e ".") # Requirements: # git, nodejs, android SDK / other platform(s) # cordova (https://cordova.apache.org/) +# optional: crosswalk-cordova (https://github.com/crosswalk-project/crosswalk-cordova-android) if [[ $2 != "" ]] then @@ -40,26 +41,50 @@ fi # add mobile-specific library; it's made available at runtime sed -i '/link rel="shortcut icon"/a\ - <script type="text/javascript" src="cordova.js"></script>' snap.html + <script type="text/javascript" src="cordova.js"></script>' snap.html +echo "Adding cordova plugins" # add everything needed and build for $device -cordova platform add "$1" -cordova plugin add org.apache.cordova.plugin.softkeyboard -cordova plugin add org.apache.cordova.vibration -cordova plugin add org.apache.cordova.device-motion -cordova plugin add org.apache.cordova.device-orientation -cordova plugin add org.apache.cordova.geolocation -cordova plugin add de.appplant.cordova.plugin.local-notification +cordova platform add "$1" > /dev/null +cordova plugin add org.apache.cordova.plugin.softkeyboard \ + org.apache.cordova.vibration \ + org.apache.cordova.device-motion \ + org.apache.cordova.device-orientation \ + org.apache.cordova.geolocation \ + de.appplant.cordova.plugin.local-notification 2> /dev/null if [[ $1 == "android" ]] then # Remove default icons cd "$builddir/platforms/android" find -name '*.png' | xargs rm + + if [[ $crosswalk != "" ]] + then + # adapted from https://crosswalk-project.org/documentation/cordova/migrate_an_application.html#migrate + echo "Preparing crosswalk" + rm -Rf "$builddir/platforms/android/CordovaLib/*" + cp -a $crosswalk/framework/* "$builddir/platforms/android/CordovaLib/" + cp -a "$crosswalk/VERSION" "$builddir/platforms/android/" + export ANDROID_HOME=$(dirname $(dirname $(which android))) + cd "$builddir/platforms/android/CordovaLib/" + android update project --subprojects --target android-21 --path . > /dev/null + ant debug > /dev/null + cd "$builddir" + # prepend permissions to end of manifest + sed -i "s,</manifest>,\ + <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />\ + <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\ + <uses-permission android:name=\"android.permission.INTERACT_ACROSS_USERS\" />\ + </manifest>,g" \ + "$builddir/platforms/android/AndroidManifest.xml" + fi fi -cordova build "$1" +echo "Building application" +cordova build "$1" > /dev/null cd $builddir # TODO other platforms find -name '*.apk' | xargs -I {} mv {} $scriptdir +echo "Finished." @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-January-21'; +modules.objects = '2015-February-28'; var SpriteMorph; var StageMorph; @@ -613,11 +613,22 @@ SpriteMorph.prototype.initBlocks = function () { category: 'control', spec: 'when %keyHat key pressed' }, + + /* migrated to a newer block version: + receiveClick: { type: 'hat', category: 'control', spec: 'when I am clicked' }, + */ + + receiveInteraction: { + type: 'hat', + category: 'control', + spec: 'when I am %interaction', + defaults: ['clicked'] + }, receiveMessage: { type: 'hat', category: 'control', @@ -1254,6 +1265,29 @@ SpriteMorph.prototype.initBlocks = function () { defaults: [localize('each item')] }, + // peer to peer communication + receivePeerMessage: { + type: 'hat', + category: 'other', + spec: 'when I receive %upvar from %upvar', + defaults: [localize('message'), localize('peer')] + }, + sendPeerMessage: { + type: 'command', + category: 'other', + spec: 'send %s to %s' + }, + reportPeerId: { + type: 'reporter', + category: 'other', + spec: 'my peer id' + }, + reportPeerList: { + type: 'reporter', + category: 'other', + spec: 'peers online' + }, + // Code mapping - experimental doMapCodeOrHeader: { // experimental type: 'command', @@ -1294,6 +1328,10 @@ SpriteMorph.prototype.initBlockMigrations = function () { doStopBlock: { selector: 'doStopThis', inputs: [['this block']] + }, + receiveClick: { + selector: 'receiveInteraction', + inputs: [['clicked']] } }; }; @@ -1342,8 +1380,6 @@ SpriteMorph.prototype.blockAlternatives = { setSize: ['changeSize'], // control: - receiveGo: ['receiveClick'], - receiveClick: ['receiveGo'], doBroadcast: ['doBroadcastAndWait'], doBroadcastAndWait: ['doBroadcast'], doIf: ['doIfElse', 'doUntil'], @@ -1514,15 +1550,13 @@ SpriteMorph.prototype.setName = function (string) { SpriteMorph.prototype.drawNew = function () { var myself = this, - currentCenter = this.center(), + currentCenter, facing, // actual costume heading based on my rotation style isFlipped, - isLoadingCostume = this.costume && - typeof this.costume.loaded === 'function', + isLoadingCostume, cst, pic, // (flipped copy of) actual costume based on my rotation style - stageScale = this.parent instanceof StageMorph ? - this.parent.scale : 1, + stageScale, newX, corners = [], origin, @@ -1536,6 +1570,11 @@ SpriteMorph.prototype.drawNew = function () { this.wantsRedraw = true; return; } + currentCenter = this.center(); + isLoadingCostume = this.costume && + typeof this.costume.loaded === 'function'; + stageScale = this.parent instanceof StageMorph ? + this.parent.scale : 1; facing = this.rotationStyle ? this.heading : 90; if (this.rotationStyle === 2) { facing = 90; @@ -1683,7 +1722,7 @@ SpriteMorph.prototype.blockForSelector = function (selector, setDefaults) { : new ReporterBlockMorph(info.type === 'predicate'); block.color = this.blockColor[info.category]; block.category = info.category; - block.selector = selector; + block.selector = migration ? migration.selector : selector; if (contains(['reifyReporter', 'reifyPredicate'], block.selector)) { block.isStatic = true; } @@ -1930,7 +1969,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('receiveGo')); blocks.push(block('receiveKey')); - blocks.push(block('receiveClick')); + blocks.push(block('receiveInteraction')); blocks.push(block('receiveMessage')); blocks.push('-'); blocks.push(block('doBroadcast')); @@ -2204,6 +2243,13 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('='); + blocks.push(block('receivePeerMessage')); + blocks.push(block('sendPeerMessage')); + blocks.push(block('reportPeerId')); + blocks.push(block('reportPeerList')); + + blocks.push('='); + if (StageMorph.prototype.enableCodeMapping) { blocks.push(block('doMapCodeOrHeader')); blocks.push(block('doMapStringCode')); @@ -2915,7 +2961,7 @@ SpriteMorph.prototype.setColor = function (aColor) { var x = this.xPosition(), y = this.yPosition(); if (!this.color.eq(aColor)) { - this.color = aColor; + this.color = aColor.copy(); this.drawNew(); this.gotoXY(x, y); } @@ -3326,6 +3372,7 @@ SpriteMorph.prototype.prepareToBeGrabbed = function (hand) { SpriteMorph.prototype.justDropped = function () { this.restoreLayers(); this.positionTalkBubble(); + this.receiveUserInteraction('dropped'); }; // SpriteMorph drawing: @@ -3655,8 +3702,8 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) { if (morph.selector === 'receiveOnClone') { return message === '__clone__init__'; } - if (morph.selector === 'receiveClick') { - return message === '__click__'; + if (morph.selector === 'receivePeerMessage') { + return message === '__peer__message__'; } } return false; @@ -3686,13 +3733,37 @@ SpriteMorph.prototype.allHatBlocksForKey = function (key) { }); }; +SpriteMorph.prototype.allHatBlocksForInteraction = function (interaction) { + return this.scripts.children.filter(function (morph) { + if (morph.selector) { + if (morph.selector === 'receiveInteraction') { + return morph.inputs()[0].evaluate()[0] === interaction; + } + } + return false; + }); +}; + // SpriteMorph events SpriteMorph.prototype.mouseClickLeft = function () { - var stage = this.parentThatIsA(StageMorph), - hats = this.allHatBlocksFor('__click__'), - procs = []; + return this.receiveUserInteraction('clicked'); +}; + +SpriteMorph.prototype.mouseEnter = function () { + return this.receiveUserInteraction('mouse-entered'); +}; + +SpriteMorph.prototype.mouseDownLeft = function () { + return this.receiveUserInteraction('pressed'); +}; +SpriteMorph.prototype.receiveUserInteraction = function (interaction) { + var stage = this.parentThatIsA(StageMorph), + procs = [], + hats; + if (!stage) {return; } // currently dragged + hats = this.allHatBlocksForInteraction(interaction); hats.forEach(function (block) { procs.push(stage.threads.startProcess(block, stage.isThreadSafe)); }); @@ -4367,6 +4438,7 @@ SpriteMorph.prototype.mouseEnterDragging = function () { }; SpriteMorph.prototype.mouseLeave = function () { + this.receiveUserInteraction('mouse-departed'); if (!this.enableNesting) {return; } this.removeHighlight(); }; @@ -4531,6 +4603,95 @@ StageMorph.prototype.init = function (globals) { this.acceptsDrops = false; this.setColor(new Color(255, 255, 255)); this.fps = this.frameRate; + + this.initPeering(); +}; + +StageMorph.prototype.initPeering = function (id) { + var myself = this; + + if (window.peers) { + // I don't know why, but it works. + window.peers.forEach(function (oldpeer) { + if (id != oldpeer.id) { + oldpeer.destroy() + } + }); + } + + this.peer = new Peer(id, { + host: 'snapmesh.herokuapp.com', + port: 443, + secure: true, + path: '/' + }); + + this.peer.on('open', function (id) { + myself.peerId = id; + }); + this.peer.on('disconnected', function () { + // peer.reconnect does not work (?) because 'id' is undefined + if (!myself.peer.destroyed) { + myself.initPeering(myself.peerId); + } + }); + this.peer.on('error', function (err) { + console.log(err); // DEBUG + }); + + this.peer.on('connection', function (connection) { + connection.on('open', function () { + connection.on('data', function (data) { + myself.newPeerMessage(data, connection.peer); + }); + }); + }); + + window.peers.push(this.peer); +}; + +StageMorph.prototype.newPeerMessage = function (data, peer) { + var ide = this.parentThatIsA(IDE_Morph); + var myself = this; + var hats = [], model, message; + + try { + model = ide.serializer.parse(data); + message = ide.serializer.loadValue(model); + + // TODO: If a Context is sent, a new Sprite appears. + // This below is just a workaround for one-level rings, + // objects should be cleaned recursively. + message.receiver = null; + message.outerContext = null; + } catch (err) { + console.log(err); // DEBUG + // Ok, it does not seem to be XML. It must be a string then. + message = data; + } + + // call hat blocks + this.children.concat(myself).forEach(function (morph) { + if (morph instanceof SpriteMorph + || morph instanceof StageMorph) { + hats = hats.concat( + morph.allHatBlocksFor('__peer__message__')); + } + }); + hats.forEach(function (block) { + var process = myself.threads.startProcess(block, + myself.isThreadSafe); + process.context.outerContext.variables.addVar(localize('message')); + process.context.outerContext.variables.setVar( + localize('message'), + message + ); + process.context.outerContext.variables.addVar(localize('peer')); + process.context.outerContext.variables.setVar( + localize('peer'), + peer + ); + }); }; // StageMorph scaling @@ -5224,7 +5385,7 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('receiveGo')); blocks.push(block('receiveKey')); - blocks.push(block('receiveClick')); + blocks.push(block('receiveInteraction')); blocks.push(block('receiveMessage')); blocks.push('-'); blocks.push(block('doBroadcast')); @@ -5484,6 +5645,12 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('='); + blocks.push(block('receivePeerMessage')); + blocks.push(block('sendPeerMessage')); + blocks.push(block('reportPeerId')); + blocks.push(block('reportPeerList')); + blocks.push('='); + if (StageMorph.prototype.enableCodeMapping) { blocks.push(block('doMapCodeOrHeader')); blocks.push(block('doMapStringCode')); @@ -5819,11 +5986,27 @@ StageMorph.prototype.allHatBlocksFor StageMorph.prototype.allHatBlocksForKey = SpriteMorph.prototype.allHatBlocksForKey; +StageMorph.prototype.allHatBlocksForInteraction + = SpriteMorph.prototype.allHatBlocksForInteraction; + // StageMorph events StageMorph.prototype.mouseClickLeft = SpriteMorph.prototype.mouseClickLeft; +StageMorph.prototype.mouseEnter + = SpriteMorph.prototype.mouseEnter; + +StageMorph.prototype.mouseLeave = function () { + this.receiveUserInteraction('mouse-departed'); +}; + +StageMorph.prototype.mouseDownLeft + = SpriteMorph.prototype.mouseDownLeft; + +StageMorph.prototype.receiveUserInteraction + = SpriteMorph.prototype.receiveUserInteraction; + // StageMorph custom blocks StageMorph.prototype.deleteAllBlockInstances @@ -0,0 +1,2711 @@ +/*! peerjs.js build:0.3.9, development. Copyright(c) 2013 Michelle Bu <michelle@michellebu.com> */ +(function(exports){ +var binaryFeatures = {}; +binaryFeatures.useBlobBuilder = (function(){ + try { + new Blob([]); + return false; + } catch (e) { + return true; + } +})(); + +binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){ + try { + return (new Blob([new Uint8Array([])])).size === 0; + } catch (e) { + return true; + } +})(); + +exports.binaryFeatures = binaryFeatures; +exports.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; + +function BufferBuilder(){ + this._pieces = []; + this._parts = []; +} + +BufferBuilder.prototype.append = function(data) { + if(typeof data === 'number') { + this._pieces.push(data); + } else { + this.flush(); + this._parts.push(data); + } +}; + +BufferBuilder.prototype.flush = function() { + if (this._pieces.length > 0) { + var buf = new Uint8Array(this._pieces); + if(!binaryFeatures.useArrayBufferView) { + buf = buf.buffer; + } + this._parts.push(buf); + this._pieces = []; + } +}; + +BufferBuilder.prototype.getBuffer = function() { + this.flush(); + if(binaryFeatures.useBlobBuilder) { + var builder = new BlobBuilder(); + for(var i = 0, ii = this._parts.length; i < ii; i++) { + builder.append(this._parts[i]); + } + return builder.getBlob(); + } else { + return new Blob(this._parts); + } +}; +exports.BinaryPack = { + unpack: function(data){ + var unpacker = new Unpacker(data); + return unpacker.unpack(); + }, + pack: function(data){ + var packer = new Packer(); + packer.pack(data); + var buffer = packer.getBuffer(); + return buffer; + } +}; + +function Unpacker (data){ + // Data is ArrayBuffer + this.index = 0; + this.dataBuffer = data; + this.dataView = new Uint8Array(this.dataBuffer); + this.length = this.dataBuffer.byteLength; +} + + +Unpacker.prototype.unpack = function(){ + var type = this.unpack_uint8(); + if (type < 0x80){ + var positive_fixnum = type; + return positive_fixnum; + } else if ((type ^ 0xe0) < 0x20){ + var negative_fixnum = (type ^ 0xe0) - 0x20; + return negative_fixnum; + } + var size; + if ((size = type ^ 0xa0) <= 0x0f){ + return this.unpack_raw(size); + } else if ((size = type ^ 0xb0) <= 0x0f){ + return this.unpack_string(size); + } else if ((size = type ^ 0x90) <= 0x0f){ + return this.unpack_array(size); + } else if ((size = type ^ 0x80) <= 0x0f){ + return this.unpack_map(size); + } + switch(type){ + case 0xc0: + return null; + case 0xc1: + return undefined; + case 0xc2: + return false; + case 0xc3: + return true; + case 0xca: + return this.unpack_float(); + case 0xcb: + return this.unpack_double(); + case 0xcc: + return this.unpack_uint8(); + case 0xcd: + return this.unpack_uint16(); + case 0xce: + return this.unpack_uint32(); + case 0xcf: + return this.unpack_uint64(); + case 0xd0: + return this.unpack_int8(); + case 0xd1: + return this.unpack_int16(); + case 0xd2: + return this.unpack_int32(); + case 0xd3: + return this.unpack_int64(); + case 0xd4: + return undefined; + case 0xd5: + return undefined; + case 0xd6: + return undefined; + case 0xd7: + return undefined; + case 0xd8: + size = this.unpack_uint16(); + return this.unpack_string(size); + case 0xd9: + size = this.unpack_uint32(); + return this.unpack_string(size); + case 0xda: + size = this.unpack_uint16(); + return this.unpack_raw(size); + case 0xdb: + size = this.unpack_uint32(); + return this.unpack_raw(size); + case 0xdc: + size = this.unpack_uint16(); + return this.unpack_array(size); + case 0xdd: + size = this.unpack_uint32(); + return this.unpack_array(size); + case 0xde: + size = this.unpack_uint16(); + return this.unpack_map(size); + case 0xdf: + size = this.unpack_uint32(); + return this.unpack_map(size); + } +} + +Unpacker.prototype.unpack_uint8 = function(){ + var byte = this.dataView[this.index] & 0xff; + this.index++; + return byte; +}; + +Unpacker.prototype.unpack_uint16 = function(){ + var bytes = this.read(2); + var uint16 = + ((bytes[0] & 0xff) * 256) + (bytes[1] & 0xff); + this.index += 2; + return uint16; +} + +Unpacker.prototype.unpack_uint32 = function(){ + var bytes = this.read(4); + var uint32 = + ((bytes[0] * 256 + + bytes[1]) * 256 + + bytes[2]) * 256 + + bytes[3]; + this.index += 4; + return uint32; +} + +Unpacker.prototype.unpack_uint64 = function(){ + var bytes = this.read(8); + var uint64 = + ((((((bytes[0] * 256 + + bytes[1]) * 256 + + bytes[2]) * 256 + + bytes[3]) * 256 + + bytes[4]) * 256 + + bytes[5]) * 256 + + bytes[6]) * 256 + + bytes[7]; + this.index += 8; + return uint64; +} + + +Unpacker.prototype.unpack_int8 = function(){ + var uint8 = this.unpack_uint8(); + return (uint8 < 0x80 ) ? uint8 : uint8 - (1 << 8); +}; + +Unpacker.prototype.unpack_int16 = function(){ + var uint16 = this.unpack_uint16(); + return (uint16 < 0x8000 ) ? uint16 : uint16 - (1 << 16); +} + +Unpacker.prototype.unpack_int32 = function(){ + var uint32 = this.unpack_uint32(); + return (uint32 < Math.pow(2, 31) ) ? uint32 : + uint32 - Math.pow(2, 32); +} + +Unpacker.prototype.unpack_int64 = function(){ + var uint64 = this.unpack_uint64(); + return (uint64 < Math.pow(2, 63) ) ? uint64 : + uint64 - Math.pow(2, 64); +} + +Unpacker.prototype.unpack_raw = function(size){ + if ( this.length < this.index + size){ + throw new Error('BinaryPackFailure: index is out of range' + + ' ' + this.index + ' ' + size + ' ' + this.length); + } + var buf = this.dataBuffer.slice(this.index, this.index + size); + this.index += size; + + //buf = util.bufferToString(buf); + + return buf; +} + +Unpacker.prototype.unpack_string = function(size){ + var bytes = this.read(size); + var i = 0, str = '', c, code; + while(i < size){ + c = bytes[i]; + if ( c < 128){ + str += String.fromCharCode(c); + i++; + } else if ((c ^ 0xc0) < 32){ + code = ((c ^ 0xc0) << 6) | (bytes[i+1] & 63); + str += String.fromCharCode(code); + i += 2; + } else { + code = ((c & 15) << 12) | ((bytes[i+1] & 63) << 6) | + (bytes[i+2] & 63); + str += String.fromCharCode(code); + i += 3; + } + } + this.index += size; + return str; +} + +Unpacker.prototype.unpack_array = function(size){ + var objects = new Array(size); + for(var i = 0; i < size ; i++){ + objects[i] = this.unpack(); + } + return objects; +} + +Unpacker.prototype.unpack_map = function(size){ + var map = {}; + for(var i = 0; i < size ; i++){ + var key = this.unpack(); + var value = this.unpack(); + map[key] = value; + } + return map; +} + +Unpacker.prototype.unpack_float = function(){ + var uint32 = this.unpack_uint32(); + var sign = uint32 >> 31; + var exp = ((uint32 >> 23) & 0xff) - 127; + var fraction = ( uint32 & 0x7fffff ) | 0x800000; + return (sign == 0 ? 1 : -1) * + fraction * Math.pow(2, exp - 23); +} + +Unpacker.prototype.unpack_double = function(){ + var h32 = this.unpack_uint32(); + var l32 = this.unpack_uint32(); + var sign = h32 >> 31; + var exp = ((h32 >> 20) & 0x7ff) - 1023; + var hfrac = ( h32 & 0xfffff ) | 0x100000; + var frac = hfrac * Math.pow(2, exp - 20) + + l32 * Math.pow(2, exp - 52); + return (sign == 0 ? 1 : -1) * frac; +} + +Unpacker.prototype.read = function(length){ + var j = this.index; + if (j + length <= this.length) { + return this.dataView.subarray(j, j + length); + } else { + throw new Error('BinaryPackFailure: read index out of range'); + } +} + +function Packer(){ + this.bufferBuilder = new BufferBuilder(); +} + +Packer.prototype.getBuffer = function(){ + return this.bufferBuilder.getBuffer(); +} + +Packer.prototype.pack = function(value){ + var type = typeof(value); + if (type == 'string'){ + this.pack_string(value); + } else if (type == 'number'){ + if (Math.floor(value) === value){ + this.pack_integer(value); + } else{ + this.pack_double(value); + } + } else if (type == 'boolean'){ + if (value === true){ + this.bufferBuilder.append(0xc3); + } else if (value === false){ + this.bufferBuilder.append(0xc2); + } + } else if (type == 'undefined'){ + this.bufferBuilder.append(0xc0); + } else if (type == 'object'){ + if (value === null){ + this.bufferBuilder.append(0xc0); + } else { + var constructor = value.constructor; + if (constructor == Array){ + this.pack_array(value); + } else if (constructor == Blob || constructor == File) { + this.pack_bin(value); + } else if (constructor == ArrayBuffer) { + if(binaryFeatures.useArrayBufferView) { + this.pack_bin(new Uint8Array(value)); + } else { + this.pack_bin(value); + } + } else if ('BYTES_PER_ELEMENT' in value){ + if(binaryFeatures.useArrayBufferView) { + this.pack_bin(new Uint8Array(value.buffer)); + } else { + this.pack_bin(value.buffer); + } + } else if (constructor == Object){ + this.pack_object(value); + } else if (constructor == Date){ + this.pack_string(value.toString()); + } else if (typeof value.toBinaryPack == 'function'){ + this.bufferBuilder.append(value.toBinaryPack()); + } else { + throw new Error('Type "' + constructor.toString() + '" not yet supported'); + } + } + } else { + throw new Error('Type "' + type + '" not yet supported'); + } + this.bufferBuilder.flush(); +} + + +Packer.prototype.pack_bin = function(blob){ + var length = blob.length || blob.byteLength || blob.size; + if (length <= 0x0f){ + this.pack_uint8(0xa0 + length); + } else if (length <= 0xffff){ + this.bufferBuilder.append(0xda) ; + this.pack_uint16(length); + } else if (length <= 0xffffffff){ + this.bufferBuilder.append(0xdb); + this.pack_uint32(length); + } else{ + throw new Error('Invalid length'); + return; + } + this.bufferBuilder.append(blob); +} + +Packer.prototype.pack_string = function(str){ + var length = utf8Length(str); + + if (length <= 0x0f){ + this.pack_uint8(0xb0 + length); + } else if (length <= 0xffff){ + this.bufferBuilder.append(0xd8) ; + this.pack_uint16(length); + } else if (length <= 0xffffffff){ + this.bufferBuilder.append(0xd9); + this.pack_uint32(length); + } else{ + throw new Error('Invalid length'); + return; + } + this.bufferBuilder.append(str); +} + +Packer.prototype.pack_array = function(ary){ + var length = ary.length; + if (length <= 0x0f){ + this.pack_uint8(0x90 + length); + } else if (length <= 0xffff){ + this.bufferBuilder.append(0xdc) + this.pack_uint16(length); + } else if (length <= 0xffffffff){ + this.bufferBuilder.append(0xdd); + this.pack_uint32(length); + } else{ + throw new Error('Invalid length'); + } + for(var i = 0; i < length ; i++){ + this.pack(ary[i]); + } +} + +Packer.prototype.pack_integer = function(num){ + if ( -0x20 <= num && num <= 0x7f){ + this.bufferBuilder.append(num & 0xff); + } else if (0x00 <= num && num <= 0xff){ + this.bufferBuilder.append(0xcc); + this.pack_uint8(num); + } else if (-0x80 <= num && num <= 0x7f){ + this.bufferBuilder.append(0xd0); + this.pack_int8(num); + } else if ( 0x0000 <= num && num <= 0xffff){ + this.bufferBuilder.append(0xcd); + this.pack_uint16(num); + } else if (-0x8000 <= num && num <= 0x7fff){ + this.bufferBuilder.append(0xd1); + this.pack_int16(num); + } else if ( 0x00000000 <= num && num <= 0xffffffff){ + this.bufferBuilder.append(0xce); + this.pack_uint32(num); + } else if (-0x80000000 <= num && num <= 0x7fffffff){ + this.bufferBuilder.append(0xd2); + this.pack_int32(num); + } else if (-0x8000000000000000 <= num && num <= 0x7FFFFFFFFFFFFFFF){ + this.bufferBuilder.append(0xd3); + this.pack_int64(num); + } else if (0x0000000000000000 <= num && num <= 0xFFFFFFFFFFFFFFFF){ + this.bufferBuilder.append(0xcf); + this.pack_uint64(num); + } else{ + throw new Error('Invalid integer'); + } +} + +Packer.prototype.pack_double = function(num){ + var sign = 0; + if (num < 0){ + sign = 1; + num = -num; + } + var exp = Math.floor(Math.log(num) / Math.LN2); + var frac0 = num / Math.pow(2, exp) - 1; + var frac1 = Math.floor(frac0 * Math.pow(2, 52)); + var b32 = Math.pow(2, 32); + var h32 = (sign << 31) | ((exp+1023) << 20) | + (frac1 / b32) & 0x0fffff; + var l32 = frac1 % b32; + this.bufferBuilder.append(0xcb); + this.pack_int32(h32); + this.pack_int32(l32); +} + +Packer.prototype.pack_object = function(obj){ + var keys = Object.keys(obj); + var length = keys.length; + if (length <= 0x0f){ + this.pack_uint8(0x80 + length); + } else if (length <= 0xffff){ + this.bufferBuilder.append(0xde); + this.pack_uint16(length); + } else if (length <= 0xffffffff){ + this.bufferBuilder.append(0xdf); + this.pack_uint32(length); + } else{ + throw new Error('Invalid length'); + } + for(var prop in obj){ + if (obj.hasOwnProperty(prop)){ + this.pack(prop); + this.pack(obj[prop]); + } + } +} + +Packer.prototype.pack_uint8 = function(num){ + this.bufferBuilder.append(num); +} + +Packer.prototype.pack_uint16 = function(num){ + this.bufferBuilder.append(num >> 8); + this.bufferBuilder.append(num & 0xff); +} + +Packer.prototype.pack_uint32 = function(num){ + var n = num & 0xffffffff; + this.bufferBuilder.append((n & 0xff000000) >>> 24); + this.bufferBuilder.append((n & 0x00ff0000) >>> 16); + this.bufferBuilder.append((n & 0x0000ff00) >>> 8); + this.bufferBuilder.append((n & 0x000000ff)); +} + +Packer.prototype.pack_uint64 = function(num){ + var high = num / Math.pow(2, 32); + var low = num % Math.pow(2, 32); + this.bufferBuilder.append((high & 0xff000000) >>> 24); + this.bufferBuilder.append((high & 0x00ff0000) >>> 16); + this.bufferBuilder.append((high & 0x0000ff00) >>> 8); + this.bufferBuilder.append((high & 0x000000ff)); + this.bufferBuilder.append((low & 0xff000000) >>> 24); + this.bufferBuilder.append((low & 0x00ff0000) >>> 16); + this.bufferBuilder.append((low & 0x0000ff00) >>> 8); + this.bufferBuilder.append((low & 0x000000ff)); +} + +Packer.prototype.pack_int8 = function(num){ + this.bufferBuilder.append(num & 0xff); +} + +Packer.prototype.pack_int16 = function(num){ + this.bufferBuilder.append((num & 0xff00) >> 8); + this.bufferBuilder.append(num & 0xff); +} + +Packer.prototype.pack_int32 = function(num){ + this.bufferBuilder.append((num >>> 24) & 0xff); + this.bufferBuilder.append((num & 0x00ff0000) >>> 16); + this.bufferBuilder.append((num & 0x0000ff00) >>> 8); + this.bufferBuilder.append((num & 0x000000ff)); +} + +Packer.prototype.pack_int64 = function(num){ + var high = Math.floor(num / Math.pow(2, 32)); + var low = num % Math.pow(2, 32); + this.bufferBuilder.append((high & 0xff000000) >>> 24); + this.bufferBuilder.append((high & 0x00ff0000) >>> 16); + this.bufferBuilder.append((high & 0x0000ff00) >>> 8); + this.bufferBuilder.append((high & 0x000000ff)); + this.bufferBuilder.append((low & 0xff000000) >>> 24); + this.bufferBuilder.append((low & 0x00ff0000) >>> 16); + this.bufferBuilder.append((low & 0x0000ff00) >>> 8); + this.bufferBuilder.append((low & 0x000000ff)); +} + +function _utf8Replace(m){ + var code = m.charCodeAt(0); + + if(code <= 0x7ff) return '00'; + if(code <= 0xffff) return '000'; + if(code <= 0x1fffff) return '0000'; + if(code <= 0x3ffffff) return '00000'; + return '000000'; +} + +function utf8Length(str){ + if (str.length > 600) { + // Blob method faster for large strings + return (new Blob([str])).size; + } else { + return str.replace(/[^\u0000-\u007F]/g, _utf8Replace).length; + } +} +/** + * Light EventEmitter. Ported from Node.js/events.js + * Eric Zhang + */ + +/** + * EventEmitter class + * Creates an object with event registering and firing methods + */ +function EventEmitter() { + // Initialise required storage variables + this._events = {}; +} + +var isArray = Array.isArray; + + +EventEmitter.prototype.addListener = function(type, listener, scope, once) { + if ('function' !== typeof listener) { + throw new Error('addListener only takes instances of Function'); + } + + // To avoid recursion in the case that type == "newListeners"! Before + // adding it to the listeners, first emit "newListeners". + this.emit('newListener', type, typeof listener.listener === 'function' ? + listener.listener : listener); + + if (!this._events[type]) { + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + } else if (isArray(this._events[type])) { + + // If we've already got an array, just append. + this._events[type].push(listener); + + } else { + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + } + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener, scope) { + if ('function' !== typeof listener) { + throw new Error('.once only takes instances of Function'); + } + + var self = this; + function g() { + self.removeListener(type, g); + listener.apply(this, arguments); + }; + + g.listener = listener; + self.on(type, g); + + return this; +}; + +EventEmitter.prototype.removeListener = function(type, listener, scope) { + if ('function' !== typeof listener) { + throw new Error('removeListener only takes instances of Function'); + } + + // does not use listeners(), so no side effect of creating _events[type] + if (!this._events[type]) return this; + + var list = this._events[type]; + + if (isArray(list)) { + var position = -1; + for (var i = 0, length = list.length; i < length; i++) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) + { + position = i; + break; + } + } + + if (position < 0) return this; + list.splice(position, 1); + if (list.length == 0) + delete this._events[type]; + } else if (list === listener || + (list.listener && list.listener === listener)) + { + delete this._events[type]; + } + + return this; +}; + + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + + +EventEmitter.prototype.removeAllListeners = function(type) { + if (arguments.length === 0) { + this._events = {}; + return this; + } + + // does not use listeners(), so no side effect of creating _events[type] + if (type && this._events && this._events[type]) this._events[type] = null; + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + if (!this._events[type]) this._events[type] = []; + if (!isArray(this._events[type])) { + this._events[type] = [this._events[type]]; + } + return this._events[type]; +}; + +EventEmitter.prototype.emit = function(type) { + var type = arguments[0]; + var handler = this._events[type]; + if (!handler) return false; + + if (typeof handler == 'function') { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + var l = arguments.length; + var args = new Array(l - 1); + for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; + handler.apply(this, args); + } + return true; + + } else if (isArray(handler)) { + var l = arguments.length; + var args = new Array(l - 1); + for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; + + var listeners = handler.slice(); + for (var i = 0, l = listeners.length; i < l; i++) { + listeners[i].apply(this, args); + } + return true; + } else { + return false; + } +}; + + + +/** + * Reliable transfer for Chrome Canary DataChannel impl. + * Author: @michellebu + */ +function Reliable(dc, debug) { + if (!(this instanceof Reliable)) return new Reliable(dc); + this._dc = dc; + + util.debug = debug; + + // Messages sent/received so far. + // id: { ack: n, chunks: [...] } + this._outgoing = {}; + // id: { ack: ['ack', id, n], chunks: [...] } + this._incoming = {}; + this._received = {}; + + // Window size. + this._window = 1000; + // MTU. + this._mtu = 500; + // Interval for setInterval. In ms. + this._interval = 0; + + // Messages sent. + this._count = 0; + + // Outgoing message queue. + this._queue = []; + + this._setupDC(); +}; + +// Send a message reliably. +Reliable.prototype.send = function(msg) { + // Determine if chunking is necessary. + var bl = util.pack(msg); + if (bl.size < this._mtu) { + this._handleSend(['no', bl]); + return; + } + + this._outgoing[this._count] = { + ack: 0, + chunks: this._chunk(bl) + }; + + if (util.debug) { + this._outgoing[this._count].timer = new Date(); + } + + // Send prelim window. + this._sendWindowedChunks(this._count); + this._count += 1; +}; + +// Set up interval for processing queue. +Reliable.prototype._setupInterval = function() { + // TODO: fail gracefully. + + var self = this; + this._timeout = setInterval(function() { + // FIXME: String stuff makes things terribly async. + var msg = self._queue.shift(); + if (msg._multiple) { + for (var i = 0, ii = msg.length; i < ii; i += 1) { + self._intervalSend(msg[i]); + } + } else { + self._intervalSend(msg); + } + }, this._interval); +}; + +Reliable.prototype._intervalSend = function(msg) { + var self = this; + msg = util.pack(msg); + util.blobToBinaryString(msg, function(str) { + self._dc.send(str); + }); + if (self._queue.length === 0) { + clearTimeout(self._timeout); + self._timeout = null; + //self._processAcks(); + } +}; + +// Go through ACKs to send missing pieces. +Reliable.prototype._processAcks = function() { + for (var id in this._outgoing) { + if (this._outgoing.hasOwnProperty(id)) { + this._sendWindowedChunks(id); + } + } +}; + +// Handle sending a message. +// FIXME: Don't wait for interval time for all messages... +Reliable.prototype._handleSend = function(msg) { + var push = true; + for (var i = 0, ii = this._queue.length; i < ii; i += 1) { + var item = this._queue[i]; + if (item === msg) { + push = false; + } else if (item._multiple && item.indexOf(msg) !== -1) { + push = false; + } + } + if (push) { + this._queue.push(msg); + if (!this._timeout) { + this._setupInterval(); + } + } +}; + +// Set up DataChannel handlers. +Reliable.prototype._setupDC = function() { + // Handle various message types. + var self = this; + this._dc.onmessage = function(e) { + var msg = e.data; + var datatype = msg.constructor; + // FIXME: msg is String until binary is supported. + // Once that happens, this will have to be smarter. + if (datatype === String) { + var ab = util.binaryStringToArrayBuffer(msg); + msg = util.unpack(ab); + self._handleMessage(msg); + } + }; +}; + +// Handles an incoming message. +Reliable.prototype._handleMessage = function(msg) { + var id = msg[1]; + var idata = this._incoming[id]; + var odata = this._outgoing[id]; + var data; + switch (msg[0]) { + // No chunking was done. + case 'no': + var message = id; + if (!!message) { + this.onmessage(util.unpack(message)); + } + break; + // Reached the end of the message. + case 'end': + data = idata; + + // In case end comes first. + this._received[id] = msg[2]; + + if (!data) { + break; + } + + this._ack(id); + break; + case 'ack': + data = odata; + if (!!data) { + var ack = msg[2]; + // Take the larger ACK, for out of order messages. + data.ack = Math.max(ack, data.ack); + + // Clean up when all chunks are ACKed. + if (data.ack >= data.chunks.length) { + util.log('Time: ', new Date() - data.timer); + delete this._outgoing[id]; + } else { + this._processAcks(); + } + } + // If !data, just ignore. + break; + // Received a chunk of data. + case 'chunk': + // Create a new entry if none exists. + data = idata; + if (!data) { + var end = this._received[id]; + if (end === true) { + break; + } + data = { + ack: ['ack', id, 0], + chunks: [] + }; + this._incoming[id] = data; + } + + var n = msg[2]; + var chunk = msg[3]; + data.chunks[n] = new Uint8Array(chunk); + + // If we get the chunk we're looking for, ACK for next missing. + // Otherwise, ACK the same N again. + if (n === data.ack[2]) { + this._calculateNextAck(id); + } + this._ack(id); + break; + default: + // Shouldn't happen, but would make sense for message to just go + // through as is. + this._handleSend(msg); + break; + } +}; + +// Chunks BL into smaller messages. +Reliable.prototype._chunk = function(bl) { + var chunks = []; + var size = bl.size; + var start = 0; + while (start < size) { + var end = Math.min(size, start + this._mtu); + var b = bl.slice(start, end); + var chunk = { + payload: b + } + chunks.push(chunk); + start = end; + } + util.log('Created', chunks.length, 'chunks.'); + return chunks; +}; + +// Sends ACK N, expecting Nth blob chunk for message ID. +Reliable.prototype._ack = function(id) { + var ack = this._incoming[id].ack; + + // if ack is the end value, then call _complete. + if (this._received[id] === ack[2]) { + this._complete(id); + this._received[id] = true; + } + + this._handleSend(ack); +}; + +// Calculates the next ACK number, given chunks. +Reliable.prototype._calculateNextAck = function(id) { + var data = this._incoming[id]; + var chunks = data.chunks; + for (var i = 0, ii = chunks.length; i < ii; i += 1) { + // This chunk is missing!!! Better ACK for it. + if (chunks[i] === undefined) { + data.ack[2] = i; + return; + } + } + data.ack[2] = chunks.length; +}; + +// Sends the next window of chunks. +Reliable.prototype._sendWindowedChunks = function(id) { + util.log('sendWindowedChunks for: ', id); + var data = this._outgoing[id]; + var ch = data.chunks; + var chunks = []; + var limit = Math.min(data.ack + this._window, ch.length); + for (var i = data.ack; i < limit; i += 1) { + if (!ch[i].sent || i === data.ack) { + ch[i].sent = true; + chunks.push(['chunk', id, i, ch[i].payload]); + } + } + if (data.ack + this._window >= ch.length) { + chunks.push(['end', id, ch.length]) + } + chunks._multiple = true; + this._handleSend(chunks); +}; + +// Puts together a message from chunks. +Reliable.prototype._complete = function(id) { + util.log('Completed called for', id); + var self = this; + var chunks = this._incoming[id].chunks; + var bl = new Blob(chunks); + util.blobToArrayBuffer(bl, function(ab) { + self.onmessage(util.unpack(ab)); + }); + delete this._incoming[id]; +}; + +// Ups bandwidth limit on SDP. Meant to be called during offer/answer. +Reliable.higherBandwidthSDP = function(sdp) { + // AS stands for Application-Specific Maximum. + // Bandwidth number is in kilobits / sec. + // See RFC for more info: http://www.ietf.org/rfc/rfc2327.txt + + // Chrome 31+ doesn't want us munging the SDP, so we'll let them have their + // way. + var version = navigator.appVersion.match(/Chrome\/(.*?) /); + if (version) { + version = parseInt(version[1].split('.').shift()); + if (version < 31) { + var parts = sdp.split('b=AS:30'); + var replace = 'b=AS:102400'; // 100 Mbps + if (parts.length > 1) { + return parts[0] + replace + parts[1]; + } + } + } + + return sdp; +}; + +// Overwritten, typically. +Reliable.prototype.onmessage = function(msg) {}; + +exports.Reliable = Reliable; +exports.RTCSessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription; +exports.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; +exports.RTCIceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate; +var defaultConfig = {'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }]}; +var dataCount = 1; + +var util = { + noop: function() {}, + + CLOUD_HOST: '0.peerjs.com', + CLOUD_PORT: 9000, + + // Browsers that need chunking: + chunkedBrowsers: {'Chrome': 1}, + chunkedMTU: 16300, // The original 60000 bytes setting does not work when sending data from Firefox to Chrome, which is "cut off" after 16384 bytes and delivered individually. + + // Logging logic + logLevel: 0, + setLogLevel: function(level) { + var debugLevel = parseInt(level, 10); + if (!isNaN(parseInt(level, 10))) { + util.logLevel = debugLevel; + } else { + // If they are using truthy/falsy values for debug + util.logLevel = level ? 3 : 0; + } + util.log = util.warn = util.error = util.noop; + if (util.logLevel > 0) { + util.error = util._printWith('ERROR'); + } + if (util.logLevel > 1) { + util.warn = util._printWith('WARNING'); + } + if (util.logLevel > 2) { + util.log = util._print; + } + }, + setLogFunction: function(fn) { + if (fn.constructor !== Function) { + util.warn('The log function you passed in is not a function. Defaulting to regular logs.'); + } else { + util._print = fn; + } + }, + + _printWith: function(prefix) { + return function() { + var copy = Array.prototype.slice.call(arguments); + copy.unshift(prefix); + util._print.apply(util, copy); + }; + }, + _print: function () { + var err = false; + var copy = Array.prototype.slice.call(arguments); + copy.unshift('PeerJS: '); + for (var i = 0, l = copy.length; i < l; i++){ + if (copy[i] instanceof Error) { + copy[i] = '(' + copy[i].name + ') ' + copy[i].message; + err = true; + } + } + err ? console.error.apply(console, copy) : console.log.apply(console, copy); + }, + // + + // Returns browser-agnostic default config + defaultConfig: defaultConfig, + // + + // Returns the current browser. + browser: (function() { + if (window.mozRTCPeerConnection) { + return 'Firefox'; + } else if (window.webkitRTCPeerConnection) { + return 'Chrome'; + } else if (window.RTCPeerConnection) { + return 'Supported'; + } else { + return 'Unsupported'; + } + })(), + // + + // Lists which features are supported + supports: (function() { + if (typeof RTCPeerConnection === 'undefined') { + return {}; + } + + var data = true; + var audioVideo = true; + + var binaryBlob = false; + var sctp = false; + var onnegotiationneeded = !!window.webkitRTCPeerConnection; + + var pc, dc; + try { + pc = new RTCPeerConnection(defaultConfig, {optional: [{RtpDataChannels: true}]}); + } catch (e) { + data = false; + audioVideo = false; + } + + if (data) { + try { + dc = pc.createDataChannel('_PEERJSTEST'); + } catch (e) { + data = false; + } + } + + if (data) { + // Binary test + try { + dc.binaryType = 'blob'; + binaryBlob = true; + } catch (e) { + } + + // Reliable test. + // Unfortunately Chrome is a bit unreliable about whether or not they + // support reliable. + var reliablePC = new RTCPeerConnection(defaultConfig, {}); + try { + var reliableDC = reliablePC.createDataChannel('_PEERJSRELIABLETEST', {}); + sctp = reliableDC.reliable; + } catch (e) { + } + reliablePC.close(); + } + + // FIXME: not really the best check... + if (audioVideo) { + audioVideo = !!pc.addStream; + } + + // FIXME: this is not great because in theory it doesn't work for + // av-only browsers (?). + if (!onnegotiationneeded && data) { + // sync default check. + var negotiationPC = new RTCPeerConnection(defaultConfig, {optional: [{RtpDataChannels: true}]}); + negotiationPC.onnegotiationneeded = function() { + onnegotiationneeded = true; + // async check. + if (util && util.supports) { + util.supports.onnegotiationneeded = true; + } + }; + var negotiationDC = negotiationPC.createDataChannel('_PEERJSNEGOTIATIONTEST'); + + setTimeout(function() { + negotiationPC.close(); + }, 1000); + } + + if (pc) { + pc.close(); + } + + return { + audioVideo: audioVideo, + data: data, + binaryBlob: binaryBlob, + binary: sctp, // deprecated; sctp implies binary support. + reliable: sctp, // deprecated; sctp implies reliable data. + sctp: sctp, + onnegotiationneeded: onnegotiationneeded + }; + }()), + // + + // Ensure alphanumeric ids + validateId: function(id) { + // Allow empty ids + return !id || /^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(id); + }, + + validateKey: function(key) { + // Allow empty keys + return !key || /^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(key); + }, + + + debug: false, + + inherits: function(ctor, superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }, + extend: function(dest, source) { + for(var key in source) { + if(source.hasOwnProperty(key)) { + dest[key] = source[key]; + } + } + return dest; + }, + pack: BinaryPack.pack, + unpack: BinaryPack.unpack, + + log: function () { + if (util.debug) { + var err = false; + var copy = Array.prototype.slice.call(arguments); + copy.unshift('PeerJS: '); + for (var i = 0, l = copy.length; i < l; i++){ + if (copy[i] instanceof Error) { + copy[i] = '(' + copy[i].name + ') ' + copy[i].message; + err = true; + } + } + err ? console.error.apply(console, copy) : console.log.apply(console, copy); + } + }, + + setZeroTimeout: (function(global) { + var timeouts = []; + var messageName = 'zero-timeout-message'; + + // Like setTimeout, but only takes a function argument. There's + // no time argument (always zero) and no arguments (you have to + // use a closure). + function setZeroTimeoutPostMessage(fn) { + timeouts.push(fn); + global.postMessage(messageName, '*'); + } + + function handleMessage(event) { + if (event.source == global && event.data == messageName) { + if (event.stopPropagation) { + event.stopPropagation(); + } + if (timeouts.length) { + timeouts.shift()(); + } + } + } + if (global.addEventListener) { + global.addEventListener('message', handleMessage, true); + } else if (global.attachEvent) { + global.attachEvent('onmessage', handleMessage); + } + return setZeroTimeoutPostMessage; + }(this)), + + // Binary stuff + + // chunks a blob. + chunk: function(bl) { + var chunks = []; + var size = bl.size; + var start = index = 0; + var total = Math.ceil(size / util.chunkedMTU); + while (start < size) { + var end = Math.min(size, start + util.chunkedMTU); + var b = bl.slice(start, end); + + var chunk = { + __peerData: dataCount, + n: index, + data: b, + total: total + }; + + chunks.push(chunk); + + start = end; + index += 1; + } + dataCount += 1; + return chunks; + }, + + blobToArrayBuffer: function(blob, cb){ + var fr = new FileReader(); + fr.onload = function(evt) { + cb(evt.target.result); + }; + fr.readAsArrayBuffer(blob); + }, + blobToBinaryString: function(blob, cb){ + var fr = new FileReader(); + fr.onload = function(evt) { + cb(evt.target.result); + }; + fr.readAsBinaryString(blob); + }, + binaryStringToArrayBuffer: function(binary) { + var byteArray = new Uint8Array(binary.length); + for (var i = 0; i < binary.length; i++) { + byteArray[i] = binary.charCodeAt(i) & 0xff; + } + return byteArray.buffer; + }, + randomToken: function () { + return Math.random().toString(36).substr(2); + }, + // + + isSecure: function() { + return location.protocol === 'https:'; + } +}; + +exports.util = util; +/** + * A peer who can initiate connections with other peers. + */ +function Peer(id, options) { + if (!(this instanceof Peer)) return new Peer(id, options); + EventEmitter.call(this); + + // Deal with overloading + if (id && id.constructor == Object) { + options = id; + id = undefined; + } else if (id) { + // Ensure id is a string + id = id.toString(); + } + // + + // Configurize options + options = util.extend({ + debug: 0, // 1: Errors, 2: Warnings, 3: All logs + host: util.CLOUD_HOST, + port: util.CLOUD_PORT, + key: 'peerjs', + path: '/', + token: util.randomToken(), + config: util.defaultConfig + }, options); + this.options = options; + // Detect relative URL host. + if (options.host === '/') { + options.host = window.location.hostname; + } + // Set path correctly. + if (options.path[0] !== '/') { + options.path = '/' + options.path; + } + if (options.path[options.path.length - 1] !== '/') { + options.path += '/'; + } + + // Set whether we use SSL to same as current host + if (options.secure === undefined && options.host !== util.CLOUD_HOST) { + options.secure = util.isSecure(); + } + // Set a custom log function if present + if (options.logFunction) { + util.setLogFunction(options.logFunction); + } + util.setLogLevel(options.debug); + // + + // Sanity checks + // Ensure WebRTC supported + if (!util.supports.audioVideo && !util.supports.data ) { + this._delayedAbort('browser-incompatible', 'The current browser does not support WebRTC'); + return; + } + // Ensure alphanumeric id + if (!util.validateId(id)) { + this._delayedAbort('invalid-id', 'ID "' + id + '" is invalid'); + return; + } + // Ensure valid key + if (!util.validateKey(options.key)) { + this._delayedAbort('invalid-key', 'API KEY "' + options.key + '" is invalid'); + return; + } + // Ensure not using unsecure cloud server on SSL page + if (options.secure && options.host === '0.peerjs.com') { + this._delayedAbort('ssl-unavailable', + 'The cloud server currently does not support HTTPS. Please run your own PeerServer to use HTTPS.'); + return; + } + // + + // States. + this.destroyed = false; // Connections have been killed + this.disconnected = false; // Connection to PeerServer killed but P2P connections still active + this.open = false; // Sockets and such are not yet open. + // + + // References + this.connections = {}; // DataConnections for this peer. + this._lostMessages = {}; // src => [list of messages] + // + + // Start the server connection + this._initializeServerConnection(); + if (id) { + this._initialize(id); + } else { + this._retrieveId(); + } + // +}; + +util.inherits(Peer, EventEmitter); + +// Initialize the 'socket' (which is actually a mix of XHR streaming and +// websockets.) +Peer.prototype._initializeServerConnection = function() { + var self = this; + this.socket = new Socket(this.options.secure, this.options.host, this.options.port, this.options.path, this.options.key); + this.socket.on('message', function(data) { + self._handleMessage(data); + }); + this.socket.on('error', function(error) { + self._abort('socket-error', error); + }); + this.socket.on('disconnected', function() { + // If we haven't explicitly disconnected, emit error and disconnect. + if (!self.disconnected) { + self.emitError('network', 'Lost connection to server.') + self.disconnect(); + } + }); + this.socket.on('close', function() { + // If we haven't explicitly disconnected, emit error. + if (!self.disconnected) { + self._abort('socket-closed', 'Underlying socket is already closed.'); + } + }); +}; + +/** Get a unique ID from the server via XHR. */ +Peer.prototype._retrieveId = function(cb) { + var self = this; + var http = new XMLHttpRequest(); + var protocol = this.options.secure ? 'https://' : 'http://'; + var url = protocol + this.options.host + ':' + this.options.port + + this.options.path + this.options.key + '/id'; + var queryString = '?ts=' + new Date().getTime() + '' + Math.random(); + url += queryString; + + // If there's no ID we need to wait for one before trying to init socket. + http.open('get', url, true); + http.onerror = function(e) { + util.error('Error retrieving ID', e); + var pathError = ''; + if (self.options.path === '/' && self.options.host !== util.CLOUD_HOST) { + pathError = ' If you passed in a `path` to your self-hosted PeerServer, ' + + 'you\'ll also need to pass in that same path when creating a new' + + ' Peer.'; + } + self._abort('server-error', 'Could not get an ID from the server.' + pathError); + } + http.onreadystatechange = function() { + if (http.readyState !== 4) { + return; + } + if (http.status !== 200) { + http.onerror(); + return; + } + self._initialize(http.responseText); + }; + http.send(null); +}; + +/** Initialize a connection with the server. */ +Peer.prototype._initialize = function(id) { + this.id = id; + this.socket.start(this.id, this.options.token); +} + +/** Handles messages from the server. */ +Peer.prototype._handleMessage = function(message) { + var type = message.type; + var payload = message.payload; + var peer = message.src; + + switch (type) { + case 'OPEN': // The connection to the server is open. + this.emit('open', this.id); + this.open = true; + break; + case 'ERROR': // Server error. + this._abort('server-error', payload.msg); + break; + case 'ID-TAKEN': // The selected ID is taken. + this._abort('unavailable-id', 'ID `' + this.id + '` is taken'); + break; + case 'INVALID-KEY': // The given API key cannot be found. + this._abort('invalid-key', 'API KEY "' + this.options.key + '" is invalid'); + break; + + // + case 'LEAVE': // Another peer has closed its connection to this peer. + util.log('Received leave message from', peer); + this._cleanupPeer(peer); + break; + + case 'EXPIRE': // The offer sent to a peer has expired without response. + this.emitError('peer-unavailable', 'Could not connect to peer ' + peer); + break; + case 'OFFER': // we should consider switching this to CALL/CONNECT, but this is the least breaking option. + var connectionId = payload.connectionId; + var connection = this.getConnection(peer, connectionId); + + if (connection) { + util.warn('Offer received for existing Connection ID:', connectionId); + //connection.handleMessage(message); + } else { + // Create a new connection. + if (payload.type === 'media') { + var connection = new MediaConnection(peer, this, { + connectionId: connectionId, + _payload: payload, + metadata: payload.metadata + }); + this._addConnection(peer, connection); + this.emit('call', connection); + } else if (payload.type === 'data') { + connection = new DataConnection(peer, this, { + connectionId: connectionId, + _payload: payload, + metadata: payload.metadata, + label: payload.label, + serialization: payload.serialization, + reliable: payload.reliable + }); + this._addConnection(peer, connection); + this.emit('connection', connection); + } else { + util.warn('Received malformed connection type:', payload.type); + return; + } + // Find messages. + var messages = this._getMessages(connectionId); + for (var i = 0, ii = messages.length; i < ii; i += 1) { + connection.handleMessage(messages[i]); + } + } + break; + default: + if (!payload) { + util.warn('You received a malformed message from ' + peer + ' of type ' + type); + return; + } + + var id = payload.connectionId; + var connection = this.getConnection(peer, id); + + if (connection && connection.pc) { + // Pass it on. + connection.handleMessage(message); + } else if (id) { + // Store for possible later use + this._storeMessage(id, message); + } else { + util.warn('You received an unrecognized message:', message); + } + break; + } +} + +/** Stores messages without a set up connection, to be claimed later. */ +Peer.prototype._storeMessage = function(connectionId, message) { + if (!this._lostMessages[connectionId]) { + this._lostMessages[connectionId] = []; + } + this._lostMessages[connectionId].push(message); +} + +/** Retrieve messages from lost message store */ +Peer.prototype._getMessages = function(connectionId) { + var messages = this._lostMessages[connectionId]; + if (messages) { + delete this._lostMessages[connectionId]; + return messages; + } else { + return []; + } +} + +/** + * Returns a DataConnection to the specified peer. See documentation for a + * complete list of options. + */ +Peer.prototype.connect = function(peer, options) { + if (this.disconnected) { + util.warn('You cannot connect to a new Peer because you called ' + + '.disconnect() on this Peer and ended your connection with the' + + ' server. You can create a new Peer to reconnect, or call reconnect' + + ' on this peer if you believe its ID to still be available.'); + this.emitError('disconnected', 'Cannot connect to new Peer after disconnecting from server.'); + return; + } + var connection = new DataConnection(peer, this, options); + this._addConnection(peer, connection); + return connection; +} + +/** + * Returns a MediaConnection to the specified peer. See documentation for a + * complete list of options. + */ +Peer.prototype.call = function(peer, stream, options) { + if (this.disconnected) { + util.warn('You cannot connect to a new Peer because you called ' + + '.disconnect() on this Peer and ended your connection with the' + + ' server. You can create a new Peer to reconnect.'); + this.emitError('disconnected', 'Cannot connect to new Peer after disconnecting from server.'); + return; + } + if (!stream) { + util.error('To call a peer, you must provide a stream from your browser\'s `getUserMedia`.'); + return; + } + options = options || {}; + options._stream = stream; + var call = new MediaConnection(peer, this, options); + this._addConnection(peer, call); + return call; +} + +/** Add a data/media connection to this peer. */ +Peer.prototype._addConnection = function(peer, connection) { + if (!this.connections[peer]) { + this.connections[peer] = []; + } + this.connections[peer].push(connection); +} + +/** Retrieve a data/media connection for this peer. */ +Peer.prototype.getConnection = function(peer, id) { + var connections = this.connections[peer]; + if (!connections) { + return null; + } + for (var i = 0, ii = connections.length; i < ii; i++) { + if (connections[i].id === id) { + return connections[i]; + } + } + return null; +} + +Peer.prototype._delayedAbort = function(type, message) { + var self = this; + util.setZeroTimeout(function(){ + self._abort(type, message); + }); +} + +/** + * Destroys the Peer and emits an error message. + * The Peer is not destroyed if it's in a disconnected state, in which case + * it retains its disconnected state and its existing connections. + */ +Peer.prototype._abort = function(type, message) { + util.error('Aborting!'); + if (!this._lastServerId) { + this.destroy(); + } else { + this.disconnect(); + } + this.emitError(type, message); +}; + +/** Emits a typed error message. */ +Peer.prototype.emitError = function(type, err) { + util.error('Error:', err); + if (typeof err === 'string') { + err = new Error(err); + } + err.type = type; + this.emit('error', err); +}; + +/** + * Destroys the Peer: closes all active connections as well as the connection + * to the server. + * Warning: The peer can no longer create or accept connections after being + * destroyed. + */ +Peer.prototype.destroy = function() { + if (!this.destroyed) { + this._cleanup(); + this.disconnect(); + this.destroyed = true; + } +} + + +/** Disconnects every connection on this peer. */ +Peer.prototype._cleanup = function() { + if (this.connections) { + var peers = Object.keys(this.connections); + for (var i = 0, ii = peers.length; i < ii; i++) { + this._cleanupPeer(peers[i]); + } + } + this.emit('close'); +} + +/** Closes all connections to this peer. */ +Peer.prototype._cleanupPeer = function(peer) { + var connections = this.connections[peer]; + for (var j = 0, jj = connections.length; j < jj; j += 1) { + connections[j].close(); + } +} + +/** + * Disconnects the Peer's connection to the PeerServer. Does not close any + * active connections. + * Warning: The peer can no longer create or accept connections after being + * disconnected. It also cannot reconnect to the server. + */ +Peer.prototype.disconnect = function() { + var self = this; + util.setZeroTimeout(function(){ + if (!self.disconnected) { + self.disconnected = true; + self.open = false; + if (self.socket) { + self.socket.close(); + } + self.emit('disconnected', self.id); + self._lastServerId = self.id; + self.id = null; + } + }); +} + +/** Attempts to reconnect with the same ID. */ +Peer.prototype.reconnect = function() { + if (this.disconnected && !this.destroyed) { + util.log('Attempting reconnection to server with ID ' + this._lastServerId); + this.disconnected = false; + this._initializeServerConnection(); + this._initialize(this._lastServerId); + } else if (this.destroyed) { + throw new Error('This peer cannot reconnect to the server. It has already been destroyed.'); + } else if (!this.disconnected && !this.open) { + // Do nothing. We're still connecting the first time. + util.error('In a hurry? We\'re still trying to make the initial connection!'); + } else { + throw new Error('Peer ' + this.id + ' cannot reconnect because it is not disconnected from the server!'); + } +}; + +/** + * Get a list of available peer IDs. If you're running your own server, you'll + * want to set allow_discovery: true in the PeerServer options. If you're using + * the cloud server, email team@peerjs.com to get the functionality enabled for + * your key. + */ +Peer.prototype.listAllPeers = function(cb) { + cb = cb || function() {}; + var self = this; + var http = new XMLHttpRequest(); + var protocol = this.options.secure ? 'https://' : 'http://'; + var url = protocol + this.options.host + ':' + this.options.port + + this.options.path + this.options.key + '/peers'; + var queryString = '?ts=' + new Date().getTime() + '' + Math.random(); + url += queryString; + + // If there's no ID we need to wait for one before trying to init socket. + http.open('get', url, true); + http.onerror = function(e) { + self._abort('server-error', 'Could not get peers from the server.'); + cb([]); + } + http.onreadystatechange = function() { + if (http.readyState !== 4) { + return; + } + if (http.status === 401) { + var helpfulError = ''; + if (self.options.host !== util.CLOUD_HOST) { + helpfulError = 'It looks like you\'re using the cloud server. You can email ' + + 'team@peerjs.com to enable peer listing for your API key.'; + } else { + helpfulError = 'You need to enable `allow_discovery` on your self-hosted' + + ' PeerServer to use this feature.'; + } + throw new Error('It doesn\'t look like you have permission to list peers IDs. ' + helpfulError); + cb([]); + } else if (http.status !== 200) { + cb([]); + } else { + cb(JSON.parse(http.responseText)); + } + }; + http.send(null); +} + +exports.Peer = Peer; +/** + * Wraps a DataChannel between two Peers. + */ +function DataConnection(peer, provider, options) { + if (!(this instanceof DataConnection)) return new DataConnection(peer, provider, options); + EventEmitter.call(this); + + this.options = util.extend({ + serialization: 'binary', + reliable: false + }, options); + + // Connection is not open yet. + this.open = false; + this.type = 'data'; + this.peer = peer; + this.provider = provider; + + this.id = this.options.connectionId || DataConnection._idPrefix + util.randomToken(); + + this.label = this.options.label || this.id; + this.metadata = this.options.metadata; + this.serialization = this.options.serialization; + this.reliable = this.options.reliable; + + // Data channel buffering. + this._buffer = []; + this._buffering = false; + this.bufferSize = 0; + + // For storing large data. + this._chunkedData = {}; + + if (this.options._payload) { + this._peerBrowser = this.options._payload.browser; + } + + Negotiator.startConnection( + this, + this.options._payload || { + originator: true + } + ); +} + +util.inherits(DataConnection, EventEmitter); + +DataConnection._idPrefix = 'dc_'; + +/** Called by the Negotiator when the DataChannel is ready. */ +DataConnection.prototype.initialize = function(dc) { + this._dc = this.dataChannel = dc; + this._configureDataChannel(); +} + +DataConnection.prototype._configureDataChannel = function() { + var self = this; + if (util.supports.sctp) { + this._dc.binaryType = 'arraybuffer'; + } + this._dc.onopen = function() { + util.log('Data channel connection success'); + self.open = true; + self.emit('open'); + } + + // Use the Reliable shim for non Firefox browsers + if (!util.supports.sctp && this.reliable) { + this._reliable = new Reliable(this._dc, util.debug); + } + + if (this._reliable) { + this._reliable.onmessage = function(msg) { + self.emit('data', msg); + }; + } else { + this._dc.onmessage = function(e) { + self._handleDataMessage(e); + }; + } + this._dc.onclose = function(e) { + util.log('DataChannel closed for:', self.peer); + self.close(); + }; +} + +// Handles a DataChannel message. +DataConnection.prototype._handleDataMessage = function(e) { + var self = this; + var data = e.data; + var datatype = data.constructor; + if (this.serialization === 'binary' || this.serialization === 'binary-utf8') { + if (datatype === Blob) { + // Datatype should never be blob + util.blobToArrayBuffer(data, function(ab) { + data = util.unpack(ab); + self.emit('data', data); + }); + return; + } else if (datatype === ArrayBuffer) { + data = util.unpack(data); + } else if (datatype === String) { + // String fallback for binary data for browsers that don't support binary yet + var ab = util.binaryStringToArrayBuffer(data); + data = util.unpack(ab); + } + } else if (this.serialization === 'json') { + data = JSON.parse(data); + } + + // Check if we've chunked--if so, piece things back together. + // We're guaranteed that this isn't 0. + if (data.__peerData) { + var id = data.__peerData; + var chunkInfo = this._chunkedData[id] || {data: [], count: 0, total: data.total}; + + chunkInfo.data[data.n] = data.data; + chunkInfo.count += 1; + + if (chunkInfo.total === chunkInfo.count) { + // Clean up before making the recursive call to `_handleDataMessage`. + delete this._chunkedData[id]; + + // We've received all the chunks--time to construct the complete data. + data = new Blob(chunkInfo.data); + this._handleDataMessage({data: data}); + } + + this._chunkedData[id] = chunkInfo; + return; + } + + this.emit('data', data); +} + +/** + * Exposed functionality for users. + */ + +/** Allows user to close connection. */ +DataConnection.prototype.close = function() { + if (!this.open) { + return; + } + this.open = false; + Negotiator.cleanup(this); + this.emit('close'); +} + +/** Allows user to send data. */ +DataConnection.prototype.send = function(data, chunked) { + if (!this.open) { + this.emit('error', new Error('Connection is not open. You should listen for the `open` event before sending messages.')); + return; + } + if (this._reliable) { + // Note: reliable shim sending will make it so that you cannot customize + // serialization. + this._reliable.send(data); + return; + } + var self = this; + if (this.serialization === 'json') { + this._bufferedSend(JSON.stringify(data)); + } else if (this.serialization === 'binary' || this.serialization === 'binary-utf8') { + var blob = util.pack(data); + + // For Chrome-Firefox interoperability, we need to make Firefox "chunk" + // the data it sends out. + var needsChunking = util.chunkedBrowsers[this._peerBrowser] || util.chunkedBrowsers[util.browser]; + if (needsChunking && !chunked && blob.size > util.chunkedMTU) { + this._sendChunks(blob); + return; + } + + // DataChannel currently only supports strings. + if (!util.supports.sctp) { + util.blobToBinaryString(blob, function(str) { + self._bufferedSend(str); + }); + } else if (!util.supports.binaryBlob) { + // We only do this if we really need to (e.g. blobs are not supported), + // because this conversion is costly. + util.blobToArrayBuffer(blob, function(ab) { + self._bufferedSend(ab); + }); + } else { + this._bufferedSend(blob); + } + } else { + this._bufferedSend(data); + } +} + +DataConnection.prototype._bufferedSend = function(msg) { + if (this._buffering || !this._trySend(msg)) { + this._buffer.push(msg); + this.bufferSize = this._buffer.length; + } +} + +// Returns true if the send succeeds. +DataConnection.prototype._trySend = function(msg) { + try { + this._dc.send(msg); + } catch (e) { + this._buffering = true; + + var self = this; + setTimeout(function() { + // Try again. + self._buffering = false; + self._tryBuffer(); + }, 100); + return false; + } + return true; +} + +// Try to send the first message in the buffer. +DataConnection.prototype._tryBuffer = function() { + if (this._buffer.length === 0) { + return; + } + + var msg = this._buffer[0]; + + if (this._trySend(msg)) { + this._buffer.shift(); + this.bufferSize = this._buffer.length; + this._tryBuffer(); + } +} + +DataConnection.prototype._sendChunks = function(blob) { + var blobs = util.chunk(blob); + for (var i = 0, ii = blobs.length; i < ii; i += 1) { + var blob = blobs[i]; + this.send(blob, true); + } +} + +DataConnection.prototype.handleMessage = function(message) { + var payload = message.payload; + + switch (message.type) { + case 'ANSWER': + this._peerBrowser = payload.browser; + + // Forward to negotiator + Negotiator.handleSDP(message.type, this, payload.sdp); + break; + case 'CANDIDATE': + Negotiator.handleCandidate(this, payload.candidate); + break; + default: + util.warn('Unrecognized message type:', message.type, 'from peer:', this.peer); + break; + } +} +/** + * Wraps the streaming interface between two Peers. + */ +function MediaConnection(peer, provider, options) { + if (!(this instanceof MediaConnection)) return new MediaConnection(peer, provider, options); + EventEmitter.call(this); + + this.options = util.extend({}, options); + + this.open = false; + this.type = 'media'; + this.peer = peer; + this.provider = provider; + this.metadata = this.options.metadata; + this.localStream = this.options._stream; + + this.id = this.options.connectionId || MediaConnection._idPrefix + util.randomToken(); + if (this.localStream) { + Negotiator.startConnection( + this, + {_stream: this.localStream, originator: true} + ); + } +}; + +util.inherits(MediaConnection, EventEmitter); + +MediaConnection._idPrefix = 'mc_'; + +MediaConnection.prototype.addStream = function(remoteStream) { + util.log('Receiving stream', remoteStream); + + this.remoteStream = remoteStream; + this.emit('stream', remoteStream); // Should we call this `open`? + +}; + +MediaConnection.prototype.handleMessage = function(message) { + var payload = message.payload; + + switch (message.type) { + case 'ANSWER': + // Forward to negotiator + Negotiator.handleSDP(message.type, this, payload.sdp); + this.open = true; + break; + case 'CANDIDATE': + Negotiator.handleCandidate(this, payload.candidate); + break; + default: + util.warn('Unrecognized message type:', message.type, 'from peer:', this.peer); + break; + } +} + +MediaConnection.prototype.answer = function(stream) { + if (this.localStream) { + util.warn('Local stream already exists on this MediaConnection. Are you answering a call twice?'); + return; + } + + this.options._payload._stream = stream; + + this.localStream = stream; + Negotiator.startConnection( + this, + this.options._payload + ) + // Retrieve lost messages stored because PeerConnection not set up. + var messages = this.provider._getMessages(this.id); + for (var i = 0, ii = messages.length; i < ii; i += 1) { + this.handleMessage(messages[i]); + } + this.open = true; +}; + +/** + * Exposed functionality for users. + */ + +/** Allows user to close connection. */ +MediaConnection.prototype.close = function() { + if (!this.open) { + return; + } + this.open = false; + Negotiator.cleanup(this); + this.emit('close') +}; +/** + * Manages all negotiations between Peers. + */ +var Negotiator = { + pcs: { + data: {}, + media: {} + }, // type => {peerId: {pc_id: pc}}. + //providers: {}, // provider's id => providers (there may be multiple providers/client. + queue: [] // connections that are delayed due to a PC being in use. +} + +Negotiator._idPrefix = 'pc_'; + +/** Returns a PeerConnection object set up correctly (for data, media). */ +Negotiator.startConnection = function(connection, options) { + var pc = Negotiator._getPeerConnection(connection, options); + + if (connection.type === 'media' && options._stream) { + // Add the stream. + pc.addStream(options._stream); + } + + // Set the connection's PC. + connection.pc = connection.peerConnection = pc; + // What do we need to do now? + if (options.originator) { + if (connection.type === 'data') { + // Create the datachannel. + var config = {}; + // Dropping reliable:false support, since it seems to be crashing + // Chrome. + /*if (util.supports.sctp && !options.reliable) { + // If we have canonical reliable support... + config = {maxRetransmits: 0}; + }*/ + // Fallback to ensure older browsers don't crash. + if (!util.supports.sctp) { + config = {reliable: options.reliable}; + } + var dc = pc.createDataChannel(connection.label, config); + connection.initialize(dc); + } + + if (!util.supports.onnegotiationneeded) { + Negotiator._makeOffer(connection); + } + } else { + Negotiator.handleSDP('OFFER', connection, options.sdp); + } +} + +Negotiator._getPeerConnection = function(connection, options) { + if (!Negotiator.pcs[connection.type]) { + util.error(connection.type + ' is not a valid connection type. Maybe you overrode the `type` property somewhere.'); + } + + if (!Negotiator.pcs[connection.type][connection.peer]) { + Negotiator.pcs[connection.type][connection.peer] = {}; + } + var peerConnections = Negotiator.pcs[connection.type][connection.peer]; + + var pc; + // Not multiplexing while FF and Chrome have not-great support for it. + /*if (options.multiplex) { + ids = Object.keys(peerConnections); + for (var i = 0, ii = ids.length; i < ii; i += 1) { + pc = peerConnections[ids[i]]; + if (pc.signalingState === 'stable') { + break; // We can go ahead and use this PC. + } + } + } else */ + if (options.pc) { // Simplest case: PC id already provided for us. + pc = Negotiator.pcs[connection.type][connection.peer][options.pc]; + } + + if (!pc || pc.signalingState !== 'stable') { + pc = Negotiator._startPeerConnection(connection); + } + return pc; +} + +/* +Negotiator._addProvider = function(provider) { + if ((!provider.id && !provider.disconnected) || !provider.socket.open) { + // Wait for provider to obtain an ID. + provider.on('open', function(id) { + Negotiator._addProvider(provider); + }); + } else { + Negotiator.providers[provider.id] = provider; + } +}*/ + + +/** Start a PC. */ +Negotiator._startPeerConnection = function(connection) { + util.log('Creating RTCPeerConnection.'); + + var id = Negotiator._idPrefix + util.randomToken(); + var optional = {}; + + if (connection.type === 'data' && !util.supports.sctp) { + optional = {optional: [{RtpDataChannels: true}]}; + } else if (connection.type === 'media') { + // Interop req for chrome. + optional = {optional: [{DtlsSrtpKeyAgreement: true}]}; + } + + var pc = new RTCPeerConnection(connection.provider.options.config, optional); + Negotiator.pcs[connection.type][connection.peer][id] = pc; + + Negotiator._setupListeners(connection, pc, id); + + return pc; +} + +/** Set up various WebRTC listeners. */ +Negotiator._setupListeners = function(connection, pc, pc_id) { + var peerId = connection.peer; + var connectionId = connection.id; + var provider = connection.provider; + + // ICE CANDIDATES. + util.log('Listening for ICE candidates.'); + pc.onicecandidate = function(evt) { + if (evt.candidate) { + util.log('Received ICE candidates for:', connection.peer); + provider.socket.send({ + type: 'CANDIDATE', + payload: { + candidate: evt.candidate, + type: connection.type, + connectionId: connection.id + }, + dst: peerId + }); + } + }; + + pc.oniceconnectionstatechange = function() { + switch (pc.iceConnectionState) { + case 'disconnected': + case 'failed': + util.log('iceConnectionState is disconnected, closing connections to ' + peerId); + connection.close(); + break; + case 'completed': + pc.onicecandidate = util.noop; + break; + } + }; + + // Fallback for older Chrome impls. + pc.onicechange = pc.oniceconnectionstatechange; + + // ONNEGOTIATIONNEEDED (Chrome) + util.log('Listening for `negotiationneeded`'); + pc.onnegotiationneeded = function() { + util.log('`negotiationneeded` triggered'); + if (pc.signalingState == 'stable') { + Negotiator._makeOffer(connection); + } else { + util.log('onnegotiationneeded triggered when not stable. Is another connection being established?'); + } + }; + + // DATACONNECTION. + util.log('Listening for data channel'); + // Fired between offer and answer, so options should already be saved + // in the options hash. + pc.ondatachannel = function(evt) { + util.log('Received data channel'); + var dc = evt.channel; + var connection = provider.getConnection(peerId, connectionId); + connection.initialize(dc); + }; + + // MEDIACONNECTION. + util.log('Listening for remote stream'); + pc.onaddstream = function(evt) { + util.log('Received remote stream'); + var stream = evt.stream; + provider.getConnection(peerId, connectionId).addStream(stream); + }; +} + +Negotiator.cleanup = function(connection) { + util.log('Cleaning up PeerConnection to ' + connection.peer); + + var pc = connection.pc; + + if (!!pc && (pc.readyState !== 'closed' || pc.signalingState !== 'closed')) { + pc.close(); + connection.pc = null; + } +} + +Negotiator._makeOffer = function(connection) { + var pc = connection.pc; + pc.createOffer(function(offer) { + util.log('Created offer.'); + + if (!util.supports.sctp && connection.type === 'data' && connection.reliable) { + offer.sdp = Reliable.higherBandwidthSDP(offer.sdp); + } + + pc.setLocalDescription(offer, function() { + util.log('Set localDescription: offer', 'for:', connection.peer); + connection.provider.socket.send({ + type: 'OFFER', + payload: { + sdp: offer, + type: connection.type, + label: connection.label, + connectionId: connection.id, + reliable: connection.reliable, + serialization: connection.serialization, + metadata: connection.metadata, + browser: util.browser + }, + dst: connection.peer + }); + }, function(err) { + connection.provider.emitError('webrtc', err); + util.log('Failed to setLocalDescription, ', err); + }); + }, function(err) { + connection.provider.emitError('webrtc', err); + util.log('Failed to createOffer, ', err); + }, connection.options.constraints); +} + +Negotiator._makeAnswer = function(connection) { + var pc = connection.pc; + + pc.createAnswer(function(answer) { + util.log('Created answer.'); + + if (!util.supports.sctp && connection.type === 'data' && connection.reliable) { + answer.sdp = Reliable.higherBandwidthSDP(answer.sdp); + } + + pc.setLocalDescription(answer, function() { + util.log('Set localDescription: answer', 'for:', connection.peer); + connection.provider.socket.send({ + type: 'ANSWER', + payload: { + sdp: answer, + type: connection.type, + connectionId: connection.id, + browser: util.browser + }, + dst: connection.peer + }); + }, function(err) { + connection.provider.emitError('webrtc', err); + util.log('Failed to setLocalDescription, ', err); + }); + }, function(err) { + connection.provider.emitError('webrtc', err); + util.log('Failed to create answer, ', err); + }); +} + +/** Handle an SDP. */ +Negotiator.handleSDP = function(type, connection, sdp) { + sdp = new RTCSessionDescription(sdp); + var pc = connection.pc; + + util.log('Setting remote description', sdp); + pc.setRemoteDescription(sdp, function() { + util.log('Set remoteDescription:', type, 'for:', connection.peer); + + if (type === 'OFFER') { + Negotiator._makeAnswer(connection); + } + }, function(err) { + connection.provider.emitError('webrtc', err); + util.log('Failed to setRemoteDescription, ', err); + }); +} + +/** Handle a candidate. */ +Negotiator.handleCandidate = function(connection, ice) { + var candidate = ice.candidate; + var sdpMLineIndex = ice.sdpMLineIndex; + connection.pc.addIceCandidate(new RTCIceCandidate({ + sdpMLineIndex: sdpMLineIndex, + candidate: candidate + })); + util.log('Added ICE candidate for:', connection.peer); +} +/** + * An abstraction on top of WebSockets and XHR streaming to provide fastest + * possible connection for peers. + */ +function Socket(secure, host, port, path, key) { + if (!(this instanceof Socket)) return new Socket(secure, host, port, path, key); + + EventEmitter.call(this); + + // Disconnected manually. + this.disconnected = false; + this._queue = []; + + var httpProtocol = secure ? 'https://' : 'http://'; + var wsProtocol = secure ? 'wss://' : 'ws://'; + this._httpUrl = httpProtocol + host + ':' + port + path + key; + this._wsUrl = wsProtocol + host + ':' + port + path + 'peerjs?key=' + key; +} + +util.inherits(Socket, EventEmitter); + + +/** Check in with ID or get one from server. */ +Socket.prototype.start = function(id, token) { + this.id = id; + + this._httpUrl += '/' + id + '/' + token; + this._wsUrl += '&id=' + id + '&token=' + token; + + this._startXhrStream(); + this._startWebSocket(); +} + + +/** Start up websocket communications. */ +Socket.prototype._startWebSocket = function(id) { + var self = this; + + if (this._socket) { + return; + } + + this._socket = new WebSocket(this._wsUrl); + + this._socket.onmessage = function(event) { + try { + var data = JSON.parse(event.data); + self.emit('message', data); + } catch(e) { + util.log('Invalid server message', event.data); + return; + } + }; + + this._socket.onclose = function(event) { + util.log('Socket closed.'); + self.disconnected = true; + self.emit('disconnected'); + }; + + // Take care of the queue of connections if necessary and make sure Peer knows + // socket is open. + this._socket.onopen = function() { + if (self._timeout) { + clearTimeout(self._timeout); + setTimeout(function(){ + self._http.abort(); + self._http = null; + }, 5000); + } + self._sendQueuedMessages(); + util.log('Socket open'); + }; +} + +/** Start XHR streaming. */ +Socket.prototype._startXhrStream = function(n) { + try { + var self = this; + this._http = new XMLHttpRequest(); + this._http._index = 1; + this._http._streamIndex = n || 0; + this._http.open('post', this._httpUrl + '/id?i=' + this._http._streamIndex, true); + this._http.onreadystatechange = function() { + if (this.readyState == 2 && this.old) { + this.old.abort(); + delete this.old; + } else if (this.readyState > 2 && this.status === 200 && this.responseText) { + self._handleStream(this); + } else if (this.status !== 200) { + // If we get a different status code, likely something went wrong. + // Stop streaming. + clearTimeout(self._timeout); + self.emit('disconnected'); + } + }; + this._http.send(null); + this._setHTTPTimeout(); + } catch(e) { + util.log('XMLHttpRequest not available; defaulting to WebSockets'); + } +} + + +/** Handles onreadystatechange response as a stream. */ +Socket.prototype._handleStream = function(http) { + // 3 and 4 are loading/done state. All others are not relevant. + var messages = http.responseText.split('\n'); + + // Check to see if anything needs to be processed on buffer. + if (http._buffer) { + while (http._buffer.length > 0) { + var index = http._buffer.shift(); + var bufferedMessage = messages[index]; + try { + bufferedMessage = JSON.parse(bufferedMessage); + } catch(e) { + http._buffer.shift(index); + break; + } + this.emit('message', bufferedMessage); + } + } + + var message = messages[http._index]; + if (message) { + http._index += 1; + // Buffering--this message is incomplete and we'll get to it next time. + // This checks if the httpResponse ended in a `\n`, in which case the last + // element of messages should be the empty string. + if (http._index === messages.length) { + if (!http._buffer) { + http._buffer = []; + } + http._buffer.push(http._index - 1); + } else { + try { + message = JSON.parse(message); + } catch(e) { + util.log('Invalid server message', message); + return; + } + this.emit('message', message); + } + } +} + +Socket.prototype._setHTTPTimeout = function() { + var self = this; + this._timeout = setTimeout(function() { + var old = self._http; + if (!self._wsOpen()) { + self._startXhrStream(old._streamIndex + 1); + self._http.old = old; + } else { + old.abort(); + } + }, 25000); +} + +/** Is the websocket currently open? */ +Socket.prototype._wsOpen = function() { + return this._socket && this._socket.readyState == 1; +} + +/** Send queued messages. */ +Socket.prototype._sendQueuedMessages = function() { + for (var i = 0, ii = this._queue.length; i < ii; i += 1) { + this.send(this._queue[i]); + } +} + +/** Exposed send for DC & Peer. */ +Socket.prototype.send = function(data) { + if (this.disconnected) { + return; + } + + // If we didn't get an ID yet, we can't yet send anything so we should queue + // up these messages. + if (!this.id) { + this._queue.push(data); + return; + } + + if (!data.type) { + this.emit('error', 'Invalid message'); + return; + } + + var message = JSON.stringify(data); + if (this._wsOpen()) { + this._socket.send(message); + } else { + var http = new XMLHttpRequest(); + var url = this._httpUrl + '/' + data.type.toLowerCase(); + http.open('post', url, true); + http.setRequestHeader('Content-Type', 'application/json'); + http.send(message); + } +} + +Socket.prototype.close = function() { + if (!this.disconnected && this._wsOpen()) { + this._socket.close(); + this.disconnected = true; + } +} + +})(this); @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-January-21'; +modules.store = '2015-February-28'; // XML_Serializer /////////////////////////////////////////////////////// @@ -320,7 +320,7 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide) { var appInfo = xmlNode.attributes.app, app = appInfo ? appInfo.split(' ')[0] : null; - if (ide && app !== this.app.split(' ')[0]) { + if (ide && app && app !== this.app.split(' ')[0]) { ide.inform( app + ' Project', 'This project has been created by a different app:\n\n' + @@ -977,7 +977,11 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) { ); } if (!receiver) { - return this.obsoleteBlock(isReporter); + if (!isGlobal) { + receiver = this.project.stage; + } else { + return this.obsoleteBlock(isReporter); + } } if (isGlobal) { info = detect(receiver.globalBlocks, function (block) { @@ -1023,6 +1027,7 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) { this.loadInput(child, inputs[i], block); } }, this); + block.cachedInputs = null; return block; }; @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-January-12'; +modules.threads = '2015-February-28'; var ThreadManager; var Process; @@ -1320,6 +1320,56 @@ Process.prototype.doRemoveTemporaries = function () { } }; +// Peer to peer primitives + +Process.prototype.sendPeerMessage = function (message, peer) { + var myself = this; + + if (peer instanceof List) { + peer.asArray().forEach(function (singlePeer) { + myself.sendPeerMessage(message, singlePeer); + }); + return; + } + + var stage = this.homeContext.receiver.parentThatIsA(StageMorph), + ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); + var connection = stage.peer.connect(peer, {reliable: true}); + connection.on('open', function () { + var data; + if (typeof message == "string") { + data = message; + } else if (typeof message == "function") { + data = message.toString(); + } else { + data = ide.serializer.serialize(message); + } + connection.send(data); + }); +}; + +Process.prototype.reportPeerList = function () { + var myself = this; + + if (!this.context.wait) { + var stage = this.homeContext.receiver.parentThatIsA(StageMorph); + stage.peer.listAllPeers(function (peers) { + myself.context.result = new List(peers); + }); + this.context.wait = true; + } else if (this.context.result) { + return this.context.result; + } + + this.pushContext('doYield'); + this.pushContext(); +}; + +Process.prototype.reportPeerId = function () { + var stage = this.homeContext.receiver.parentThatIsA(StageMorph); + return stage.peerId; +}; + // Process lists primitives Process.prototype.reportNewList = function (elements) { @@ -1969,7 +2019,7 @@ Process.prototype.reportTypeOf = function (thing) { if (thing === true || (thing === false)) { return 'Boolean'; } - if (!isNaN(filterFloat(thing))) { + if (!isNaN(+thing)) { return 'number'; } if (isString(thing)) { |
