psc-cms-js
Advanced tools
Comparing version 1.4.0-69b6388 to 1.4.0-be39184
@@ -20,2 +20,3 @@ | ||
lib/Psc/AjaxFormHandler.js | ||
vendor/lodash/lodash-0.10.0.min.js | ||
lib/Psc/InvalidArgumentException.js | ||
@@ -35,3 +36,2 @@ lib/Psc/Request.js | ||
lib/Psc/UI/FormController.js | ||
vendor/lodash/lodash-0.10.0.min.js | ||
lib/Psc/UI/Tab.js | ||
@@ -38,0 +38,0 @@ lib/Psc/UI/TabNotFoundException.js |
@@ -1,2 +0,2 @@ | ||
define(['joose', 'Psc/Code','Psc/Exception'], function(Joose) { | ||
define(['joose', 'lodash', 'Psc/Code','Psc/Exception'], function(Joose, _) { | ||
Joose.Class('Psc.InvalidArgumentException', { | ||
@@ -23,3 +23,3 @@ isa: Psc.Exception, | ||
return Joose.O.extend(this.SUPER(msg), { | ||
return _.extend(this.SUPER(msg), { | ||
arg: arg, | ||
@@ -26,0 +26,0 @@ expected: expected, |
@@ -1,2 +0,2 @@ | ||
define(['joose', 'jquery'], function (Joose, $) { | ||
define(['joose', 'jquery', 'lodash'], function (Joose, $, _) { | ||
Joose.Class('Psc.UI.Component', { | ||
@@ -14,2 +14,11 @@ | ||
var $html = $('<div class="component-wrapper input-set-wrapper"/>'); | ||
var dashedName; | ||
if (_.isArray(this.$$name)) { | ||
dashedName = this.$$name.join('-'); | ||
} else { | ||
dashedName = this.$$name; | ||
} | ||
$html.addClass('component-'+dashedName); | ||
@@ -16,0 +25,0 @@ if (this.$$label) { |
@@ -66,2 +66,14 @@ define(['joose', 'Psc/UI/Component'], function(Joose) { | ||
.val(value); | ||
return this._component(label, name, value, $field); | ||
}, | ||
miniTextField: function(label, name, value, length) { | ||
length = length || 3; | ||
var $field = $('<input type="text"/>') // type immer angeben sonst gehts nicht in IE http://api.jquery.com/jQuery/#jQuery2 | ||
.css({'width': (length+1)+'em'}) | ||
.attr('name',this._generateName(name)) | ||
.attr('class','text ui-widget-content ui-corner-all') | ||
.val(value); | ||
@@ -68,0 +80,0 @@ return this._component(label, name, value, $field); |
@@ -55,3 +55,5 @@ define(['joose', 'jquery-fileupload', 'jquery-iframe-transport', 'Psc/UI/GridTable', 'Psc/Code', 'Psc/Request', 'Psc/UI/Dialog','Psc/FormRequest'], function(Joose) { | ||
that.$$grid.onCellsDoubleClick(function (event, $cell, rowIndex, columnIndex) { | ||
that.openChangeValueDialog(rowIndex, columnIndex); | ||
if (that.$$grid.getColumns()[columnIndex].editable) { | ||
that.openChangeValueDialog(rowIndex, columnIndex); | ||
} | ||
}); | ||
@@ -58,0 +60,0 @@ }, |
@@ -16,8 +16,13 @@ define(['joose', 'Psc/UI/SplitPane', 'Psc/UI/UploadableImage', 'Psc/UI/Group', 'Psc/UI/LayoutManagerComponent'], function(Joose) { | ||
caption: { is : 'rw', required: false, isPrivate: true }, | ||
align: { is : 'rw', required: false, isPrivate: true } | ||
align: { is : 'rw', required: false, isPrivate: true }, | ||
resize: { is : 'rw', required: false, isPrivate: true } // a hash with width and height or both how the maximum values should be for the inline image | ||
}, | ||
before: { | ||
initialize: function () { | ||
initialize: function (props) { | ||
this.$$type = 'Image'; | ||
if (!props.resize) { | ||
props.resizie = this.$$resize = {}; | ||
} | ||
} | ||
@@ -46,2 +51,5 @@ }, | ||
this.$$formBuilder.radios('Bild-Position im Text', 'align', this.$$align, {'left': 'links','right': 'rechts','full-width':'volle Breite'}); | ||
this.$$formBuilder.miniTextField('Maximal-Breite', 'resize-width', this.$$resize.width); | ||
this.$$formBuilder.miniTextField('Maximal-Höhe', 'resize-height', this.$$resize.height); | ||
@@ -58,2 +66,15 @@ //var group = new Psc.UI.Group({label: 'Optionen', content: this.$$formBuilder.build()}); | ||
}); | ||
$form.on('change', 'input[name="resize-width"], input[name="resize-height"]', function (e) { | ||
var $input = $(e.currentTarget), name = $input.attr('name').substr(7); | ||
var px = parseInt($input.val(), 10); | ||
if (px > 0) { | ||
that.$$resize[name] = px; | ||
$input.val(px); | ||
} else if(that.$$resize[name]) { | ||
delete that.$$resize[name]; | ||
$input.val(''); | ||
} | ||
}); | ||
@@ -77,2 +98,3 @@ $form.on('change','input[name="align"]', function (e) { | ||
s.align = this.getAlign(); | ||
s.resize = this.getResize(); | ||
}, | ||
@@ -79,0 +101,0 @@ |
@@ -577,3 +577,3 @@ /* global confirm:true, alert:true */ | ||
/* prview - Button */ | ||
/* preview - Button */ | ||
$tabs.on('click','form.psc-cms-ui-form button.psc-cms-ui-button-preview', function(e) { | ||
@@ -584,2 +584,9 @@ e.preventDefault(); | ||
}); | ||
/* view - Button */ | ||
$tabs.on('click','form.psc-cms-ui-form button.psc-cms-ui-button-view', function(e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
$(this).trigger('view'); | ||
}); | ||
@@ -586,0 +593,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
define(['joose', 'Psc/Code', 'Psc/Exception'], function(Joose) { | ||
define(['joose', 'lodash', 'Psc/Code', 'Psc/Exception'], function(Joose, _) { | ||
Joose.Class('Psc.UI.TabNotFoundException', { | ||
@@ -11,3 +11,3 @@ isa: Psc.Exception, | ||
BUILD: function (search) { | ||
return Joose.O.extend(this.SUPER("Tab nicht gefunden, gesucht wurde durch: "+Psc.Code.odump(search)), { | ||
return _.extend(this.SUPER("Tab nicht gefunden, gesucht wurde durch: "+Psc.Code.odump(search)), { | ||
search: search | ||
@@ -14,0 +14,0 @@ }); |
@@ -61,7 +61,10 @@ define(['joose', 'jquery', 'jquery-ui', 'Psc/UI/ResizableImage', 'Psc/Request', 'Psc/UI/WidgetWrapper', 'Psc/EventDispatching'], function(Joose, $) { | ||
$('<div class="psc-cms-ui-uploadable-image" title="Doppelklick zum Bearbeiten" />') | ||
.css('overflow','hidden') | ||
.css('display','inline-block') | ||
.css('border','1px solid black') | ||
.css('text-align','right') | ||
.css('min-height','50px').css('min-width','50px') | ||
.css({ | ||
'overflow': 'hidden', | ||
'display': 'inline-block', | ||
'border': '1px solid black', | ||
'text-align': 'right', | ||
'min-height': '50px', | ||
'min-width': '50px' | ||
}) | ||
.append($('<img src="'+this.$$url+'?nocache='+(new Date()).getTime()+'" alt="" title="Doppelklick zum Bearbeiten" />')) | ||
@@ -68,0 +71,0 @@ .on('dblclick', function (e) { |
@@ -1,1 +0,1 @@ | ||
define("tiptoi/Main",["joose","Psc/Request","Psc/Code","Psc/UI/WidgetWrapper"],function(e){e.Class("tiptoi.Main",{isa:Psc.UI.WidgetWrapper,has:{productName:{is:"rw",required:!0,isPrivate:!0},main:{is:"rw",required:!0,isPrivate:!0,handles:["handleAjaxRequest"]}},after:{initialize:function(){this.$$main.register(this,"tiptoiMain")}},methods:{createAction:function(e){return this.$$main.handleAjaxRequest(this.createRequest(["matrix-manager","create-action"],"GET",e,"html"))},createTransition:function(e){return this.$$main.handleAjaxRequest(this.createRequest(["matrix-manager","create-transition"],"GET",e,"html"))},dispatch:function(e){return this.$$main.handleAjaxRequest(e)},createRequest:function(e,t,i,n,r){t||(t="GET"),n||(n="json");var s=new Psc.Request({url:"/api/product/"+this.$$productName+"/"+e.join("/"),method:t,body:i,format:n,sendAs:r});return s},toString:function(){return"[tiptoi.Main]"}}})}),define("tiptoi/Timer",["joose","jquery"],function(e,t){e.Class("tiptoi.Timer",{has:{deferred:{is:"rw",required:!1,isPrivate:!0},timeout:{is:"rw",required:!1,isPrivate:!0},seconds:{is:"rw",required:!0,isPrivate:!0}},methods:{getTime:function(){return 1e3*this.$$seconds},start:function(){this.stop();var e=t.Deferred();return this.$$deferred=e,this.$$timeout=window.setTimeout(function(){e.reject()},this.getTime()),e.promise()},hasRunOut:function(e){this.$$deferred&&this.$$deferred.fail(e)},stop:function(){this.$$deferred&&(window.clearTimeout(this.$$timeout),this.$$deferred.resolve())},toString:function(){return"[tiptoi.Timer]"}}})}),define("tiptoi/Sound",["joose","jquery"],function(e,t){e.Class("tiptoi.Sound",{has:{content:{is:"rw",required:!0,isPrivate:!0},number:{is:"rw",required:!0,isPrivate:!0},speakers:{is:"rw",required:!1,isPrivate:!0}},my:{methods:{list:function(e){var i=[];return t.each(e,function(e,t){i.push(new tiptoi.Sound({content:t[0],number:t[1]}))}),i}}},methods:{toString:function(){return this.$$content?"„"+this.$$content+"“ ("+this.$$number+")":"[tiptoi.Sound]"}}})}),define("tiptoi/cpu",["joose","tiptoi/Timer","Psc/EventDispatching","tiptoi/Sound"],function(e){e.Class("tiptoi.cpu",{does:[Psc.EventDispatching],has:{eventManager:{is:"rw",required:!1,isPrivate:!0,handles:["on","one","off"]},inputProvider:{is:"rw",required:!0,isPrivate:!0},startedTimers:{is:"rw",required:!0,isPrivate:!0,init:e.I.Array}},methods:{start:function(e){this._trigger("start",[this,e])},waitForInput:function(e){var t=this;this._trigger("waiting-for-input"),$.when(this.$$inputProvider.getInput()).then(function(i){t._trigger("input-given",["OID",i]);try{e(i)}catch(n){t._trigger("crash",[n]),t.end()}})},waitForInputWithTimer:function(e,t){var i=this;this._trigger("waiting-for-input-with-timer",[e]);var n=!1;e.hasRunOut(function(){n=!0}),$.when(this.$$inputProvider.getInput()).then(function(e){if(n)i._trigger("input-ignored",["timedout","OID",e]);else{i._trigger("input-given",["OID",e]);try{t(e)}catch(r){i._trigger("crash",[r]),i.end()}}})},require:function(e,t){for(var i=e.length-1;i>=0;i--)e[i]="gdl/"+e[i].replace(/\./g,"/");return require(e,t)},startTimer:function(e){var t=new tiptoi.Timer({seconds:e});return this.$$startedTimers.push(t),this._trigger("start-timer",[t]),t.start(),t},evaluate:function(){this._trigger("evaluate",arguments)},startGame:function(e){this._trigger("start-game",[e])},createSound:function(e){return new tiptoi.Sound(e)},end:function(){for(var e,t=0;t<this.$$startedTimers.length;t++)e=this.$$startedTimers[t],e.stop();this._trigger("end",[this])},_trigger:function(e,t){t=t||[],this.getEventManager().triggerEvent("tiptoi-"+e,{tiptoi:this},t)},toString:function(){return"[tiptoi.cpu]"}}})}),define("tiptoi/StringOutput",["joose","Psc/Code","tiptoi/cpu","Psc/Exception"],function(e){e.Class("tiptoi.StringOutput",{has:{eventManager:{is:"rw",required:!0,isPrivate:!0},pipe:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){if(!Psc.Code.isFunction(this.$$pipe))throw new Psc.Exception("ableitende Klasse für StringOutput muss pipe auf eine function setzen: "+this.toString());this.initEvents()}},methods:{initEvents:function(){var e=this.getEventManager(),t=this.getPipe();e.on({"play-sounds":function(e,i,n){t(i.join("\n + "),e.type,[n])},"play-sound":function(e,i,n){t(i.toString(),e.type,[n])},"tiptoi-waiting-for-input":function(e){t("tiptoi wartet auf input...",e.type)},"tiptoi-waiting-for-input-with-timer":function(e,i){t("tiptoi wartet auf input "+i.getSeconds()+" Sekunde(n) timeout...",e.type)},"tiptoi-input-given":function(e,i,n){t("getippt wurde: "+i+": "+n,e.type)},"tiptoi-crash":function(e,i){var n=i.message||i.getMessage();t("ERROR: tiptoi ist gecrasht wegen Programmierfehler: "+n,e.type)},"tiptoi-start-game":function(e,i){i||(i="(nicht angegeben)"),t("tiptoi würde Spiel "+i+" starten. Dies ist jedoch im Simulator nicht möglich.")},"tiptoi-start-timer":function(e,i){t("Starte timer mit "+i.getSeconds()+" Sekunden..")},"tiptoi-evaluate":function(e,i){t("Evaluation von "+i+" richtigen Antworten",e.type)},"tiptoi-start":function(e,i,n){t("Spiel „"+n.getName()+"“ startet",e.type)},"tiptoi-end":function(e){t("Spiel beendet",e.type)}})},reset:function(){},toString:function(){return"[tiptoi.StringOutput]"}}})}),define("tiptoi/HTMLOutput",["joose","tiptoi/StringOutput"],function(e){e.Class("tiptoi.HTMLOutput",{isa:tiptoi.StringOutput,has:{widget:{is:"rw",required:!0,isPrivate:!0}},before:{initialize:function(){var e=this,t=this.getEventManager(),i=this.$$widget;this.$$pipe=function(e,t,n){if("tiptoi-input-given"===t)return!1;var r=$('<p class="'+t+'">'+e+"</p>");return"play-sound"===t||"play-sounds"===t?(-1!==e.search(/Wrong-Sound/)&&r.addClass("wrong-sound"),-1!==e.search(/(Right-Sound|tusch)/i)&&r.addClass("right-sound"),n&&"question"===n[0]&&r.addClass("question-sound")):"crash"===t&&r.addClass("crash"),i.append(r)},t.on("input-provider-listening",function(){var e=i.find("p.tiptoi-waiting-for-input").last();e.effect("pulsate",[300],2500)}),t.on("input-provider-got-input",function(t,n){var r=i.find("p.tiptoi-waiting-for-input");e.stopFlashing(r,n)}),t.on("tiptoi-end",function(){var t=i.find("p.tiptoi-waiting-for-input");e.stopFlashing(t,{oid:0,label:"keine, da Spiel beendet"})})}},methods:{reset:function(){this.$$widget.empty()},stopFlashing:function(e,t){e.stop(!0).queue(function(){e.css("opacity",1).removeClass("tiptoi-waiting-for-input").addClass("tiptoi-waited-for-input").html("getippt wurde: "+t.oid+" "+t.label)})},toString:function(){return"[tiptoi.HTMLOutput]"}}})}),define("Psc/Numbers",["joose"],function(e){e.Class("Psc.Numbers",{has:{},my:{methods:{randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e},formatBytes:function(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}}},methods:{toString:function(){return"[Psc.Numbers]"}}})}),define("tiptoi/SimpleSoundPlayer",["joose","jquery","Psc/Code","tiptoi/Sound","Psc/Numbers","Psc/EventDispatching"],function(e){e.Class("tiptoi.SimpleSoundPlayer",{does:[Psc.EventDispatching],has:{onPlay:{is:"rw",required:!0,isPrivate:!0}},methods:{playSound:function(e,t){e&&(t||(t="normal"),e=this.normalizeSound(e),this.$$eventManager.triggerEvent("play-sound",{},[e,t]),this.$$onPlay.apply(this,[[e]]))},playSounds:function(e){e&&e.length&&(e=this.normalizeSounds(e),this.$$eventManager.triggerEvent("play-sounds",{},[e]),this.$$onPlay.apply(this,[e]))},playRandomSound:function(e){if(e&&e.length){e=this.normalizeSounds(e);var t=Psc.Numbers.randomInt(0,e.length-1),i=e[t];this.$$eventManager.triggerEvent("play-sound",{},[i]),this.$$onPlay.apply(this,[e])}},normalizeSounds:function(e){for(var t=[],i=0,n=e.length;n>i;i++)t.push(this.normalizeSound(e[i]));return t},normalizeSound:function(e){return Psc.Code.isArray(e)&&2===e.length?new tiptoi.Sound({content:e[0],number:e[1]}):"string"==typeof e?new tiptoi.Sound({content:e,number:null}):Psc.Code.isInstanceOf(e,tiptoi.Sound)?e:"object"==typeof e?new tiptoi.Sound(e):new tiptoi.Sound({content:e,number:null})}}})}),define("tiptoi/Program",["joose"],function(e){e.Class("tiptoi.Program",{has:{code:{is:"rw",required:!0,isPrivate:!0},tables:{is:"rw",required:!1,isPrivate:!0,init:e.I.Object},sounds:{is:"rw",required:!1,isPrivate:!0,init:e.I.Object},name:{is:"rw",required:!1,isPrivate:!0}},methods:{setTable:function(e,t){return this.$$tables[e]=t,this},setSound:function(e,t){return this.$$sounds[e]=t,this},setSounds:function(e,t){return this.$$sounds[e]=t,this},setSoundsList:function(e,t){return this.setSounds(e,tiptoi.Sound.list(t))}}})}),define("tiptoi/GameTable",["joose","Psc/Numbers","Psc/Code"],function(e){e.Class("tiptoi.GameTable",{has:{rows:{is:"rw",required:!0,isPrivate:!1},name:{is:"rw",required:!0,isPrivate:!0},blocksNum:{is:"rw",required:!1,isPrivate:!0,init:!1},rowsLeft:{is:"rw",required:!1,isPrivate:!0},blockNumsLeft:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){Psc.Code.assertArray(this.rows,"this.rows","GameTable.chooseRandomBlock()"),this.$$rowsLeft=this.shuffle(this.rows.slice())}},methods:{getRow:function(e){return this.rows[e]},chooseNotYetUsedRandomRow:function(){return this.$$rowsLeft.pop()},chooseNotYetUsedRandomBlock:function(){if(!this.$$blockNumsLeft){this.$$blockNumsLeft=[];for(var e=1,t=this.getBlocksNum();t>=e;e++)this.$$blockNumsLeft.push(e);this.shuffle(this.$$blockNumsLeft)}var i=this.$$blockNumsLeft.pop();return void 0!==i?this.getBlock(i):void 0},chooseRandomBlock:function(){var e=this.getBlocksNum(),t=this.getRandomInt(1,e);return this.getBlock(t)},chooseRandomRow:function(){var e=this.getRandomInt(0,this.rows.length-1);return this.rows[e]},getBlock:function(e){e=Math.max(1,e);var t=this.getBlocksNum(),i=[];if(e>t)throw new Psc.Exception("Den Block "+e+" gibt es im "+this.getName()+"Table nicht");return $.each(this.rows,function(t,n){n.block===e&&i.push(n)}),i},getBlocksNum:function(){if(this.$$blocksNum===!1){var e=this,t=0;$.each(this.rows,function(i,n){Psc.Code.assertInteger(n.block,"row["+i+"].block in GameTable "+e.getName(),"GameTable.getBlocksNum()");var r=n.block;t=Math.max(r,t)}),this.$$blocksNum=t}return this.$$blocksNum},getRandomInt:function(e,t){return Psc.Numbers.randomInt(e,t)},toString:function(){return"[tiptoi.GameTable]"},shuffle:function(e){return e.sort(function(){return.5-Math.random()}),e}}})}),define("tiptoi/ProgramRunner",["joose","jquery","stacktrace","tiptoi/SimpleSoundPlayer","tiptoi/Program","tiptoi/cpu","tiptoi/GameTable","tiptoi/Sound","tiptoi/StringOutput","Psc/InvalidArgumentException","Psc/Code"],function(Joose,$,printStackTrace){Joose.Class("tiptoi.ProgramRunner",{does:[Psc.EventDispatching],has:{soundPlayer:{is:"rw",required:!1,isPrivate:!0},inputProvider:{is:"rw",required:!0,isPrivate:!0},cpu:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(e){e.soundPlayer||(this.$$soundPlayer=new tiptoi.SimpleSoundPlayer({eventManager:this.getEventManager(),onPlay:function(){}})),e.cpu||(this.$$cpu=new tiptoi.cpu({inputProvider:this.getInputProvider(),eventManager:this.getEventManager()}))}},methods:{run:function(e){if(!Psc.Code.isInstanceOf(e,tiptoi.Program))throw new Psc.InvalidArgumentException("program","Instance of tiptoiProgram",e,"ProgramRunner::run()");this.$$eventManager;var t=this.$$soundPlayer,i=$.Deferred(),n=this.$$cpu,r={playSound:function(e){t.playSound(e)},playQuestionSound:function(e){t.playSound(e,"question")},playSounds:function(e){t.playSounds(e)},playRandomSound:function(e){t.playRandomSound(e)},tiptoi:n,A:{contains:function(e,t){if(!e)throw new Psc.InvalidArgumentException("array","array",e,"A.contains in tiptoi Programm");if(Psc.Code.isArray(e))return Joose.A.exists(e,t);for(var i in e)if(e[i]==t)return!0;return!1},remove:function(e,t){if(!e)throw new Psc.InvalidArgumentException("array","array",e,"A.remove in tiptoi Programm");for(var i=0,n=e.length;n>i;i++)if(e[i]===t)return e.splice(i,1),void 0},copy:function(e){for(var t=[],i=0,n=e.length;n>i;i++)t.push(e[i]);return t},shuffle:function(e){if(!e.sort)throw new Error("Das objekt hat keine Funktion .sort und ist deshalb kein Array. (Parameter von Shuffle)");return e.sort(function(){return.5-Math.random()}),e},range:function(e,t){for(var i=[],n=e;t>=n;n++)i.push(n);return i}},random:Psc.Numbers.randomInt,chooseRandom:function(e){var t=Psc.Numbers.randomInt(0,e.lenght-1);return e[t]},debug:Psc.Code.debug};$.each(e.getTables(),function(e,t){Psc.Code.assertArray(t,"rows in Table: "+e,"ProgramRunner.run()"),r[e+"Table"]=new tiptoi.GameTable({rows:t,name:e})});var s=[],o=[];Joose.O.eachOwn(r,function(e,t){s.push(t),o.push(e)}),r.sounds=$.extend({},this.getCommonSounds(),e.getSounds()),$.extend(r,this.getCommonSounds());var a=this.compile(e,s,r),l="";return new tiptoi.StringOutput({eventManager:n.getEventManager(),pipe:function(e){l+=e+"\n"}}),n.getEventManager().on("tiptoi-end",function(){i.resolve(!0)}),setTimeout(function(){i.notify(n),n.start(e);try{a.apply(r,o)}catch(t){Psc.Code.warning("Fehler beim Ausführen von jSprogram",t,printStackTrace({e:t})),Psc.Code.debug(l),i.reject(t)}},1),i.promise()},getCommonSounds:function(){return{gameButtonSound:new tiptoi.Sound({content:"Game-Button-Sound",number:"091104ak009"}),rightSound:new tiptoi.Sound({content:"Right-Sound",number:"091104ak004"}),tusch:new tiptoi.Sound({content:"Tusch",number:"110207md5"}),wrongSound:new tiptoi.Sound({content:"Wrong-Sound",number:"091104ak005"}),pause:new tiptoi.Sound({content:"0,3 sec. Silent-Pause",number:"091104ak000"}),tickingSound:new tiptoi.Sound({content:"Ticking Sound",number:"101019js000"})}},compile:function(program,exports,programScope){for(var pCode=program.getCode(),soundsRx=/(this|that)\.sounds\.([a-zA-Z0-9]+)/g,match;match=soundsRx.exec(pCode);)programScope.sounds[match[2]]||(programScope.sounds[match[2]]=[]);var jsProgram;return eval("jsProgram = function("+exports.join(",")+") {"+pCode+"};"),jsProgram}}})}),define("tiptoi/InteractiveInputProvider",["joose","Psc/Code","Psc/EventDispatching","Psc/UI/WidgetWrapper"],function(e){e.Class("tiptoi.InteractiveInputProvider",{isa:Psc.UI.WidgetWrapper,does:[Psc.EventDispatching],has:{handlers:{is:"rw",required:!1,isPrivate:!0,init:1},deferred:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){var e=this,t=this.unwrap(),i=this.getEventManager();t.on("tiptoi-tip",function(n,r){var s=e.getDeferred();void 0!==s?(n.preventDefault(),n.stopPropagation(),i.triggerEvent("input-provider-got-input",{provider:this},[r,t]),r&&r.oid?s.resolve(r.oid):s.reject("unbekanntes tiptoi-tip event")):Psc.Code.warning("Deferred ist nicht gesetzt gewesen, dropping event")})}},methods:{getInput:function(){var e=this,t=this.unwrap(),i=this.getEventManager(),n=this.$$handlers++;return this.$$deferred=$.Deferred(),setTimeout(function(){i.triggerEvent("input-provider-listening",{provider:e,handler:n},[t])},1),this.$$deferred.promise()},toString:function(){return"[tiptoi.InteractiveInputProvider]"}}})}),define("tiptoi/GameSimulator",["joose","jquery","tiptoi/StringOutput","tiptoi/HTMLOutput","tiptoi/ProgramRunner","tiptoi/SimpleSoundPlayer","tiptoi/InteractiveInputProvider","Psc/EventManager","Psc/Code","Psc/EventDispatching"],function(e){e.Class("tiptoi.GameSimulator",{does:[Psc.EventDispatching],has:{output:{is:"rw",required:!0,isPrivate:!0},runner:{is:"rw",required:!1,isPrivate:!0},startButton:{is:"rw",required:!0,isPrivate:!0},runStatus:{is:"rw",required:!1,isPrivate:!0},program:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(e){if(!e.runner){if(!e.layout)throw new Psc.Exception("Wenn kein runner an GameSimulator übergeben wird, muss layout (jquery container mit den buttons) übergeben werden");this.$$runner=new tiptoi.ProgramRunner({eventManager:this.getEventManager(),inputProvider:new tiptoi.InteractiveInputProvider({widget:e.layout,eventManager:this.getEventManager()})})}Psc.Code.isInstanceOf(e.output,tiptoi.StringOutput)||(this.$$output=new tiptoi.HTMLOutput({widget:e.output,eventManager:this.getEventManager()})),this.attachHandlers()}},methods:{attachHandlers:function(){var e=this;this.$$eventManager,this.$$startButton.on("click",function(t){t.preventDefault(),e.reset();try{e.setRunStatus(e.getRunner().run(e.createProgram()))}catch(i){Psc.Code.error(i.message+"\n"+"Möglicherweise fehlen Sounds, die im Spiel verwendet werden oder der Program Code selbst hat einen Fehler."+"\n\n")}})},reset:function(){this.getOutput().reset(),this.$$runStatus&&this.$$runStatus.reject&&this.$$runStatus.reject("reset von GameSimulator")},createProgram:function(){return this.$$program},setRunStatus:function(e){this.$$runStatus=e,e.fail(function(e){alert("Es befindet sich ein Fehler im Spiel. Es kann auch sein, dass dies ein Interner Fehler ist. Fehlermeldung:\n\n"+e.message+"\n")})},toString:function(){return"[tiptoi.GameSimulator]"}}})}),define("Psc/UI/Group",["joose","Psc/UI/HTML/Base"],function(e){e.Class("Psc.UI.Group",{does:[Psc.UI.HTML.Base],has:{label:{is:"rw",required:!0,isPrivate:!0},content:{is:"rw",required:!1,isPrivate:!0}},methods:{refresh:function(){this.$$html?this.$$html.find("fieldset").find("> legend").html(this.$$label).end().find("> div.content").html(this.$$content).end():(this.$$html=$('<fieldset class="psc-cms-ui-group ui-corner-all ui-widget-content"><legend>'+this.$$label+'</legend><div class="content"></div></div>'),this.$$content&&this.getContentTag().append(this.$$content))},getContentTag:function(){return this.$$html.find("> div.content")},toString:function(){return"[Psc.UI.Group]"}}})}),define("Psc/AjaxResponseErrorHandler",["joose","Psc/UI/ErrorPane","Psc/UI/Dialog","Psc/ResponseMetaReader","Psc/UI/Group"],function(e){e.Class("Psc.AjaxResponseErrorHandler",{my:{methods:{openDialog:function(e){var t=new Psc.AjaxResponseErrorHandler({response:e});return t.createDialog().open()}}},has:{response:{is:"r",required:!0,isPrivate:!0}},methods:{getErrorMessage:function(){var e,t=this.$$response.getHeader();return e="true"===t["X-Psc-CMS-Error"]?t["X-Psc-CMS-Error-Message"]:this.$$response.getBody(),e.replace(/\n/,"<br />\n").substring(0,300)},createDialog:function(){var e=this,t=new Psc.UI.Dialog({title:"Ein Fehler ist aufgetreten",closeButton:"schließen",width:"50%",onCreate:function(t,i){i.setContent($('<div class="psc-cms-ui-error-pane" />').append(e.getErrorMessage()))}});return t},appendErrorPane:function(e){var t=this;return new Psc.UI.ErrorPane({label:"Error",container:e,errorMessage:t.getErrorMessage()})}}})}),define("tiptoi/TitoGameEditor",["joose","jquery","Psc/TableModel","Psc/EventDispatching","Psc/CMS/FastItem","Psc/UI/EffectsManaging","Psc/UI/Button","Psc/Numbers","Psc/UI/Dialog","Psc/UI/WidgetWrapper","Psc/AjaxResponseErrorHandler"],function(e,t){e.Class("tiptoi.TitoGameEditor",{isa:Psc.UI.WidgetWrapper,does:[Psc.EventDispatching,Psc.UI.EffectsManaging],has:{service:{is:"rw",required:!0,isPrivate:!0},tito:{is:"rw",required:!0,isPrivate:!0},gameNum:{is:"rw",required:!0,isPrivate:!0}},after:{initialize:function(){this.checkWidget(),this.linkWidget(),this.initUI()}},methods:{initUI:function(){var e,i=this,n=this.unwrap(),r=n.find("fieldset:eq(0) div.content").first(),s=new Psc.UI.Button({label:"Sounds in die Datenbank übernehmen und Texte aktualisieren",leftIcon:"disk"}),o=t('<div class="psc-cms-ui-buttonset psc-cms-ui-buttonset-right"></div>').css("float","right");return o.append(e=s.create().addClass("sync-button")),r.append(o),o.after('<div class="clear" />'),e.on("click",function(t){t.preventDefault(),t.stopPropagation(),i.$$service.dispatch(i.$$service.createRequest(["tito","synchronize"],"POST",{gameNum:i.getGameNum()},"json")).done(function(t){i.setTito(t.getBody().tito),r.find("pre").remove(),i.loadCode(r),i.getEffectsManager().successBlink(e)}).fail(function(t){i.getEffectsManager().errorBlink(e);var n=Psc.AjaxResponseErrorHandler.openDialog(t);i._trigger("error",[t,n])})}),i.loadCode(r),this},loadCode:function(e){var t=this;this.$$service.dispatch(this.$$service.createRequest(["tito","highlight"],"POST",{tito:t.$$tito},"html")).done(function(i){e.append('<pre style="overflow:hidden">'+i.getBody()+"</pre>"),t.loadButtons(),t._trigger("code-loaded",[i.getBody()])})},loadButtons:function(){var e=this;e.findCode().find("span.token-sound.real").each(function(i,n){var r=t(n),s=r.attr("data-ident");if(s){var o=new Psc.UI.Button({label:r.html()}),a=o.create(),l=e.$$service.createRequest(["sound",s,"form"]).getUrl();r.replaceWith(a),new Psc.CMS.FastItem({widget:a,button:{label:o.getLabel(),mode:1},identifier:s,entityName:"sound",tab:{label:r.attr("data-text")+" ("+s+")",id:l.replace(/\//g,"-").substr(1),url:l}})}})},findCode:function(){return this.unwrap().find("fieldset:eq(0) div.content pre")},toString:function(){return"[tiptoi.GameEditor]"},_trigger:function(e,t){return this.getEventManager().triggerEvent(e,{},t)}}})}); | ||
define("tiptoi/Main",["joose","Psc/Request","Psc/Code","Psc/UI/WidgetWrapper"],function(e){e.Class("tiptoi.Main",{isa:Psc.UI.WidgetWrapper,has:{productName:{is:"rw",required:!0,isPrivate:!0},main:{is:"rw",required:!0,isPrivate:!0,handles:["handleAjaxRequest"]}},after:{initialize:function(){this.$$main.register(this,"tiptoiMain")}},methods:{createAction:function(e){return this.$$main.handleAjaxRequest(this.createRequest(["matrix-manager","create-action"],"GET",e,"html"))},createTransition:function(e){return this.$$main.handleAjaxRequest(this.createRequest(["matrix-manager","create-transition"],"GET",e,"html"))},dispatch:function(e){return this.$$main.handleAjaxRequest(e)},createRequest:function(e,t,i,n,r){t||(t="GET"),n||(n="json");var s=new Psc.Request({url:"/api/product/"+this.$$productName+"/"+e.join("/"),method:t,body:i,format:n,sendAs:r});return s},toString:function(){return"[tiptoi.Main]"}}})}),define("tiptoi/Timer",["joose","jquery"],function(e,t){e.Class("tiptoi.Timer",{has:{deferred:{is:"rw",required:!1,isPrivate:!0},timeout:{is:"rw",required:!1,isPrivate:!0},seconds:{is:"rw",required:!0,isPrivate:!0}},methods:{getTime:function(){return 1e3*this.$$seconds},start:function(){this.stop();var e=t.Deferred();return this.$$deferred=e,this.$$timeout=window.setTimeout(function(){e.reject()},this.getTime()),e.promise()},hasRunOut:function(e){this.$$deferred&&this.$$deferred.fail(e)},stop:function(){this.$$deferred&&(window.clearTimeout(this.$$timeout),this.$$deferred.resolve())},toString:function(){return"[tiptoi.Timer]"}}})}),define("tiptoi/Sound",["joose","jquery"],function(e,t){e.Class("tiptoi.Sound",{has:{content:{is:"rw",required:!0,isPrivate:!0},number:{is:"rw",required:!0,isPrivate:!0},speakers:{is:"rw",required:!1,isPrivate:!0}},my:{methods:{list:function(e){var i=[];return t.each(e,function(e,t){i.push(new tiptoi.Sound({content:t[0],number:t[1]}))}),i}}},methods:{toString:function(){return this.$$content?"„"+this.$$content+"“ ("+this.$$number+")":"[tiptoi.Sound]"}}})}),define("tiptoi/cpu",["joose","tiptoi/Timer","Psc/EventDispatching","tiptoi/Sound"],function(e){e.Class("tiptoi.cpu",{does:[Psc.EventDispatching],has:{eventManager:{is:"rw",required:!1,isPrivate:!0,handles:["on","one","off"]},inputProvider:{is:"rw",required:!0,isPrivate:!0},startedTimers:{is:"rw",required:!0,isPrivate:!0,init:e.I.Array}},methods:{start:function(e){this._trigger("start",[this,e])},waitForInput:function(e){var t=this;this._trigger("waiting-for-input"),$.when(this.$$inputProvider.getInput()).then(function(i){t._trigger("input-given",["OID",i]);try{e(i)}catch(n){t._trigger("crash",[n]),t.end()}})},waitForInputWithTimer:function(e,t){var i=this;this._trigger("waiting-for-input-with-timer",[e]);var n=!1;e.hasRunOut(function(){n=!0}),$.when(this.$$inputProvider.getInput()).then(function(e){if(n)i._trigger("input-ignored",["timedout","OID",e]);else{i._trigger("input-given",["OID",e]);try{t(e)}catch(r){i._trigger("crash",[r]),i.end()}}})},require:function(e,t){for(var i=e.length-1;i>=0;i--)e[i]="gdl/"+e[i].replace(/\./g,"/");return require(e,t)},startTimer:function(e){var t=new tiptoi.Timer({seconds:e});return this.$$startedTimers.push(t),this._trigger("start-timer",[t]),t.start(),t},evaluate:function(){this._trigger("evaluate",arguments)},startGame:function(e){this._trigger("start-game",[e])},createSound:function(e){return new tiptoi.Sound(e)},end:function(){for(var e,t=0;t<this.$$startedTimers.length;t++)e=this.$$startedTimers[t],e.stop();this._trigger("end",[this])},_trigger:function(e,t){t=t||[],this.getEventManager().triggerEvent("tiptoi-"+e,{tiptoi:this},t)},toString:function(){return"[tiptoi.cpu]"}}})}),define("tiptoi/StringOutput",["joose","Psc/Code","tiptoi/cpu","Psc/Exception"],function(e){e.Class("tiptoi.StringOutput",{has:{eventManager:{is:"rw",required:!0,isPrivate:!0},pipe:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){if(!Psc.Code.isFunction(this.$$pipe))throw new Psc.Exception("ableitende Klasse für StringOutput muss pipe auf eine function setzen: "+this.toString());this.initEvents()}},methods:{initEvents:function(){var e=this.getEventManager(),t=this.getPipe();e.on({"play-sounds":function(e,i,n){t(i.join("\n + "),e.type,[n])},"play-sound":function(e,i,n){t(i.toString(),e.type,[n])},"tiptoi-waiting-for-input":function(e){t("tiptoi wartet auf input...",e.type)},"tiptoi-waiting-for-input-with-timer":function(e,i){t("tiptoi wartet auf input "+i.getSeconds()+" Sekunde(n) timeout...",e.type)},"tiptoi-input-given":function(e,i,n){t("getippt wurde: "+i+": "+n,e.type)},"tiptoi-crash":function(e,i){var n=i.message||i.getMessage();t("ERROR: tiptoi ist gecrasht wegen Programmierfehler: "+n,e.type)},"tiptoi-start-game":function(e,i){i||(i="(nicht angegeben)"),t("tiptoi würde Spiel "+i+" starten. Dies ist jedoch im Simulator nicht möglich.")},"tiptoi-start-timer":function(e,i){t("Starte timer mit "+i.getSeconds()+" Sekunden..")},"tiptoi-evaluate":function(e,i){t("Evaluation von "+i+" richtigen Antworten",e.type)},"tiptoi-start":function(e,i,n){t("Spiel „"+n.getName()+"“ startet",e.type)},"tiptoi-end":function(e){t("Spiel beendet",e.type)}})},reset:function(){},toString:function(){return"[tiptoi.StringOutput]"}}})}),define("tiptoi/HTMLOutput",["joose","tiptoi/StringOutput"],function(e){e.Class("tiptoi.HTMLOutput",{isa:tiptoi.StringOutput,has:{widget:{is:"rw",required:!0,isPrivate:!0}},before:{initialize:function(){var e=this,t=this.getEventManager(),i=this.$$widget;this.$$pipe=function(e,t,n){if("tiptoi-input-given"===t)return!1;var r=$('<p class="'+t+'">'+e+"</p>");return"play-sound"===t||"play-sounds"===t?(-1!==e.search(/Wrong-Sound/)&&r.addClass("wrong-sound"),-1!==e.search(/(Right-Sound|tusch)/i)&&r.addClass("right-sound"),n&&"question"===n[0]&&r.addClass("question-sound")):"crash"===t&&r.addClass("crash"),i.append(r)},t.on("input-provider-listening",function(){var e=i.find("p.tiptoi-waiting-for-input").last();e.effect("pulsate",[300],2500)}),t.on("input-provider-got-input",function(t,n){var r=i.find("p.tiptoi-waiting-for-input");e.stopFlashing(r,n)}),t.on("tiptoi-end",function(){var t=i.find("p.tiptoi-waiting-for-input");e.stopFlashing(t,{oid:0,label:"keine, da Spiel beendet"})})}},methods:{reset:function(){this.$$widget.empty()},stopFlashing:function(e,t){e.stop(!0).queue(function(){e.css("opacity",1).removeClass("tiptoi-waiting-for-input").addClass("tiptoi-waited-for-input").html("getippt wurde: "+t.oid+" "+t.label)})},toString:function(){return"[tiptoi.HTMLOutput]"}}})}),define("Psc/Numbers",["joose"],function(e){e.Class("Psc.Numbers",{has:{},my:{methods:{randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e},formatBytes:function(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}}},methods:{toString:function(){return"[Psc.Numbers]"}}})}),define("tiptoi/SimpleSoundPlayer",["joose","jquery","Psc/Code","tiptoi/Sound","Psc/Numbers","Psc/EventDispatching"],function(e){e.Class("tiptoi.SimpleSoundPlayer",{does:[Psc.EventDispatching],has:{onPlay:{is:"rw",required:!0,isPrivate:!0}},methods:{playSound:function(e,t){e&&(t||(t="normal"),e=this.normalizeSound(e),this.$$eventManager.triggerEvent("play-sound",{},[e,t]),this.$$onPlay.apply(this,[[e]]))},playSounds:function(e){e&&e.length&&(e=this.normalizeSounds(e),this.$$eventManager.triggerEvent("play-sounds",{},[e]),this.$$onPlay.apply(this,[e]))},playRandomSound:function(e){if(e&&e.length){e=this.normalizeSounds(e);var t=Psc.Numbers.randomInt(0,e.length-1),i=e[t];this.$$eventManager.triggerEvent("play-sound",{},[i]),this.$$onPlay.apply(this,[e])}},normalizeSounds:function(e){for(var t=[],i=0,n=e.length;n>i;i++)t.push(this.normalizeSound(e[i]));return t},normalizeSound:function(e){return Psc.Code.isArray(e)&&2===e.length?new tiptoi.Sound({content:e[0],number:e[1]}):"string"==typeof e?new tiptoi.Sound({content:e,number:null}):Psc.Code.isInstanceOf(e,tiptoi.Sound)?e:"object"==typeof e?new tiptoi.Sound(e):new tiptoi.Sound({content:e,number:null})}}})}),define("tiptoi/Program",["joose"],function(e){e.Class("tiptoi.Program",{has:{code:{is:"rw",required:!0,isPrivate:!0},tables:{is:"rw",required:!1,isPrivate:!0,init:e.I.Object},sounds:{is:"rw",required:!1,isPrivate:!0,init:e.I.Object},name:{is:"rw",required:!1,isPrivate:!0}},methods:{setTable:function(e,t){return this.$$tables[e]=t,this},setSound:function(e,t){return this.$$sounds[e]=t,this},setSounds:function(e,t){return this.$$sounds[e]=t,this},setSoundsList:function(e,t){return this.setSounds(e,tiptoi.Sound.list(t))}}})}),define("tiptoi/GameTable",["joose","Psc/Numbers","Psc/Code"],function(e){e.Class("tiptoi.GameTable",{has:{rows:{is:"rw",required:!0,isPrivate:!1},name:{is:"rw",required:!0,isPrivate:!0},blocksNum:{is:"rw",required:!1,isPrivate:!0,init:!1},rowsLeft:{is:"rw",required:!1,isPrivate:!0},blockNumsLeft:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){Psc.Code.assertArray(this.rows,"this.rows","GameTable.chooseRandomBlock()"),this.$$rowsLeft=this.shuffle(this.rows.slice())}},methods:{getRow:function(e){return this.rows[e]},chooseNotYetUsedRandomRow:function(){return this.$$rowsLeft.pop()},chooseNotYetUsedRandomBlock:function(){if(!this.$$blockNumsLeft){this.$$blockNumsLeft=[];for(var e=1,t=this.getBlocksNum();t>=e;e++)this.$$blockNumsLeft.push(e);this.shuffle(this.$$blockNumsLeft)}var i=this.$$blockNumsLeft.pop();return void 0!==i?this.getBlock(i):void 0},chooseRandomBlock:function(){var e=this.getBlocksNum(),t=this.getRandomInt(1,e);return this.getBlock(t)},chooseRandomRow:function(){var e=this.getRandomInt(0,this.rows.length-1);return this.rows[e]},getBlock:function(e){e=Math.max(1,e);var t=this.getBlocksNum(),i=[];if(e>t)throw new Psc.Exception("Den Block "+e+" gibt es im "+this.getName()+"Table nicht");return $.each(this.rows,function(t,n){n.block===e&&i.push(n)}),i},getBlocksNum:function(){if(this.$$blocksNum===!1){var e=this,t=0;$.each(this.rows,function(i,n){Psc.Code.assertInteger(n.block,"row["+i+"].block in GameTable "+e.getName(),"GameTable.getBlocksNum()");var r=n.block;t=Math.max(r,t)}),this.$$blocksNum=t}return this.$$blocksNum},getRandomInt:function(e,t){return Psc.Numbers.randomInt(e,t)},toString:function(){return"[tiptoi.GameTable]"},shuffle:function(e){return e.sort(function(){return.5-Math.random()}),e}}})}),define("tiptoi/ProgramRunner",["joose","lodash","jquery","stacktrace","tiptoi/SimpleSoundPlayer","tiptoi/Program","tiptoi/cpu","tiptoi/GameTable","tiptoi/Sound","tiptoi/StringOutput","Psc/InvalidArgumentException","Psc/Code"],function(Joose,_,$,printStackTrace){Joose.Class("tiptoi.ProgramRunner",{does:[Psc.EventDispatching],has:{soundPlayer:{is:"rw",required:!1,isPrivate:!0},inputProvider:{is:"rw",required:!0,isPrivate:!0},cpu:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(e){e.soundPlayer||(this.$$soundPlayer=new tiptoi.SimpleSoundPlayer({eventManager:this.getEventManager(),onPlay:function(){}})),e.cpu||(this.$$cpu=new tiptoi.cpu({inputProvider:this.getInputProvider(),eventManager:this.getEventManager()}))}},methods:{run:function(e){if(!Psc.Code.isInstanceOf(e,tiptoi.Program))throw new Psc.InvalidArgumentException("program","Instance of tiptoiProgram",e,"ProgramRunner::run()");this.$$eventManager;var t=this.$$soundPlayer,i=$.Deferred(),n=this.$$cpu,r={playSound:function(e){t.playSound(e)},playQuestionSound:function(e){t.playSound(e,"question")},playSounds:function(e){t.playSounds(e)},playRandomSound:function(e){t.playRandomSound(e)},tiptoi:n,A:{contains:function(e,t){if(!e)throw new Psc.InvalidArgumentException("array","array",e,"A.contains in tiptoi Programm");if(Psc.Code.isArray(e))return _.contains(e,t);for(var i in e)if(e[i]==t)return!0;return!1},remove:function(e,t){if(!e)throw new Psc.InvalidArgumentException("array","array",e,"A.remove in tiptoi Programm");for(var i=0,n=e.length;n>i;i++)if(e[i]===t)return e.splice(i,1),void 0},copy:function(e){for(var t=[],i=0,n=e.length;n>i;i++)t.push(e[i]);return t},shuffle:function(e){if(!e.sort)throw new Error("Das objekt hat keine Funktion .sort und ist deshalb kein Array. (Parameter von Shuffle)");return e.sort(function(){return.5-Math.random()}),e},range:function(e,t){for(var i=[],n=e;t>=n;n++)i.push(n);return i}},random:Psc.Numbers.randomInt,chooseRandom:function(e){var t=Psc.Numbers.randomInt(0,e.lenght-1);return e[t]},debug:Psc.Code.debug};$.each(e.getTables(),function(e,t){Psc.Code.assertArray(t,"rows in Table: "+e,"ProgramRunner.run()"),r[e+"Table"]=new tiptoi.GameTable({rows:t,name:e})});var s=[],o=[];_.forOwn(r,function(e,t){s.push(t),o.push(e)}),r.sounds=$.extend({},this.getCommonSounds(),e.getSounds()),$.extend(r,this.getCommonSounds());var a=this.compile(e,s,r),l="";return new tiptoi.StringOutput({eventManager:n.getEventManager(),pipe:function(e){l+=e+"\n"}}),n.getEventManager().on("tiptoi-end",function(){i.resolve(!0)}),setTimeout(function(){i.notify(n),n.start(e);try{a.apply(r,o)}catch(t){Psc.Code.warning("Fehler beim Ausführen von jSprogram",t,printStackTrace({e:t})),Psc.Code.debug(l),i.reject(t)}},1),i.promise()},getCommonSounds:function(){return{gameButtonSound:new tiptoi.Sound({content:"Game-Button-Sound",number:"091104ak009"}),rightSound:new tiptoi.Sound({content:"Right-Sound",number:"091104ak004"}),tusch:new tiptoi.Sound({content:"Tusch",number:"110207md5"}),wrongSound:new tiptoi.Sound({content:"Wrong-Sound",number:"091104ak005"}),pause:new tiptoi.Sound({content:"0,3 sec. Silent-Pause",number:"091104ak000"}),tickingSound:new tiptoi.Sound({content:"Ticking Sound",number:"101019js000"})}},compile:function(program,exports,programScope){for(var pCode=program.getCode(),soundsRx=/(this|that)\.sounds\.([a-zA-Z0-9]+)/g,match;match=soundsRx.exec(pCode);)programScope.sounds[match[2]]||(programScope.sounds[match[2]]=[]);var jsProgram;return eval("jsProgram = function("+exports.join(",")+") {"+pCode+"};"),jsProgram}}})}),define("tiptoi/InteractiveInputProvider",["joose","Psc/Code","Psc/EventDispatching","Psc/UI/WidgetWrapper"],function(e){e.Class("tiptoi.InteractiveInputProvider",{isa:Psc.UI.WidgetWrapper,does:[Psc.EventDispatching],has:{handlers:{is:"rw",required:!1,isPrivate:!0,init:1},deferred:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(){var e=this,t=this.unwrap(),i=this.getEventManager();t.on("tiptoi-tip",function(n,r){var s=e.getDeferred();void 0!==s?(n.preventDefault(),n.stopPropagation(),i.triggerEvent("input-provider-got-input",{provider:this},[r,t]),r&&r.oid?s.resolve(r.oid):s.reject("unbekanntes tiptoi-tip event")):Psc.Code.warning("Deferred ist nicht gesetzt gewesen, dropping event")})}},methods:{getInput:function(){var e=this,t=this.unwrap(),i=this.getEventManager(),n=this.$$handlers++;return this.$$deferred=$.Deferred(),setTimeout(function(){i.triggerEvent("input-provider-listening",{provider:e,handler:n},[t])},1),this.$$deferred.promise()},toString:function(){return"[tiptoi.InteractiveInputProvider]"}}})}),define("tiptoi/GameSimulator",["joose","jquery","tiptoi/StringOutput","tiptoi/HTMLOutput","tiptoi/ProgramRunner","tiptoi/SimpleSoundPlayer","tiptoi/InteractiveInputProvider","Psc/EventManager","Psc/Code","Psc/EventDispatching"],function(e){e.Class("tiptoi.GameSimulator",{does:[Psc.EventDispatching],has:{output:{is:"rw",required:!0,isPrivate:!0},runner:{is:"rw",required:!1,isPrivate:!0},startButton:{is:"rw",required:!0,isPrivate:!0},runStatus:{is:"rw",required:!1,isPrivate:!0},program:{is:"rw",required:!1,isPrivate:!0}},after:{initialize:function(e){if(!e.runner){if(!e.layout)throw new Psc.Exception("Wenn kein runner an GameSimulator übergeben wird, muss layout (jquery container mit den buttons) übergeben werden");this.$$runner=new tiptoi.ProgramRunner({eventManager:this.getEventManager(),inputProvider:new tiptoi.InteractiveInputProvider({widget:e.layout,eventManager:this.getEventManager()})})}Psc.Code.isInstanceOf(e.output,tiptoi.StringOutput)||(this.$$output=new tiptoi.HTMLOutput({widget:e.output,eventManager:this.getEventManager()})),this.attachHandlers()}},methods:{attachHandlers:function(){var e=this;this.$$eventManager,this.$$startButton.on("click",function(t){t.preventDefault(),e.reset();try{e.setRunStatus(e.getRunner().run(e.createProgram()))}catch(i){Psc.Code.error(i.message+"\n"+"Möglicherweise fehlen Sounds, die im Spiel verwendet werden oder der Program Code selbst hat einen Fehler."+"\n\n")}})},reset:function(){this.getOutput().reset(),this.$$runStatus&&this.$$runStatus.reject&&this.$$runStatus.reject("reset von GameSimulator")},createProgram:function(){return this.$$program},setRunStatus:function(e){this.$$runStatus=e,e.fail(function(e){alert("Es befindet sich ein Fehler im Spiel. Es kann auch sein, dass dies ein Interner Fehler ist. Fehlermeldung:\n\n"+e.message+"\n")})},toString:function(){return"[tiptoi.GameSimulator]"}}})}),define("Psc/UI/Group",["joose","Psc/UI/HTML/Base"],function(e){e.Class("Psc.UI.Group",{does:[Psc.UI.HTML.Base],has:{label:{is:"rw",required:!0,isPrivate:!0},content:{is:"rw",required:!1,isPrivate:!0}},methods:{refresh:function(){this.$$html?this.$$html.find("fieldset").find("> legend").html(this.$$label).end().find("> div.content").html(this.$$content).end():(this.$$html=$('<fieldset class="psc-cms-ui-group ui-corner-all ui-widget-content"><legend>'+this.$$label+'</legend><div class="content"></div></div>'),this.$$content&&this.getContentTag().append(this.$$content))},getContentTag:function(){return this.$$html.find("> div.content")},toString:function(){return"[Psc.UI.Group]"}}})}),define("Psc/AjaxResponseErrorHandler",["joose","Psc/UI/ErrorPane","Psc/UI/Dialog","Psc/ResponseMetaReader","Psc/UI/Group"],function(e){e.Class("Psc.AjaxResponseErrorHandler",{my:{methods:{openDialog:function(e){var t=new Psc.AjaxResponseErrorHandler({response:e});return t.createDialog().open()}}},has:{response:{is:"r",required:!0,isPrivate:!0}},methods:{getErrorMessage:function(){var e,t=this.$$response.getHeader();return e="true"===t["X-Psc-CMS-Error"]?t["X-Psc-CMS-Error-Message"]:this.$$response.getBody(),e.replace(/\n/,"<br />\n").substring(0,300)},createDialog:function(){var e=this,t=new Psc.UI.Dialog({title:"Ein Fehler ist aufgetreten",closeButton:"schließen",width:"50%",onCreate:function(t,i){i.setContent($('<div class="psc-cms-ui-error-pane" />').append(e.getErrorMessage()))}});return t},appendErrorPane:function(e){var t=this;return new Psc.UI.ErrorPane({label:"Error",container:e,errorMessage:t.getErrorMessage()})}}})}),define("tiptoi/TitoGameEditor",["joose","jquery","Psc/TableModel","Psc/EventDispatching","Psc/CMS/FastItem","Psc/UI/EffectsManaging","Psc/UI/Button","Psc/Numbers","Psc/UI/Dialog","Psc/UI/WidgetWrapper","Psc/AjaxResponseErrorHandler"],function(e,t){e.Class("tiptoi.TitoGameEditor",{isa:Psc.UI.WidgetWrapper,does:[Psc.EventDispatching,Psc.UI.EffectsManaging],has:{service:{is:"rw",required:!0,isPrivate:!0},tito:{is:"rw",required:!0,isPrivate:!0},gameNum:{is:"rw",required:!0,isPrivate:!0}},after:{initialize:function(){this.checkWidget(),this.linkWidget(),this.initUI()}},methods:{initUI:function(){var e,i=this,n=this.unwrap(),r=n.find("fieldset:eq(0) div.content").first(),s=new Psc.UI.Button({label:"Sounds in die Datenbank übernehmen und Texte aktualisieren",leftIcon:"disk"}),o=t('<div class="psc-cms-ui-buttonset psc-cms-ui-buttonset-right"></div>').css("float","right");return o.append(e=s.create().addClass("sync-button")),r.append(o),o.after('<div class="clear" />'),e.on("click",function(t){t.preventDefault(),t.stopPropagation(),i.$$service.dispatch(i.$$service.createRequest(["tito","synchronize"],"POST",{gameNum:i.getGameNum()},"json")).done(function(t){i.setTito(t.getBody().tito),r.find("pre").remove(),i.loadCode(r),i.getEffectsManager().successBlink(e)}).fail(function(t){i.getEffectsManager().errorBlink(e);var n=Psc.AjaxResponseErrorHandler.openDialog(t);i._trigger("error",[t,n])})}),i.loadCode(r),this},loadCode:function(e){var t=this;this.$$service.dispatch(this.$$service.createRequest(["tito","highlight"],"POST",{tito:t.$$tito},"html")).done(function(i){e.append('<pre style="overflow:hidden">'+i.getBody()+"</pre>"),t.loadButtons(),t._trigger("code-loaded",[i.getBody()])})},loadButtons:function(){var e=this;e.findCode().find("span.token-sound.real").each(function(i,n){var r=t(n),s=r.attr("data-ident");if(s){var o=new Psc.UI.Button({label:r.html()}),a=o.create(),l=e.$$service.createRequest(["sound",s,"form"]).getUrl();r.replaceWith(a),new Psc.CMS.FastItem({widget:a,button:{label:o.getLabel(),mode:1},identifier:s,entityName:"sound",tab:{label:r.attr("data-text")+" ("+s+")",id:l.replace(/\//g,"-").substr(1),url:l}})}})},findCode:function(){return this.unwrap().find("fieldset:eq(0) div.content pre")},toString:function(){return"[tiptoi.GameEditor]"},_trigger:function(e,t){return this.getEventManager().triggerEvent(e,{},t)}}})}); |
/*jshint evil:true*/ | ||
define(['joose', 'jquery', 'stacktrace','tiptoi/SimpleSoundPlayer','tiptoi/Program', 'tiptoi/cpu', 'tiptoi/GameTable', 'tiptoi/Sound', 'tiptoi/StringOutput', | ||
'Psc/InvalidArgumentException', 'Psc/Code'], function (Joose, $, printStackTrace) { | ||
define(['joose', 'lodash', 'jquery', 'stacktrace','tiptoi/SimpleSoundPlayer','tiptoi/Program', 'tiptoi/cpu', 'tiptoi/GameTable', 'tiptoi/Sound', 'tiptoi/StringOutput', | ||
'Psc/InvalidArgumentException', 'Psc/Code'], function (Joose, _, $, printStackTrace) { | ||
@@ -73,3 +73,3 @@ Joose.Class('tiptoi.ProgramRunner', { | ||
if (Psc.Code.isArray(array)) { | ||
return Joose.A.exists(array, value); | ||
return _.contains(array, value); | ||
} else { | ||
@@ -145,3 +145,3 @@ for (var key in array) { | ||
// übernehme alle properties aus dem scope als globale variablen für das Program | ||
Joose.O.eachOwn(programScope, function (parameter, paramName) { | ||
_.forOwn(programScope, function (parameter, paramName) { | ||
exports.push(paramName); | ||
@@ -148,0 +148,0 @@ parameters.push(parameter); |
@@ -18,3 +18,3 @@ { | ||
}, | ||
"version": "1.4.0-69b6388", | ||
"version": "1.4.0-be39184", | ||
"config": { | ||
@@ -33,5 +33,6 @@ "branch-alias": { | ||
"grunt-contrib-jshint": "~0.3", | ||
"grunt-contrib-qunit": "0.2.1", | ||
"grunt-contrib-qunit": "~0.2.2", | ||
"grunt-contrib-connect": "~0.2", | ||
"grunt-contrib-requirejs": "~0.4.1", | ||
"grunt-blanket-qunit": "~0.2.0", | ||
"semver": "~2.1.0", | ||
@@ -38,0 +39,0 @@ "npm": "~1.3.9", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
20807264
1313
373355
11
152
27