psc-cms-js
Advanced tools
Comparing version 1.4.0-5757307 to 1.4.0-4cf283e
@@ -1,49 +0,38 @@ | ||
/* | ||
* the production file for bootstrapping the libraries from psc-cms-js | ||
* | ||
* in your local project: | ||
* create a file in your javascripts-directory (lets say its: /js) named boot.js and insert the contents: | ||
* | ||
* requirejs.config({ | ||
* // set baseUrl to the path to the lib directory of the psc-cms-js repository (this dir) | ||
* baseUrl: "/psc-cms-js/lib/" | ||
* }); | ||
* | ||
* // unfortunately we cannot name it also "boot" because then in the | ||
* define(['boot-helper', 'require'], function (boot, require) { | ||
* // only use the nested require for libraries like jquery, vendors, etc, | ||
* // because boot has to be loaded at first to set requirejs.config for the paths to vendor, etc | ||
* // require(['js/other/project/dependency', 'jquery', 'Psc/UI/Main'], function (dependency, jQuery) { | ||
* // load something with the dependency and jQuery here | ||
* | ||
* // for example you could create a Psc.UI.Main here: (Psc/UI/Main loads it globally beforehand), Joose is loaded from boot globally | ||
* new Psc.UI.Main({ | ||
* tabs: $(..), | ||
* | ||
* // in boot.getLoader() all inline scripts are already appended. | ||
* // load them with: $.when(boot.getLoader().finished()).then(function () {... }); | ||
* loader: boot.getLoader() | ||
* }); | ||
* }); | ||
* | ||
* // inject something to boot, etc, if you can load your main synchronously | ||
* // to provide the inline scripts with main loaded asyncronously you should do something deferred | ||
* | ||
* return boot; | ||
* }); | ||
* | ||
* boot is a simple object with function .getLoader() which returns a Psc.Loader which can be used for inline scripts with: | ||
* <script type="text/javascript"> | ||
* require(['boot'], function (boot) { | ||
* boot.getLoader().onRequire(['my/dependency1'], function (dependency1) { | ||
* // do something here | ||
* }); | ||
* }); | ||
* </script> | ||
* | ||
*/ | ||
/* global requirejs */ | ||
var require = { | ||
requirejs.config({ | ||
packages: [ | ||
{ | ||
name: "knockout", | ||
location: "../node_modules/shimney-knockout" | ||
}, | ||
{ | ||
name: "jquery", | ||
location: "../node_modules/shimney-jquery" | ||
}, | ||
{ | ||
name: "sammy", | ||
location: "../node_modules/shimney-sammy" | ||
}, | ||
{ | ||
name: "twitter-bootstrap", | ||
location: "../node_modules/shimney-twitter-bootstrap" | ||
}, | ||
{ | ||
name: "lodash", | ||
location: "../node_modules/shimney-lodash" | ||
}, | ||
{ | ||
name: "hogan", | ||
location: "../node_modules/shimney-hogan" | ||
}, | ||
{ | ||
name: "cookie-monster", | ||
location: "../node_modules/shimney-cookie-monster" | ||
}, | ||
{ | ||
name: "JSON", // is a direct dependency (in package.json) | ||
location: "../node_modules/shimney-json" | ||
} | ||
], | ||
@@ -56,5 +45,7 @@ /* set paths and vendor versions for applications | ||
paths: { | ||
'app': '/js', | ||
'img-files': '../img', | ||
'test-setup': '../tests/setup', | ||
'test-files': "../tests/files", | ||
'templates': "../templates", | ||
'jquery': "../vendor/jquery/jquery-1.8.2", | ||
'jquery-ui': "../vendor/jquery-ui/jquery-ui-1.8.24.custom.patched", | ||
@@ -65,13 +56,10 @@ 'jquery-ui-i18n': "../vendor/jquery-ui/jquery-ui-i18n.custom", | ||
'ace': "../vendor/ace/lib/ace", | ||
'lodash': "../vendor/lodash/lodash-0.10.0.min", | ||
'psc-tests-assert': '../vendor/qunit-assert/lib/assert', | ||
'qunit-assert': '../vendor/qunit-assert/lib/assert', | ||
'TestRunner': "../vendor/qunit-assert/lib/TestRunner", | ||
'img-files': '../img', | ||
'jquery-form': "../vendor/jquery-form/jquery.form-3.20", | ||
'jquery-fileupload': "../vendor/jquery-fileupload/jquery.fileupload", | ||
'jquery-iframe-transport': "../vendor/jquery-fileupload/jquery.iframe-transport", | ||
'jquery.ui.widget': "../vendor/jquery-fileupload/vendor/jquery.ui.widget", | ||
'jquery-tmpl': "../vendor/jquery-tmpl/jquery.tmpl", | ||
'jqwidgets': "../vendor/jqwidgets/jqx-all.min", | ||
'jqwidgets': "../vendor/jqwidgets/jqx.custom.min", | ||
'jquery-simulate': "../vendor/jquery-simulate/jquery.simulate.patched", | ||
@@ -82,11 +70,6 @@ 'jquery-rangyinputs': "../vendor/jquery-rangyinputs/rangyinputs_jquery.min", | ||
'ui-paging': "../vendor/webforge/ui.paging", | ||
"JSON": "../vendor/json/json2", | ||
"hogan": "../vendor/hogan/hogan-2.0.0.min.amd", | ||
'placeholder': "../vendor/mths.be/placeholder-2.0.6", | ||
'stacktrace': "../vendor/eriwen/stacktrace-min-0.4", | ||
'twitter-bootstrap': "../vendor/twitter-bootstrap/bootstrap.min", | ||
'twitter-typeahead': "../vendor/twitter/typeahead/typeahead.min", | ||
'knockout': "../vendor/knockout/knockout-2.2.1", | ||
'knockout-mapping': "../vendor/knockout/knockout.mapping", | ||
'test-files': "../tests/files", | ||
'knockout-bindings': "lib/Psc/ko/bindings", | ||
@@ -96,3 +79,2 @@ 'jquery-selectrange': "../vendor/stackoverflow/jquery-selectrange", | ||
'jquery-global-de-DE': "../vendor/jqwidgets/globalization/jquery.glob.de-DE", | ||
'templates': "../templates", | ||
'html5shiv': "../vendor/afarkas/html5shiv", | ||
@@ -102,2 +84,6 @@ 'i18next': '../vendor/i18next/i18next.amd.withJQuery-1.6.3.min', | ||
} | ||
}); | ||
}; | ||
if (typeof(requirejs) === "function") { | ||
requirejs.config(require); | ||
} |
@@ -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); |
@@ -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 @@ /* |
@@ -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,54 @@ | ||
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)}}})}); | ||
define(['joose', 'Psc/Request', 'Psc/Code', 'Psc/UI/WidgetWrapper'], function(Joose) { | ||
Joose.Class('tiptoi.Main', { | ||
isa: Psc.UI.WidgetWrapper, | ||
has: { | ||
productName: { is : 'rw', required: true, isPrivate: true }, | ||
main: { is : 'rw', required: true, isPrivate: true, handles: [ 'handleAjaxRequest' ] } | ||
}, | ||
after: { | ||
initialize: function () { | ||
this.$$main.register(this, 'tiptoiMain'); | ||
} | ||
}, | ||
methods: { | ||
createAction: function (data) { | ||
return this.$$main.handleAjaxRequest( | ||
this.createRequest(['matrix-manager', 'create-action'], 'GET', data, 'html') | ||
); | ||
}, | ||
createTransition: function (data) { | ||
return this.$$main.handleAjaxRequest( | ||
this.createRequest(['matrix-manager', 'create-transition'], 'GET', data, 'html') | ||
); | ||
}, | ||
dispatch: function (request) { | ||
return this.$$main.handleAjaxRequest( | ||
request | ||
); | ||
}, | ||
createRequest: function(urlParts, method, body, format, sendAs) { | ||
if (!method) { method = 'GET'; } | ||
if (!format) { format = 'json'; } | ||
var request = new Psc.Request({ | ||
url: '/api/product/'+this.$$productName+'/'+urlParts.join('/'), | ||
method: method, | ||
body: body, | ||
format: format, | ||
sendAs: sendAs | ||
}); | ||
return request; | ||
}, | ||
toString: function() { | ||
return "[tiptoi.Main]"; | ||
} | ||
} | ||
}); | ||
}); |
@@ -18,3 +18,3 @@ { | ||
}, | ||
"version": "1.4.0-5757307", | ||
"version": "1.4.0-4cf283e", | ||
"config": { | ||
@@ -39,4 +39,15 @@ "branch-alias": { | ||
"npm": "~1.3.9", | ||
"process": "~0.5.1" | ||
"process": "~0.5.1", | ||
"grunt-shimney-sweeper": "~1.1.1" | ||
}, | ||
"dependencies": { | ||
"shimney-json": "~1.0.0", | ||
"shimney-hogan": "~2.0.0", | ||
"shimney-twitter-bootstrap": "~2.3.1", | ||
"shimney-knockout": "~2.3.0", | ||
"shimney-cookie-monster": "~0.2.0", | ||
"shimney-sammy": "~0.7.4", | ||
"shimney-jquery": "~1.8.3", | ||
"shimney-lodash": "~1.3.1" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
5
138
19
19031349
8
12
1295
352223
+ Addedshimney-hogan@~2.0.0
+ Addedshimney-jquery@~1.8.3
+ Addedshimney-json@~1.0.0
+ Addedshimney-knockout@~2.3.0
+ Addedshimney-lodash@~1.3.1
+ Addedshimney-sammy@~0.7.4
+ Addedshimney-cookie-monster@0.2.0(transitive)
+ Addedshimney-hogan@2.0.0(transitive)
+ Addedshimney-jquery@1.8.3(transitive)
+ Addedshimney-json@1.0.0(transitive)
+ Addedshimney-knockout@2.3.0(transitive)
+ Addedshimney-lodash@1.3.1(transitive)
+ Addedshimney-sammy@0.7.4(transitive)
+ Addedshimney-twitter-bootstrap@2.3.1(transitive)