From 0d37e2f9f08018eb9e236bc3ab70a4a9842e90a2 Mon Sep 17 00:00:00 2001 From: russa Date: Fri, 9 Aug 2013 22:23:16 +0200 Subject: [PATCH] update to version 2.1 --- .classpath | 5 +- .gitignore | 1 + README.md | 1 - .../calendar_client.js} | 54 +- .../show_appointments.js | 0 assets/www/config/configuration.json | 2 +- assets/www/config/directories.json | 1 + .../www/config/languages/de/grammar.json.MD5 | 1 + .../www/config/languages/en/grammar.json.MD5 | 1 + .../config/languages/en/grammar.json_DISABLED | 718 ++++ assets/www/config/languages/en/speaker.json | 4 +- assets/www/config/parsed_directories.json | 1 - .../config/statedef/dialogDescription.xml.MD5 | 1 - ...ription.xml => dialogDescriptionSCXML.xml} | 12 +- .../statedef/dialogDescriptionSCXML.xml.MD5 | 1 + ...er_scxml.xml => inputDescriptionSCXML.xml} | 72 +- .../statedef/inputDescriptionSCXML.xml.MD5 | 1 + .../statedef/input_manager_scxml.xml.MD5 | 1 - assets/www/config/statedef/scxml2js.bat | 2 +- assets/www/config/statedef/scxml2js.sh | 2 +- assets/www/content/images/ajax-loader.png | Bin 503 -> 0 bytes assets/www/content/images/icons-18-black.png | Bin 2064 -> 0 bytes assets/www/content/images/icons-18-white.png | Bin 2200 -> 0 bytes assets/www/content/images/icons-36-black.png | Bin 3403 -> 0 bytes assets/www/content/images/icons-36-white.png | Bin 4020 -> 0 bytes .../stylesheets/images/ajax-loader.gif | Bin 7825 -> 0 bytes assets/www/controllers/application.js | 58 +- assets/www/controllers/calendar.js | 20 +- assets/www/external.html | 97 +- assets/www/gen/grammar/de_grammar.js | 4 +- .../gen => gen/scxml}/DialogDescription.js | 272 +- .../scxml/InputDescription.js} | 673 ++-- assets/www/helpers/.gitignore | 0 assets/www/helpers/applicationHelper.js | 5 +- assets/www/index.html | 165 +- .../www/javascripts/manager/modelManager.js | 228 -- .../www/javascripts/mediators/audioInput.js | 92 - .../www/javascripts/mediators/audioOutput.js | 88 - .../javascripts/mediators/concurrentSCION.js | 91 - .../javascripts/mediators/html5AudioInput.js | 231 -- .../javascripts/mediators/html5AudioOutput.js | 139 - .../mediators/html5ConcurrentScion.js | 53 - .../javascripts/mediators/maryAudioOutput.js | 84 - .../mediators/nativeConcurrentSCION.js | 56 - assets/www/javascripts/popup.js | 95 - .../semantic/grammar_parser_template.js | 1 - assets/www/javascripts/semantic/stemmer.js | 132 - assets/www/javascripts/tools/commonUtils.js | 1154 ------- assets/www/javascripts/tools/queue.js | 111 - .../3rdParty => libs}/childbrowser.js | 0 .../datebox/jqm-datebox-1.4.0.comp.datebox.js | 0 .../jqm-datebox-1.4.0.comp.datebox.min.js | 0 .../datebox/jqm-datebox-1.4.0.comp.flipbox.js | 0 .../jqm-datebox-1.4.0.comp.flipbox.min.js | 0 .../datebox/jquery.mobile.datebox-1.0.1.js | 0 .../jquery.mobile.datebox-1.0.1.min.js | 0 .../jquery.mobile.datebox.i18n.de.utf8.js | 0 .../jquery.mobile.datebox.i18n.en.utf8.js | 0 .../3rdParty => libs}/facebook.js | 0 .../googleMap/jquery.ui.map.extensions.js | 0 .../googleMap/jquery.ui.map.js | 0 .../googleMap/jquery.ui.map.services.js | 0 .../3rdParty => libs}/jquery-ui-1.10.3.js | 0 .../www/mmirf/env/media/cordovaAudioOutput.js | 151 + .../env/media}/cordovaGoogleAudioOutput.js | 0 assets/www/mmirf/env/media/html5AudioInput.js | 238 ++ .../www/mmirf/env/media/html5AudioOutput.js | 119 + .../www/mmirf/env/media/maryTextToSpeech.js | 237 ++ .../env/media}/nuanceAudioInput.js | 2 +- .../env/media/nuanceTextToSpeech.js} | 79 +- .../mediators => mmirf/env/media}/recorder.js | 24 +- .../env/media}/silenceDetection.js | 14 +- .../gen/parser/ES3.tokens | 0 .../gen/parser/ES3Lexer.js | 0 .../gen/parser/ES3Parser.js | 0 .../gen/parser/MmirES3Walker.js | 0 .../gen/parser/MmirES3Walker.tokens | 0 .../gen/parser/MmirScriptBlock.tokens | 0 .../gen/parser/MmirScriptBlockLexer.js | 0 .../gen/parser/MmirScriptBlockParser.js | 0 .../gen/parser/MmirScriptContent.tokens | 0 .../gen/parser/MmirScriptContentLexer.js | 0 .../gen/parser/MmirScriptContentParser.js | 0 .../gen/parser/MmirScriptStatement.tokens | 0 .../gen/parser/MmirScriptStatementLexer.js | 0 .../gen/parser/MmirScriptStatementParser.js | 0 .../gen/parser/MmirTemplate.tokens | 0 .../gen/parser/MmirTemplateLexer.js | 0 .../gen/parser/MmirTemplateParser.js | 0 .../gesture/accelerometerGestureDetector.js | 8 +- .../gesture/compassHandler.js | 4 +- .../gesture/locationObserver.js | 2 +- assets/www/{javascripts => mmirf}/main.js | 214 +- .../manager/controllerManager.js | 168 +- .../manager/dialog/dialogEngine.js} | 184 +- .../manager/dialog/inputEngine.js} | 109 +- assets/www/mmirf/manager/mediaManager.js | 215 ++ assets/www/mmirf/manager/modelManager.js | 385 +++ .../manager/presentationManager.js | 398 ++- .../manager/settings/configurationManager.js | 10 +- .../manager/settings/languageManager.js | 281 +- .../mvc/controllers/controller.js | 24 +- .../mvc/controllers/helper.js | 6 +- .../mvc/parser/antlr/ES3.g3 | 0 .../mvc/parser/antlr/ES3_license.txt | 0 .../mvc/parser/antlr/MmirES3Walker.g | 0 .../mvc/parser/antlr/MmirScript.g | 0 .../mvc/parser/antlr/MmirScriptBlock.g | 0 .../mvc/parser/antlr/MmirScriptContent.g | 0 .../mvc/parser/antlr/MmirScriptStatement.g | 0 .../mvc/parser/antlr/MmirTemplate.g | 0 .../mvc/parser/parseElementTypes.js | 2 +- .../mvc/parser/parsingResult.js | 2 +- .../mvc/parser/templateParseUtils.js | 0 .../mvc/parser/templateProcessor.js | 0 .../mvc/parser/templateRenderUtils.js | 6 +- .../mvc/views/contentElement.js | 2 +- .../mvc/views/layout.js | 10 +- .../mvc/views/partial.js | 6 +- .../{javascripts => mmirf}/mvc/views/view.js | 12 +- .../{javascripts => mmirf}/mvc/views/yield.js | 2 +- .../{javascripts => mmirf}/notification.js | 13 +- .../plugins/beepPlugin.js | 0 .../plugins/cookiePlugin.js | 0 .../plugins/directoryListing.js | 4 +- .../plugins/multitouchPlugin.js | 0 .../plugins/nativeTTS.js | 0 .../{javascripts => mmirf}/plugins/nuance.js | 0 .../plugins/queuePlugin.js | 0 .../plugins/softkeyboard.js | 0 .../{javascripts => mmirf}/plugins/video.js | 0 .../res/libs}/antlr3-all-min.js | 0 .../3rdParty => mmirf/res/libs}/antlr3-all.js | 0 .../res/libs}/cordova-2.8.1.js | 0 .../mmirf/res/libs/easyXDM-2.4.17.1.debug.js | 2877 +++++++++++++++++ assets/www/mmirf/res/libs/easyXDM-2.4.17.1.js | 2576 +++++++++++++++ .../mmirf/res/libs/easyXDM-2.4.17.1.min.js | 24 + .../3rdParty => mmirf/res/libs}/jpath.js | 0 .../res/libs}/jquery-1.9.1.js | 0 .../res/libs}/jquery-1.9.1.min.js | 0 .../res/libs}/jquery.mobile-1.3.1.js | 0 .../res/libs}/jquery.mobile-1.3.1.min.js | 0 .../res/libs/jquery.simplemodal-1.4.4.js | 716 ++++ .../res/libs/jquery.simplemodal.1.4.4.min.js | 26 + .../3rdParty => mmirf/res/libs}/jscc.js | 0 .../3rdParty => mmirf/res/libs}/scion-min.js | 0 .../3rdParty => mmirf/res/libs}/scion.js | 0 .../3rdParty => mmirf/res/libs}/timer.js | 0 .../mmirf/res/sounds/beep-notification.mp3 | Bin 0 -> 4388 bytes .../res/styles}/images/ajax-loader.gif | Bin .../www/mmirf/res/styles/images/datebox.png | Bin 0 -> 2424 bytes .../res/styles}/images/icons-18-black.png | Bin .../res/styles}/images/icons-18-white.png | Bin .../res/styles}/images/icons-36-black.png | Bin .../res/styles}/images/icons-36-white.png | Bin .../res/styles}/jquery.mobile-1.3.1.css | 0 .../res/styles}/jquery.mobile-1.3.1.min.css | 0 .../semantic/grammarConverter.js} | 109 +- .../mmirf/semantic/grammarParserTemplate.js | 1 + .../semantic/semanticInterpreter.js} | 127 +- assets/www/mmirf/semantic/stemmer.js | 144 + .../tools/build}/ant/AntScriptFileHandler.js | 0 .../build}/ant/AntScriptFileListGenerator.js | 6 +- .../ant/AntScriptGrammarLanguageList.js | 0 .../build}/ant/InitForAntDefaultScriptEnv.js | 0 .../StandaloneSemanticParserCompileExec.js | 0 .../nodejs/InitForAntNodeJsScriptEnv.js | 0 .../tools/build}/nodejs/NodeJsFileHandler.js | 0 .../build}/rhino/InitForAntRhinoScriptEnv.js | 0 assets/www/mmirf/tools/commonUtils.js | 1419 ++++++++ .../{javascripts => mmirf}/tools/constants.js | 102 +- assets/www/mmirf/tools/dictionary.js | 246 ++ .../tools/extensions}/ArrayExtensions.js | 0 .../tools/extensions}/FunctionExtensions.js | 0 .../mmirf/tools/extensions/SCIONExtension.js | 168 + .../tools/extensions}/StringExtensions.js | 55 +- .../InitJSCC.js => mmirf/tools/initJSCC.js} | 0 .../{javascripts => mmirf}/tools/logger.js | 0 .../test}/AntTestGenerateBrowserParameter.js | 0 .../tools/test}/AntTestRunTestdriver.js | 0 .../workers/ScionQueueWorker.js | 52 +- .../workers}/recorderWorker.js | 32 +- .../{calendarmodel.js => calendarModel.js} | 35 +- assets/www/testSemanticInterpreter.html | 36 +- assets/www/views/application/login.ehtml | 4 +- ...languagemenu.ehtml => ~languageMenu.ehtml} | 2 +- build.properties | 51 +- build.settingsDefault | 37 - build.xml | 225 +- doc/.gitignore | 1 + doc/create_doc.bat | 4 +- jsTestDriver.conf | 4 +- libs/cordova-2.8.1-mod.jar | Bin 0 -> 760905 bytes libs/cordova-2.8.1-src.jar | Bin 288596 -> 0 bytes libs/cordova-2.8.1.jar | Bin 445463 -> 0 bytes libs/jdom/jdom-1.1.3.jar | Bin 151304 -> 0 bytes libs/oauth/commons-codec-1.5.jar | Bin 73098 -> 0 bytes libs/oauth/scribe-1.2.3.jar | Bin 63570 -> 0 bytes read-me.pdf | Bin 764919 -> 813229 bytes res/xml/config.xml | 147 +- src/de/dfki/iui/mmig/MMIGAppActivity.java | 4 +- test.settings | 6 +- test.xml | 4 +- test/cases/mds/TestCommonUtils.js | 30 +- test/cases/mds/TestDictionary.js | 140 + test/drivers/jsTestDriverCommonUtils.conf | 4 +- test/drivers/jsTestDriverDictionary.conf | 10 + test/test.settings | 4 +- test/test.xml | 4 +- user-guide.pdf | Bin 2136408 -> 2278128 bytes version.txt | 250 +- 211 files changed, 13177 insertions(+), 4166 deletions(-) rename assets/www/{javascripts/tools/calendarClient.js => appStarterKit/calendar_client.js} (96%) rename assets/www/{javascripts/commands => appStarterKit}/show_appointments.js (100%) create mode 100644 assets/www/config/directories.json create mode 100644 assets/www/config/languages/de/grammar.json.MD5 create mode 100644 assets/www/config/languages/en/grammar.json.MD5 create mode 100644 assets/www/config/languages/en/grammar.json_DISABLED delete mode 100644 assets/www/config/parsed_directories.json delete mode 100644 assets/www/config/statedef/dialogDescription.xml.MD5 rename assets/www/config/statedef/{dialogDescription.xml => dialogDescriptionSCXML.xml} (82%) create mode 100644 assets/www/config/statedef/dialogDescriptionSCXML.xml.MD5 rename assets/www/config/statedef/{input_manager_scxml.xml => inputDescriptionSCXML.xml} (79%) create mode 100644 assets/www/config/statedef/inputDescriptionSCXML.xml.MD5 delete mode 100644 assets/www/config/statedef/input_manager_scxml.xml.MD5 delete mode 100644 assets/www/content/images/ajax-loader.png delete mode 100644 assets/www/content/images/icons-18-black.png delete mode 100644 assets/www/content/images/icons-18-white.png delete mode 100644 assets/www/content/images/icons-36-black.png delete mode 100644 assets/www/content/images/icons-36-white.png delete mode 100644 assets/www/content/stylesheets/images/ajax-loader.gif rename assets/www/{javascripts/gen => gen/scxml}/DialogDescription.js (87%) rename assets/www/{javascripts/gen/input_manager_state_chart.js => gen/scxml/InputDescription.js} (83%) delete mode 100644 assets/www/helpers/.gitignore delete mode 100644 assets/www/javascripts/manager/modelManager.js delete mode 100644 assets/www/javascripts/mediators/audioInput.js delete mode 100644 assets/www/javascripts/mediators/audioOutput.js delete mode 100644 assets/www/javascripts/mediators/concurrentSCION.js delete mode 100644 assets/www/javascripts/mediators/html5AudioInput.js delete mode 100644 assets/www/javascripts/mediators/html5AudioOutput.js delete mode 100644 assets/www/javascripts/mediators/html5ConcurrentScion.js delete mode 100644 assets/www/javascripts/mediators/maryAudioOutput.js delete mode 100644 assets/www/javascripts/mediators/nativeConcurrentSCION.js delete mode 100644 assets/www/javascripts/popup.js delete mode 100644 assets/www/javascripts/semantic/grammar_parser_template.js delete mode 100644 assets/www/javascripts/semantic/stemmer.js delete mode 100644 assets/www/javascripts/tools/commonUtils.js delete mode 100644 assets/www/javascripts/tools/queue.js rename assets/www/{javascripts/3rdParty => libs}/childbrowser.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jqm-datebox-1.4.0.comp.datebox.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jqm-datebox-1.4.0.comp.datebox.min.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jqm-datebox-1.4.0.comp.flipbox.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jqm-datebox-1.4.0.comp.flipbox.min.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jquery.mobile.datebox-1.0.1.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jquery.mobile.datebox-1.0.1.min.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jquery.mobile.datebox.i18n.de.utf8.js (100%) rename assets/www/{javascripts/3rdParty => libs}/datebox/jquery.mobile.datebox.i18n.en.utf8.js (100%) rename assets/www/{javascripts/3rdParty => libs}/facebook.js (100%) rename assets/www/{javascripts/3rdParty => libs}/googleMap/jquery.ui.map.extensions.js (100%) rename assets/www/{javascripts/3rdParty => libs}/googleMap/jquery.ui.map.js (100%) rename assets/www/{javascripts/3rdParty => libs}/googleMap/jquery.ui.map.services.js (100%) rename assets/www/{javascripts/3rdParty => libs}/jquery-ui-1.10.3.js (100%) create mode 100644 assets/www/mmirf/env/media/cordovaAudioOutput.js rename assets/www/{javascripts/mediators => mmirf/env/media}/cordovaGoogleAudioOutput.js (100%) create mode 100644 assets/www/mmirf/env/media/html5AudioInput.js create mode 100644 assets/www/mmirf/env/media/html5AudioOutput.js create mode 100644 assets/www/mmirf/env/media/maryTextToSpeech.js rename assets/www/{javascripts/mediators => mmirf/env/media}/nuanceAudioInput.js (96%) rename assets/www/{javascripts/mediators/nuanceAudioOutput.js => mmirf/env/media/nuanceTextToSpeech.js} (52%) rename assets/www/{javascripts/mediators => mmirf/env/media}/recorder.js (85%) rename assets/www/{javascripts/mediators => mmirf/env/media}/silenceDetection.js (90%) rename assets/www/{javascripts => mmirf}/gen/parser/ES3.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/ES3Lexer.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/ES3Parser.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirES3Walker.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirES3Walker.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptBlock.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptBlockLexer.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptBlockParser.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptContent.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptContentLexer.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptContentParser.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptStatement.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptStatementLexer.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirScriptStatementParser.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirTemplate.tokens (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirTemplateLexer.js (100%) rename assets/www/{javascripts => mmirf}/gen/parser/MmirTemplateParser.js (100%) rename assets/www/{javascripts => mmirf}/gesture/accelerometerGestureDetector.js (96%) rename assets/www/{javascripts => mmirf}/gesture/compassHandler.js (97%) rename assets/www/{javascripts => mmirf}/gesture/locationObserver.js (98%) rename assets/www/{javascripts => mmirf}/main.js (60%) rename assets/www/{javascripts => mmirf}/manager/controllerManager.js (71%) rename assets/www/{javascripts/manager/dialog/DialogEngine.js => mmirf/manager/dialog/dialogEngine.js} (71%) rename assets/www/{javascripts/manager/dialog/input_manager_engine.js => mmirf/manager/dialog/inputEngine.js} (52%) create mode 100644 assets/www/mmirf/manager/mediaManager.js create mode 100644 assets/www/mmirf/manager/modelManager.js rename assets/www/{javascripts => mmirf}/manager/presentationManager.js (64%) rename assets/www/{javascripts => mmirf}/manager/settings/configurationManager.js (91%) rename assets/www/{javascripts => mmirf}/manager/settings/languageManager.js (68%) rename assets/www/{javascripts => mmirf}/mvc/controllers/controller.js (90%) rename assets/www/{javascripts => mmirf}/mvc/controllers/helper.js (92%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/ES3.g3 (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/ES3_license.txt (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirES3Walker.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirScript.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirScriptBlock.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirScriptContent.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirScriptStatement.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/antlr/MmirTemplate.g (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/parseElementTypes.js (96%) rename assets/www/{javascripts => mmirf}/mvc/parser/parsingResult.js (96%) rename assets/www/{javascripts => mmirf}/mvc/parser/templateParseUtils.js (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/templateProcessor.js (100%) rename assets/www/{javascripts => mmirf}/mvc/parser/templateRenderUtils.js (97%) rename assets/www/{javascripts => mmirf}/mvc/views/contentElement.js (96%) rename assets/www/{javascripts => mmirf}/mvc/views/layout.js (96%) rename assets/www/{javascripts => mmirf}/mvc/views/partial.js (92%) rename assets/www/{javascripts => mmirf}/mvc/views/view.js (91%) rename assets/www/{javascripts => mmirf}/mvc/views/yield.js (96%) rename assets/www/{javascripts => mmirf}/notification.js (91%) rename assets/www/{javascripts => mmirf}/plugins/beepPlugin.js (100%) rename assets/www/{javascripts => mmirf}/plugins/cookiePlugin.js (100%) rename assets/www/{javascripts => mmirf}/plugins/directoryListing.js (97%) rename assets/www/{javascripts => mmirf}/plugins/multitouchPlugin.js (100%) rename assets/www/{javascripts => mmirf}/plugins/nativeTTS.js (100%) rename assets/www/{javascripts => mmirf}/plugins/nuance.js (100%) rename assets/www/{javascripts => mmirf}/plugins/queuePlugin.js (100%) rename assets/www/{javascripts => mmirf}/plugins/softkeyboard.js (100%) rename assets/www/{javascripts => mmirf}/plugins/video.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/antlr3-all-min.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/antlr3-all.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/cordova-2.8.1.js (100%) create mode 100644 assets/www/mmirf/res/libs/easyXDM-2.4.17.1.debug.js create mode 100644 assets/www/mmirf/res/libs/easyXDM-2.4.17.1.js create mode 100644 assets/www/mmirf/res/libs/easyXDM-2.4.17.1.min.js rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jpath.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jquery-1.9.1.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jquery-1.9.1.min.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jquery.mobile-1.3.1.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jquery.mobile-1.3.1.min.js (100%) create mode 100644 assets/www/mmirf/res/libs/jquery.simplemodal-1.4.4.js create mode 100644 assets/www/mmirf/res/libs/jquery.simplemodal.1.4.4.min.js rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/jscc.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/scion-min.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/scion.js (100%) rename assets/www/{javascripts/3rdParty => mmirf/res/libs}/timer.js (100%) create mode 100644 assets/www/mmirf/res/sounds/beep-notification.mp3 rename assets/www/{content => mmirf/res/styles}/images/ajax-loader.gif (100%) create mode 100644 assets/www/mmirf/res/styles/images/datebox.png rename assets/www/{content/stylesheets => mmirf/res/styles}/images/icons-18-black.png (100%) rename assets/www/{content/stylesheets => mmirf/res/styles}/images/icons-18-white.png (100%) rename assets/www/{content/stylesheets => mmirf/res/styles}/images/icons-36-black.png (100%) rename assets/www/{content/stylesheets => mmirf/res/styles}/images/icons-36-white.png (100%) rename assets/www/{content/stylesheets => mmirf/res/styles}/jquery.mobile-1.3.1.css (100%) rename assets/www/{content/stylesheets => mmirf/res/styles}/jquery.mobile-1.3.1.min.css (100%) rename assets/www/{javascripts/semantic/grammar_converter.js => mmirf/semantic/grammarConverter.js} (72%) create mode 100644 assets/www/mmirf/semantic/grammarParserTemplate.js rename assets/www/{javascripts/semantic/semantic_interpreter.js => mmirf/semantic/semanticInterpreter.js} (79%) create mode 100644 assets/www/mmirf/semantic/stemmer.js rename assets/www/{javascripts/tools => mmirf/tools/build}/ant/AntScriptFileHandler.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/ant/AntScriptFileListGenerator.js (90%) rename assets/www/{javascripts/tools => mmirf/tools/build}/ant/AntScriptGrammarLanguageList.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/ant/InitForAntDefaultScriptEnv.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/ant/StandaloneSemanticParserCompileExec.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/nodejs/InitForAntNodeJsScriptEnv.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/nodejs/NodeJsFileHandler.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/build}/rhino/InitForAntRhinoScriptEnv.js (100%) create mode 100644 assets/www/mmirf/tools/commonUtils.js rename assets/www/{javascripts => mmirf}/tools/constants.js (67%) create mode 100644 assets/www/mmirf/tools/dictionary.js rename assets/www/{javascripts/tools => mmirf/tools/extensions}/ArrayExtensions.js (100%) rename assets/www/{javascripts/tools => mmirf/tools/extensions}/FunctionExtensions.js (100%) create mode 100644 assets/www/mmirf/tools/extensions/SCIONExtension.js rename assets/www/{javascripts/tools => mmirf/tools/extensions}/StringExtensions.js (85%) rename assets/www/{javascripts/tools/InitJSCC.js => mmirf/tools/initJSCC.js} (100%) rename assets/www/{javascripts => mmirf}/tools/logger.js (100%) rename assets/www/{javascripts/tools/ant => mmirf/tools/test}/AntTestGenerateBrowserParameter.js (100%) rename assets/www/{javascripts/tools/ant => mmirf/tools/test}/AntTestRunTestdriver.js (100%) rename assets/www/{javascripts => mmirf}/workers/ScionQueueWorker.js (51%) rename assets/www/{javascripts/mediators => mmirf/workers}/recorderWorker.js (87%) rename assets/www/models/{calendarmodel.js => calendarModel.js} (74%) rename assets/www/views/application/{~languagemenu.ehtml => ~languageMenu.ehtml} (91%) create mode 100644 doc/.gitignore create mode 100644 libs/cordova-2.8.1-mod.jar delete mode 100644 libs/cordova-2.8.1-src.jar delete mode 100644 libs/cordova-2.8.1.jar delete mode 100644 libs/jdom/jdom-1.1.3.jar delete mode 100644 libs/oauth/commons-codec-1.5.jar delete mode 100644 libs/oauth/scribe-1.2.3.jar create mode 100644 test/cases/mds/TestDictionary.js create mode 100644 test/drivers/jsTestDriverDictionary.conf diff --git a/.classpath b/.classpath index 364e393..3505d23 100644 --- a/.classpath +++ b/.classpath @@ -1,14 +1,11 @@ - - - - + diff --git a/.gitignore b/.gitignore index fc03e73..18b7807 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /bin /gen /build.settings +/public_release-diff-info.txt diff --git a/README.md b/README.md index 5be4a95..e850ec1 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,3 @@ The StarterKit provides basic capabilities for recognizing speech input (ASR, us ---- If not stated otherwise, the code, resource files etc. is provided under the MIT license (see the license file). - diff --git a/assets/www/javascripts/tools/calendarClient.js b/assets/www/appStarterKit/calendar_client.js similarity index 96% rename from assets/www/javascripts/tools/calendarClient.js rename to assets/www/appStarterKit/calendar_client.js index 47a302a..439b74b 100644 --- a/assets/www/javascripts/tools/calendarClient.js +++ b/assets/www/appStarterKit/calendar_client.js @@ -99,31 +99,35 @@ function SendRequestException(responseText, responseXML, msg, fail) { } function sendRequest(url, credentials, body, method, headers) { - var response; - $.ajax(url, { - type: method, - contentType: 'text/calendar; charset=UTF-8', - dataType: 'html', - data: body, - processData: false, - async: false, - crossDomain: true, - headers: $.extend({'Authorization': 'BASIC ' + credentials }, headers), - timeout: 5000 - // xhrFields: { withCredentials: true } - }).done(function (res) { - // alert(res); - response = res; - }).error(function (xhr, msg, fail) { - // window.alert(); - if (typeof(xhr) !== 'undefined') { - throw new SendRequestException(xhr.responseText, xhr.responseXML, msg, fail); - } else { - throw "send request failed " + msg + " " + fail; - } - }); + var response; + var options = { + type: method, + contentType: 'text/calendar; charset=UTF-8', + dataType: 'html', + data: body, + processData: false, + async: false, + crossDomain: true, + headers: $.extend({'Authorization': 'BASIC ' + credentials }, headers), + timeout: 5000 + // xhrFields: { withCredentials: true } + }; + + console.info('Sending AJAX request with options: '+JSON.stringify(options)); + + $.ajax(url, options).done(function (res) { + // alert(res); + response = res; + }).error(function (xhr, msg, fail) { + // window.alert(); + if (typeof(xhr) !== 'undefined') { + throw new SendRequestException(xhr.responseText, xhr.responseXML, msg, fail); + } else { + throw "send request failed " + msg + " " + fail; + } + }); - return response; + return response; } // =========== Base64 encoder @@ -679,7 +683,7 @@ function CalDavCalendarClient(uri, user, password) { var events = [], xmlParseStart, xmlParseEnd, calendarContent, found, start, end, lines, line, level, beginRegExp, endRegExp, reminders, curDataStack, curData, i, r, splitter, parsed, - calDavLine = /^[A-Za-z\-;=/]+:.*?\r\n/, + calDavLine = /^[A-Za-z\-;=\/]+:.*?\r\n/, calDavNewLine = /^\s.*?\r\n/; // parse out calendar from xml data diff --git a/assets/www/javascripts/commands/show_appointments.js b/assets/www/appStarterKit/show_appointments.js similarity index 100% rename from assets/www/javascripts/commands/show_appointments.js rename to assets/www/appStarterKit/show_appointments.js diff --git a/assets/www/config/configuration.json b/assets/www/config/configuration.json index 981359e..2a111bd 100644 --- a/assets/www/config/configuration.json +++ b/assets/www/config/configuration.json @@ -7,7 +7,7 @@ "HTML5InputSilenceBuffer": "2000000", "HTML5InputWebSocketAddress": "ws://127.0.0.1:9999", "HTML5InputSoundPackageSize": "4096", - "HTML5InputSilenceDetectorPath": "javascripts/mediators/silenceDetection.js", + "HTML5InputSilenceDetectorPath": "mmirf/env/media/silenceDetection.js", "HTML5OutputServerBasePath": "http://mary.dfki.de:59125/", "autoLogin": "true", "TEST_prefetchRemoteResources": "false", diff --git a/assets/www/config/directories.json b/assets/www/config/directories.json new file mode 100644 index 0000000..f8a64c3 --- /dev/null +++ b/assets/www/config/directories.json @@ -0,0 +1 @@ +{"/controllers":["application.js","calendar.js"],"/views":["application","calendar","layouts"],"/views/application":["login.ehtml","registration.ehtml","welcome.ehtml","~languageMenu.ehtml"],"/views/calendar":["create_appointment.ehtml"],"/views/layouts":["application.ehtml"],"/models":["calendarModel.js","user.js"],"/config":["languages","statedef","configuration.json","directories.json"],"/config/languages":["de","en"],"/config/languages/de":["dictionary.dic","grammar.json","grammar.json.MD5","speaker.json"],"/config/languages/en":["dictionary.dic","speaker.json"],"/config/statedef":["dialogDescriptionSCXML.xml","dialogDescriptionSCXML.xml.MD5","inputDescriptionSCXML.xml","inputDescriptionSCXML.xml.MD5","readme.txt","scxml2js.bat","scxml2js.sh"],"/mmirf/plugins":["beepPlugin.js","cookiePlugin.js","directoryListing.js","multitouchPlugin.js","nativeTTS.js","nuance.js","queuePlugin.js","softkeyboard.js","video.js"],"/helpers":["applicationHelper.js"],"/gen/grammar":["de_grammar.js"]} \ No newline at end of file diff --git a/assets/www/config/languages/de/grammar.json.MD5 b/assets/www/config/languages/de/grammar.json.MD5 new file mode 100644 index 0000000..9b1b2d3 --- /dev/null +++ b/assets/www/config/languages/de/grammar.json.MD5 @@ -0,0 +1 @@ +b5cb6b265edec7fba9a67d7cd566f7a4 diff --git a/assets/www/config/languages/en/grammar.json.MD5 b/assets/www/config/languages/en/grammar.json.MD5 new file mode 100644 index 0000000..4cdbc80 --- /dev/null +++ b/assets/www/config/languages/en/grammar.json.MD5 @@ -0,0 +1 @@ +673bae1b4633751d85d39b54cac272b5 diff --git a/assets/www/config/languages/en/grammar.json_DISABLED b/assets/www/config/languages/en/grammar.json_DISABLED new file mode 100644 index 0000000..5f5e373 --- /dev/null +++ b/assets/www/config/languages/en/grammar.json_DISABLED @@ -0,0 +1,718 @@ +{ + "comment_license" : "Copyright (C) 2012-2013 DFKI GmbH\nDeutsches Forschungszentrum fuer Kuenstliche Intelligenz\nGerman Research Center \nfor Artificial Intelligence\nhttp://www.dfki.de\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "stop_word": [ + "please", + "doch", + "der", + "der", + "die", + "das", + "dem", + "den", + "des", + "diese", + "dieser", + "diesem", + "diesen", + "dieses", + "mir", + "mal", + "jetzt", + "lass", + "m__oe__chte", + "ich", + "bla" + ], + "tokens": { + + "UNDEF_ARTICLE": [ + "a", + "the" + ], + "PP_MINE": [ + "mein", + "meine", + "meinen" + ], + "V_PLAY_IMP": [ + "spiel", + "spiele" + ], + "V_PLAY_INF": [ + "spielen", + "abspielen", + "h__oe__ren", + "anh__oe__ren", + "erkennen" + ], + "V_PLAY_RADIO_INF": [ + "radioh__oe__ren" + ], + "V_PLAY_FIN": [ + "l__ae__uft", + "spielt", + "abspielt" + ], + "V_SHOW_IMP": [ + "zeig", + "zeige" + ], + "V_SHOW_INF": [ + "zeigen", + "anzeigen" + ], + "V_RECORD_IMP": [ + "nimm", + "nehme" + ], + "V_RECORD_INF": [ + "aufnehmen", + "aufnahme", + "abgeben" + ], + "V_SEND_IMP": [ + "sende", + "send", + "schicke", + "schick", + "poste" + ], + "V_SEND_INF": [ + "schicken", + "senden", + "posten", + "weg damit" + ], + "V_SEND_FIN": [ + "sendet", + "postet" + ], + "V_OPEN_INF": [ + "__oe__ffnen", + "starten" + ], + "V_OPEN_FIN": [ + "__oe__ffnet", + "startet" + ], + "V_FIND_IMP": [ + "scanne", + "suche", + "finde" + ], + "RADAR": [ + "radar", + "scanner" + ], + "RADIO": [ + "radio", + "stream", + "aupeo" + ], + "AUDIOTAG": [ + "audiotag", + "audiotags", + "audionotiz" + ], + "VOICETAG": [ + "voicetag", + "voicetags", + "sprachnotiz", + "kommentar", + "kommentare", + "bewertung", + "bewertungen" + ], + "SOCIAL_NETWORK": [ + "twitter", + "facebook", + "qype", + "voice2social" + ], + "TWEET": [ + "tweet", + "tweeten", + "tweete" + ], + "INFO": [ + "info", + "information", + "informationen", + "daten", + "detail", + "details" + ], + "PREPOSITION": [ + "an", + "um", + "am", + "an", + "im", + "in", + "auf", + "ab", + "f__ue__r", + "nach", + "von", + "vom", + "zum" + ], + "PR_UPTO": [ + "bis" + ], + "WHAT":[ + "was" + ], + "WHERE":[ + "wo" + ], + "POI_CATEGORY": [ + "cafe", + "restaurant", + "bar", + "bars", + "clubs" + ], + "LOCATION_NAME": [ + "mitte", + "sch__oe__neberg", + "berlin", + "moabit", + "berlin hauptbahnhof", + "tiergarten", + "zoo", + "wedding", + "prenzlauer berg", + "fridrichshain", + "kreuzberg", + "charlottenburg", + "spandau", + "wilmersdorf", + "zehlendorf", + "steglitz", + "tempelhof", + "treptow", + "lichtenberg", + "pankow", + "reinickendorf" + ], + "SQUARE":[ + "[a-zA-Z_]+platz", + "([a-zA-Z_]+-)+platz" + ], + "NEAR_TO_ME": [ + "meiner n__ae__he", + "umgebung", + "n__ae__he", + "hier" + ], + "STREET": [ + "[a-zA-Z_]+ str", + "[a-zA-Z_]+ stra__ss__e", + "[a-zA-Z_]+ str.", + "[a-zA-Z_]+str", + "[a-zA-Z_]+stra__ss__e", + "[a-zA-Z_]+str.", + "[a-zA-Z_]+damm" + ], + "MUSIC": [ + "house", + "pop", + "jazz", + "musik", + "meine lieblingsmusik" + ], + "NUMBER": [ + "ein", + "eins", + "zwei", + "drei", + "vier", + "f__ue__nf", + "sechs", + "sieben", + "acht", + "neun", + "zehn", + "elf", + "zw__oe__lf", + "[0-9]+" + ], + "THEME": [ + "thema" + ], + "DATENUMBER": [ + "[0-9]+\\.[0-9]+\\.", + "[0-9]+\\.[0-9]+\\.[0-9]+" + ], + "DATE_VARIABLE": [ + "heute", + "morgen", + "__ue__bermorgen", + "gestern", + "vorgestern" + ], + "PERSON": [ + "vater", + "mutter", + "bruder", + "schwester" + ], + "TIMENUMBER": [ + "[0-9][0-9]?\\:[0-9][0-9]" + ], + "ORDINAL": [ + "[0-9]+\\." + ], + "MONTH": [ + "januar", + "februar", + "m__ae__rz", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "dezember", + "[1-9]|1[0-2]" + ], + "TIMEWORD": [ + "uhr" + ], + "STARS": [ + "stern", + "sterne" + ], + "MORE": [ + "mehr" + ], + "AGAIN": [ + "nochmal" + ], + "AND": [ + "und" + ], + "ALL": [ + "alle", + "allen", + "alles" + ], + "THAT": [ + "dazu" + ], + "LIKE": [ + "super", + "gef__ae__llt" + ], + "MICRO": [ + "mikro", + "mikrophon", + "mikrofon" + ], + "CAFE": [ + "monopol" + ], + "APPOINTMENTS": [ + "termine" + ], + "APPOINTMENT": [ + "termin" + ], + "CREATE": [ + "erstelle" + ], + "REST": [ + "[a-zA-Z_]+" + ] + }, + "utterances": { + "DATE": { + "phrases": [ + "ORDINAL", + "ORDINAL MONTH", + "ORDINAL MONTH NUMBER", + "DATENUMBER", + "DATE_VARIABLE" + ], + "semantic": { + "NoMatch":{}, + "date": { + "dateString": { + "day": "_$ordinal[0]", + "month": "_$month[0]", + "year": "_$number[0]" + }, + "date": "_$datenumber[0]", + "variable": "_$date_variable[0]" + } + } + }, + "TIME": { + "phrases": [ + "TIMENUMBER TIMEWORD" + ], + "semantic": { + "NoMatch":{}, + "time": "_$timenumber[0]" + } + }, + "TIMERANGE": { + "phrases": [ + "NUMBER PR_UPTO TIME", + "TIME PR_UPTO TIME" + ], + "semantic": { + "NoMatch":{}, + "timerange": { + "time1": { + "number": "_$number[0]", + "timeValue": "_$time[0]['semantic']" + }, + "time2": "_$time[1]['semantic']" + } + } + }, + "DATETIME": { + "phrases": [ + "DATE", + "TIME", + "DATE TIME", + "DATE PREPOSITION TIME" + ], + "semantic": { + "NoMatch":{}, + "datetime": { + "time": "_$time[0]['semantic']", + "date": "_$date[0]['semantic']" + } + } + }, + "LOCATION": { + "phrases": [ + "STREET", + "NEAR_TO_ME", + "LOCATION_NAME", + "SQUARE" + ], + "semantic": { + "Place": { + "name": "_$phrase" + } + } + }, + "PLAY": { + "phrases": [ + "V_PLAY_INF", + "V_PLAY_IMP PREPOSITION" + ], + "semantic": { + "Play": {} + } + }, + "PLAY_MORE": { + "phrases": [ + "MORE V_PLAY_INF", + "V_PLAY_IMP MORE" + ], + "semantic": { + "Play": { "more" : "yes"} + } + }, + "PLAY_AGAIN": { + "phrases": [ + "AGAIN V_PLAY_INF", + "V_PLAY_IMP AGAIN" + ], + "semantic": { + "Play": { "again" : "yes" } + } + }, + "PLAY_RADIO": { + "phrases": [ + "V_PLAY_IMP RADIO", + "V_PLAY_IMP RADIO PREPOSITION", + "V_PLAY_IMP RADIO THAT", + "RADIO V_PLAY_INF", + "RADIO V_PLAY_FIN", + "THAT RADIO V_PLAY_INF", + "V_PLAY_INF RADIO", + "RADIO PREPOSITION", + "V_PLAY_RADIO_INF" + ], + "semantic": { + "Play": { "type" : "radio" } + } + }, + "PLAY_AUDIOTAGS": { + "phrases": [ + "V_PLAY_IMP AUDIOTAG", + "V_PLAY_IMP AUDIOTAG PREPOSITION", + "AUDIOTAG V_PLAY_INF", + "AUDIOTAG V_PLAY_FIN", + "V_PLAY_INF AUDIOTAG" + ], + "semantic": { + "Play": { "type" : "audio" } + } + }, + "PLAY_VOICETAGS": { + "phrases": [ + "V_PLAY_IMP VOICETAG", + "V_PLAY_IMP VOICETAG PREPOSITION", + "VOICETAG V_PLAY_INF", + "VOICETAG V_PLAY_FIN", + "V_PLAY_INF VOICETAG" + ], + "semantic": { + "Play": { "type" : "voice" } + } + }, + "RECORD_AUDIOTAG": { + "phrases": [ + "V_RECORD_IMP AUDIOTAG", + "V_RECORD_IMP AUDIOTAG PREPOSITION", + "AUDIOTAG V_RECORD_INF", + "V_RECORD_INF AUDIOTAG" + ], + "semantic": { + "Record": { "type" : "audio" } + } + }, + "RECORD_VOICETAG": { + "phrases": [ + "V_RECORD_IMP VOICETAG", + "V_RECORD_IMP VOICETAG PREPOSITION", + "VOICETAG V_RECORD_INF", + "V_RECORD_INF VOICETAG", + "VOICETAG PREPOSITION CAFE" + ], + "semantic": { + "Record": { "type" : "voice" } + } + }, + "RECORD": { + "phrases": [ + "V_RECORD_INF", + "MICRO PREPOSITION" + ], + "semantic": { + "Record": { } + } + }, + "SEND": { + "phrases": [ + "V_SEND_IMP PREPOSITION SOCIAL_NETWORK", + "V_SEND_IMP SOCIAL_NETWORK", + "PREPOSITION SOCIAL_NETWORK V_SEND_INF", + "PREPOSITION SOCIAL_NETWORK V_SEND_FIN", + "PREPOSITION SOCIAL_NETWORK AND SOCIAL_NETWORK V_SEND_INF", + "PREPOSITION SOCIAL_NETWORK AND SOCIAL_NETWORK V_SEND_FIN", + "PREPOSITION ALL V_SEND_INF", + "PREPOSITION ALL V_SEND_FIN", + "AUDIOTAG PREPOSITION SOCIAL_NETWORK V_SEND_INF", + "AUDIOTAG PREPOSITION SOCIAL_NETWORK V_SEND_FIN", + "VOICETAG PREPOSITION SOCIAL_NETWORK V_SEND_INF", + "VOICETAG PREPOSITION SOCIAL_NETWORK V_SEND_FIN", + "V_SEND_INF PREPOSITION SOCIAL_NETWORK", + "V_SEND_FIN PREPOSITION SOCIAL_NETWORK", + "V_SEND_INF", + "V_SEND_FIN" + ], + "semantic": { + "Send": { "recipient" : "_$social_network[0]", + "recipient2" : "_$social_network[1]", + "all" : "_$all[0]" } + } + }, + "SEND_TWEET": { + "phrases": [ + "TWEET", + "V_SEND_IMP TWEET", + "V_SEND_IMP TWEET PREPOSITION", + "TWEET V_SEND_INF", + "TWEET V_SEND_FIN" + ], + "semantic": { + "Send": { "recipient" : "twitter" } + } + }, + "SHOW_INFO": { + "phrases": [ + "V_SHOW_IMP INFO", + "V_SHOW_IMP INFO THAT", + "V_SHOW_IMP INFO PREPOSITION", + "INFO V_SHOW_INF", + "MORE INFO", + "INFO THAT" + ], + "semantic": { + "ShowInfo": {} + } + }, + "SHOW_POIs": { + "phrases": [ + "V_SHOW_IMP REST POI_CATEGORY PREPOSITION LOCATION", + "V_SHOW_IMP REST MUSIC POI_CATEGORY PREPOSITION LOCATION", + "V_SHOW_IMP REST PREPOSITION LOCATION" + ], + "semantic": { + "ShowPOIs": { "poicat" : "_$poi_category[0]", + "genre" : "_$music[0]", + "location": "_$location[0]['semantic']"} + } + }, + "JUST_SHOW_APPOINTMENTs": { + "phrases": [ + "V_SHOW_IMP PP_MINE APPOINTMENTS" + ], + "semantic": { "ShowAppointments": {} } + }, + "SHOW_APPOINTMENTs_FROM": { + "phrases": [ + "V_SHOW_IMP PP_MINE APPOINTMENTS PREPOSITION DATETIME" + ], + "semantic": { + "ShowAppointments": { "datetime": "_$datetime[0]['semantic']" } + } + }, + "SHOW_APPOINTMENTs_FROM_TO": { + "phrases": [ + "V_SHOW_IMP PP_MINE APPOINTMENTS PREPOSITION DATETIME PR_UPTO DATETIME", + "V_SHOW_IMP PP_MINE APPOINTMENTS PREPOSITION DATETIME PR_UPTO PREPOSITION DATETIME" + ], + "semantic": { + "ShowAppointments": { + "prep1": "_$preposition[0]", + "datetime": "_$datetime[0]['semantic']", + "datetime2": "_$datetime[1]['semantic']" + } + } + }, + "CREATE_APPOINTMENTS": { + "phrases": [ + "CREATE DATE UNDEF_ARTICLE APPOINTMENT", + "CREATE DATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIME", + "CREATE DATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIMERANGE", + "CREATE DATE PREPOSITION TIME UNDEF_ARTICLE APPOINTMENT", + "CREATE DATE PREPOSITION TIMERANGE UNDEF_ARTICLE APPOINTMENT", + "CREATE DATE UNDEF_ARTICLE APPOINTMENT FULL_TITLE", + "CREATE DATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIME FULL_TITLE", + "CREATE DATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIMERANGE FULL_TITLE", + "CREATE DATE PREPOSITION TIME UNDEF_ARTICLE APPOINTMENT FULL_TITLE", + "CREATE DATE PREPOSITION TIMERANGE UNDEF_ARTICLE APPOINTMENT FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIME", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIMERANGE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE PREPOSITION TIMERANGE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE PREPOSITION TIME", + "CREATE UNDEF_ARTICLE APPOINTMENT REST PREPOSITION DATE PREPOSITION TIMERANGE", + "CREATE UNDEF_ARTICLE APPOINTMENT REST PREPOSITION DATE PREPOSITION TIME", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIME FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION TIMERANGE FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE PREPOSITION TIMERANGE FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT PREPOSITION DATE PREPOSITION TIME FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT REST PREPOSITION DATE PREPOSITION TIMERANGE FULL_TITLE", + "CREATE UNDEF_ARTICLE APPOINTMENT REST PREPOSITION DATE PREPOSITION TIME FULL_TITLE" + ], + "semantic": { + "CreateAppointment": { + "prep1": "_$preposition[0]", + "date": "_$date[0]['semantic']", + "time": "_$time[0]['semantic']", + "timerange": "_$timerange[0]['semantic']", + "full_title": "_$full_title[0]['semantic']" + } + } + }, + "FIND_PERSON": { + "phrases": [ + "V_FIND_IMP PP_MINE PERSON" + ], + "semantic": { + "FindPerson": { + "person": "_$person[0]" + } + } + }, + "RECORD_MEMO": { + "phrases": [ + "V_RECORD_IMP UNDEF_ARTICLE VOICETAG PREPOSITION", + "V_RECORD_IMP PP_MINE UNDEF_ARTICLE VOICETAG PREPOSITION" + ], + "semantic": { + "RecordMemo": {} + } + }, + "FIND_MUSIC": { + "phrases": [ + "WHERE V_PLAY_FIN MUSIC", + "WHAT V_PLAY_FIN PREPOSITION MUSIC AND MUSIC POI_CATEGORY", + "V_FIND_IMP MUSIC PREPOSITION NEAR_TO_ME", + "WHAT V_PLAY_FIN PREPOSITION LOCATION", + "WHERE V_PLAY_FIN LOCATION MUSIC" + ], + "semantic": { + "ShowPOIs": { "poicat": "_$poi_category[0]", + "genre" : "_$music[0]", + "genre2" : "_$music[1]", + "location": "_$location[0]['semantic']" } + } + }, + "START_RADAR": { + "phrases": [ + "RADAR", + "RADAR PREPOSITION", + "RADAR V_OPEN_INF", + "RADAR V_OPEN_FIN", + "V_OPEN_FIN RADAR", + "RADAR V_SHOW_INF", + "V_FIND_IMP PREPOSITION MUSIC PREPOSITION NEAR_TO_ME" + ], + "semantic": { + "RadarStart": {} + } + }, + "LIKED": { + "phrases": [ + "LIKE" + ], + "semantic": { + "Rating": { "stars" : "f__ue__nf" } + } + }, + "RATING": { + "phrases": [ + "NUMBER STARS", + "REST NUMBER STARS", + "REST REST NUMBER STARS", + "REST REST REST NUMBER STARS" + ], + "semantic": { + "Rating": { "stars" : "_$number[0]" } + } + }, + "FULL_TITLE": { + "phrases": [ + "PREPOSITION THEME TITLE", + "PREPOSITION TITLE" + ], + "semantic": { + "title": "_$title[0]['semantic']" + } + }, + "TITLE": { + "phrases": [ + "REST", + "REST TITLE" + ], + "semantic": { + "value": "_$rest[0]", + "title": "_$title[0]['semantic']" + } + } + } +} \ No newline at end of file diff --git a/assets/www/config/languages/en/speaker.json b/assets/www/config/languages/en/speaker.json index cecc226..84dd90d 100644 --- a/assets/www/config/languages/en/speaker.json +++ b/assets/www/config/languages/en/speaker.json @@ -1,5 +1,5 @@ { - "voice_lang": "en_US", - "lang_simple": "en_US", + "voice_lang": "en_GB", + "lang_simple": "en_GB", "speaker": "dfki-spike" } \ No newline at end of file diff --git a/assets/www/config/parsed_directories.json b/assets/www/config/parsed_directories.json deleted file mode 100644 index 351f351..0000000 --- a/assets/www/config/parsed_directories.json +++ /dev/null @@ -1 +0,0 @@ -{"/controllers":["application.js","calendar.js"],"/views":["application","calendar","layouts"],"/views/application":["login.ehtml","registration.ehtml","temp-languagemenu.html","welcome.ehtml","~languagemenu.ehtml"],"/views/calendar":["create_appointment.ehtml"],"/views/layouts":["application.ehtml"],"/models":["calendarmodel.js","user.js"],"/config":["languages","statedef","configuration.json","parsed_directories.json"],"/config/languages":["de","en"],"/config/languages/de":["dictionary.dic","grammar.json","speaker.json"],"/config/languages/en":["dictionary.dic","speaker.json"],"/config/statedef":["dialogDescription.xml","dialogDescription.xml.MD5","input_manager_scxml.xml","input_manager_scxml.xml.MD5","readme.txt","scxml2js.bat","scxml2js.sh"],"/javascripts/plugins":["beepPlugin.js","cookiePlugin.js","directoryListing.js","multitouchPlugin.js","nativeTTS.js","nuance.js","queuePlugin.js","softkeyboard.js","video.js"],"/helpers":["applicationHelper.js"],"/gen/grammar":["de_grammar.js"]} \ No newline at end of file diff --git a/assets/www/config/statedef/dialogDescription.xml.MD5 b/assets/www/config/statedef/dialogDescription.xml.MD5 deleted file mode 100644 index 27e0477..0000000 --- a/assets/www/config/statedef/dialogDescription.xml.MD5 +++ /dev/null @@ -1 +0,0 @@ -8378eb04bf67bcae5deb5752e3e61817 diff --git a/assets/www/config/statedef/dialogDescription.xml b/assets/www/config/statedef/dialogDescriptionSCXML.xml similarity index 82% rename from assets/www/config/statedef/dialogDescription.xml rename to assets/www/config/statedef/dialogDescriptionSCXML.xml index a12afce..377ffff 100644 --- a/assets/www/config/statedef/dialogDescription.xml +++ b/assets/www/config/statedef/dialogDescriptionSCXML.xml @@ -39,8 +39,8 @@ - - + + - + @@ -93,7 +93,7 @@ dialogManager.render('Application', 'welcome'); - + @@ -107,10 +107,10 @@ - + - + diff --git a/assets/www/config/statedef/dialogDescriptionSCXML.xml.MD5 b/assets/www/config/statedef/dialogDescriptionSCXML.xml.MD5 new file mode 100644 index 0000000..6916495 --- /dev/null +++ b/assets/www/config/statedef/dialogDescriptionSCXML.xml.MD5 @@ -0,0 +1 @@ +dc8e9aa68438feccae271061cb3e65e5 diff --git a/assets/www/config/statedef/input_manager_scxml.xml b/assets/www/config/statedef/inputDescriptionSCXML.xml similarity index 79% rename from assets/www/config/statedef/input_manager_scxml.xml rename to assets/www/config/statedef/inputDescriptionSCXML.xml index 56b4559..8d8b162 100644 --- a/assets/www/config/statedef/input_manager_scxml.xml +++ b/assets/www/config/statedef/inputDescriptionSCXML.xml @@ -44,10 +44,17 @@ @@ -71,7 +78,7 @@ var dm = null;//TODO: mobileDS.CalendarModel.getInstance().getDiscourseManager(); if (dm == null) { var msg = mobileDS.LanguageManager.getInstance().getText('did_not_understand_msg'); - mobileDS.AudioOutput.getInstance().textToSpeech(msg, null, null); + mobileDS.MediaManager.getInstance().textToSpeech(msg, null, null); } else { dm.getCommand().parse(command); } @@ -87,24 +94,17 @@ - - - - - + - - - @@ -112,7 +112,7 @@ @@ -128,7 +128,7 @@ @@ -136,7 +136,7 @@ @@ -144,7 +144,7 @@ @@ -160,7 +160,7 @@ @@ -168,7 +168,7 @@ @@ -176,7 +176,7 @@ @@ -213,13 +213,13 @@ - - - + + + - - - + + + @@ -228,7 +228,7 @@ @@ -236,7 +236,7 @@ @@ -244,7 +244,7 @@ @@ -252,7 +252,7 @@ @@ -260,7 +260,7 @@ @@ -268,7 +268,7 @@ @@ -276,7 +276,7 @@ @@ -284,7 +284,7 @@ @@ -292,7 +292,7 @@ diff --git a/assets/www/config/statedef/inputDescriptionSCXML.xml.MD5 b/assets/www/config/statedef/inputDescriptionSCXML.xml.MD5 new file mode 100644 index 0000000..937e887 --- /dev/null +++ b/assets/www/config/statedef/inputDescriptionSCXML.xml.MD5 @@ -0,0 +1 @@ +b1cf703be2045f6231768be92f1a71d4 diff --git a/assets/www/config/statedef/input_manager_scxml.xml.MD5 b/assets/www/config/statedef/input_manager_scxml.xml.MD5 deleted file mode 100644 index 6823d49..0000000 --- a/assets/www/config/statedef/input_manager_scxml.xml.MD5 +++ /dev/null @@ -1 +0,0 @@ -7c5bfcdf9f0f0234a95017c85e4db225 diff --git a/assets/www/config/statedef/scxml2js.bat b/assets/www/config/statedef/scxml2js.bat index 29fd175..596179c 100644 --- a/assets/www/config/statedef/scxml2js.bat +++ b/assets/www/config/statedef/scxml2js.bat @@ -1 +1 @@ -mvn -q -f C:\Users\user-name\dev\commons-scxml-js\\pom.xml exec:java -DscxmlInputArgs="--backend state --beautify --ie dialogDescription.xml" > DialogDescription.js +mvn -q -f C:\Users\user-name\dev\commons-scxml-js\\pom.xml exec:java -DscxmlInputArgs="--backend state --beautify --ie dialogDescriptionSCXML.xml" > DialogDescription.js diff --git a/assets/www/config/statedef/scxml2js.sh b/assets/www/config/statedef/scxml2js.sh index bc8865e..8553b74 100644 --- a/assets/www/config/statedef/scxml2js.sh +++ b/assets/www/config/statedef/scxml2js.sh @@ -1,3 +1,3 @@ #!/bin/bash -mvn -q -f /Users/user-name/dev/commons-scxml-js/pom.xml exec:java -DscxmlInputArgs="--backend state --beautify --ie input_manager_scxml.xml" > input_manager_state_chart.js \ No newline at end of file +mvn -q -f /Users/user-name/dev/commons-scxml-js/pom.xml exec:java -DscxmlInputArgs="--backend state --beautify --ie inputDescriptionSCXML.xml" > InputDescription.js \ No newline at end of file diff --git a/assets/www/content/images/ajax-loader.png b/assets/www/content/images/ajax-loader.png deleted file mode 100644 index 811a2cdd1b492c47faf85c1206ad6606521eb6e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 503 zcmeAS@N?(olHy`uVBq!ia0vp^${@_b3?$!tUzY`>n2Vh}LpV4%Za?&Y0OT43_=LFr z|Ns9ZDd7Dck0hX8fs!DgJ6C3d)qYMwA5Sr=f?F`h}-_x&BOOZ@XQnE}c<_xEZu zoIX1zlA-v_?sD-1ZfECkmVe(>o?xwNmGDbK;?2MR41rRzXA2bX{on66#ob*wrsMPf z`i=nRm=4)s4z4?=xi7SyIo*As^~h=O3#~U!U4D?`wnG2XC7uMQrY5F@nOn9v%usT4 zdzCN$d=k-PVy!W z7#|-W8yg!P9p!SlBO@aN0|R{mK7a1*?d|F5>Fn%mZEbC8YO1fVudAy&klNbH%1RcC z^|XRjURGAhWIiq~rqk)UIXSrxbJNn&Qd3joC^4~=0|*2{SXfwaaPVdS06!nBr>7?p ziL|x0v9`9hu&^*THa0OdIxXPjDJ?B6sJaFi3>GXZ*m3S1!&2b6kUcQx1>yeo&l7^llt2;=0KZDOg449alW-IQDJ)9U_Pl9i zJUC;x zy6M89cft{$=<7vnXr!lw9&oYOZ z3+=Q|XDIJS&7B6C)UVw!$hlw26{IJ@KH)%*dAKVg2i(M%Spi5d5N z%XfE{LXl-_;bLAEFtWv=Oj}HWTUfS`7i%e=TGaEJ#HfYo**}}_9^jgrmWm3tU zu{dSLeC>xnPPcqcg2L|PFy)d(~c)9ajmJRiC zM~yTr8lipMb41QCJ>#>=t;k?YK(?!00gF?qke4)qXc8O-#J!H*Z20ujgt9 z&*YJ;5lVAd{#gNd)l2=N_7nN368)lSQ9U8AzJGZivy0I3iM^p&;PaZ*xhXo^A{36% zkXH_IsWbfU707+6c-uJR)Oj0q<*(XM=@)PXkJV9H(arl$=`rrk;;<^@Yh;IEp9PSu z+v~Xc?Wk_FF0HUzH*+IPR{uk0`}3r}Ho&zMYwLYy>X*V#Td{5Ixu9!0wAlHEMeV9! zn_HG<;7>T8YZy&PN}ow(d~IAQR|S!S>qIGK_`lO`q761j>1G}Yw*q@I^jFRT;VZ>> zWac;w-ti=uo+GU`P-cQ|5=oK*(UYr$h#ZjnS5Dp>K*c?OHv@ECG0|Y!&hgkLaE+6JMY+YJV#yHn=ataxA}xEKRu4^;D%c7+hyQpQftG$kJj}%e;Kt3iEBNVU?cp8$KYy%l1Ol(B0Y=@^0(an zOQl>o%B)=fj6_NDu6bABal%#&Q5h&n;>*p| zS|^R!m9)Z!lMJhuaSe7$L+|AMLirwzBX7tiUXtF+$64#qre2CG6D^H-UZ4T~%%JR5 zNCeWT!q3GiJN|~RyyBPe#Otx99oJvk>xYx0nT3zsiD3P%ricMaQCDr3FC_to*h<$ zqqn&iWEzijfKuF)Z}ETo9lFXHQHA4jzFcuUTi{T-t*2m=!S+7no-c|YI(`C6xf-CQ zdN)McqyWaa^m`lLIX-H%#?0?C_D0ZbUgYL(8Kl|BwavEST$_{fxQXhFl&81-Okhw* zO}b!o?c~_edT<}su|YPWdHQ0jftA{$yde-ND2P>{Qs6E~k#zxfH3qK!v*dEQz!<0j0h7rD!P?qdVPWB> zE06?3fr&sK*anksdfv={C8(s)XyC0tAOM>Hh60q$Ca+(=1_hfj;GRc}!NL4tEN>DS zqWoV#{XYQL-{ABeJ^(<8#{Pzkj0_;m|2Nvc18nJl_#1%M5>UnP*i%4H_L!?b69SQY z^X-!0WGMuIB$DOq$0A45SnQBkD#RfyI+UtQV8l|{(Xo+CT}Lt|rfKF!P^bQ_&M}r6 z!eT@p)uk|^s1OSibBu|ZnS9zMa7wlk-JBdK;i-!Ok?aX4*hn*j@sT)^Zy%h01iqoJ z+}Ev4Q8?tq$7|hlKb4TtIQ8|b4DDcSX#aSjeoUZZ-}-y3&RWS>Ui{L4*vB|B8}miA zr3oTMw3xfdFrV^=xAh{Tp*kav?OT1y!-q98m+P^S=+uplsIKGh2`mRbvjSXsO(!7y{5t8DP+@dW&6nVSLaUVx^}k;k+S7;+Bcw|!VO%}_agr$&$c zZQn3cO$%8TiAS3ihFy6OVxe~=&)lG*^guUfVLLV`goLRrkJ~e=O%$WE)K4{<8NO z6`J#oH|lXW0z>FuWtNBg#7mE;q+92DUBye`^hTwEg|n7w?m9Gmyla}kF$*r~gO{G+ z$x(Mpy6@kTKTE54XdmAS`#2_NCY4);PG9B-u3f)?MAwI6JkMQKha0jC62!>jfy!Tb z>Ky2m=?h4u=~DjBub9;F+5*`S%Z;rGFS3PbZamxa(t-|BTYJHiP=2(n@W!b`A(0E~ zk0MR(o|Dd|;J4;vAbRZChF7KY!y-lp-TJzp+)-XET!+5i#x4Nq;Ilu5LcD)=sOT7{m-Wv7}!u{e{OZ()Pj9WHmRV$lW>Jx#?}Y3um^B zh{!&;9OK;Ku3bsi{I)LN39j@s^5d4@?(>*YL&v;iGbEY_%|V`L>-_b7T-BHp>yv*T zO%!bG6VRvc`@VDtUS{m2tJaQP3)m$htK?L_z`L|OU)r|b@geN(gF)Eq@cQA7jsb?~ z35vWsI*HFrwiDRq{< zLxb&6DB&0XhlalouDYYNqC#?LZ*QQd0qTQW)ryf)zu9cJN6i6B6#Teu>N>h!qRIvy zD;9jnjC*RA;*XkC{|8hw(KEk3y_#xC=p>z9ydgIgn`FxCF#7FX1P*!A#40AD3fqpI zhmKDl-o^FfwT;)gPpHZh%$tyOf@tn+BSD2>@ig!=oK!1Su@kQN0zTULp8 z4o0h385JN?b~itOAAF^GOrDR;sTXH8D&;4aDU1G?V*1~&FvDrwu1kt4oO$*HHrFAK z$D&0{C@1#qcj3phWI>wRm+)XMc~WV)pO0f{ZH|ZS&0bTIp~HNs%?Z?mhT2o*gX5a5 zp*6&RHdg;WG$He`m_(Uvlyo~xe< zgibwpOD!mGNQ&1BiWT3j#vodjDhNW2;jD%?V;EBi@zE_os-%ro$2!~T( zmnisi!2~1y$%ol=F>Kzp<6`IKDeEmgg!Q0!PP0LIPviNdL)Ri=h|mv-V@}WpoicoZ zf0JEYQOwA^XXhtJ@06l7?XD5(IkJl*PoZz|d}Z*1o)yvXa#!4sm#~IDNkEsU125->vW7)vEm{U(VLZ+A&fMAIq_F z(wLtggNcy*ixARMhiZ*QT46*zU7AA%}at zS3&3+Gix^Jp9%Bh2T1fqd)8W7ZGO|V^4L>- zNBShoPHxelu^U<>Jot;BE+f+&w$GxhBhKZzN-GLsa_`n7siIonYgS)A^@#@A#raM> zQJ&YphX>aqon&ttU0e^S%|ZxmX0794HIqFltHvdQ!-VHXh6N4JRkqn0)rN3f$pyc| z0`7?C=`%mQ3Bq4*4m7S5$-LJcihp-x;@tsD9_CqsOv{Svm612AJMvl@2NEeRKksZ# zCXPOPe_U0Fh-{ZSVw2EvN=AXVzTHsC?&-bT%z9)e+r{p(EIk|Z+;-22>!;-R^VZ=8 m?52j%#WvFuTE?pwp$qUeOUIX~;K-`>3PIdUhoPPnK{^_Uy diff --git a/assets/www/content/images/icons-36-black.png b/assets/www/content/images/icons-36-black.png deleted file mode 100644 index 4c72adf1e81039a59ae8ab74cdeb6148c67acfbb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3403 zcmV-R4Ycx!P)m zW^QY2ac^*UcXxSqcY1etdw6+Cl_s;jE1t*x!Iva+?bw6(RhxVX5xySu->zQV!6#KXhH#KgwN#>&dd%*@Qq z&CSlv&e74))6>(`)6?7A+uhyW-rnBd-{0Wi;Njun;^N}tlq(=H}<; z=jiC@>FMd~>+A0A?(XjH@9*#M@bK~Q@bU5S^78WY^Yird^!4@i_V)Jp`1twx`TF|$ z`}_O+{QUj>{r~^}Ep7Oj00001bW%=J06^y0W&i*SPWoFB+rOJg}J8s%|*7yG&BM1TnB}yXi&K6_i`6HJ26Q2Me zaL?W0g@b{Gg@uKMg@uKMg@pvq)`8zLjman}ImcFzh{wXh!s6a)L2ENkM6-gA6IIXZ zfrW*IMKj)S!mZMjI9 zKoMKOct&XsJ9;c&a0DU}s*sInw7^3Xg-&80trdgqhyhKe3B(gKH^*Ij#+m1)WR9lq z4)5-0h`|c zM9k4$BXJ#YH{q_R6isX(w17el_^6M$IL?aN0g6`G+@utP@(Wy&LJ^)icm*E@p6f9j zQK1E%?*$llL|9#6cBNJd$#qawOK9Y2NTPGH*N`L!L%ahpbY&+FAdjorW$kr>4JL-j_L?*X>v#c-yH4KiPHIY>W<2aeZ6H3*8j0er>6{O9gr@vket zK#k1Ma~+K#-YnpVjIy{P{E-ohL0&3~(4eRs!}|0owAVC;g9&nADL}@1qZR+nPJ!Jm zhyhWq3CPnQF^E~^&nGU%nn!9dOHzaRSQW#d>2#T!5T)E4!?RV9DHCmNw5`;Uf(h z?mIDJ9GgQCR=Wig4i|%fgeWAb6tx%>{SX}*WXuV<$T(p$Gl{4i-Wkzt4OatczPvDy znc>buqREOsl3MWa;P%D9s2hTQS6!!f{w`yq`M3}p=H`X0min+Yq4T!h5w(13X!D|nzbFNxzg zw{iKuaXQGvA9x>1%kCT?eVb4!5W0vRg5RHO{< zijVvpdJszyck@f#xr%NmR3Ez{vUaKPk@*vy$1LT>5g;t!-dj~YfP z*uU{AF~H6tr%{XzOBW)`5X2W4I>H$sgx6O5kE3^47Ptfm) z4=OwJ8fwKcVsN2<{*N6K@AUPHK{uXNxVRB9@ET}Ba2L^Pz`Ow#+GN6Rk8VT@ptH!4 zwzr(?CXb;eL5!IgktEV$P}&r@7^w0lX6N5kL>z9LWJgacI;DbxZH5erTt|qM*#0=*^H)#Qsh+;*OE=BIY z3~{r_5lJ#mhZQbHD76?!%N>zK2FhQA6^X%onGN;qff&@)06Z!(vRp3FrZZm8p2A#! zp`niB|H^9m(i4qli!yAic2Xd`D1IgsdF%cs32&8bO75`<;_U1{V z!>x$HNB#5t2S#yzwy&@MIOxW+3P0Y67({Fd;Elg=xyHNNeYU;0z*GZxNz@dGJPR&G z2^5cLHtKo=s;$PMOgtdg^^0sJQyzU`r-1H#Om~)cJxjFxJvcsr7^Kw`&(IIQKVndZ z+xbd11{+w?ice<0H?`p5Y=1jq@Javt{qKzO{PAmj{nMZu&nkSn5iuY{85b~>75DH? zy-O2b;8t){hO(Tffgbo6kp%gb8eq=Y;2urhp|H1dU15;{mT$~aa zD2Wg%m5~&9^^J=?@x$OqjQk9Ec+rUgi{dy!kwv)a_0oz@XKyN3{K3D*huaZ@!Lk1R z?B}{X&!+n7q-C{^H8k)`6&MSMHi_{_hCI-03gK}SW*cWnlj)9(r3l*>17BtM;AAms zg8lqRVlsR4P#NDZCr1X(yU?sgJ25!XzdxQlD~t1da;UF<*RonC8%pzC&&8lTD5qFc zs^-iBT-PT!#2UFiwTKPkdRinzc&{-!E-;!JlT@KQsLsc)Hka^Fi^o>5mwQKE{-1IKu34 zlsOEN_xqJNSyB;E~yH9(s51704O>O*`435`#fTKt}Vp1{U`h zN!K({%}S0>{`q!%yiG9}Tu)b0%&t3BjEcv?qIEVzAhGRW@p)pwice;fbN1E{{!l+yGXx+*mVE^002ovPDHLkV1kWKj}-s_ diff --git a/assets/www/content/images/icons-36-white.png b/assets/www/content/images/icons-36-white.png deleted file mode 100644 index 84ea9fb31ae442d0c60523fbce08ec5f202b7d9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4020 zcmaKvcT`i`w#GvXEtDui=v9ieKqvu}-V}@!0TG2nV(2}zLopB_bVQ^CRH}m1C>;v~ zQ0W3n6#;<*NJm9b+THhX$9Z?Wd*A#0vBp|+uC?a(&9TSWVg&Tv=IJUtizZ**Q8odVGBR|C};2GXoAfI5^;NxRc{CF)_)>$(fm%Po6vh z?s@(CbzfiK^z`)R<|c5}f2|Hw1Zw@S?1_wj5B|FnKsiwK?<}wcl;H9BzxSNDJF#{m z53qKU1uUPK1@@n)1!@5)peMj3fD0f9=m&y;1t1RCIhmid1#ol{1hPPvfaQsJz$VZx zz$uVDnJg|Yp19uK-35Z3?z!1OD`K3(aM`4lo}WnYHLH zIW*igmaUso{Ji+_m)9no$cOI8#eSNU&Kwf?UR$xF58}~WW|DAP<6*YirFzdqMQe1M zapYBISPllhhjtdD@DA2@Z;`8<&FIuqFI>Z;^~O*b5uE~YI0G9J;v3f_l}Xft4d-Cq z^ZUHP=@nnGx=e`(H{s7(4P~!XL-M^@&8ym|nSSdd6lCuWzXOw#LV13pk4-wRa#Uoz z&nqNvCk)2vB!0M^B>2{s4nBe#WP=jbBt3XR+huCbW-tXBzS-#OLqeD)#pqho?@1iJ6%hkNeC&cHcT; z5?H^W8I`&_Tz+%XnhD5w>T&z%Q3H`K11oPT#V^hG!WC#LtX;d*^K z1!O??Oge$KMp3rov7PC;#Ie|M;jqv9H6_+QEnz!V8XdDGcq7W}Gwkr#9h9pDtqkH& z!+uBE(rKs-bwr!?@arEmV-);TUeW9?dk5{k>Tl0Jts&*Cq?&ZlGJDT7XhvXfi4@EQ zQsO!r#T#5ivL!4K4fDuKmx(Ly%E<>Dd$3DAu6{H690uM|XpV`xZD_{;L}*qN9JDC$ z(1u-lDcv$4>CKEJN0XeAg;CKSro!HdjDXmlc7d_JHrHC(lwV|C8t&)jo}0E^cI9L(|P6FY9*1J*2- zp2qUpZ~0f*nOBb~aTge{6*c@_Y*?+cC9DH^U5QcEOC}l%zlHYT6hT>7=b38<6U~ne zL8~~SS63hSigtf^I%30(Y|OpvSm>hbx^r|deU&h_z9_xt%CNb)%n~&bnfs zWWIC|7iv2*IfqMZM`y($qNQ2H6_nnd(iqIqeQx^W`Mgl$%%!{hB}xLJvr2Y7arHe{ zoqVwNph|xF?#|V=^iNylVft24A&0IbW{a!a8G|v}P(I1eM4juJ1vGQ*G)}HcQhTR* zxm+IT@@Vl7(b$zjKDFT-hl@$z4;oU|eRG99X46xz7 zb?cnqbydtg%6-zSNt41P`IT2Orr)s4o`|7K`Bss)vV*%!TVr41M@>6ukACJ>$-&yz zclahAQKi}1yv))v=XUR2z_)m&bwUPXc55#)(`4L?o5Ah!RO%j&96D|u@syi>^vYst zHH0IJ(Ss3pSM$PTAOoX`ljQ2!OcITFgrPOL8~h!n6wGvOuoU*g7HNtfCY~>lKkvYB zU%SW@%eG$AjzP1HP7D2^;bRFq_4dG6GfsbRxp-Vx=m|}e7w$nUP5JMUwnsF49kkba zUD1P{GpAX%m(n7$WlnW3YuUjbI3N4vjZ{uHpR*J=Zusn(6-8}!rlGT2=b>M=S}&MO zBhvWitKFta4M$EOsro#J3Z7;Zj|##d zw(kb!*e}fE4n6per}}PVLo+#`z9{I)>J%qLU&emx^3iKFY@GNZYCOXO+|pyk*PFrkS)b zY%jHx!l7QYx2(qmvM);Cqt0xV%l5-PZ$6-{ZVQHhox0uWe-AU0U9Lg6=}fw@0m{?$mJw zJm@MIKfLS)+I$2bnEq8~L3plD%e~-6cv?}W<)|0aGRlVw2s`>%aOHw#v~$5gIw$xZ z7L6%T%Uz@16PTu~w28Puw7R*eU_32xL#K9tA~tmN^9@7W?58!I4a&!Yi1A*{AEg~? zW{{vJ@~(%`y7}1t8Is-~o5-itCh-Ik$NaA;P(YoQ^>5Sa4>bH)g*1zq>2!Q(M`?7j zfJ_7RLWx@ZdGmO`FQp@;Z)HUuc#@^Jxq9xAxk9{77tQPyrluy$-PJ6Gm`DjiXoGm) zCp}9OeD?U;^yK6udnvV}@o9P^2Rkq8=&4tBAN%lUl&u|>rafylhcKI=EAMN)^QdlN zB>M^J@yZ?EX>$tjA1ixF$SfRjlnwFTSIKLoXO3e!CKkw^Gn#$%qRuKtu8?6_p9;ieh4S_Bj%~M%m&Kr;lUBZkiK;2LSR78Oo{6UGYb%V3+VfxT z>YQj-!CjLqFO{Vw=DxXPxVGZCFbU%8l2<>Rpf+Vzrf+w0D3&v=;~9J~>*XSFPG% z+jDR1I5sYEGi7T7-AHo@`L6c{GuX9Q9Sw%om4Aia?y~YVR+;X=y`%F4 z@I|hfiRJ*`@vvO(gdiSzx_PTOaB!G;Fb6`e$?8V}vsQ*`H!AQagpZ2;kh27ahFtIE zGdA^KyD=UKDPDebEg!ZFqvTU zd*w|Dn?im=b~d=XjgeXhg8B4p2v5?Ar3T6|s)ba+I3h7=~9RnEWIT zX|qFuTqM8a;8VAhJ2%|O(;p8D>q92aB0idP&D?%mM9e>ok?$DeW+YBlnN6LEB5FaH z))-Bw3hI7;+9t#?Yt7sAq-NQEac9b|+Sgk>wsujsQsP^qjQ8qq{x&vtG0P(xH98UwHE7IM^YYeF*HxDJ4rJ=Bd}*90>pQZPz>c7BcfM5zdP9 zAKphI?eint`$qail4n}{4h^7GotKdv^d#SNe<`@min)(r$HGjoOLweED5!@QO#|@s O16?#i8CL6~qyGU`IBHY? diff --git a/assets/www/content/stylesheets/images/ajax-loader.gif b/assets/www/content/stylesheets/images/ajax-loader.gif deleted file mode 100644 index fd1a189c21fed1c7ba00c4bb4fad407bd6d1e5f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7825 zcmbuES5#ApyTy~7eo}yd8UkVpXkY*_Q9y_qiinOPDmsj9qNsz4jwlKWVnXkP4hk5G z^b(393euZ^(u<-X0-}Q58OQNIb2H9b_uh5y|K)lgvd&t0I1j(IzrDZxoedl9%vT>U zCKwYc2!y}>`s>xJSC1Y&>gwvcefxGnK|xANN=QhEr>EzUBS&`b+-YlTD-Z}c9FCfr z8i7Dy|3!9K@3h0l%5gp4*aRT{{nzgx1}L9~%AfM3#smWRmumaQ@4U>9pSbO+0$LIPtr>H><{{!d^!|HwbAIt1{-+7Ta2>x>}r<$279U7FR%5w|JIQ-7uka zgOwiqlR{u=9DeWlvEEZ6R_mcX_D>?!>0WF)7j`|0NDVG9f412Pc!v4~*d&C+3h)FQ zDA^3X0!Y&NfeCKe#@31Xe6SRh6&ou`vnqJkFWuC?6;s23t|!&A5d{Rda8R%jf~qf2v__<&*>hT?j;)XK+f ztS03*6|qPPs?5Z>TZh$I&;Xj@2w}WgW3jm-&%UQ8qdt6vFQ-g#l zFP9MgVXC(Igxa%BYo*{KhHakWKByrg(VSRs#f^bSS2cz>%S1mlM=i0srSS8cvWrsR zVQ?VjptL(mXJ^iv7-~=@^G`=&?Z~k_rh}cO`KG&P^m@>5mnBP;LPi5$_HRPN9j(Mn zRSmjPkNp9LUEM%Fd(cV`wV7PRgvA{i0*m6PUHK9}Lt~5neh@}b6xp}K^n3aq>r3D- zY?OqWg>w)9JOd!YQx`91fbr?PP%R`AOuJ@@7q}E#q6M;YL4HPAl^F~{AXHQ%sB68^ zY}8uU-ofkq;U2#e?(SpXfgfZK^MW4uJ<`V}5MjJ+XQR_ zk-wpCJ#mr%Na(wvfPh_G6!d|eP1#7I4PuNCW#3qA{4qpHBef0 zHC9{WUT>+Wt!uS}J8pKG!F_!#J%aweLqo&;$b*O1LP7>7^e3NA^TR{Jo*QG6VdPi( zdqPoc>Vp;*_6d7G+ucZ*`iTTl#iY7V5)7Y=|?9n=^KTrBx}O>hwOGVyhkcFV0;y-JHswxK=BXRjL+Xuw<04-vi60w zKUJ|*RhxIJ?>XlQLI{Fk2z`;+ab{N2QCIi`2dHM=88f`vr%Kj+s6k!&2i0A zTrxuQiS%@BE~3cFF++R^pk-+mj0m?2RWSJ8y>h`#bF2I9og?A*LPkb|gL@wd#)JDO z`QzxuXO_V)Ue1}lelhdb<3;GlUrRn=IOUJMhW1li8~h~e-WfR)R1c`A0Sg$1>g7ah zM^!4nXqLrlRi&(7xP5A*cRx#wt#9f&A=kaVnrm0$c9fnIl3=(mUEqH($H8s4W966X zh)^4*UG%R#?v+8=7ag|Vi8xlFwKH8<@>!;~>ML338V{xRws)Bdn@g}584&Z?7Hl<?dh(AhJ@%{ zT!Mw77j%hnkWLhqjO)U2aVNEsGcIwFG-8lE1*hnuIYb@2yu658l2eA0Z(q05yiKMw z-eESjQkyl~s8m|VA}Xb;``-P9{j^b)p#`)7m5GOA>JOewJ|)b&n0@|oj{fTP{JRey zfBo&#@1Otp@>%VhMpb_qVj~stG-!XD;CAhZ9=7|jzXb(ZGtw?#{tbT%DmBQ%=`&RY z9pX>>)$UBz{Bw!wl5KWm)bFe-iUt1+iGc_oUpf!- z^G8q@rRzsr0h6>%*?36YMSbMt6#$OrP=ZSn1!#W6HEjuA9h`22R2B*-eKJLe-R(dcD5Il71~>?fJm?#P2SEY#`HL|XbP$+*PNUN1UJVLppa1xEkn}s_ zle?uV>qo0|a}>~-LC~?*0T?jhH&uibN-Wt~!zOSmBDq#5$=QAd$dhT&A}SMz^t-a6 z{gcV8Gp$!IZ#p^Yv-0O4IaWC<}6I4|E`d1!o7Wj;gu7GO?hlH@Ylnq1am9ZvNH# zs_xcuOnTM|^^>C8y~EsBnsRWNUtk0igTsD-;x*|%%3`o9Y%~l25MK_3Ttt?U1=%?j z7ngG>Hw(!WbEF~%HltQo3!yq7lSA$5qELlcJ1U?Jbt{q9HSmYVl>-U`q#4kBViKL1 z0Y;yU&drl1Un*x)`2N*rA^f4|_oi(n`=nAcRZt#`XG9RmkfGCzW0RD?SfS&zO|7XV zf?<2y{nS(sfgpQi?eXFhp`nA&@kM5ci6reY-~E_r0 z?(RFiLS&$IScpCV#w@Y%C$|Pj6Vrmnr1|GBjN$ot@C_e)PlA3m!hR>^eafg$Qb`d} zkw52mG^jMJBUYM^IC`=~5}zT~mZ=<(q$QeY4Kun_^~VUZMchsC1eN*?#QT57PubN^ z6B54D&+9jf)lE6Q=FHvIvjVJF$AUIAl6UfX*KvnnyYSC($j&A9iFRLI;QyS}`pd(> zgZ7)-*BZel4Z1q%TLUs7=BoI5u{v=LDj8Q3H-RpF3x@*V_kDVwL*&dvNjnCnA5jq#qY=j7Iu^NUBks0Ly~FC<7rs1FXna z+)#llE268+uv;KnD=eynn=FxAP`fz_fIv_8oxY)g{Gq;)G9^`G@w zxlY$o+O4>yRI&QPmpsd=IDPZY%(yF>0cS6sPFjsw$WIx@*g)QEmq3A1e=Q^^FhnaN zI8qbV*cFqg2NJ-Pq(xV*rY*dBB_mUQZISF+L7qBLT3YO_C@Zc6%5M@B(=@AjtMAG|x<5(5tQ+>IL;t9@ANQ#nav%#pF6 zJi7A<0S|7qCB=wxM4d-e3uK%-JDq-R^`M16eoZ{EbK9xI>@v&s+OLAo&0cglHofnd z*LkkGkW1d-4+oqK=3(J58fY5Li9z5i@CD7pq~uf>LNbJxvmq!w*9a>ti!U)ND9ou8 zpk)wTeX9^Gtm7-dMzGl!YwNyigm$;x*GKxG0Up$MXOxWreHD+H5b)$l@hI|a{*m`x zbbcO-s+)Tc-1L@bbdd-T)f|Uy8l(0fpJOlx3U=)#*qwrkVh%Qili&e=hC3_?V^}Vy zkIc^4mPIeL!Dn@kL{NweTuco`u~{7p@vbeDQzZngMQdvs+IM9wDb5Uv;!LX_%l}@- z!JlOGjgA&-8D-~h6@T%Zi0z)?Xt-Pc)2Vi`0o}nVI4OI#`oy!@W~ya`UV- zB-aehhTtLr23=Q_^DA#aH;r%Is5L@wfHe&~qy+@a+PH9MXW>0I*4vppz=Vdus}DMc z``La)CqK_hAj3UUnGsN%P8qzeofN{8$@TL+IcQYxJ4Rn zyY6n$y_5B31yA?8u4k3DMcYn~W43z_XZ_6ZI)CA`uNL_T8j9iufowcX*_opR=VN0d z5{zWYFm}ZlO^(Yj!eZgr9Q{1F6fWXniqdj!Whqov#m1oe+qG=8p|Obxw<7JDb*=H; zDliBQLYLc7aBQqAGIKoh(b$NOvTPG4dC1h`fMUW6A|U6~0k3C#F0v8&Y(7`MDO#5V z&|kbfw>*HUhJ)x=oPmt$RUV&uh6xuIuC+P1*;&kuROf1F5H#O$T7gmXR@a^K!|MaD zUN+xI%ojC=gNv%)xRZm5n15=s)8rmU+qe#;UqUu{@cO>(mecY6>UgV_n>0Z4U{=fv z)~ZcG8fPyYjHf>Luq|5~5_Qd^Ongf3abdF6E?(Y^58Tdk%N`fpOs!QcTWD}vi{gu7 zetcZHd`C(`^vMyCsF#cv7oVgbfuy5XczAkt1~)4k$>HQ(E7Vdp>576gIQjE zU6^QwLCr7}ECc`{(tNLh4-kmNIzD=@c}SZ}8W@-JF>n;>S}o3V`sy-!N6JTu=q~37EM1>=63A*i<<{4_C&tB%kytaHclxM z=k;7(oOlD5eY=V8ZAVMmExi5B;wIE+}z(S+e!Z=`x|q^^1F| zE8edPezO6yVA@aGdfA%Bf4|HHhqQA?3<#ahhLt-?7tQTVUK7wD5%E@Z%>*nH<#uj} z2-yExZ2&-Y$=*JTflIJ1jz*xK+R!CEEHa8s@{MLi5K@=;CX=`*a!s0)k;%exu5t1? zp~YMUpab88OLPn9H<-EAw+xOEpfn8_>TIiSK2}F?JJH%j57qB!>FZbTYBPL5?;jXK zjYpn7qED=Ab8AB`@BXJ3ulu$*{!bCv;M?=|lJp#MjE<#l|7ECf==sgXXh@#RSi%C5 zq@MMK8?9AgCDt)PJ0ibq7O5!C)6P>V6v0JbYyW_Npff&~EW-lG-b9iQVof2Zrn)C4 zom)r2$#|{+N=gE)b4zgnQkaAZ$yjxDJRh$l6$8 z(f&~rt^|N~eGHkJzQ=at;2>%I74%GNaC#aYeejThz4`(`L)D3z40G9j!v*S&b1yf@ z4>XZf+4Pm7SFFYWE?srvS`4EFz7=)GY}n1S zB)ny}fM)LW(O4qft8G^`;5vEec_+sqcvt9M>!AK`_q(ri`Cmv6h2+RHY+0ui1$Kc( zEXkW&8V@}h#w@a{4x1XJ>a_3hmxxsJ9&hmR-n)$^@D6qt(!wKxf=Qv45i}|_DtO`hch+z*6DrXWIJ z+7&Fh8iw%*QCjv2$$EgXz`#~cXbDxrZ1Bz5u5S;vMlSwiRhg$`vL+TXVTzu=MQhL~IyDoU1xuUq3WmjC2Fwj*R)y00x~a3-!`?Y{rF-`U_eTa+1}8NllC z2wKW*VW|?FinaH&*H2$)c;cG!ok%X2+#L4G9PARZVB zNAN;V#Bk%V1WsIF3KQ@HJkyv_R{_~NT0x-z21mSCHdEV*?B8WdBbbZMeevRS z5@SuaWDeYeP zJU#!$?RGZ$Zc?k+#|O=etIbPhFYl*?sC_`2!?uYj+OZlr8pmSz`I|xsdpz9hChm#( zu*$t>CKkmG+y_se&03X4+v425296ZH4GgQ7LHcu_GAZf?EN zakuLZW#vHoP#4x?(e~(W=e>>SBV_p5fmg5JynXk6<+u5q@;fK6{QXfqTq-#+@=~r5 zlpUX98A%6@(#3MqWjwd-ay_rQPU^1urOS{&fpa#ia+GL2xq0((il>|MhRngFBs4&q zEAjLX*T(_RBQZv3{0Z+QeF%^PiD^7A1CV8Na)Gb{Zc%C}yQri>D<`wKiVcBvV1A7X zTo1Z8X`-zcIv8hL_uW%L>LKVxlJEUH!^7o9Gy$DE_!xpmxwJX{ln49_h7p`g{WLde zbcVg*@%ve}y<9A{g2@b%_FNSx(By4Tx24FP)!>IO;(L5L1!{zTu%WRSDH8{+1AjN) zo#8L$tdCiU>DcCGwUIe(nQjutQd` LHfkt@K(PD|Q{O_Y diff --git a/assets/www/controllers/application.js b/assets/www/controllers/application.js index 7e15ae0..14c8953 100644 --- a/assets/www/controllers/application.js +++ b/assets/www/controllers/application.js @@ -49,9 +49,10 @@ Application.prototype.on_page_load_login = function (){ - var isUseAlphaMagLanguageSelection = mobileDS.ConfigurationManager.getInstance().get('ALPHA_MapLanguageSelection'); + var self = this; + //handle language selection: $('#languageListView li') .bind('vmousedown', function(){ $(this).addClass( 'ui-focus ui-btn-active ui-btn-down-a');}) @@ -67,26 +68,26 @@ // Using the click event here does not have this side effect, obviously. // .bind('click', function(event){ -// event.preventDefault(); var lang = $(this).attr('lang'); // console.log('lang-clicked: ' + lang); - mobileDS.LanguageManager.getInstance().changeLanguage(lang, true); + self.changeLanguage(lang, true); + if(isUseAlphaMagLanguageSelection){ showLoader();//actually this does not really work, but at least something is shown... - mobileDS.DialogEngine.getInstance().perform_helper_method('GoogleMap', 'update_map_language'); + //TODO: replace/set calendar's language specific resources } - mobileDS.InputManager.getInstance().raiseEvent('touch_input_event'); - mobileDS.InputManager.getInstance().raiseEvent('language_choosen'); + mobileDS.InputEngine.getInstance().raise('touch_input_event'); + mobileDS.InputEngine.getInstance().raise('language_choosen'); return false; }); // if(isUseAlphaMagLanguageSelection){ // showLoader();//actually this does not really work, but at least something is shown... -// mobileDS.DialogEngine.getInstance().perform_helper_method('GoogleMap', 'update_map_language'); +// mobileDS.DialogEngine.getInstance().performHelper('GoogleMap', 'update_map_language'); // } }; @@ -106,13 +107,11 @@ var password = $('#passwordField #password').val(); if(this.verify(email,password)){ mobileDS.User.create(email); - //need to invoke this asynchronously, since this function is called from within the dialogEngine - setTimeout(function(){mobileDS.DialogEngine.getInstance().raiseEvent("user_logged_in");},0); + mobileDS.DialogEngine.getInstance().raise("user_logged_in"); } else { alert('Wrong user name or password.\n\nDir you register?'); - //need to invoke this asynchronously, since this function is called from within the dialogEngine - setTimeout(function(){mobileDS.DialogEngine.getInstance().raiseEvent("login_failed");},0); + mobileDS.DialogEngine.getInstance().raise("login_failed"); } }; @@ -123,8 +122,7 @@ this.registerUsers[email] = password; mobileDS.User.create(email); - //need to invoke this asynchronously, since this function is called from within the dialogEngine - setTimeout(function(){mobileDS.DialogEngine.getInstance().raiseEvent("user_logged_in");},0); + mobileDS.DialogEngine.getInstance().raise("user_logged_in"); }; Application.prototype.verify = function(name, pw){ @@ -142,4 +140,38 @@ Application.prototype.slide_up_language_menu = function() { $('#language-menu-panel').slideUp(); + }; + + /** + * + * + * This function changes the application language and, if requested, renders the current view again, so that + * the change of the language is applied to the currently displayed view. + *
DISABLED: After changing the language (and re-rendering the view) an event "language_choosen" is raised + * on the DialogEngine.
+ * + *
+ * Note: + * Momentarily this function is used by 'controllers/application.js' in the generated language menu, when the user selects a new language.
+ * This should better be implemented as a partial. + *
+ * + * @function changeLanguage + * @param {String} newLang The new language which is to be used henceforth + * @param {Boolean} doReRenderView Should the currently displayed view be rendered again in the new language? + * @returns {String} The translation of the keyword + * @public + * + * @see mobileDS.LanguageManager#setToCompatibilityMode#changeLanguage + */ + Application.prototype.changeLanguage = function(newLang, doReRenderView) { + + if(IS_DEBUG_ENABLED) console.debug("[Language] selected " + newLang);//debug + + mobileDS.LanguageManager.getInstance().setLanguage(newLang); + + if (doReRenderView == true){ + mobileDS.PresentationManager.getInstance().reRenderView(); + } +// mobileDS.DialogEngine.getInstance().raise("language_choosen", newLang); }; \ No newline at end of file diff --git a/assets/www/controllers/calendar.js b/assets/www/controllers/calendar.js index 19a4eae..03daa5d 100644 --- a/assets/www/controllers/calendar.js +++ b/assets/www/controllers/calendar.js @@ -40,16 +40,16 @@ //This method will be called only for view create_appointment, after on_page_load was called Calendar.prototype.on_page_load_create_appointment = function(){ - $('#create_appointment input').each(function(index, el) { - var tis = $(this); - if ('datebox' == tis.attr('data-role')) { - - tis.on('focus vclick', function(event) { - $('a', tis.parent()).trigger('click'); - }); - - } - }); +// $('#create_appointment input').each(function(index, el) { +// var tis = $(this); +// if ('datebox' == tis.attr('data-role')) { +// +// tis.on('focus vclick', function(event) { +// $('a', tis.parent()).trigger('click'); +// }); +// +// } +// }); }; Calendar.prototype.create_appointment = function (data){ diff --git a/assets/www/external.html b/assets/www/external.html index 9db3af7..593a498 100644 --- a/assets/www/external.html +++ b/assets/www/external.html @@ -5,97 +5,92 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - + +
diff --git a/assets/www/gen/grammar/de_grammar.js b/assets/www/gen/grammar/de_grammar.js index 4f4c88e..8f28c0b 100644 --- a/assets/www/gen/grammar/de_grammar.js +++ b/assets/www/gen/grammar/de_grammar.js @@ -8749,7 +8749,7 @@ switch( match ) function __parse( src, err_off, err_la ) -{ theGrammarConverterInstance.asr_semantic_annotation={}; +{ theGrammarConverterInstance.semanticAnnotationResult={}; var sstack = new Array(); var vstack = new Array(); var err_cnt = 0; @@ -9715,7 +9715,7 @@ switch( act ) break; case 1: { - _$result['semantic'] = _$result['semantic'].replace(/"{/g,'{').replace(/}"/g,'}'); console.log(_$result); theGrammarConverterInstance.asr_semantic_annotation = _$result + _$result['semantic'] = _$result['semantic'].replace(/"{/g,'{').replace(/}"/g,'}'); console.log(_$result); theGrammarConverterInstance.semanticAnnotationResult = _$result } break; case 2: diff --git a/assets/www/javascripts/gen/DialogDescription.js b/assets/www/gen/scxml/DialogDescription.js similarity index 87% rename from assets/www/javascripts/gen/DialogDescription.js rename to assets/www/gen/scxml/DialogDescription.js index 05a3a2f..e826b10 100644 --- a/assets/www/javascripts/gen/DialogDescription.js +++ b/assets/www/gen/scxml/DialogDescription.js @@ -14,32 +14,36 @@ function StatechartExecutionContext() { }; //variable declarations relating to data model //send timeout id variables - var $default_Regexp_N103C4 = /^($default)/, - init_Regexp_N103C9 = /^(init)/, - touch_end_on_login_btn_Regexp_N103CE = /^(touch_end_on_login_btn)/, - touch_end_on_sign_up_btn_Regexp_N103D3 = /^(touch_end_on_sign_up_btn)/, - touch_end_on_register_btn_Regexp_N103D8 = /^(touch_end_on_register_btn)/, - back_Regexp_N103DD = /^(back)/, - login_failed_Regexp_N103E2 = /^(login_failed)/, - user_logged_in_Regexp_N103E7 = /^(user_logged_in)/, - touch_end_on_appointment_btn_Regexp_N103EC = /^(touch_end_on_appointment_btn)/, - touch_end_on_save_appointment_btn_Regexp_N103F1 = /^(touch_end_on_save_appointment_btn)/, - touch_end_on_discard_appointment_btn_Regexp_N103F6 = /^(touch_end_on_discard_appointment_btn)/; + var $default_Regexp_N103F4 = /^($default)/, + init_Regexp_N103F9 = /^(init)/, + click_on_login_btn_Regexp_N103FE = /^(click_on_login_btn)/, + click_on_sign_up_btn_Regexp_N10403 = /^(click_on_sign_up_btn)/, + click_on_language_btn_Regexp_N10408 = /^(click_on_language_btn)/, + language_choosen_Regexp_N1040D = /^(language_choosen)/, + click_on_register_btn_Regexp_N10412 = /^(click_on_register_btn)/, + back_Regexp_N10417 = /^(back)/, + login_failed_Regexp_N1041C = /^(login_failed)/, + user_logged_in_Regexp_N10421 = /^(user_logged_in)/, + click_on_appointment_btn_Regexp_N10426 = /^(click_on_appointment_btn)/, + click_on_save_appointment_btn_Regexp_N1042B = /^(click_on_save_appointment_btn)/, + click_on_discard_appointment_btn_Regexp_N10430 = /^(click_on_discard_appointment_btn)/; //abstract state var AbstractState = new function() { //triggers are methods this.$default = function() {}; this.init = function() {}; - this.touch_end_on_login_btn = function() {}; - this.touch_end_on_sign_up_btn = function() {}; - this.touch_end_on_register_btn = function() {}; + this.click_on_login_btn = function() {}; + this.click_on_sign_up_btn = function() {}; + this.click_on_language_btn = function() {}; + this.language_choosen = function() {}; + this.click_on_register_btn = function() {}; this.back = function() {}; this.login_failed = function() {}; this.user_logged_in = function() {}; - this.touch_end_on_appointment_btn = function() {}; - this.touch_end_on_save_appointment_btn = function() {}; - this.touch_end_on_discard_appointment_btn = function() {}; + this.click_on_appointment_btn = function() {}; + this.click_on_save_appointment_btn = function() {}; + this.click_on_discard_appointment_btn = function() {}; this.$default = function() {}; this.$dispatchPrefixEvent = function() {}; } @@ -205,7 +209,7 @@ function StatechartExecutionContext() { return scxmlRoot['init'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(init_Regexp_N103C9)) { + if (e.match(init_Regexp_N103F9)) { return { preemptedBasicStates: {}, action: function() { @@ -268,7 +272,7 @@ function StatechartExecutionContext() { listener.onExit("main_state"); } } - this.touch_end_on_login_btn = function() { + this.click_on_login_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -280,7 +284,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "login_user", "main_state_touch_end_on_login_btn_3"); + listener.onTransition("", "login_user", "main_state_click_on_login_btn_3"); } //enter states login_user.enterAction(); @@ -290,9 +294,9 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_login_btn'](); + return scxmlRoot['click_on_login_btn'](); } - this.touch_end_on_sign_up_btn = function() { + this.click_on_sign_up_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -304,7 +308,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "registration_form", "main_state_touch_end_on_sign_up_btn_4"); + listener.onTransition("", "registration_form", "main_state_click_on_sign_up_btn_4"); } //enter states registration_form.enterAction(); @@ -314,10 +318,42 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_sign_up_btn'](); + return scxmlRoot['click_on_sign_up_btn'](); + } + this.click_on_language_btn = function() { + return { + preemptedBasicStates: {}, + action: function() { + //transition action + dialogManager.perform('Application', 'slide_down_language_menu'); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + } + } + } + return scxmlRoot['click_on_language_btn'](); + } + this.language_choosen = function() { + return { + preemptedBasicStates: {}, + action: function() { + //transition action + dialogManager.perform('Application', 'slide_up_language_menu'); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + } + } + } + return scxmlRoot['language_choosen'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(touch_end_on_login_btn_Regexp_N103CE)) { + if (e.match(click_on_login_btn_Regexp_N103FE)) { return { preemptedBasicStates: {}, action: function() { @@ -329,7 +365,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("main_state", "login_user", "main_state_touch_end_on_login_btn_3"); + listener.onTransition("main_state", "login_user", "main_state_click_on_login_btn_3"); } //enter states login_user.enterAction(); @@ -340,7 +376,7 @@ function StatechartExecutionContext() { } } } - if (e.match(touch_end_on_sign_up_btn_Regexp_N103D3)) { + if (e.match(click_on_sign_up_btn_Regexp_N10403)) { return { preemptedBasicStates: {}, action: function() { @@ -352,7 +388,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("main_state", "registration_form", "main_state_touch_end_on_sign_up_btn_4"); + listener.onTransition("main_state", "registration_form", "main_state_click_on_sign_up_btn_4"); } //enter states registration_form.enterAction(); @@ -363,6 +399,36 @@ function StatechartExecutionContext() { } } } + if (e.match(click_on_language_btn_Regexp_N10408)) { + return { + preemptedBasicStates: {}, + action: function() { + //transition action + dialogManager.perform('Application', 'slide_down_language_menu'); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + } + } + } + } + if (e.match(language_choosen_Regexp_N1040D)) { + return { + preemptedBasicStates: {}, + action: function() { + //transition action + dialogManager.perform('Application', 'slide_up_language_menu'); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + } + } + } + } return scxmlRoot.$dispatchPrefixEvent(e); } } @@ -395,15 +461,15 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N10136_iterator = 0, N10136_hoist = listeners.length; - N10136_iterator < N10136_hoist; - N10136_iterator++) { - var listener = listeners[N10136_iterator]; + for (var N10168_iterator = 0, N10168_hoist = listeners.length; + N10168_iterator < N10168_hoist; + N10168_iterator++) { + var listener = listeners[N10168_iterator]; //from listener.onExit("registration_form"); } } - this.touch_end_on_register_btn = function() { + this.click_on_register_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -415,7 +481,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "try_to_register_new_user", "registration_form_touch_end_on_register_btn_5"); + listener.onTransition("", "try_to_register_new_user", "registration_form_click_on_register_btn_5"); } //enter states try_to_register_new_user.enterAction(); @@ -425,7 +491,7 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_register_btn'](); + return scxmlRoot['click_on_register_btn'](); } this.back = function() { return { @@ -452,7 +518,7 @@ function StatechartExecutionContext() { return scxmlRoot['back'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(touch_end_on_register_btn_Regexp_N103D8)) { + if (e.match(click_on_register_btn_Regexp_N10412)) { return { preemptedBasicStates: {}, action: function() { @@ -464,7 +530,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("registration_form", "try_to_register_new_user", "registration_form_touch_end_on_register_btn_5"); + listener.onTransition("registration_form", "try_to_register_new_user", "registration_form_click_on_register_btn_5"); } //enter states try_to_register_new_user.enterAction(); @@ -475,7 +541,7 @@ function StatechartExecutionContext() { } } } - if (e.match(back_Regexp_N103DD)) { + if (e.match(back_Regexp_N10417)) { return { preemptedBasicStates: {}, action: function() { @@ -530,10 +596,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N101D1_iterator = 0, N101D1_hoist = listeners.length; - N101D1_iterator < N101D1_hoist; - N101D1_iterator++) { - var listener = listeners[N101D1_iterator]; + for (var N10203_iterator = 0, N10203_hoist = listeners.length; + N10203_iterator < N10203_hoist; + N10203_iterator++) { + var listener = listeners[N10203_iterator]; //from listener.onExit("try_to_register_new_user"); } @@ -618,10 +684,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N10268_iterator = 0, N10268_hoist = listeners.length; - N10268_iterator < N10268_hoist; - N10268_iterator++) { - var listener = listeners[N10268_iterator]; + for (var N1029A_iterator = 0, N1029A_hoist = listeners.length; + N1029A_iterator < N1029A_hoist; + N1029A_iterator++) { + var listener = listeners[N1029A_iterator]; //from listener.onExit("login_user"); } @@ -696,7 +762,7 @@ function StatechartExecutionContext() { return scxmlRoot['user_logged_in'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(login_failed_Regexp_N103E2)) { + if (e.match(login_failed_Regexp_N1041C)) { return { preemptedBasicStates: {}, action: function() { @@ -719,7 +785,7 @@ function StatechartExecutionContext() { } } } - if (e.match(user_logged_in_Regexp_N103E7)) { + if (e.match(user_logged_in_Regexp_N10421)) { if (mobileDS.User.getInstance() != null) return { preemptedBasicStates: {}, action: function() { @@ -742,7 +808,7 @@ function StatechartExecutionContext() { } } } - if (e.match(user_logged_in_Regexp_N103E7)) { + if (e.match(user_logged_in_Regexp_N10421)) { if (mobileDS.User.getInstance() == null) return { preemptedBasicStates: {}, action: function() { @@ -797,10 +863,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N10344_iterator = 0, N10344_hoist = listeners.length; - N10344_iterator < N10344_hoist; - N10344_iterator++) { - var listener = listeners[N10344_iterator]; + for (var N10376_iterator = 0, N10376_hoist = listeners.length; + N10376_iterator < N10376_hoist; + N10376_iterator++) { + var listener = listeners[N10376_iterator]; //from listener.onExit("logged_in"); } @@ -829,7 +895,7 @@ function StatechartExecutionContext() { } return scxmlRoot['back'](); } - this.touch_end_on_appointment_btn = function() { + this.click_on_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -841,7 +907,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "create_appointment_initial", "logged_in_touch_end_on_appointment_btn_12"); + listener.onTransition("", "create_appointment_initial", "logged_in_click_on_appointment_btn_12"); } //enter states create_appointment.enterAction(); @@ -852,10 +918,10 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_appointment_btn'](); + return scxmlRoot['click_on_appointment_btn'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(touch_end_on_appointment_btn_Regexp_N103EC)) { + if (e.match(click_on_appointment_btn_Regexp_N10426)) { return { preemptedBasicStates: {}, action: function() { @@ -867,7 +933,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("logged_in", "create_appointment_initial", "logged_in_touch_end_on_appointment_btn_12"); + listener.onTransition("logged_in", "create_appointment_initial", "logged_in_click_on_appointment_btn_12"); } //enter states create_appointment.enterAction(); @@ -879,7 +945,7 @@ function StatechartExecutionContext() { } } } - if (e.match(back_Regexp_N103DD)) { + if (e.match(back_Regexp_N10417)) { return { preemptedBasicStates: {}, action: function() { @@ -930,10 +996,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N103E5_iterator = 0, N103E5_hoist = listeners.length; - N103E5_iterator < N103E5_hoist; - N103E5_iterator++) { - var listener = listeners[N103E5_iterator]; + for (var N10417_iterator = 0, N10417_hoist = listeners.length; + N10417_iterator < N10417_hoist; + N10417_iterator++) { + var listener = listeners[N10417_iterator]; //from listener.onExit("create_appointment"); } @@ -984,7 +1050,7 @@ function StatechartExecutionContext() { } return scxmlRoot['back'](); } - this.touch_end_on_save_appointment_btn = function() { + this.click_on_save_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1018,7 +1084,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "save_appointment", "create_appointment_touch_end_on_save_appointment_btn_14"); + listener.onTransition("", "save_appointment", "create_appointment_click_on_save_appointment_btn_14"); } //enter states create_appointment.enterAction(); @@ -1029,9 +1095,9 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_save_appointment_btn'](); + return scxmlRoot['click_on_save_appointment_btn'](); } - this.touch_end_on_discard_appointment_btn = function() { + this.click_on_discard_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1065,7 +1131,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "logged_in", "create_appointment_touch_end_on_discard_appointment_btn_15"); + listener.onTransition("", "logged_in", "create_appointment_click_on_discard_appointment_btn_15"); } //enter states logged_in.enterAction(); @@ -1075,10 +1141,10 @@ function StatechartExecutionContext() { ]; } } - return scxmlRoot['touch_end_on_discard_appointment_btn'](); + return scxmlRoot['click_on_discard_appointment_btn'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(touch_end_on_save_appointment_btn_Regexp_N103F1)) { + if (e.match(click_on_save_appointment_btn_Regexp_N1042B)) { return { preemptedBasicStates: {}, action: function() { @@ -1112,7 +1178,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("create_appointment", "save_appointment", "create_appointment_touch_end_on_save_appointment_btn_14"); + listener.onTransition("create_appointment", "save_appointment", "create_appointment_click_on_save_appointment_btn_14"); } //enter states create_appointment.enterAction(); @@ -1124,7 +1190,7 @@ function StatechartExecutionContext() { } } } - if (e.match(touch_end_on_discard_appointment_btn_Regexp_N103F6)) { + if (e.match(click_on_discard_appointment_btn_Regexp_N10430)) { return { preemptedBasicStates: {}, action: function() { @@ -1158,7 +1224,7 @@ function StatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("create_appointment", "logged_in", "create_appointment_touch_end_on_discard_appointment_btn_15"); + listener.onTransition("create_appointment", "logged_in", "create_appointment_click_on_discard_appointment_btn_15"); } //enter states logged_in.enterAction(); @@ -1169,7 +1235,7 @@ function StatechartExecutionContext() { } } } - if (e.match(back_Regexp_N103DD)) { + if (e.match(back_Regexp_N10417)) { return { preemptedBasicStates: {}, action: function() { @@ -1249,10 +1315,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N103EA_iterator = 0, N103EA_hoist = listeners.length; - N103EA_iterator < N103EA_hoist; - N103EA_iterator++) { - var listener = listeners[N103EA_iterator]; + for (var N1041C_iterator = 0, N1041C_hoist = listeners.length; + N1041C_iterator < N1041C_hoist; + N1041C_iterator++) { + var listener = listeners[N1041C_iterator]; //from listener.onExit("create_appointment_initial"); } @@ -1293,10 +1359,10 @@ function StatechartExecutionContext() { } } this.exitAction = function() { - for (var N1046F_iterator = 0, N1046F_hoist = listeners.length; - N1046F_iterator < N1046F_hoist; - N1046F_iterator++) { - var listener = listeners[N1046F_iterator]; + for (var N104A1_iterator = 0, N104A1_hoist = listeners.length; + N104A1_iterator < N104A1_hoist; + N104A1_iterator++) { + var listener = listeners[N104A1_iterator]; //from listener.onExit("save_appointment"); } @@ -1366,29 +1432,47 @@ function StatechartExecutionContext() { return undefined; } } - this["touch_end_on_login_btn"] = function(data) { + this["click_on_login_btn"] = function(data) { + if (isInStableState && !destroyed) { + runToCompletion( + //TODO: conditionally wrap in quotes for enumerated pattern + "click_on_login_btn", data, true) + } else { + return undefined; + } + } + this["click_on_sign_up_btn"] = function(data) { + if (isInStableState && !destroyed) { + runToCompletion( + //TODO: conditionally wrap in quotes for enumerated pattern + "click_on_sign_up_btn", data, true) + } else { + return undefined; + } + } + this["click_on_language_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_login_btn", data, true) + "click_on_language_btn", data, true) } else { return undefined; } } - this["touch_end_on_sign_up_btn"] = function(data) { + this["language_choosen"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_sign_up_btn", data, true) + "language_choosen", data, true) } else { return undefined; } } - this["touch_end_on_register_btn"] = function(data) { + this["click_on_register_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_register_btn", data, true) + "click_on_register_btn", data, true) } else { return undefined; } @@ -1420,29 +1504,29 @@ function StatechartExecutionContext() { return undefined; } } - this["touch_end_on_appointment_btn"] = function(data) { + this["click_on_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_appointment_btn", data, true) + "click_on_appointment_btn", data, true) } else { return undefined; } } - this["touch_end_on_save_appointment_btn"] = function(data) { + this["click_on_save_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_save_appointment_btn", data, true) + "click_on_save_appointment_btn", data, true) } else { return undefined; } } - this["touch_end_on_discard_appointment_btn"] = function(data) { + this["click_on_discard_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_discard_appointment_btn", data, true) + "click_on_discard_appointment_btn", data, true) } else { return undefined; } diff --git a/assets/www/javascripts/gen/input_manager_state_chart.js b/assets/www/gen/scxml/InputDescription.js similarity index 83% rename from assets/www/javascripts/gen/input_manager_state_chart.js rename to assets/www/gen/scxml/InputDescription.js index add07b8..1ff3746 100644 --- a/assets/www/javascripts/gen/input_manager_state_chart.js +++ b/assets/www/gen/scxml/InputDescription.js @@ -13,6 +13,7 @@ function inputStatechartExecutionContext() { _sessionid: _sessionid }; //variable declarations relating to data model + var data = new Object(); var command_name = '', command = {}, emma = { @@ -21,30 +22,33 @@ function inputStatechartExecutionContext() { "mode": "voice" } }; - var playable = ''; //send timeout id variables - var $default_Regexp_N10665 = /^($default)/, - speech_input_event_Regexp_N1066A = /^(speech_input_event)/, - touch_input_event_Regexp_N1066F = /^(touch_input_event)/, - back_Regexp_N10674 = /^(back)/, - touch_end_on_login_btn_Regexp_N10679 = /^(touch_end_on_login_btn)/, - touch_end_on_register_btn_Regexp_N1067E = /^(touch_end_on_register_btn)/, - touch_end_on_sign_up_btn_Regexp_N10683 = /^(touch_end_on_sign_up_btn)/, - touch_end_on_appointment_btn_Regexp_N10688 = /^(touch_end_on_appointment_btn)/, - touch_end_on_save_appointment_btn_Regexp_N1068D = /^(touch_end_on_save_appointment_btn)/, - touch_end_on_discard_appointment_btn_Regexp_N10692 = /^(touch_end_on_discard_appointment_btn)/; + var $default_Regexp_N10670 = /^($default)/, + speech_input_event_Regexp_N10675 = /^(speech_input_event)/, + touch_input_event_Regexp_N1067A = /^(touch_input_event)/, + back_Regexp_N1067F = /^(back)/, + click_on_login_btn_Regexp_N10684 = /^(click_on_login_btn)/, + click_on_register_btn_Regexp_N10689 = /^(click_on_register_btn)/, + click_on_sign_up_btn_Regexp_N1068E = /^(click_on_sign_up_btn)/, + click_on_appointment_btn_Regexp_N10693 = /^(click_on_appointment_btn)/, + click_on_save_appointment_btn_Regexp_N10698 = /^(click_on_save_appointment_btn)/, + click_on_discard_appointment_btn_Regexp_N1069D = /^(click_on_discard_appointment_btn)/, + click_on_language_btn_Regexp_N106A2 = /^(click_on_language_btn)/, + language_choosen_Regexp_N106A7 = /^(language_choosen)/; //abstract state var AbstractState = new function() { //triggers are methods this.$default = function() {}; this.back = function() {}; - this.touch_end_on_login_btn = function() {}; - this.touch_end_on_register_btn = function() {}; - this.touch_end_on_sign_up_btn = function() {}; - this.touch_end_on_appointment_btn = function() {}; - this.touch_end_on_save_appointment_btn = function() {}; - this.touch_end_on_discard_appointment_btn = function() {}; + this.click_on_login_btn = function() {}; + this.click_on_register_btn = function() {}; + this.click_on_sign_up_btn = function() {}; + this.click_on_appointment_btn = function() {}; + this.click_on_save_appointment_btn = function() {}; + this.click_on_discard_appointment_btn = function() {}; + this.click_on_language_btn = function() {}; + this.language_choosen = function() {}; this.speech_input_event = function() {}; this.touch_input_event = function() {}; this.$default = function() {}; @@ -281,7 +285,7 @@ function inputStatechartExecutionContext() { return scxml_N10001['touch_input_event'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(speech_input_event_Regexp_N1066A)) { + if (e.match(speech_input_event_Regexp_N10675)) { return { preemptedBasicStates: {}, action: function() { @@ -327,7 +331,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_input_event_Regexp_N1066F)) { + if (e.match(touch_input_event_Regexp_N1067A)) { return { preemptedBasicStates: {}, action: function() { @@ -469,10 +473,16 @@ function inputStatechartExecutionContext() { this.enterAction = function() { var actionName; for (name in _event.data) { - actionName = name; - break; + if (name == 'phrase') { + continue; + } + if (_event.data.hasOwnProperty(name)) { + actionName = name; + break; + } } show_phrase(_event.data); + console.log('InputManager: setting command_name to "' + actionName + '" for event-data ' + JSON.stringify(_event.data)); command_name = actionName; command = _event.data; for (var N10000_iterator = 0, N10000_hoist = listeners.length; @@ -484,10 +494,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N100F6_iterator = 0, N100F6_hoist = listeners.length; - N100F6_iterator < N100F6_hoist; - N100F6_iterator++) { - var listener = listeners[N100F6_iterator]; + for (var N100FF_iterator = 0, N100FF_hoist = listeners.length; + N100FF_iterator < N100FF_hoist; + N100FF_iterator++) { + var listener = listeners[N100FF_iterator]; //from listener.onExit("speech_input"); } @@ -784,9 +794,10 @@ function inputStatechartExecutionContext() { return "no_match" } this.enterAction = function() { - var dm = mobileDS.CalendarModel.getInstance().getDiscourseManager(); + var dm = null; //TODO: mobileDS.CalendarModel.getInstance().getDiscourseManager(); if (dm == null) { - window.plugins.nuancePlugin.speak('Ich habe Sie leider nicht verstanden.', null, null); + var msg = mobileDS.LanguageManager.getInstance().getText('did_not_understand_msg'); + mobileDS.MediaManager.getInstance().textToSpeech(msg, null, null); } else { dm.getCommand().parse(command); } @@ -799,10 +810,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10435_iterator = 0, N10435_hoist = listeners.length; - N10435_iterator < N10435_hoist; - N10435_iterator++) { - var listener = listeners[N10435_iterator]; + for (var N1043E_iterator = 0, N1043E_hoist = listeners.length; + N1043E_iterator < N1043E_hoist; + N1043E_iterator++) { + var listener = listeners[N1043E_iterator]; //from listener.onExit("no_match"); } @@ -843,10 +854,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10447_iterator = 0, N10447_hoist = listeners.length; - N10447_iterator < N10447_hoist; - N10447_iterator++) { - var listener = listeners[N10447_iterator]; + for (var N10450_iterator = 0, N10450_hoist = listeners.length; + N10450_iterator < N10450_hoist; + N10450_iterator++) { + var listener = listeners[N10450_iterator]; //from listener.onExit("send"); } @@ -876,8 +887,7 @@ function inputStatechartExecutionContext() { return "play" } this.enterAction = function() { - mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - playable = command.Play.type; + alert('play something ...'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -887,83 +897,14 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10459_iterator = 0, N10459_hoist = listeners.length; - N10459_iterator < N10459_hoist; - N10459_iterator++) { - var listener = listeners[N10459_iterator]; + for (var N10462_iterator = 0, N10462_hoist = listeners.length; + N10462_iterator < N10462_hoist; + N10462_iterator++) { + var listener = listeners[N10462_iterator]; //from listener.onExit("play"); } } - this.$default = function() { - if (playable == 'radio') return { - preemptedBasicStates: {}, - action: function() { - hasTakenDefaultTransition = true; - //exit states - play.exitAction(); - //transition action - for (var N10000_iterator = 0, N10000_hoist = listeners.length; - N10000_iterator < N10000_hoist; - N10000_iterator++) { - var listener = listeners[N10000_iterator]; - //transition id - listener.onTransition("", "play_radio", "play_$default_17"); - } - //enter states - play_radio.enterAction(); - //update configuration - currentConfiguration = [ - play_radio - ]; - } - } - if (playable == 'audio') return { - preemptedBasicStates: {}, - action: function() { - hasTakenDefaultTransition = true; - //exit states - play.exitAction(); - //transition action - for (var N10000_iterator = 0, N10000_hoist = listeners.length; - N10000_iterator < N10000_hoist; - N10000_iterator++) { - var listener = listeners[N10000_iterator]; - //transition id - listener.onTransition("", "play_audio", "play_$default_18"); - } - //enter states - play_audio.enterAction(); - //update configuration - currentConfiguration = [ - play_audio - ]; - } - } - if (playable == 'voice') return { - preemptedBasicStates: {}, - action: function() { - hasTakenDefaultTransition = true; - //exit states - play.exitAction(); - //transition action - for (var N10000_iterator = 0, N10000_hoist = listeners.length; - N10000_iterator < N10000_hoist; - N10000_iterator++) { - var listener = listeners[N10000_iterator]; - //transition id - listener.onTransition("", "play_voice", "play_$default_19"); - } - //enter states - play_voice.enterAction(); - //update configuration - currentConfiguration = [ - play_voice - ]; - } - } - return input_manager_initial_state['$default'](); - } this.$dispatchPrefixEvent = function(e) { return input_manager_initial_state.$dispatchPrefixEvent(e); } @@ -990,7 +931,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('click_on_rec_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_rec_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1000,10 +941,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10540_iterator = 0, N10540_hoist = listeners.length; - N10540_iterator < N10540_hoist; - N10540_iterator++) { - var listener = listeners[N10540_iterator]; + for (var N10474_iterator = 0, N10474_hoist = listeners.length; + N10474_iterator < N10474_hoist; + N10474_iterator++) { + var listener = listeners[N10474_iterator]; //from listener.onExit("record"); } @@ -1034,7 +975,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('poi.display_details'); + mobileDS.DialogEngine.getInstance().raise('poi.display_details'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1044,10 +985,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10552_iterator = 0, N10552_hoist = listeners.length; - N10552_iterator < N10552_hoist; - N10552_iterator++) { - var listener = listeners[N10552_iterator]; + for (var N10486_iterator = 0, N10486_hoist = listeners.length; + N10486_iterator < N10486_hoist; + N10486_iterator++) { + var listener = listeners[N10486_iterator]; //from listener.onExit("show_info"); } @@ -1088,10 +1029,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10564_iterator = 0, N10564_hoist = listeners.length; - N10564_iterator < N10564_hoist; - N10564_iterator++) { - var listener = listeners[N10564_iterator]; + for (var N10498_iterator = 0, N10498_hoist = listeners.length; + N10498_iterator < N10498_hoist; + N10498_iterator++) { + var listener = listeners[N10498_iterator]; //from listener.onExit("rating"); } @@ -1122,7 +1063,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('click_on_radar_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_radar_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1132,10 +1073,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10576_iterator = 0, N10576_hoist = listeners.length; - N10576_iterator < N10576_hoist; - N10576_iterator++) { - var listener = listeners[N10576_iterator]; + for (var N104AA_iterator = 0, N104AA_hoist = listeners.length; + N104AA_iterator < N104AA_hoist; + N104AA_iterator++) { + var listener = listeners[N104AA_iterator]; //from listener.onExit("start_radar"); } @@ -1166,7 +1107,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('click_on_start_radio_btn', emma); + mobileDS.DialogEngine.getInstance().raise('click_on_start_radio_btn', emma); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1176,10 +1117,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10588_iterator = 0, N10588_hoist = listeners.length; - N10588_iterator < N10588_hoist; - N10588_iterator++) { - var listener = listeners[N10588_iterator]; + for (var N104BC_iterator = 0, N104BC_hoist = listeners.length; + N104BC_iterator < N104BC_hoist; + N104BC_iterator++) { + var listener = listeners[N104BC_iterator]; //from listener.onExit("play_radio"); } @@ -1210,7 +1151,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('click_on_start_audio_btn', emma); + mobileDS.DialogEngine.getInstance().raise('click_on_start_audio_btn', emma); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1220,10 +1161,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N1059A_iterator = 0, N1059A_hoist = listeners.length; - N1059A_iterator < N1059A_hoist; - N1059A_iterator++) { - var listener = listeners[N1059A_iterator]; + for (var N104CE_iterator = 0, N104CE_hoist = listeners.length; + N104CE_iterator < N104CE_hoist; + N104CE_iterator++) { + var listener = listeners[N104CE_iterator]; //from listener.onExit("play_audio"); } @@ -1264,10 +1205,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N105AC_iterator = 0, N105AC_hoist = listeners.length; - N105AC_iterator < N105AC_hoist; - N105AC_iterator++) { - var listener = listeners[N105AC_iterator]; + for (var N104E0_iterator = 0, N104E0_hoist = listeners.length; + N104E0_iterator < N104E0_hoist; + N104E0_iterator++) { + var listener = listeners[N104E0_iterator]; //from listener.onExit("play_voice"); } @@ -1298,7 +1239,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('show_appointments_speech', command); + mobileDS.DialogEngine.getInstance().raise('show_appointments_speech', command); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1308,10 +1249,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N105BE_iterator = 0, N105BE_hoist = listeners.length; - N105BE_iterator < N105BE_hoist; - N105BE_iterator++) { - var listener = listeners[N105BE_iterator]; + for (var N104F2_iterator = 0, N104F2_hoist = listeners.length; + N104F2_iterator < N104F2_hoist; + N104F2_iterator++) { + var listener = listeners[N104F2_iterator]; //from listener.onExit("show_appointments"); } @@ -1342,7 +1283,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - mobileDS.DialogEngine.getInstance().raiseEvent('create_appointment_speech', command); + mobileDS.DialogEngine.getInstance().raise('create_appointment_speech', command); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1352,10 +1293,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N105D0_iterator = 0, N105D0_hoist = listeners.length; - N105D0_iterator < N105D0_hoist; - N105D0_iterator++) { - var listener = listeners[N105D0_iterator]; + for (var N10504_iterator = 0, N10504_hoist = listeners.length; + N10504_iterator < N10504_hoist; + N10504_iterator++) { + var listener = listeners[N10504_iterator]; //from listener.onExit("create_appointment"); } @@ -1386,7 +1327,7 @@ function inputStatechartExecutionContext() { } this.enterAction = function() { mobileDS.CalendarModel.getInstance().clearDiscourseManager(); - dialogManager.perform_helper_method('Calendar', 'capture'); + dialogManager.performHelper('Calendar', 'capture'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1396,10 +1337,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N105E2_iterator = 0, N105E2_hoist = listeners.length; - N105E2_iterator < N105E2_hoist; - N105E2_iterator++) { - var listener = listeners[N105E2_iterator]; + for (var N10516_iterator = 0, N10516_hoist = listeners.length; + N10516_iterator < N10516_hoist; + N10516_iterator++) { + var listener = listeners[N10516_iterator]; //from listener.onExit("record_memo"); } @@ -1440,10 +1381,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N105F4_iterator = 0, N105F4_hoist = listeners.length; - N105F4_iterator < N105F4_hoist; - N105F4_iterator++) { - var listener = listeners[N105F4_iterator]; + for (var N10528_iterator = 0, N10528_hoist = listeners.length; + N10528_iterator < N10528_hoist; + N10528_iterator++) { + var listener = listeners[N10528_iterator]; //from listener.onExit("find_person"); } @@ -1484,10 +1425,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10606_iterator = 0, N10606_hoist = listeners.length; - N10606_iterator < N10606_hoist; - N10606_iterator++) { - var listener = listeners[N10606_iterator]; + for (var N1053A_iterator = 0, N1053A_hoist = listeners.length; + N1053A_iterator < N1053A_hoist; + N1053A_iterator++) { + var listener = listeners[N1053A_iterator]; //from listener.onExit("show_pois"); } @@ -1521,10 +1462,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10618_iterator = 0, N10618_hoist = listeners.length; - N10618_iterator < N10618_hoist; - N10618_iterator++) { - var listener = listeners[N10618_iterator]; + for (var N1054C_iterator = 0, N1054C_hoist = listeners.length; + N1054C_iterator < N1054C_hoist; + N1054C_iterator++) { + var listener = listeners[N1054C_iterator]; //from listener.onExit("touch_input"); } @@ -1566,10 +1507,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N1061D_iterator = 0, N1061D_hoist = listeners.length; - N1061D_iterator < N1061D_hoist; - N1061D_iterator++) { - var listener = listeners[N1061D_iterator]; + for (var N10551_iterator = 0, N10551_hoist = listeners.length; + N10551_iterator < N10551_hoist; + N10551_iterator++) { + var listener = listeners[N10551_iterator]; //from listener.onExit("touch_input_initial"); } @@ -1587,7 +1528,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "start_touch", "touch_input_initial_$default_20"); + listener.onTransition("", "start_touch", "touch_input_initial_$default_17"); } //enter states start_touch.enterAction(); @@ -1626,6 +1567,13 @@ function inputStatechartExecutionContext() { return "start_touch" } this.enterAction = function() { + data = { + "Emma": { + "medium": "tactile", + "mode": "gui" + } + }; + data.Data = {}; for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -1635,10 +1583,11 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10664_iterator = 0, N10664_hoist = listeners.length; - N10664_iterator < N10664_hoist; - N10664_iterator++) { - var listener = listeners[N10664_iterator]; + data.Data.data = _event.data; + for (var N10598_iterator = 0, N10598_hoist = listeners.length; + N10598_iterator < N10598_hoist; + N10598_iterator++) { + var listener = listeners[N10598_iterator]; //from listener.onExit("start_touch"); } @@ -1655,7 +1604,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "back", "start_touch_back_21"); + listener.onTransition("", "back", "start_touch_back_18"); } //enter states back.enterAction(); @@ -1667,7 +1616,7 @@ function inputStatechartExecutionContext() { } return touch_input['back'](); } - this.touch_end_on_login_btn = function() { + this.click_on_login_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1679,7 +1628,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "login", "start_touch_touch_end_on_login_btn_22"); + listener.onTransition("", "login", "start_touch_click_on_login_btn_19"); } //enter states login.enterAction(); @@ -1689,9 +1638,9 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_login_btn'](); + return touch_input['click_on_login_btn'](); } - this.touch_end_on_register_btn = function() { + this.click_on_register_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1703,7 +1652,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "register", "start_touch_touch_end_on_register_btn_23"); + listener.onTransition("", "register", "start_touch_click_on_register_btn_20"); } //enter states register.enterAction(); @@ -1713,9 +1662,9 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_register_btn'](); + return touch_input['click_on_register_btn'](); } - this.touch_end_on_sign_up_btn = function() { + this.click_on_sign_up_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1727,7 +1676,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "sign_up", "start_touch_touch_end_on_sign_up_btn_24"); + listener.onTransition("", "sign_up", "start_touch_click_on_sign_up_btn_21"); } //enter states sign_up.enterAction(); @@ -1737,9 +1686,9 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_sign_up_btn'](); + return touch_input['click_on_sign_up_btn'](); } - this.touch_end_on_appointment_btn = function() { + this.click_on_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1751,7 +1700,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "appointment", "start_touch_touch_end_on_appointment_btn_25"); + listener.onTransition("", "appointment", "start_touch_click_on_appointment_btn_22"); } //enter states appointment.enterAction(); @@ -1761,9 +1710,9 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_appointment_btn'](); + return touch_input['click_on_appointment_btn'](); } - this.touch_end_on_save_appointment_btn = function() { + this.click_on_save_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1775,7 +1724,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "save_appointment", "start_touch_touch_end_on_save_appointment_btn_26"); + listener.onTransition("", "save_appointment", "start_touch_click_on_save_appointment_btn_23"); } //enter states save_appointment.enterAction(); @@ -1785,9 +1734,9 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_save_appointment_btn'](); + return touch_input['click_on_save_appointment_btn'](); } - this.touch_end_on_discard_appointment_btn = function() { + this.click_on_discard_appointment_btn = function() { return { preemptedBasicStates: {}, action: function() { @@ -1799,7 +1748,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("", "discard_appointment", "start_touch_touch_end_on_discard_appointment_btn_27"); + listener.onTransition("", "discard_appointment", "start_touch_click_on_discard_appointment_btn_24"); } //enter states discard_appointment.enterAction(); @@ -1809,10 +1758,58 @@ function inputStatechartExecutionContext() { ]; } } - return touch_input['touch_end_on_discard_appointment_btn'](); + return touch_input['click_on_discard_appointment_btn'](); + } + this.click_on_language_btn = function() { + return { + preemptedBasicStates: {}, + action: function() { + //exit states + start_touch.exitAction(); + //transition action + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + listener.onTransition("", "language_btn", "start_touch_click_on_language_btn_25"); + } + //enter states + language_btn.enterAction(); + //update configuration + currentConfiguration = [ + language_btn + ]; + } + } + return touch_input['click_on_language_btn'](); + } + this.language_choosen = function() { + return { + preemptedBasicStates: {}, + action: function() { + //exit states + start_touch.exitAction(); + //transition action + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + listener.onTransition("", "language_chosen", "start_touch_language_choosen_26"); + } + //enter states + language_chosen.enterAction(); + //update configuration + currentConfiguration = [ + language_chosen + ]; + } + } + return touch_input['language_choosen'](); } this.$dispatchPrefixEvent = function(e) { - if (e.match(back_Regexp_N10674)) { + if (e.match(back_Regexp_N1067F)) { return { preemptedBasicStates: {}, action: function() { @@ -1824,7 +1821,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "back", "start_touch_back_21"); + listener.onTransition("start_touch", "back", "start_touch_back_18"); } //enter states back.enterAction(); @@ -1835,7 +1832,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_login_btn_Regexp_N10679)) { + if (e.match(click_on_login_btn_Regexp_N10684)) { return { preemptedBasicStates: {}, action: function() { @@ -1847,7 +1844,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "login", "start_touch_touch_end_on_login_btn_22"); + listener.onTransition("start_touch", "login", "start_touch_click_on_login_btn_19"); } //enter states login.enterAction(); @@ -1858,7 +1855,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_register_btn_Regexp_N1067E)) { + if (e.match(click_on_register_btn_Regexp_N10689)) { return { preemptedBasicStates: {}, action: function() { @@ -1870,7 +1867,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "register", "start_touch_touch_end_on_register_btn_23"); + listener.onTransition("start_touch", "register", "start_touch_click_on_register_btn_20"); } //enter states register.enterAction(); @@ -1881,7 +1878,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_sign_up_btn_Regexp_N10683)) { + if (e.match(click_on_sign_up_btn_Regexp_N1068E)) { return { preemptedBasicStates: {}, action: function() { @@ -1893,7 +1890,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "sign_up", "start_touch_touch_end_on_sign_up_btn_24"); + listener.onTransition("start_touch", "sign_up", "start_touch_click_on_sign_up_btn_21"); } //enter states sign_up.enterAction(); @@ -1904,7 +1901,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_appointment_btn_Regexp_N10688)) { + if (e.match(click_on_appointment_btn_Regexp_N10693)) { return { preemptedBasicStates: {}, action: function() { @@ -1916,7 +1913,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "appointment", "start_touch_touch_end_on_appointment_btn_25"); + listener.onTransition("start_touch", "appointment", "start_touch_click_on_appointment_btn_22"); } //enter states appointment.enterAction(); @@ -1927,7 +1924,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_save_appointment_btn_Regexp_N1068D)) { + if (e.match(click_on_save_appointment_btn_Regexp_N10698)) { return { preemptedBasicStates: {}, action: function() { @@ -1939,7 +1936,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "save_appointment", "start_touch_touch_end_on_save_appointment_btn_26"); + listener.onTransition("start_touch", "save_appointment", "start_touch_click_on_save_appointment_btn_23"); } //enter states save_appointment.enterAction(); @@ -1950,7 +1947,7 @@ function inputStatechartExecutionContext() { } } } - if (e.match(touch_end_on_discard_appointment_btn_Regexp_N10692)) { + if (e.match(click_on_discard_appointment_btn_Regexp_N1069D)) { return { preemptedBasicStates: {}, action: function() { @@ -1962,7 +1959,7 @@ function inputStatechartExecutionContext() { N10000_iterator++) { var listener = listeners[N10000_iterator]; //transition id - listener.onTransition("start_touch", "discard_appointment", "start_touch_touch_end_on_discard_appointment_btn_27"); + listener.onTransition("start_touch", "discard_appointment", "start_touch_click_on_discard_appointment_btn_24"); } //enter states discard_appointment.enterAction(); @@ -1973,6 +1970,52 @@ function inputStatechartExecutionContext() { } } } + if (e.match(click_on_language_btn_Regexp_N106A2)) { + return { + preemptedBasicStates: {}, + action: function() { + //exit states + start_touch.exitAction(); + //transition action + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + listener.onTransition("start_touch", "language_btn", "start_touch_click_on_language_btn_25"); + } + //enter states + language_btn.enterAction(); + //update configuration + currentConfiguration = [ + language_btn + ]; + } + } + } + if (e.match(language_choosen_Regexp_N106A7)) { + return { + preemptedBasicStates: {}, + action: function() { + //exit states + start_touch.exitAction(); + //transition action + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //transition id + listener.onTransition("start_touch", "language_chosen", "start_touch_language_choosen_26"); + } + //enter states + language_chosen.enterAction(); + //update configuration + currentConfiguration = [ + language_chosen + ]; + } + } + } return touch_input.$dispatchPrefixEvent(e); } } @@ -1999,7 +2042,7 @@ function inputStatechartExecutionContext() { return "back" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('back'); + mobileDS.DialogEngine.getInstance().raise('back'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2009,10 +2052,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10839_iterator = 0, N10839_hoist = listeners.length; - N10839_iterator < N10839_hoist; - N10839_iterator++) { - var listener = listeners[N10839_iterator]; + for (var N1080B_iterator = 0, N1080B_hoist = listeners.length; + N1080B_iterator < N1080B_hoist; + N1080B_iterator++) { + var listener = listeners[N1080B_iterator]; //from listener.onExit("back"); } @@ -2044,7 +2087,7 @@ function inputStatechartExecutionContext() { return "login" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_login_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_login_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2054,10 +2097,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N1084B_iterator = 0, N1084B_hoist = listeners.length; - N1084B_iterator < N1084B_hoist; - N1084B_iterator++) { - var listener = listeners[N1084B_iterator]; + for (var N1081D_iterator = 0, N1081D_hoist = listeners.length; + N1081D_iterator < N1081D_hoist; + N1081D_iterator++) { + var listener = listeners[N1081D_iterator]; //from listener.onExit("login"); } @@ -2089,7 +2132,7 @@ function inputStatechartExecutionContext() { return "register" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_register_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_register_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2099,10 +2142,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N1085D_iterator = 0, N1085D_hoist = listeners.length; - N1085D_iterator < N1085D_hoist; - N1085D_iterator++) { - var listener = listeners[N1085D_iterator]; + for (var N1082F_iterator = 0, N1082F_hoist = listeners.length; + N1082F_iterator < N1082F_hoist; + N1082F_iterator++) { + var listener = listeners[N1082F_iterator]; //from listener.onExit("register"); } @@ -2134,7 +2177,7 @@ function inputStatechartExecutionContext() { return "sign_up" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_sign_up_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_sign_up_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2144,10 +2187,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N1086F_iterator = 0, N1086F_hoist = listeners.length; - N1086F_iterator < N1086F_hoist; - N1086F_iterator++) { - var listener = listeners[N1086F_iterator]; + for (var N10841_iterator = 0, N10841_hoist = listeners.length; + N10841_iterator < N10841_hoist; + N10841_iterator++) { + var listener = listeners[N10841_iterator]; //from listener.onExit("sign_up"); } @@ -2179,7 +2222,7 @@ function inputStatechartExecutionContext() { return "appointment" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_appointment_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_appointment_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2189,10 +2232,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10881_iterator = 0, N10881_hoist = listeners.length; - N10881_iterator < N10881_hoist; - N10881_iterator++) { - var listener = listeners[N10881_iterator]; + for (var N10853_iterator = 0, N10853_hoist = listeners.length; + N10853_iterator < N10853_hoist; + N10853_iterator++) { + var listener = listeners[N10853_iterator]; //from listener.onExit("appointment"); } @@ -2224,7 +2267,7 @@ function inputStatechartExecutionContext() { return "save_appointment" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_save_appointment_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_save_appointment_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2234,10 +2277,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N10893_iterator = 0, N10893_hoist = listeners.length; - N10893_iterator < N10893_hoist; - N10893_iterator++) { - var listener = listeners[N10893_iterator]; + for (var N10865_iterator = 0, N10865_hoist = listeners.length; + N10865_iterator < N10865_hoist; + N10865_iterator++) { + var listener = listeners[N10865_iterator]; //from listener.onExit("save_appointment"); } @@ -2269,7 +2312,7 @@ function inputStatechartExecutionContext() { return "discard_appointment" } this.enterAction = function() { - mobileDS.DialogEngine.getInstance().raiseEvent('touch_end_on_discard_appointment_btn'); + mobileDS.DialogEngine.getInstance().raise('click_on_discard_appointment_btn'); for (var N10000_iterator = 0, N10000_hoist = listeners.length; N10000_iterator < N10000_hoist; N10000_iterator++) { @@ -2279,10 +2322,10 @@ function inputStatechartExecutionContext() { } } this.exitAction = function() { - for (var N108A5_iterator = 0, N108A5_hoist = listeners.length; - N108A5_iterator < N108A5_hoist; - N108A5_iterator++) { - var listener = listeners[N108A5_iterator]; + for (var N10877_iterator = 0, N10877_hoist = listeners.length; + N10877_iterator < N10877_hoist; + N10877_iterator++) { + var listener = listeners[N10877_iterator]; //from listener.onExit("discard_appointment"); } @@ -2294,6 +2337,96 @@ function inputStatechartExecutionContext() { discard_appointmentConstructor.prototype = touch_input; return new discard_appointmentConstructor(); })(); + var language_btn = (function() { + function language_btnConstructor() { + this.parent = touch_input; + this.initial = null; + this.depth = 3; + this.historyState = null; + //these variables facilitate fast In predicate + this.isBasic = + true; + this.ancestors = [ + scxml_N10001 + , + input_manager_initial_state + , + touch_input + ]; + this.toString = function() { + return "language_btn" + } + this.enterAction = function() { + mobileDS.DialogEngine.getInstance().raise('click_on_language_btn', data); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //to + listener.onEntry("language_btn"); + } + } + this.exitAction = function() { + for (var N10889_iterator = 0, N10889_hoist = listeners.length; + N10889_iterator < N10889_hoist; + N10889_iterator++) { + var listener = listeners[N10889_iterator]; + //from + listener.onExit("language_btn"); + } + } + this.$dispatchPrefixEvent = function(e) { + return touch_input.$dispatchPrefixEvent(e); + } + } + language_btnConstructor.prototype = touch_input; + return new language_btnConstructor(); + })(); + var language_chosen = (function() { + function language_chosenConstructor() { + this.parent = touch_input; + this.initial = null; + this.depth = 3; + this.historyState = null; + //these variables facilitate fast In predicate + this.isBasic = + true; + this.ancestors = [ + scxml_N10001 + , + input_manager_initial_state + , + touch_input + ]; + this.toString = function() { + return "language_chosen" + } + this.enterAction = function() { + mobileDS.DialogEngine.getInstance().raise('language_choosen', data); + for (var N10000_iterator = 0, N10000_hoist = listeners.length; + N10000_iterator < N10000_hoist; + N10000_iterator++) { + var listener = listeners[N10000_iterator]; + //to + listener.onEntry("language_chosen"); + } + } + this.exitAction = function() { + for (var N1089B_iterator = 0, N1089B_hoist = listeners.length; + N1089B_iterator < N1089B_hoist; + N1089B_iterator++) { + var listener = listeners[N1089B_iterator]; + //from + listener.onExit("language_chosen"); + } + } + this.$dispatchPrefixEvent = function(e) { + return touch_input.$dispatchPrefixEvent(e); + } + } + language_chosenConstructor.prototype = touch_input; + return new language_chosenConstructor(); + })(); var $basicStateDescendantsOfParallelStates = {} //states enum for glass-box unit testing this._states = { @@ -2323,7 +2456,9 @@ function inputStatechartExecutionContext() { sign_up: sign_up, appointment: appointment, save_appointment: save_appointment, - discard_appointment: discard_appointment + discard_appointment: discard_appointment, + language_btn: language_btn, + language_chosen: language_chosen } //trigger methods for synchronous interaction this["$default"] = function(data) { @@ -2362,56 +2497,74 @@ function inputStatechartExecutionContext() { return undefined; } } - this["touch_end_on_login_btn"] = function(data) { + this["click_on_login_btn"] = function(data) { + if (isInStableState && !destroyed) { + runToCompletion( + //TODO: conditionally wrap in quotes for enumerated pattern + "click_on_login_btn", data, true) + } else { + return undefined; + } + } + this["click_on_register_btn"] = function(data) { + if (isInStableState && !destroyed) { + runToCompletion( + //TODO: conditionally wrap in quotes for enumerated pattern + "click_on_register_btn", data, true) + } else { + return undefined; + } + } + this["click_on_sign_up_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_login_btn", data, true) + "click_on_sign_up_btn", data, true) } else { return undefined; } } - this["touch_end_on_register_btn"] = function(data) { + this["click_on_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_register_btn", data, true) + "click_on_appointment_btn", data, true) } else { return undefined; } } - this["touch_end_on_sign_up_btn"] = function(data) { + this["click_on_save_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_sign_up_btn", data, true) + "click_on_save_appointment_btn", data, true) } else { return undefined; } } - this["touch_end_on_appointment_btn"] = function(data) { + this["click_on_discard_appointment_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_appointment_btn", data, true) + "click_on_discard_appointment_btn", data, true) } else { return undefined; } } - this["touch_end_on_save_appointment_btn"] = function(data) { + this["click_on_language_btn"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_save_appointment_btn", data, true) + "click_on_language_btn", data, true) } else { return undefined; } } - this["touch_end_on_discard_appointment_btn"] = function(data) { + this["language_choosen"] = function(data) { if (isInStableState && !destroyed) { runToCompletion( //TODO: conditionally wrap in quotes for enumerated pattern - "touch_end_on_discard_appointment_btn", data, true) + "language_choosen", data, true) } else { return undefined; } diff --git a/assets/www/helpers/.gitignore b/assets/www/helpers/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/assets/www/helpers/applicationHelper.js b/assets/www/helpers/applicationHelper.js index c6648af..5d10609 100644 --- a/assets/www/helpers/applicationHelper.js +++ b/assets/www/helpers/applicationHelper.js @@ -91,7 +91,7 @@ ApplicationHelper.prototype.get_language_menu = function(ctrl, data){ } // check if item is current language--- if so: mark by another theme - if (mobileDS.LanguageManager.getInstance().getCurrentLanguage() === par_available_languages[i]){ + if (mobileDS.LanguageManager.getInstance().getLanguage() === par_available_languages[i]){ li.attr( "data-theme", self.listItemThemeCurrent ); class_li += "ui-body-"+self.listItemThemeCurrent; } else { @@ -102,8 +102,7 @@ ApplicationHelper.prototype.get_language_menu = function(ctrl, data){ li.addClass( class_li ); li.css("padding", "0px" ); - // add onclick actions -// li.attr( "onclick", "mobileDS.LanguageManager.getInstance().changeLanguage('"+par_available_languages[i]+"', true);mobileDS.InputManager.getInstance().raiseEvent('touch_input_event');mobileDS.InputManager.getInstance().raiseEvent('language_choosen');"); + // add onclick actions: do register these in view's controller (in on_page_load_xxx) li.attr('lang',par_available_languages[i]); diff --git a/assets/www/index.html b/assets/www/index.html index 2384a30..0fb25e2 100644 --- a/assets/www/index.html +++ b/assets/www/index.html @@ -32,41 +32,56 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - + + + - - - - + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +
diff --git a/assets/www/javascripts/manager/modelManager.js b/assets/www/javascripts/manager/modelManager.js deleted file mode 100644 index dd3b71b..0000000 --- a/assets/www/javascripts/manager/modelManager.js +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * @module mobileDS.javascripts.manager - * - */ -var mobileDS = window.mobileDS || -{}; - -/** - *
- * Note: - * This class is unused at the moment. - *
- * A class for managing the models of the application (MVC-Component).
- * It's purpose is to load the models automatically. - * - * This "class" is structured as a singleton - so that only one instance is in use.
- * You can access the instance of the class via - * @example mobileDS.ModelManager.getInstance() - * @class ModelManager - * @category core - * - * @see mobileDS.ModelManager#constructor - */ -mobileDS.ModelManager = (function(){ - - - /** - * Object containing the instance of the class {@link mobileDS.ModelManager} - * - * @property instance - * @type Object - * @private - */ - var instance = null; - - /** - * Constructor-Method of Class {@link mobileDS.ModelManager}.
- * This class is similar to the class {@link mobileDS.ControllerManager}. - * - *
- * Note: - * The callback function should contain all (!) instructions which require the prior loading of the models.
- * A callback function is used, because the loading process is asynchronous. - *
- * - * @param {Function} callbackFunction A callback function - * @constructor - * @augments mobileDS.ModelManager - * @memberOf mobileDS.ModelManager.prototype - */ - function constructor(callbackFunction){ - // private members - /** - * Array of models - * - * @property models - * @type Array - * @private - */ - // // if anyone wants to gain access to the model-names, - // // well... here you can. - var models = new Array(); - - - /** - * Index for the array of models - * - * @property mod_i - * @type Integer - * @private - */ - var mod_i = 0; - // // I don't know if you really need model-instances, but - // // you'll never know. - // var modelsIntances = new Array(); - - /** - * - * This function returns all loaded models. - * - * @function getModels - * @returns {Array} all loaded models - * @public - */ - function getModels(){ - return models; - } - - - /** - * This function loads the models one after another.
- * The function is first called by {@link mobileDS.ControllerManager-constructor-loadControllers} - * - * @function foundModelsCallBack - * @param {Array} foundModels This parameter contains all model-filenames - * @param {Function} myCallbackFunction A callback function which shall be called after the completion of the model loading process - * @private - */ - function foundModelsCallBack(foundModels, myCallbackFunction, isRecursiveCall){ - if (foundModels.length < 1){ - if(!isRecursiveCall){ - console.warn("Load Model: no models found in "+mobileDS.constants.getInstance(forBrowser).getModelPath()+"/"); - } - if (typeof myCallbackFunction == 'function'){ - myCallbackFunction(); - } - } else { - var tmpModel = foundModels[0]; - - if(IS_DEBUG_ENABLED) console.debug("Load Model: "+mobileDS.constants.getInstance(forBrowser).getModelPath() + "/" + tmpModel);//debug - - // Create Controller after (!!!!) the adequate controller-js-file is loaded. - // or else there is no constructor and the controller-contructor fails. - - mobileDS.CommonUtils.getInstance().getLocalScript(mobileDS.constants.getInstance(forBrowser).getModelPath() + tmpModel, - function(){ - // save Modelname in models-array - starting with an upper-case character and - // cutting of the extension of the file containing the model. - models[mod_i++] = tmpModel.charAt(0).toUpperCase() + tmpModel.slice(1).replace(/\.[^.]+$/g,""); - foundModels = foundModels.slice(1); - foundModelsCallBack(foundModels, myCallbackFunction, true); - }, - function(exception) { - // print out an error message - console.error("[ERROR] " + exception); //failure - }); - - } - return 0; - } - - /** - * This function invokes the method {@link mobileDS.ModelManager-constructor-foundModelsCallBack} to load all models in the path specified by *modelPath*. - * - * @function loadModels - * @param {Function} myCallbackFunction The callback function from the constructor which shall be called after the initialization of the {@link mobileDS.ModelManager}. - * @private - */ - function loadModels(myCallbackFunction){ - // Load application's models. -// var mod_i = 0; -// console.log("[MODELS] " + mobileDS.constants.getInstance(forBrowser).getModelPath()); - var foundModels = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(mobileDS.constants.getInstance(forBrowser).getModelPath(), "*.js"); - foundModelsCallBack(foundModels, myCallbackFunction); - } - - loadModels(callbackFunction); - - /** @lends mobileDS.ModelManager.prototype */ - return { // public members - /** - * This function gets the model by name. - * - * @function getModel - * @param {String} modelName Name of the model which should be returned - * @returns {Object} The model if found, null else - * @public - */ - getModel: function(modelName){ - var retModel = null; - $.each(models, function(index, model){ - if (model.getName() == modelName) { - retModel = model; - return false; - } - }); - return retModel; - }, - - - /** - * This function returns all loaded models. - * - * @function getModels - * @returns {Array} All loaded models - * @public - */ - getModels: function(){ - return models; - } - }; - } - - return { - /** - * Object containing the instance of the class {@link mobileDS.ModelManager} - * - * @function getInstance - * @param {Function} callbackFunction The function which should be called after loading all models - * @returns {Object} Object containing the instance of the class {@link mobileDS.ModelManager} - * @public - */ - getInstance: function(callbackFunction){ - if (instance===null) { - instance = constructor(callbackFunction); - } - return instance; - } - }; - -})(); \ No newline at end of file diff --git a/assets/www/javascripts/mediators/audioInput.js b/assets/www/javascripts/mediators/audioInput.js deleted file mode 100644 index eebf139..0000000 --- a/assets/www/javascripts/mediators/audioInput.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -var mobileDS = window.mobileDS || -{}; - -/** - * - * - * This "class" is structured as a singleton - so that only one instance is in use.
- * You can access the instance of the class via - */ -mobileDS.AudioInput = (function(){ - - var instance = null; - - //those are the standard audioInput procedures, that should be implemented by a loaded file - function constructor(){ - return { - recognize: function(blob, successCallBack, failureCallBack){ - alert("Audio Input is not supported."); - }, - startRecord: function(successCallBack,failureCallBack){ - alert("Audio Input is not supported."); - }, - stopRecord: function(successCallBack){ - alert("Audio Input is not supported."); - } - } - }; - - - return { - /** - * Object containing the instance of the class {{#crossLink "audioInput"}}{{/crossLink}} - * - * @method getInstance - * @return {Object} Object containing the instance of the class {{#crossLink "CommonUtils"}}{{/crossLink}} - * @public - */ - getInstance: function(){ - if (instance === null) { - instance = constructor(); - } - return instance; - }, - /** - * loads a file. If the file implements a function newAudioInput.initialize(f) - * where the function f is called with a set of functions e, then those functions in e - * are added to the visibility of audioInput, and will from now on be applicable by calling - * audioInput.getInstance.. - */ - loadFile: function(filePath,callBack){ - mobileDS.CommonUtils.getInstance().loadScript(filePath, function(){ - if (instance === null) { - instance = constructor(); - } - if (newAudioInput){ - newAudioInput.initialize(function(functions){ - jQuery.extend(true,instance,functions); - callBack(); - }); - } - }); - - } - }; -}) (); diff --git a/assets/www/javascripts/mediators/audioOutput.js b/assets/www/javascripts/mediators/audioOutput.js deleted file mode 100644 index 2fa307d..0000000 --- a/assets/www/javascripts/mediators/audioOutput.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -var mobileDS = window.mobileDS || -{}; - -/** - * - * - * This "class" is structured as a singleton - so that only one instance is in use.
- * You can access the instance of the class via - */ -mobileDS.AudioOutput = (function(){ - - var instance = null; - - //those are the standard audioOutput procedures, that should be implemented by a loaded file - function constructor(){ - return { - playWAV: function(blob, successCallBack, failureCallBack){ - alert("Audio Output is not supported."); - }, - textToSpeech: function(text, successCallBack,failureCallBack){ - alert("Audio Output is not supported."); - } - }; - }; - - - return { - /** - * Object containing the instance of the class {{#crossLink "audioOutput"}}{{/crossLink}} - * - * @method getInstance - * @return {Object} Object containing the instance of the class {{#crossLink "CommonUtils"}}{{/crossLink}} - * @public - */ - getInstance: function(){ - if (instance === null) { - instance = constructor(); - } - return instance; - }, - /** - * loads a file. If the file implements a function newAudioOutput.initialize(f) - * where the function f is called with a set of functions e, then those functions in e - * are added to the visibility of audioOutput, and will from now on be applicable by calling - * audioOutput.getInstance.. - */ - loadFile: function(filePath,callBack){ - mobileDS.CommonUtils.getInstance().loadScript(filePath, function(){ - if (instance === null) { - instance = constructor(); - } - if (newAudioOutput){ - newAudioOutput.initialize(function(functions){ - jQuery.extend(true,instance,functions); - callBack(); - }); - } - }); - - } - }; -}) (); diff --git a/assets/www/javascripts/mediators/concurrentSCION.js b/assets/www/javascripts/mediators/concurrentSCION.js deleted file mode 100644 index ed30aef..0000000 --- a/assets/www/javascripts/mediators/concurrentSCION.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -var mobileDS = window.mobileDS || -{}; - -/** - * - * - * This "class" is structured as a singleton - so that only one instance is in use.
- * You can access the instance of the class via - */ -mobileDS.ConcurrentSCION = (function(){ - - var instance = null; - //those are the standard ConcurrentSCION procedures, that should be returned by the initialize function of a loaded file - - function constructor() { - return { - newConcurrentSCION: function(interpreter, failureCallBack){ - failureCallBack('No concurrentScion implementation loaded.'); - return { - gen: function(eventName, data){ - interpreter.gen(eventName, data); - } - }; - } - }; - }; - - - - return { - /** - * Object containing the instance of the class {{#crossLink "ConcurrentSCION"}}{{/crossLink}} - * - * @method getInstance - * @return {Object} Object containing the instance of the class {{#crossLink "CommonUtils"}}{{/crossLink}} - * @public - */ - getInstance: function(){ - if (instance === null) { - instance = constructor(); - } - return instance; - }, - /** - * loads a file. If the file implements a function newConcurrentSCION.initialize(f) - * where the function f is called with a set of functions e, then those functions in e - * are added to the visibility of ConcurrentSCION, and will from now on be applicable by calling - * ConcurrentSCION.getInstance.. - */ - loadFile: function(filePath,callBack){ - mobileDS.CommonUtils.getInstance().loadScript(filePath, function(){ - if (instance === null) { - instance = constructor(); - } - if (newConcurrentSCION){ - newConcurrentSCION.initialize(function(functions){ - jQuery.extend(true,instance,functions); - callBack(); - }); - } - }); - - } - }; -}) (); diff --git a/assets/www/javascripts/mediators/html5AudioInput.js b/assets/www/javascripts/mediators/html5AudioInput.js deleted file mode 100644 index e962e63..0000000 --- a/assets/www/javascripts/mediators/html5AudioInput.js +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -newAudioInput = { - initialize: function(callBack){ - function htmlAudioConstructor(){ - // variable that describes if recording is in process - var recording = false; - var webSocket = null; - var nonFunctional = false; - var inputId = 1; - var audio_context=null; - var stream = null; - var recorder=null; - //the function that is called on the recognized text that came back from the server - var textProcessor = function(e,id){}; - var silenceDetection = null; - var silenceDetectionInput = null; - - //for gathering partial ASR results when using startRecord: - var recordAsrResultCache = []; - var recordAsrResultSorter = function(a,b){return a.id - b.id;}; - var asrResultCacheToString = function(cache){ - var size = cache.length; - var sb = new Array(size);//use "StringBuffer" for concatenating partial results - for(var i = 0; i < size; ++i){ - sb[i] = cache[i].text; - } - return sb.join(''); - }; - var recordAsrResultAggregator = function printResult(res,id){ - recordAsrResultCache.push({ - text: res, - id:id - }); - recordAsrResultCache.sort(recordAsrResultSorter); - - //FIXME debug output: - console.debug( asrResultCacheToString(recordAsrResultCache) ); - }; - - /** initializes the connection to the googleMediator-server, - * where the audio will be sent in order to be recognized. **/ - function initializeWebSocket(){ - webSocket = new WebSocket(mobileDS.ConfigurationManager.getInstance().get("HTML5InputWebSocketAddress")); - webSocket.onopen = function () { - if(IS_DEBUG_ENABLED) console.log("Openened connection to websocket"); - }; - - webSocket.onmessage = function(e) { - var id = e.data.substring(0,e.data.indexOf("_")); - var jsonText = e.data.substring(e.data.indexOf("_")+1, e.data.length); - var jsonResponse = jQuery.parseJSON(jsonText ); - if (jsonResponse.hypotheses.length>0){ - if(textProcessor){ - textProcessor(jsonResponse.hypotheses[0].utterance, id); - } - - //aggregate / gather text-parts into the recordAsrResultCache: - recordAsrResultAggregator(jsonResponse.hypotheses[0].utterance, id); - } - }; - webSocket.onerror = function(e) { - console.log('Websocket Error: '+e); - // initializeWebSocket(); - }; - } - /** - * creates a new AudioNode, that communicates sound to the silence detector - */ - function startNewInputNode(){ - if (silenceDetectionInput) { - silenceDetectionInput.onaudioprocess= function(e){}; - } - var input = audio_context.createMediaStreamSource(stream); - silenceDetectionInput = input.context.createJavaScriptNode(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSoundPackageSize"), 2, 2); - silenceDetectionInput.onaudioprocess = function(e){ - if (recording){ - silenceDetection.postMessage({ - command: 'isSilent', - buffer: e.inputBuffer.getChannelData(0) - }); - } - }; - input.connect(silenceDetectionInput); - silenceDetectionInput.connect(input.context.destination); - - } - - /** - * creates Silence detector and recorder and connects them to the input stream - * @param inputstream - */ - function startUserMedia(inputstream){ - stream = inputstream; - var input = audio_context.createMediaStreamSource(stream); - recorder = new Recorder(input); - silenceDetection = new Worker(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceDetectorPath")); - silenceDetection.onmessage = function (e){ - if(IS_DEBUG_ENABLED) console.log(e.data); - if (e.data=='Silence detected!'){ - // send record to server! - recorder && recorder.exportWAV(function(blob, id){ - if(IS_DEBUG_ENABLED) console.log("wav exported"); - if(blob.size>2000000) { - console.log("Message too large. You need to pause from time to time."); - } else - { - //mobileDS.AudioOutput.getInstance().playWAV(blob,function(){},function(){alert("could not play blob");}); - webSocket.send("clear"); - webSocket.send("language "+mobileDS.ConfigurationManager.getInstance().getLanguage()); - webSocket.send("start "+inputId); - webSocket.send(blob); - webSocket.send("analyze "+inputId++); - } - }, mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceBuffer"),inputId); - } - if (e.data=='clear'){ - recorder.clear(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceBuffer")); - } - }; - silenceDetection.postMessage({ - command: 'init', - config: { - sampleRate: input.context.sampleRate, - noiseTreshold : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorNoiseTreshold"), - pauseCount : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorPauseCount"), - resetCount : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorResetCount") - } - }); - }//END: startUserMedia - try { - // unify the different kinds of HTML5 implementations - //window.AudioContext = window.AudioContext || window.webkitAudioContext; - html5Navigator.getUserMedia = html5Navigator.getUserMedia || html5Navigator.webkitGetUserMedia || html5Navigator.mozGetUserMedia; - //window.URL = window.URL || window.webkitURL; - audio_context = new webkitAudioContext; - } - catch (e) { - console.error('No web audio support in this browser!'); - nonFunctional = true; - } - try { - initializeWebSocket(); - } catch (e) { - console.error('Could not reach the voice recognition server!'); - nonFunctional = true; - } - // get audioInputStream - html5Navigator.webkitGetUserMedia({audio: true}, startUserMedia, function(e) {}); - if (nonFunctional) { - return {}; - } else { - return { - startRecord: function(callBack){ - textProcessor = callBack; - silenceDetection && startNewInputNode(); - recording=true; - recorder && recorder.clear(); - recorder && recorder.record(); - silenceDetection && silenceDetection.postMessage({command: 'start'}); - }, - stopRecord: function(successCallBack,failureCallBack){//blobHandler){ - recording=false; - recorder && recorder.stop(); - recorder && recorder.exportWAV(function (blob) { - webSocket.send("clear"); - webSocket.send("start "+inputId); - webSocket.send(blob); - webSocket.send("stop"); - webSocket.send("analyze "+inputId++); - webSocket.send("clear"); -// blobHandler(blob); - if(successCallBack){ - successCallBack( recordAsrResultCache.join('') ); - } - - //reset result-cache: - recordAsrResultCache = []; - }); - silenceDetection && silenceDetection.postMessage({command: 'stop'}); - }, - recognize: function(successCallBack,failureCallBack){ - textProcessor = successCallBack; - recorder && recorder.stop(); - silenceDetection && silenceDetection.postMessage({command: 'stop'}); - recorder && recorder.exportWAV(function(blob){ - webSocket.send("clear"); - webSocket.send("start "+ inputId); - webSocket.send(blob); - webSocket.send("stop"); - webSocket.send("analyze "+ inputId++); - webSocket.send("clear"); - }); - } - };//END: return - }//END: else - }; - // the code starts here, loads the necessary scripts and then calls htmlAudioConstructor - mobileDS.CommonUtils.getInstance().loadScript('javascripts/mediators/recorderWorker.js',function(){ - mobileDS.CommonUtils.getInstance().loadScript('javascripts/mediators/recorder.js', function(){ - callBack(htmlAudioConstructor()); - }); - }); - } - -}; \ No newline at end of file diff --git a/assets/www/javascripts/mediators/html5AudioOutput.js b/assets/www/javascripts/mediators/html5AudioOutput.js deleted file mode 100644 index 6d60e83..0000000 --- a/assets/www/javascripts/mediators/html5AudioOutput.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -newAudioOutput = { - initialize: function(callBack){ - - var audio_context=null; - try { - // unify the different kinds of HTML5 implementations - //window.AudioContext = window.AudioContext || window.webkitAudioContext; - //window.URL = window.URL || window.webkitURL; - audio_context = new webkitAudioContext; - } - catch (e) { - console.error('No web audio support in this browser!'); - } - - callBack({ - playWAV: function(blob, successCallBack, failureCallBack){ - try { - blobURL = window.webkitURL.createObjectURL(blob); - var my_audio = new Audio(blobURL,null,failureCallBack); - if(successCallBack){ - my_audio.addEventListener('ended', successCallBack, false); - } - my_audio.play(); - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - }, - textToSpeech: function(text,successCallBack,failureCallBack, startCallBack){ - try { - text = text.replace(/\s/g, '%20'); - var speaker = window.mobileDS.LanguageManager.getInstance().getSpeaker(); - var lang = speaker["lang_simple"]; - var voice = speaker["speaker"]; - - var my_media = new Audio( - window.mobileDS.ConfigurationManager.getInstance().get("HTML5OutputServerBasePath")+'process?INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&INPUT_TEXT=' + text + '&LOCALE='+lang+'&VOICE='+voice+'&AUDIO=WAVE_FILE', - null, - failureCallBack - ); - - this.current_speech = my_media; - - my_media.addEventListener('ended', function() { - this.current_speech = null; - if(successCallBack){ - successCallBack(); - } - }, false); - - if(startCallBack){ - my_media.addEventListener('playing', startCallBack, false); - } - - my_media.play(); - } catch (e){ - this.current_speech = null; - if(failureCallBack){ - failureCallBack(e); - } - } - }, - cancelSpeech: function(successCallBack,failureCallBack){ - - if(this.current_speech){ - try{ - this.current_speech.pause(); - } catch(e){ - if(failureCallBack){ - failureCallBack(e); - return;////////////////// EARLY EXIT //////////////// - } - } - } - - if(successCallBack){ - successCallBack(); - } - }, - playURL: function(url, successCallBack, failureCallBack){ - try { - - var my_media = new Audio(url,null,failureCallBack); - if(successCallBack){ - my_media.addEventListener('ended', successCallBack, false); - } - my_media.play(); - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - }, - getURLAsAudio: function(url, successCallBack, failureCallBack){ - try { - - var my_media = new Audio(url,null,failureCallBack); - if(successCallBack){ - my_media.addEventListener('ended', successCallBack, false); - } - return my_media; - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - } - }); - } -}; - diff --git a/assets/www/javascripts/mediators/html5ConcurrentScion.js b/assets/www/javascripts/mediators/html5ConcurrentScion.js deleted file mode 100644 index 007cdc0..0000000 --- a/assets/www/javascripts/mediators/html5ConcurrentScion.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -newConcurrentSCION = { - initialize: function(callBack){ - - callBack({ - newConcurrentSCION: function(scion, failureCallBack){ - var newWorker = new Worker(mobileDS.constants.getInstance().getWorkerPath()+'ScionQueueWorker.js'); - newWorker.onmessage= function(e){ - if (e.data.command == "toDo"){ - console.log('raising:'+ e.data.toDo.event); - var generatedState = scion.gen(e.data.toDo.event, e.data.toDo.eventData); - newWorker.postMessage({command: 'readyForJob'}); - }; - }; - return {gen: function (event, eventData){ - console.log('new Job:'+ event); - newWorker.postMessage( - {command: 'newJob', - job: {event: event, eventData: eventData} - }); - } - }; - } - }); - } -}; - diff --git a/assets/www/javascripts/mediators/maryAudioOutput.js b/assets/www/javascripts/mediators/maryAudioOutput.js deleted file mode 100644 index 19682ea..0000000 --- a/assets/www/javascripts/mediators/maryAudioOutput.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -newAudioOutput = { - initialize: function(callBack){ - callBack({ - textToSpeech: function(text,successCallBack,failureCallBack,startCallBack){ - try { - text = text.replace(/\s/g, '%20'); - var speaker = window.mobileDS.LanguageManager.getInstance().getSpeaker(); - var lang = speaker["lang_simple"]; - var voice = speaker["speaker"]; - - var my_media = new Media( - window.mobileDS.ConfigurationManager.getInstance().get("HTML5OutputServerBasePath")+'process?INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&INPUT_TEXT=' + text + '&LOCALE='+lang+'&VOICE='+voice+'&AUDIO=WAVE_FILE', - successCallBack, - failureCallBack - ); - - if(startCallBack){ - my_media.addEventListener('playing', startCallBack, false); - } - - my_media.play(); - } catch (e){ - console.log('error!'+e); - if (failureCallBack){ - failureCallBack(e); - } - } - }, - playWav: function(blob, successCallback, failureCallBack){ - try { - var blobURL = window.URL.createObjectURL(blob); - var my_media = new Media(blobURL,null,failureCallBack); - my_media.play(); - if(successCallback){ - successCallback(); - } - } catch (e){ - console.log('error!'+e); - if (failureCallBack){ - failureCallBack(); - } - } - }, - playURL: function(url, successCallBack, failureCallBack){ - try { - var my_media = new Media(url,successCallBack, failureCallBack,null,null); - my_media.play(); - } catch (e){ - console.log('error!'+e); - if (failureCallBack){ - failureCallBack(e); - } - } - } - }); - } -} \ No newline at end of file diff --git a/assets/www/javascripts/mediators/nativeConcurrentSCION.js b/assets/www/javascripts/mediators/nativeConcurrentSCION.js deleted file mode 100644 index d31aca7..0000000 --- a/assets/www/javascripts/mediators/nativeConcurrentSCION.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -newConcurrentSCION = { - initialize: function(callBack){ - var callBackList = []; - function successCallBackHandler(args){ - if (args.length=2){ - callBackList[args[0]](args[1]); - } - } - callBack({ - newConcurrentSCION: function(scion, failureCallBack){ - var id = callBackList.length; - callBackList.push(function(data){ - // console.log('raising:'+ data.event); - var generatedState = scion.gen(data.event, data.eventData); - plugins.queuePlugin.readyForJob(id, successCallBackHandler, failureCallBack); - }); - plugins.queuePlugin.newQueue(id, function(args){console.log('Queue '+id+' created.');},failureCallBack); - - return { - gen: function (event, eventData){ - // console.log('new Job:'+ event); - plugins.queuePlugin.newJob(id, {event: event, eventData: eventData}, successCallBackHandler,failureCallBack); - } - }; - } - }); - } -}; - diff --git a/assets/www/javascripts/popup.js b/assets/www/javascripts/popup.js deleted file mode 100644 index 6db18f1..0000000 --- a/assets/www/javascripts/popup.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * base on http://www.joelpeterson.com/blog/2010/12/quick-and-easy-windowless-popup-overlay-in-jquery/ - * - * - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -function loadPopup(prefix){ - //loads popup only if it is disabled - - var dataPrefix = '', popupBgDiv; - if (prefix != null) { - dataPrefix = '[data-prefix="'+prefix+'"]'; - } - - if (typeof($("div.popupBg" + dataPrefix).data("state")) === 'undefined') { - $("div.popupBg" + dataPrefix).last().data("state", 0); - } - - popupBgDiv = $("div.popupBg" + dataPrefix).last(); - console.log(">>>> " + typeof(popupBgDiv.data('state'))); - - if(popupBgDiv.data("state")==0 || typeof(popupBgDiv.data('state')) === 'undefined'){ - popupBgDiv.data('state', 0); - centerPopup(prefix); - $("div.popupBg" + dataPrefix).last().fadeIn("medium"); - $("div.Popup" + dataPrefix).last().fadeIn("medium"); - $("div.popupBg" + dataPrefix).last().data("state",1); - $("div.Popup"+ dataPrefix + " .close").last().unbind("click"); - $("div.Popup" + dataPrefix + " .close").last().click(function(){ - disablePopup(prefix); - }); - $("div.popupBg" + dataPrefix).unbind('click'); - $("div.popupBg" + dataPrefix).click(function(){ - disablePopup(prefix); - }); - } -} - -function disablePopup(prefix){ - var dataPrefix = ''; - if (prefix != null) { - dataPrefix = '[data-prefix='+prefix+']'; - } - - if ($("div.popupBg" + dataPrefix).last().data("state")==1){ - $("div.popupBg" + dataPrefix).last().fadeOut("medium"); - $("div.Popup" + dataPrefix).last().fadeOut("medium"); - $("div.popupBg" + dataPrefix).last().data("state",0); - } -} - -function centerPopup(prefix){ - var dataPrefix = ''; - if (prefix != null) { - dataPrefix = '[data-prefix='+prefix+']'; - } - - var winw = $(window).width(); - var winh = $(window).height(); - var popw = $('div.Popup' + dataPrefix).last().width(); - var poph = $('div.Popup' + dataPrefix).last().height(); - $("div.Popup" + dataPrefix).last().css({ - "position" : "absolute", - "top" : 55, - "left" : 15 - }); - //IE6 - $("div.popupBg" + dataPrefix).last().css({ - "height": winh - }); -} \ No newline at end of file diff --git a/assets/www/javascripts/semantic/grammar_parser_template.js b/assets/www/javascripts/semantic/grammar_parser_template.js deleted file mode 100644 index f5b6bef..0000000 --- a/assets/www/javascripts/semantic/grammar_parser_template.js +++ /dev/null @@ -1 +0,0 @@ -GrammarConverter.prototype.PARSER_TEMPLATE = "\n var theGrammarConverterInstance = this;\n\n ##HEADER##\n\n/*\n\tJS/CC: A LALR(1) Compiler-Compiler written in JavaScript\n\tCopyright (C) 2007, 2008 by J.M.K S.F. Software Technologies, Jan Max Meyer\n\thttp://www.jmksf.com ++ jscc<-AT->jmksf.com\n\t\n\tFile:\tjscc.html\n\tAuthor:\tJan Max Meyer\n\tUsage:\tModified parser template for the Web Environment Module\n\t\t\tBased on \"driver_web.js_\" parser template, but NOT in the public domain!\n\t\n\tYou may use, modify and distribute this software under the terms and conditions\n\tof the Artistic License. Please see ARTISTIC for more information.\n\n\tDriver for the JS/CC Web Environment with integrated HTML parse tree generator!\n\t\n\tFeatures:\n\t- Parser trace messages\n\t- Integrated panic-mode error recovery\n\t- Parse tree construction for the JS/CC web environment\n*/\n\nvar ##PREFIX##_dbg_withtrace\t\t= false;\nvar ##PREFIX##_dbg_string\t\t\t= new String();\n\nfunction __##PREFIX##dbg_print( text )\n{\n\t##PREFIX##_dbg_string += text + \"\\n\";\n}\n\nfunction __##PREFIX##lex( info )\n{\n\tvar state\t\t= 0;\n\tvar match\t\t= -1;\n\tvar match_pos\t= 0;\n\tvar start\t\t= 0;\n\tvar pos\t\t\t= info.offset + 1;\n\n\tdo\n\t{\n\t\tpos--;\n\t\tstate = 0;\n\t\tmatch = -2;\n\t\tstart = pos;\n\n\t\tif( info.src.length <= start )\n\t\t\treturn ##EOF##;\n\n\t\tdo\n\t\t{\n\n##DFA##\n\t\t\tpos++;\n\n\t\t}\n\t\twhile( state > -1 );\n\n\t}\n\twhile( ##WHITESPACE## > -1 && match == ##WHITESPACE## );\n\n\tif( match > -1 )\n\t{\n\t\tinfo.att = info.src.substr( start, match_pos - start );\n\t\tinfo.offset = match_pos;\n\t\t\n##TERMINAL_ACTIONS##\n\t}\n\telse\n\t{\n\t\tinfo.att = new String();\n\t\tmatch = -1;\n\t}\n\n\treturn match;\n}\n\n\nfunction __##PREFIX##parse( src, err_off, err_la )\n{ theGrammarConverterInstance.asr_semantic_annotation={};\n\tvar\t\tsstack\t\t\t= new Array();\n\tvar\t\tvstack\t\t\t= new Array();\n\tvar \terr_cnt\t\t\t= 0;\n\tvar\t\tact;\n\tvar\t\tgo;\n\tvar\t\tla;\n\tvar\t\trval;\n\tvar \tparseinfo\t\t= new Function( \"\", \"var offset; var src; var att;\" );\n\tvar\t\tinfo\t\t\t= new parseinfo();\n\t\n\t//Visual parse tree generation\n\tvar \ttreenode\t\t= new Function( \"\", \"var sym; var att; var child;\" );\n\tvar\t\ttreenodes\t\t= new Array();\n\tvar\t\ttree\t\t\t= new Array();\n\tvar\t\ttmptree\t\t\t= null;\n\t\n##TABLES##\n\n##LABELS##\n\t\n\tinfo.offset = 0;\n\tinfo.src = src;\n\tinfo.att = new String();\n\t\n\tif( !err_off )\n\t\terr_off\t= new Array();\n\tif( !err_la )\n\terr_la = new Array();\n\t\n\tsstack.push( 0 );\n\tvstack.push( 0 );\n\t\n\tla = __##PREFIX##lex( info );\n\n\twhile( true )\n\t{\n\t\tact = ##ERROR##;\n\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t{\n\t\t\tif( act_tab[sstack[sstack.length-1]][i] == la )\n\t\t\t{\n\t\t\t\tact = act_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif( ##PREFIX##_dbg_withtrace && sstack.length > 0 )\n\t\t{\n\t\t\t__##PREFIX##dbg_print( \"\\nState \" + sstack[sstack.length-1] + \"\\n\" +\n\t\t\t\t\t\t\t\"\\tLookahead: \" + labels[la] + \" (\\\"\" + info.att + \"\\\")\\n\" +\n\t\t\t\t\t\t\t\"\\tAction: \" + act + \"\\n\" + \n\t\t\t\t\t\t\t\"\\tSource: \\\"\" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ?\n\t\t\t\t\t\t\t\t\t\"...\" : \"\" ) + \"\\\"\\n\" +\n\t\t\t\t\t\t\t\"\\tStack: \" + sstack.join() + \"\\n\" +\n\t\t\t\t\t\t\t\"\\tValue stack: \" + vstack.join() + \"\\n\" );\n\t\t}\n\t\t\n\t\t\t\n\t\t//Panic-mode: Try recovery when parse-error occurs!\n\t\tif( act == ##ERROR## )\n\t\t{\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Error detected: There is no reduce or shift on the symbol \" + labels[la] );\n\t\t\t\n\t\t\terr_cnt++;\n\t\t\terr_off.push( info.offset - info.att.length );\t\t\t\n\t\t\terr_la.push( new Array() );\n\t\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t\terr_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] );\n\t\t\t\n\t\t\t//Remember the original stack!\n\t\t\tvar rsstack = new Array();\n\t\t\tvar rvstack = new Array();\n\t\t\tfor( var i = 0; i < sstack.length; i++ )\n\t\t\t{\n\t\t\t\trsstack[i] = sstack[i];\n\t\t\t\trvstack[i] = vstack[i];\n\t\t\t}\n\t\t\t\n\t\t\twhile( act == ##ERROR## && la != ##EOF## )\n\t\t\t{\n\t\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery\\n\" +\n\t\t\t\t\t\t\t\t\t\"Current lookahead: \" + labels[la] + \" (\" + info.att + \")\\n\" +\n\t\t\t\t\t\t\t\t\t\"Action: \" + act + \"\\n\\n\" );\n\t\t\t\tif( la == -1 )\n\t\t\t\t\tinfo.offset++;\n\t\t\t\t\t\n\t\t\t\twhile( act == ##ERROR## && sstack.length > 0 )\n\t\t\t\t{\n\t\t\t\t\tsstack.pop();\n\t\t\t\t\tvstack.pop();\n\t\t\t\t\t\n\t\t\t\t\tif( sstack.length == 0 )\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tact = ##ERROR##;\n\t\t\t\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( act_tab[sstack[sstack.length-1]][i] == la )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tact = act_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif( act != ##ERROR## )\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tfor( var i = 0; i < rsstack.length; i++ )\n\t\t\t\t{\n\t\t\t\t\tsstack.push( rsstack[i] );\n\t\t\t\t\tvstack.push( rvstack[i] );\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tla = __##PREFIX##lex( info );\n\t\t\t}\n\t\t\t\n\t\t\tif( act == ##ERROR## )\n\t\t\t{\n\t\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery failed, terminating parse process...\" );\n\t\t\t\tbreak;\n\t\t\t}\n\n\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery succeeded, continuing\" );\n\t\t}\n\t\t\n\t\t/*\n\t\tif( act == ##ERROR## )\n\t\t\tbreak;\n\t\t*/\n\t\t\n\t\t\n\t\t//Shift\n\t\tif( act > 0 )\n\t\t{\n\t\t\t//Parse tree\n\t\t\tvar node = new treenode();\n\t\t\tnode.sym = labels[ la ];\n\t\t\tnode.att = info.att;\n\t\t\tnode.child = new Array();\n\t\t\ttree.push( treenodes.length );\n\t\t\ttreenodes.push( node );\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Shifting symbol: \" + labels[la] + \" (\" + info.att + \")\" );\n\t\t\n\t\t\tsstack.push( act );\n\t\t\tvstack.push( info.att );\n\t\t\t\n\t\t\tla = __##PREFIX##lex( info );\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tNew lookahead symbol: \" + labels[la] + \" (\" + info.att + \")\" );\n\t\t}\n\t\t//Reduce\n\t\telse\n\t\t{\t\t\n\t\t\tact *= -1;\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Reducing by producution: \" + act );\n\t\t\t\n\t\t\trval = void(0);\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPerforming semantic action...\" );\n\t\t\t\n##ACTIONS##\n\n\t\t\ttmptree = new Array();\n\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPopping \" + pop_tab[act][1] + \" off the stack...\" );\n\t\t\t\t\n\t\t\tfor( var i = 0; i < pop_tab[act][1]; i++ )\n\t\t\t{\t\t\t\n\t\t\t\ttmptree.push( tree.pop() );\n\n\t\t\t\tsstack.pop();\n\t\t\t\tvstack.pop();\n\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\tgo = -1;\n\t\t\tfor( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t{\n\t\t\t\tif( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] )\n\t\t\t\t{\n\t\t\t\t\tgo = goto_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Parse tree\n\t\t\tvar node = new treenode();\n\t\t\tnode.sym = labels[ pop_tab[act][0] ];\n\t\t\tnode.att = rval;\n\t\t\tnode.child = tmptree.reverse();\n\t\t\ttree.push( treenodes.length );\n\t\t\ttreenodes.push( node );\n\t\t\t\n\t\t\tif( act == 0 )\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPushing non-terminal \" + labels[ pop_tab[act][0] ] );\n\t\t\t\t\n\t\t\tsstack.push( go );\n\t\t\tvstack.push( rval );\t\t\t\n\t\t}\n\t\t\n\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t{\t\t\n\t\t\talert( ##PREFIX##_dbg_string );\n\t\t\t##PREFIX##_dbg_string = new String();\n\t\t}\n\t}\n\n\tif( ##PREFIX##_dbg_withtrace )\n\t{\n\t\t__##PREFIX##dbg_print( \"\\nParse complete.\" );\n\t\talert( ##PREFIX##_dbg_string );\n\t}\n\t\n\tif( err_cnt == 0 )\n\t{}\n\t\n\treturn err_cnt;\n}\n\nfunction __##PREFIX##dbg_image( name )\n{\n\treturn \"\";\n}\n\nfunction __##PREFIX##dbg_get_tree_depth( nodes, tree, max )\n{\n\tvar\t\ttmp\t\t= 0;\n\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tif( max < ( tmp = __dbg_get_tree_depth( nodes, nodes[ tree[i] ].child, max+1 ) ) )\n\t\t\t\tmax = tmp;\n\t}\n\t\n\treturn max;\n}\n\nfunction __##PREFIX##dbg_parsetree( prev, cnt, depth, nodes, tree )\n{\n\tvar str = new String();\n\t\n\tif( cnt == 0 )\n\t\tstr += \"\";\n\t\n\tif( !prev )\n\t\tprev = new Array();\n\t\t\n\tif( cnt > 0 )\n\t\tprev[cnt-1] = true;\n\t\t\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tstr += \"\";\n\n\t\tfor( var j = 0; j < cnt; j++ )\n\t\t{\n\t\t\tstr += \"\";\n\t\t}\n\t\t\n\t\tif( cnt > 0 && i == tree.length - 1 )\n\t\t\tprev[cnt-1] = false;\n\n\t\tstr += \"\";\n\t\t\n\t\tstr += \"\";\n\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tstr += __##PREFIX##dbg_parsetree( prev, cnt+1, depth, nodes, nodes[ tree[i] ].child );\n\t}\n\t\n\tif( cnt == 0 )\n\t\tstr += \"
\";\n\n\t\t\tif( prev[j] )\n\t\t\t{\n\t\t\t\tif( j == cnt - 1 && i == tree.length - 1 )\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"ll\" );\n\t\t\t\telse if( j == cnt - 1 )\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"la\" );\n\t\t\t\telse\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"l\" );\n\t\t\t}\n\t\t\telse\n\t\t\t\tstr += __##PREFIX##dbg_image( \"e\" );\n\t\t\t\t\n\t\t\tstr += \"\";\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tif( cnt == 0 )\n\t\t\t\tstr += __##PREFIX##dbg_image( \"rn\" );\n\t\t\telse\n\t\t\t\tstr += __##PREFIX##dbg_image( \"n\" );\t\n\t\telse\n\t\t\tstr += __##PREFIX##dbg_image( \"t\" );\n\t\tstr += \"\" + nodes[ tree[i] ].sym ;\n\t\tif( nodes[ tree[i] ].att && nodes[ tree[i] ].att != \"\" )\n\t\t\tstr += \":\" + nodes[ tree[i] ].att + \"\" ;\n\t\t\t\n\t\tstr += \"
\";\n\t\n\treturn str;\n}\n\nfunction __##PREFIX##dbg_parsetree_phpSyntaxTree( nodes, tree )\n{\n\tvar str = new String();\n\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tstr += \" [ \";\n\n\t\tstr += nodes[ tree[i] ].sym;\n\t\tif( nodes[ tree[i] ].att && nodes[ tree[i] ].att != \"\" )\n\t\t{\n\t\t\tvar attr = new String( nodes[ tree[i] ].att );\n\t\t\tstr += \":\\\"\" + attr.replace( / |\\t|\\r|\\n|\\[|\\]/g, \"_\" ) + \"\\\"\";\n\t\t}\n\t\t\t\n\t\tstr += \" \";\n\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tstr += __##PREFIX##dbg_parsetree_phpSyntaxTree( nodes, nodes[ tree[i] ].child );\n\n\t\tstr += \" ] \";\n\t}\n\t\n\treturn str;\n}\n\n\n##FOOTER##"; diff --git a/assets/www/javascripts/semantic/stemmer.js b/assets/www/javascripts/semantic/stemmer.js deleted file mode 100644 index cf622ca..0000000 --- a/assets/www/javascripts/semantic/stemmer.js +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -/* Really simple JavaScript stemmer based on the Snowball stemmer - http://snowball.tartarus.org/algorithms/german/stemmer.html - Some simplifications were made, e.g. ignoring R2 and the special - provision for words ending in -isse- */ -/* Definitions */ - -// var vowel = /[aeiouyäöüUY]/; -// var cons = /[^aeiouyäöüUY]/; -var sEnding = "[bdfghklmnrt]"; -var stEnding = "[bdfghklmnt]"; - -var prefix = "^((.[aeiouyäöüUY][^aeiouyäöüUY])|([aeiouyäöüUY][^aeiouyäöüUY].))"; - - -function stem_word(word){ - - word = word.toLowerCase(); - word = word.replace(/ß/g, "ss"); - - if (word.length < 4) { - return word; - } - - word = word.replace(/([aeiouyäöü])y([aeiouyäöü])/g, "$1Y$2"); // replace y between vowels with Y - word = word.replace(/([aeiouyäöü])u([aeiouyäöü])/g, "$1U$2"); // replace u between vowels with U - /* Step 1 */ - - if (word.match(prefix + "(.*)" + "ern$")) { - word = word.slice(0, -3); - } - else - if (word.match(prefix + "(.*)" + "(em$|en$|er$|es$)")) { - word = word.slice(0, -2); - } - else - if (word.match(prefix + "(.*)" + "(e$)")) { - word = word.slice(0, -1); - } - else - if (word.match(sEnding + "s$") && word.match(prefix + "(.*)" + "(s$)")) { - word = word.slice(0, -1); - } - - - - /* Step 2 */ - - if (word.match(prefix + "(.*)" + "est$")) { - word = word.slice(0, -3); - } - else - if (word.match(prefix + "(.*)" + "(en$|er$)")) { - word = word.slice(0, -2); - } - else - if (word.match(prefix + "(.*)" + stEnding + "(st$)")) { - word = word.slice(0, -2); - } - - - - /* Step 3 */ - // simplified!! Really these should be in R2 not R1 - - if (word.match(prefix + "(.*)" + "keit$")) { - word = word.slice(0, -4); - } - if (word.match(prefix + "(.*)" + "(lich$|heit$)")) { - word = word.slice(0, -4); - if (word.match(prefix + "(.*)" + "(er$|en$)")) { - word = word.slice(0, -2); - } - } - else - if (word.match(prefix + "(.*)" + "(isch$)")) { - if (!word.match("eisch$")) { - word = word.slice(0, -4); - } - } - else - if (word.match(prefix + "(.*)" + "(ig$|ik$)")) { - if (!word.match("e..$")) { - word = word.slice(0, -2); - } - } - else - if (word.match(prefix + "(.*)" + "(end$|ung$)")) { - word = word.slice(0, -3); - } - - - - /* Clean up */ - - word = word.replace(/([aeiouyäöü])Y/g, "$1y"); // replace Y with y - word = word.replace(/([aeiouyäöü])U/g, "$1u"); // replace U with u - word = word.replace(/ä/g, "a"); - word = word.replace(/ö/g, "o"); - word = word.replace(/ü/g, "u"); - - - return word; - -} diff --git a/assets/www/javascripts/tools/commonUtils.js b/assets/www/javascripts/tools/commonUtils.js deleted file mode 100644 index 0d74be2..0000000 --- a/assets/www/javascripts/tools/commonUtils.js +++ /dev/null @@ -1,1154 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * @module mobileDS.javascripts.tools - * - */ -var mobileDS = window.mobileDS || -{}; - -/** - * A Utility class to support various functions.
- * It contains nearly all regular expressions used in the application - so that changes can be arranged inside this file.
- * This "class" is structured as a singleton - so that only one instance is in use.
- * You can access the instance of the class via - * @example mobileDS.CommonUtils.getInstance() - * @class CommonUtils - * @category core - * - * @see mobileDS.CommonUtils#constructor - */ -mobileDS.CommonUtils = (function(){ - - /** - * Object containing the instance of the class CommonUtils - * - * @property instance - * @type Object - * @private - */ - var instance = null; - - /** - * JSON-Object containing the directory Structure of the application. Only directories defined by the Property - * {@link mobileDS.CommonUtils-constructor-directoriesToParse} are contained within the JSON-Object. - * - * @property directoryStructure - * @type JSON - * @private - */ - var directoryStructure; - - /** - * Property holding this instance of CommonUtils for referencing _this_-object inside sub-functions - * - * @property self - * @type Object - * @private - * @deprecated This Property is unused - */ - var self = this; - - /** - * This function is used by {@link mobileDS.CommonUtils-constructor.getDirectoryContents} and {@link mobileDS.CommonUtils-constructor.getDirectoryContentsWithFilter} to strip the pathname parameter - * @function stripPathName - * @private - * @param {string} pathname The path that should be stripped of "file://" and a beginning or trailing "/" - * @returns {String} The stripped pathname - devoid of beginning "file://" or "/" and trailing "/" - */ - function stripPathName(pathname){ - - //FIXME this is a HACK; TODO handle this in a general way! - var basePath = mobileDS.constants.getInstance(forBrowser).getBasePath(); - - if(pathname.startsWith(basePath)){ - pathname = pathname.substring(basePath.length); - } - - if (pathname.indexOf("file://") != -1){ - pathname = pathname.replace("file://", ""); - } - if (pathname[pathname.length-1] == "/"){ - pathname = pathname.substring(0,pathname.length-1); - } - if (pathname[0] != "/"){ - pathname = "/" + pathname; - } - - return pathname; - } - - /** - * This helper initializes a function for detecting if an Object is an Array. - * - * The helper tries to find functions of JavaScript libraries for this; if none can be found, - * a custom implementation is used. - * - * The returned function is used by {@link mobileDS.CommonUtils-constructor.isArray} - * - * NOTE: The current implementation checks $.isArray for presences - * - * @function isArrayHelper - * @private - * @returns {Function} a function that takes one parameter (Object) and returns true if this parameter is an Array (false otherwise) - */ - var isArrayHelper = function(obj){ - - //this is the initializer: the following will overwrite the isArray-function - // with the appropriate version (use jQuery method, if present, otherwise use alternative) - - //if present, use jQuery method: - if(typeof $ !== 'undefined' && typeof $.isArray === 'function'){ - isArrayHelper = $.isArray; - } - else { - //use the toString method with well-defined return-value from Object: - var staticToString = Object.prototype.toString; - - isArrayHelper = function(obj){ - return staticToString.call(obj) === '[object Array]'; - }; - } - }; - //initialize the isArray-function - isArrayHelper(); - - /** - * Constructor-Method of Class {@link mobileDS.CommonUtils} - * - * @constructor - * @augments mobileDS.CommonUtils - * - * @memberOf mobileDS.CommonUtils.prototype - */ - function constructor(){ - //private members. - /** - * HTML-Dom-Element for logging directly on the main HTML-Page - * as of now there is no element with the id "log" in the index.html - * - * @property debugNode - * @type Element - * @private - * @deprecated unused - */ - var debugNode = document.getElementById("log"); - - /** - * Regular Expression to identify a styleSheet-tag for the transformation of ehtml to html - * - * @property styleSheetRegExp - * @type String|RegExp - * @private - * @deprecated unused - */ - var styleSheetRegExp = /<(%=\s*stylesheet_link_tag)\s* (\"(.*)\" %)>/; - - /** - * Regular Expression to identify a javascript for the transformation of ehtml to html - * - * @property javaScriptRegExp - * @type String|RegExp - * @private - * @deprecated unused - */ - var javaScriptRegExp = /<(%=\s*javascript_include_tag)\s* (\"(.*)\" %)>/; - - /** - * Regular Expression to identify content for a view-element:
- * either _header_, _footer_, _dialogs_ or _content_ - * - * @deprecated old template syntax format - * - * @property contentForRegExp - * @type String|RegExp - * @private - */ - var contentForRegExp = /<%\s*content_for\s*:([^\s]*)\s*do\s*%>(([\s|\n]*.*[\s|\n]*)*)<%\s*end\s*%>/i ; - - /** - * Regular Expression to identify if a partial should be rendered inside a view (ehtml-String) - * - * @deprecated old template syntax format - * - * @property renderPartialRegExp - * @type String|RegExp - * @private - */ - var renderPartialRegExp = /<%\s*render\s*([^\s]*)\s*\{\}\s*%>/i ; - - /** - * Regular Expression for matching a translation-tag for the localization of view content (ehtml-String) - * - * @deprecated old template syntax format - * - * @property translationRegExpString - * @type String|RegExp - * @private - */ - var translationRegExpString = '<%t\\s*:([^\\s]*)\\s*%>'; - - /** - * The Prefix for the file names of partial-files.
- * Files named <PARTIAL-PREFIX>filename.ehtml inside a views-directory - * are recognized as partials. - * - * @property partialsPrefix - * @type String - * @private - */ - var partialsPrefix = '~'; - -// /** -// * The Prefix for the names of view-files - currently unused and deprecated. -// * -// * @property viewsPrefix -// * @type String -// * @private -// * @deprecated has no further value -// */ -// var viewsPrefix = '#'; - - /** - * Array of Directories (Strings) to parse at the starting process
- * those directories are then accessable by the functions {@link mobileDS.CommonUtils-constructor.getDirectoryContents} and {@link mobileDS.CommonUtils-constructor.getDirectoryContentsWithFilter} - * - * TODO read from properties (implement mechanism such that \build.settings and this refer to the same resource) - * - * @property directoriesToParse - * @type Array - * @private - */ - var directoriesToParse = [ - "www/controllers", - "www/views", - "www/models", - "www/config", - "www/javascripts/plugins", - "www/helpers" - ]; - /** - * Property holding this instance of CommonUtils for referencing _this_ constructor-object inside sub-functions - * - * @property self - * @type Object - * @private - * @deprecated This Property is unused - */ - var self = this; - - - - /** - * Array of strings for the conversion of month represented by integers to strings - * Default Language for months is english, 'en' - * @property months - * @type Object - * @private - */ - this.months = new Object(); - this.months['01'] = 'January'; - this.months['02'] = 'February'; - this.months['03'] = 'March'; - this.months['04'] = 'April'; - this.months['05'] = 'May'; - this.months['06'] = 'June'; - this.months['07'] = 'July'; - this.months['08'] = 'August'; - this.months['09'] = 'September'; - this.months['10'] = 'October'; - this.months['11'] = 'November'; - this.months['12'] = 'December'; - - this.months['de'] = new Object(); - this.months['de']['01'] = 'Januar'; - this.months['de']['02'] = 'Februar'; - this.months['de']['03'] = 'März'; - this.months['de']['04'] = 'April'; - this.months['de']['05'] = 'Mai'; - this.months['de']['06'] = 'Juni'; - this.months['de']['07'] = 'Juli'; - this.months['de']['08'] = 'August'; - this.months['de']['09'] = 'September'; - this.months['de']['10'] = 'Oktober'; - this.months['de']['11'] = 'November'; - this.months['de']['12'] = 'Dezember'; - - /** @lends mobileDS.CommonUtils.prototype */ - return { - //public members. - /** - * @function getPartialsPrefix - * @public - * @returns {String} The Prefix for the file names of partial-files - */ - getPartialsPrefix: function(){ - return partialsPrefix; - }, - - /** - * @function getDirectoryStructure - * @public - * @returns {Object} Directory structure as json object - */ - getDirectoryStructure: function(){ - return this.directoryStructure; - }, - -// /** -// * Get the prefix for views. -// * @function getViewsPrefix -// * @public -// * @returns {String} The Prefix for the file names of views -// * @deprecated This function is unused and superfluous -// */ -// getViewsPrefix: function(){ -// return viewsPrefix; -// }, - - /** - * Gets the Regular Expression for translation tags. - * @function getTranslationRegExp - * @public - * @returns {String} The regular expression for matching a translation-tag - used inside a ehtml-String - */ - getTranslationRegExp: function(){ - return new RegExp(translationRegExpString, 'gi'); - }, - - /** - * Appends a log-message to the main document (index.html) and prints it in the console - * @function log - * @param {String} clazz A prefix for the output of the log message in the console - * @param {String} logMessage The log message which should be printed - * @public - * @deprecated - */ - log: function(clazz,logMessage){ - this.debugNode = document.getElementById("log"); - if (this.debugNode) { - this.debugNode.innerHTML += "
\n" + logMessage + "\n
\n"; - } - console.log(clazz + ":" + logMessage); - }, - - /** - * Regular Expression for matching HTML comments.
- * - * This RegExp also matches multi-line comments. - * - * Note upon using the RegExp that it does not consider - * if a HTML comment is specified within a String or data-definition - * (i.e. the comment is matched regardless were its defined). - * - * @example - * @property html_comment_regex - * @type String|RegExp - * @public - */ - html_comment_regex: //igm, - - /** - * Regular Expression to identify content in a view that will be inserted.
- * The content is generated by a helper function of the controller and usually saved as a JSON-Object with a _helper_ and _content_ part.
- * If the string is escaped and must be unescaped a second parameter can be given to ensure that the string will be unescaped before the insertion in the view. - * - * @deprecated old template syntax format - * - * @example <%= value_of(languageMenu::header, true) %> - * @property value_of_regex - * @type String|RegExp - * @public - */ - value_of_regex: /<%=\s*value_of\s*\(([^\)]*)\)\s*%>/igm, - - /** - * See Property: {@link mobileDS.CommonUtils-constructor.value_of_regex}
- * This regular expression is an extension to parse the parameters of the value_of-function.
- * - * Regular Expression to identify content in a view that will be inserted.
- * The content is generated by a helper function of the controller and usually saved as a JSON-Object with a _helper_ and _content_ part.
- * If the string is escaped and must be unescaped a second parameter can be given to ensure that the string will be unescaped before the insertion in the view. - * - * @deprecated old template syntax format - * - * @example <%= value_of(languageMenu::header, true) %> - * @property value_of_path_regex - * @type String|RegExp - * @public - */ - value_of_path_regex: /\(\s*([^\),]*),?\s*([^\)]*)\s*\)/i, - - /** - * Regular Expression to identify if a partial is to be inserted in a view.
- * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * @deprecated old template syntax format - * - * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> - * @property render_partial_regex - * @type String|RegExp - * @public - */ - render_partial_regex: /<%\s*render\s*([^\s]*)\s*\{([^\}]*)\}\s*%>/igm, - - /** - * See Property: {@link mobileDS.CommonUtils-constructor.render_partial_regex}
- * This regular expression is an extension for the parsing of the parameters of the partial (for customization).
- * - * Regular Expression to identify if a partial is to be inserted in a view.
- * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * @deprecated old template syntax format - * - * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> - * @property partial_parameter_regex - * @type String|RegExp - * @public - */ - partial_parameter_regex: /\s*:(\S*)\s*=>\s*(("([\S ]+)")|([^,]+))/i, - - /** - * See Property: {@link mobileDS.CommonUtils-constructor.render_partial_regex}
- * This regular expression is an extension for the parsing of the parameters of the partial (for customization) to get the name of the corresponding controller of the partial.
- * - * Regular Expression to identify if a partial is to be inserted in a view.
- * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * @deprecated old template syntax format - * - * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> - * @property partial_name_regex - * @type String|RegExp - * @public - */ - partial_name_regex: /^([^\/]+)\/(.+)$/i, - - /** - * Regular expression for the parsing of partial-files.
- * This expression detects all variables and data-instructions for the customization of the partial. There are 3 types of variables or instructions: - * - * + if-else-statement, controls which part of the partial will be displayed - depending on the condition - * + data-instruction, which is evaluated, but not displayed - * + variable or javascript-code, which are evaluated and displayed in the view - * - * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * @deprecated old template syntax format - * - * @example {::address = address + " " + {:curr_poi_data}.query('addressBean/housenumber')} - * @property partial_var_pattern_regex - * @type String|RegExp - * @public - */ - partial_var_pattern_regex: /(\{[^\}\{]+\})|(\{[^\{]*(\{(?=[^\}]*\}).*)\})/gmi, - - /** - * Regular expression for the parsing of partial-files.
- * This expression detects all simple variables for the customization of the partial in the form of {:curr_poi_data}.
- * Form of simple object: {:SIMPLE_OBJECT}
- * - * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * - * @deprecated old template syntax format - * - * @example {:curr_poi_data} - * @property partial_var_pattern_simpleobject_regex - * @type String|RegExp - * @public - */ - partial_var_pattern_simpleobject_regex: /\{:([^\}]+)\}/, - - /** - * Regular expression for the parsing of partial-files.
- * This expression detects all data objects for the customization of the partial in the form of {::curr_poi_data={:curr_poi_data_jpath}}.
- * Form of data object: {::DATA_OBJECT}
- * - * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
- * A partial is first processed and then integrated into the view. - * - * - * @deprecated old template syntax format - * - * @example {::address = address + "<br/>"} - * @property partial_var_pattern_dataobject_regex - * @type String|RegExp - * @public - */ - partial_var_pattern_dataobject_regex: /\{::([^\}\{]+)\}|\{::([^\{]*(?:\{(?:[^\}]*\}).*))\}/ig, - - /** - * Regular expression for detecting an assignment expression in templates, - * e.g. {::theVariable=... }. - * - * - * @deprecated old template syntax format - * - * @example {::address = address + "<br/>"} or {::address = {:anotherVariable} + "<br/>"} - * @property partial_var_pattern_assignment_regex - * @type String|RegExp - * @public - */ - partial_var_pattern_assignment_regex: /\{::([^\}\{=]+)=([^\}\{]+)\}|\{::([^\}\{=]+)=([^\{]*(?:\{(?:[^\}]*\}).*))\}/ig, - -// /** -// * Deprecated regular expression for partials. -// * @property partial_var_pattern_object_with_function_regex -// * @type String|RegExp -// * @public -// * @deprecated unused -// */ -// partial_var_pattern_object_with_function_regex: /\{?([^\.]+)([\.\[])([^\s\}]+)()/ig, - - /** - * Function which transforms a ehtml string (while parsing views) into html by replacing stylesheet-, javascript- and content_for-tags with corresponding contents. - * - * - * @deprecated used for parsing/rendering old template syntax format - * - * @function ehtml2Html - * @param {String} eHtmlTag A string that should be transformed from ehtml to html - * @public - * @returns {String} From ehtml into html transformed string - */ - ehtml2Html: function(eHtmlTag){ - - var result; - if (eHtmlTag.match(styleSheetRegExp)) { - var group = eHtmlTag.match(styleSheetRegExp); - result = eHtmlTag.replace(group[1], "link rel=\"stylesheet\" ").replace(group[2], "href=\"content/stylesheets/" + group[3] + ".css\"/"); - }else if (eHtmlTag.match(javaScriptRegExp)) { - var group = eHtmlTag.match(javaScriptRegExp); - result = eHtmlTag.replace(group[1], "script type=\"text/javascript\" charset=\"utf-8\" ").replace(group[2], "src=\"javascripts/" + group[3] + ".js\">' to header - // thus loading it dynamically - var newScript = document.createElement('script'); - newScript.type="text/javascript"; - newScript.src=scriptSrc; - document.head.appendChild(newScript); - }, - - /** - * Similar to the jQuery.getScript() function - appending a url of a javascript-source to the header of the main document.
- * This function also calls a callback if the script was loaded. - * @function loadScript - * @param {String} url source of javascript-file - * @param {Function} callback callback function - * @public - * @async - * @deprecated superseded by getLocalScript - */ - loadScript: function (url, callback){ - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = url; - - if (typeof callback === 'function'){ - script.onload = function(){ - callback(); - }; - } - document.getElementsByTagName("head")[0].appendChild(script); - }, - - /** - * Function which transforms a ehtml string (while parsing views) into html by replacing stylesheet-, javascript- and content_for-tags with corresponding contents. - * @function loadAllPhonegapPlugins - * @param {String} pluginspath Path of the plugins which should be loaded, e.g. file:///android_asset/www/javascripts/plugins/ - * @param {Function} cbFunction The function that should be executed after the plugins are loaded. If the execution of following functions is dependent on the present of plugins they should be capsuled inside the callback-function. - * @async - * @public - */ - loadAllPhonegapPlugins: function (pluginsPath, cbFunction){ - var self = this; - // reads all *.js files under /assets/www/javascript/plugins - // and loads them dynamically - // IMPORTANT: the Plugin "DirectoryListing" MUST be present and loaded - // the javascript file directoryDisting.js respectively - // Also important: ALL Plugins must be present in the /res/plugins.xml file! - - function loadAllPluginFilesCB(data){ - if (data.length < 1){ - if (typeof cbFunction == 'function'){ - cbFunction(); - } else { - console.warn("[loadAllPluginFilesCB] callback-Parameter is not a function."); - } - } else { - var tmpPlugin = data[0]; - if (window.plugins[tmpPlugin.replace(/\.[^.]+$/g,"")]){ - - if(IS_DEBUG_ENABLED) console.info("[DEBUG] Plugin already loaded " + tmpPlugin);//debug - - data = data.slice(1); - loadAllPluginFilesCB(data); - } else { - - /// ATTENTION: $.getScript --> mobileDS.CommonUtils.getInstance().getLocalScript - /// under Android 4.0 getScript is not wokring properly - mobileDS.CommonUtils.getInstance().getLocalScript(pluginsPath+tmpPlugin, - function(){ - - if(IS_DEBUG_ENABLED) console.debug("[DEBUG] Loaded " + pluginsPath+tmpPlugin);//debug - - data = data.slice(1); - loadAllPluginFilesCB(data); - }, - function(exception) { - // print out an error message - console.error("[ERROR] Could not load '" + pluginsPath+tmpPlugin + "': "+ exception); //failure - }); - } - } - } - //console.log('about to load all plugins from path "'+pluginsPath+'"...');//FIXME debug - loadAllPluginFilesCB(mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(pluginsPath, "*.js")); - - - }, - - /** - * Detects via the user-agent-string if the application is running on android. - * @function isRunningOnAndroid - * @public - * @returns {Boolean} True if application is running on android, False otherwise - * @deprecated unused - */ - isRunningOnAndroid: function (){ - // Testing if user-Agent-/ or appVersion-String contains 'android' - if ((navigator.userAgent.toLowerCase().indexOf("android")>-1) || (navigator.appVersion.toLowerCase().indexOf("android")>-1)){ - return true; - } else { - return false; - } - }, - - /** - * Should detect - via the user-agent-string - if the application is running on android, symbian or ios; in other words: on a smartphone. - * @function isRunningOnSmartphone - * @public - * @returns {Boolean} True if application is running on smartphone, False otherwise - * @deprecated unused - */ - isRunningOnSmartphone: function (){ - // Testing if user-Agent-/ or appVersion-String contains 'android' or 'iOS' - // at the moment only android-, ios and symbian-strings are 'implemented' - var testString = navigator.userAgent.toLowerCase() + navigator.appVersion.toLowerCase(); - if ((testString.indexOf("android")>-1) || (testString.indexOf("ios")>-1) || (testString.indexOf("symbian")>-1)){ - return true; - } else { - return false; - } - }, - - /** - *
- * Note: - * On Android 4.0 jQuery.getScript() is not working properly - so use this function instead! - *
- * - * Similar to the jQuery.getScript() function - appending a url of a javascript-source to the header of the main document.
- * This function also calls a success-callback if the script was successfully loaded or a fail-callback.
- * - * - * @function getLocalScript - * @param {String} scriptUrl source of javascript-file - * @param {Function} success success callback function - * @param {Function} fail fail callback function - * @async - * @public - */ - getLocalScript: function (scriptUrl, success, fail){ - var head = document.getElementsByTagName("head")[0]; - script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = scriptUrl; - script.onload = function() { success && success(); }; - script.onerror = function(e) { - if(IS_DEBUG_ENABLED) console.info("Insert Script Failed - " + scriptUrl + ": " + e); - fail && fail(e); - }; - head.appendChild(script); - }, - - /** - * This function returns an array of strings with the contents of a directory. - * @function getDirectoryContents - * @param {String} pathname Path of the directory which contents should be returned - * @public - * @returns {Array} Array of Strings which contains the contents of the directory - */ - getDirectoryContents: function(pathname){ - var retValue; - - pathname=stripPathName(pathname); - - try{ - retValue = this.directoryStructure[pathname]; - } catch(e){ - console.warn(e); - retValue = null; - } - return retValue; - }, - - /** - * This function returns an array of strings with the contents of a directory, giving only those files which match the filter. - * @function getDirectoryContentsWithFilter - * @param {String} pathname Path of the directory which contents should be returned - * @param {String} filter Filter of file-names: *.js, * or *.ehtml - * @public - * @returns {Array} Array of Strings which contains the contents of the directory - */ - getDirectoryContentsWithFilter: function(pathname, filter){ - var retValue = new Array(); - - var tmpfilter="^" + filter.replace(".","\\.").replace("*", ".*").replace("\$", "\\$") + "$"; - - var filterRegExp = new RegExp(tmpfilter, 'gi'); - - pathname=stripPathName(pathname); - - try{ - var tmp=this.directoryStructure[pathname]; - if (tmp == undefined){ - console.warn("["+pathname+" / " + filter + "] not found."); - retValue = null; - } else { - for (var i=0;iArray. - * - *

- * This function can be savely run in arbirtray contexts, e.g. - * - *

 var checkArray = mobileDS.CommonUtils.getInstance().isArray;
-             * if( checkArray(someObject) ){
-             *   ...
- * - * @function isArray - * @param {Object} object the Object for checking if it is an Array - * @public - * @returns {Boolean} true if object is an Array, otherwise false. - */ - isArray: function(object){ - return isArrayHelper(object); - }, - - /** - * This function iterates over all elements of a specific class and changes the font-size of the contained text to the maximal possible size - while still being small enough to fit in the element. - * @function html_resize_font_to_fit_surrounding_box - * @param {String} class_name Name of the class which inner text should be fitted to the size of the element - * @public - */ - html_resize_font_to_fit_surrounding_box: function(class_name){ - // resize the font in box_fit-class, so that it won't overlap its div-box - $(function(){ - - var smallest_font=1000; - $( class_name ).each(function ( i, box ) { - var width = $( box ).width(), - html = '', - line = $( box ).wrapInner( html ).children()[ 0 ], - n = parseInt($( box ).css("font-size"), 10); - - $( box ).css( 'font-size', n ); - - while ( $( line ).width() > width ) { - $( box ).css( 'font-size', --n ); - } - - $( box ).text( $( line ).text() ); - - n = parseInt($( box ).css("font-size"), 10); - - if (n < smallest_font){ - smallest_font = n; - } - }); - - $( class_name ).each(function ( i, box ) { - $( box ).css( 'font-size', smallest_font ); - }); - }); - }, - - /** - * Converts the object to a valid JSON String value. - * - * Ensures that the returned value does not contain (un-escaped) double-quotes, so that - * the returned value can be used as a JSON value, e.g.
- * @example var jsonValue = to_json_string_value(someValue); - * var data = JSON.parse('"theValue":"' + jsonValue + '"'); - * @function to_json_string_value - * @param {Object} theObjectValue the object to convert to a JSON String value. If NULL or UNDEFINED, an EMPTY String will be returned - * @returns {String} the String value - * @public - */ - to_json_string_value: function(theObjectValue){ - if(typeof theObjectValue !== 'undefined' && theObjectValue !== null){ - if(typeof theObjectValue !== 'string'){ - theObjectValue = theObjectValue.toString(); - } - theObjectValue = theObjectValue.escapeDoubleQuotes(); - } else { - theObjectValue = ''; - } - return theObjectValue; - }, - - - /** - * Converts the object to a valid JSON String value. - * - * Ensures that the returned value does not contain (un-escaped) double-quotes, so that - * the returned value can be used as a JSON value, also does replace all newlines with the - * HTML-equivalent '<br/>', e.g. - * @example var jsonValue = to_json_string_value(someValue); - * var data = JSON.parse('"theValue":"' + jsonValue + '"'); - * ... - * @function convert_to_json_value_HTML_string - * @param {Object} theObjectValue the object to convert to a JSON String value. If NULL or UNDEFINED, an EMPTY String will be returned - * @returns {String} the String value - * @public - */ - convert_to_json_value_HTML_string: function(str){ - if(typeof str !== 'undefined' && str !== null){ - if(typeof str !== 'string'){ - str = str.toString(); - } - //escape double-quotes, if necessary - //replace (all variants of) newlines with HTML-newlines - str = str.escapeDoubleQuotes().replaceAll('\r\n','
').replaceAll('\n','
').replaceAll('\r','
'); - } else { - str = ''; - } - return str; - - }, - - convert_json_to_HTML_string: function(_o){ -// var parse = function(_o){ - var a = new Array(), t; - for(var p in _o){ - if(_o.hasOwnProperty(p)){ - t = _o[p]; - if (t != null){ - if(t && typeof t == "object"){ - a[a.length]= p + ":{ " + arguments.callee(t).join(", ") + "}"; - } else { - if(typeof t == "string"){ - a[a.length] = [ p+ ": \"" + t.toString() + "\"" ]; - } else{ - a[a.length] = [ p+ ": " + t.toString()]; - } - } - } - } - } -// return a; -// }; -// return "{" + parse(o).join(", ") + "}"; - - return "{" + a.join(", ") + "}"; - }, - - /** - * Reformat the String representation of a date. - * - * @example converts 2012-07-23 16:37:33.0 into → 23. July 2012 - * - * @function get_date_as_string - * @param {String} the date String in format yyyy-mm-dd HH:mm:ss.S - * @param {String} [Optional] the language code (currently used to format the name of the month). Currently supported languages: en, de. If unkown or omitted, default en is used. - * @return {String} a new String representation for the date - * @public - */ - get_date_as_string: function(date, languageCode){ - var day, month, year; - var date_time = date.split(" "); - var splited_date = date_time[0].split("-"); - year = splited_date[0]; - month = splited_date[1]; - - //add leading zero if necessary - if(month.length == 1){ - month = '0'+month; - } - day = splited_date[2]; - - var theLanguage = typeof languageCode === 'string'? languageCode.toLowerCase() : null; - var monthName; - if(theLanguage !== null && languageCode !== 'en' && self.months[theLanguage]){ - //get language specific name for month, if possible - monthName = self.months[theLanguage][month]; - } else { - //get default name for month - monthName = self.months[month]; - } - return day +". "+monthName+" "+year; - }, - - /** - * Convert a duration (in seconds) into a String representation. - * - * @example 2:09:19 h, 12:05 min - * - * @function get_duration_as_string - * @param {Integer} the duration in seconds - * @return {String} a String representation for the duration - * @public - */ - get_duration_as_string: function (duration){ - var sec = duration % 60; - var min = (duration - sec) / 60; - - var hour = 0; - if(min > 59){ - min = min % 60; - hour = ((duration - (min*60))-sec) / 3600; - } - if(sec < 10 ){ - sec = "0"+sec; - } - if(min < 10){ - min = "0"+min; - } - - if(hour > 0){ - return hour+":"+min+":"+ sec + " h"; - } else { - return min+":"+sec + " min"; - } - - }, - /** - * Convert parameter-part of an URL to a "dictionary", containing - * the parameter keys and values - * - * @example ?id=5&name=heinz&name=kunzdict['id']=5, dict['name'] = ['heinz', 'kunz'] - * - * The returnd "dictionary" has the following functions: - *
    - *
  • has(String key): returns true if the dictionary contains an entry for key
  • - *
  • isMultiple(String key): returns true if the entry for key is an Array (i.e. the URL contained multiple values for this key)
  • - *
  • getKeys(): returns an Array with the keys (String) for all entries
  • - *
- * - * @function get_params_as_dict - * @param {String} the parameter-part of the URL, i.e. &... - * @return {Object} an "dictionary" for the parameters - * @public - */ - get_params_as_dict: function(urlParamsPartStrings){ - var dict = new Object(); - - dict.has = function(key){ - return typeof dict[key] !== 'undefined'; - }; - dict.isMultiple = function(key){ - //use not-allowed-as-part-of-parameter-name char & as prefix for meta-data 'isMultiple' on field 'key': - return typeof dict['&'+key] !== 'undefined' && dict['&'+key] === true; - }; - //use not-allowed-as-part-of-parameter-name char & as prefix for meta-data 'keys-list': - dict['&&keys'] = new Array(); - dict.getKeys = function(){ - return dict['&&keys']; - }; - - if(urlParamsPartStrings){ - if(typeof urlParamsPartStrings !== 'string'){ - urlParamsPartStrings = urlParamsPartStrings.toString(); - } - if(urlParamsPartStrings.length < 1){ - return dict;//////////////////////// EARLY EXIT /////////////////////////// - } - if(urlParamsPartStrings.charAt(0)==='?'){ - urlParamsPartStrings = urlParamsPartStrings.substring(1); - } - - var params = urlParamsPartStrings.split('&'); - var cur = null; - var keyValue = null; - var theKey = null; - var theValue= null; - for(var i_params = 0, size_params = params.length; i_params < size_params; ++ i_params) { - - cur = params[i_params]; - - //"parse" parameter into key & value: - keyValue = cur.split('='); - theKey = keyValue[0]; - if(keyValue.length > 1){ - theValue = keyValue[1]; - } - else { - theValue = null; - } - - //create entry in dict for the parameter - if(dict.has(theKey)){ - - if(dict.isMultiple(theKey)){ - dict[theKey].push(theValue); - } - else { - //entry already exist, but is not multiple (=Array) yet: - var arr = new Array(2); - arr[0] = dict[theKey]; - arr[1] = theValue; - dict[theKey] = arr; - dict['&'+theKey] = true; - } - } - else { - dict[theKey] = theValue; - dict['&&keys'].push(theKey); - } - } - } - return dict; - }, - /** - * This function is used check whether a network connection is enabled.
- * This version of checking the network connection is based on the cordova 2.3.0 API. - * - * TODO implement with HTML5 functions (in addition to / instead of cordova)? - * - * @function checkNetworkConnection - * @private - * @returns {Boolean} true if a network connection is enabled - */ - checkNetworkConnection: function() { - console.log("Check network status."); - var networkState = navigator.connection.type; - - var states = {}; - states[Connection.UNKNOWN] = 'Unknown connection'; - states[Connection.ETHERNET] = 'Ethernet connection'; - states[Connection.WIFI] = 'WiFi connection'; - states[Connection.CELL_2G] = 'Cell 2G connection'; - states[Connection.CELL_3G] = 'Cell 3G connection'; - states[Connection.CELL_4G] = 'Cell 4G connection'; - states[Connection.NONE] = 'No network connection'; - - if (Connection.NONE === networkState){ - //alert('Connection type: ' + states[networkState]); - return false; - } - return true; - }, - /** - * Parses the directory structure - paths given by property {@link mobileDS.CommonUtils-constructor-directoriesToParse} - and storing the result in the class-property {@link mobileDS.CommonUtils-directoryStructure} - * @function initialize - * @param {Function} cb The function that should be executed after the diretories are parsed - it's best to include all following functions inside the callback-function. - * @async - * @public - */ - initialize: function(cb){ - var self = this; - - window.plugins.directoryListing.getDirectoryStructure( - directoriesToParse, - function(dirStruct){ - - if(IS_DEBUG_ENABLED) console.debug(JSON.stringify(dirStruct));//debug - - self.directoryStructure = dirStruct; - - if(IS_DEBUG_ENABLED) console.debug("[getDirectoryStructure] finished.");//debug - if(IS_DEBUG_ENABLED) console.debug(JSON.stringify(dirStruct));//debug - - if ((cb) && (typeof cb == 'function')){ - cb.call(); - } - }, - function(e){ - console.error("[ERROR] " + e); - } - ); - } - - }; - } - - return { - /** - * Object containing the instance of the class {@link mobileDS.CommonUtils} - * - * @function getInstance - * @returns {Object} Object containing the instance of the class {@link mobileDS.CommonUtils} - * @public - */ - getInstance: function(){ - if (instance === null) { - instance = constructor(); - } - return instance; - } - }; - - -})(); diff --git a/assets/www/javascripts/tools/queue.js b/assets/www/javascripts/tools/queue.js deleted file mode 100644 index f73a97b..0000000 --- a/assets/www/javascripts/tools/queue.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012-2013 DFKI GmbH - * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz - * German Research Center for Artificial Intelligence - * http://www.dfki.de - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - -Queue.js - -A function to represent a queue - -Created by Stephen Morley - http://code.stephenmorley.org/ - and released under -the terms of the CC0 1.0 Universal legal code: - -http://creativecommons.org/publicdomain/zero/1.0/legalcode - -*/ - -/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure - - * items are added to the end of the queue and removed from the front. - */ -function Queue(){ - - // initialise the queue and offset - var queue = []; - var offset = 0; - - /* Returns the length of the queue. - */ - this.getLength = function(){ - - // return the length of the queue - return (queue.length - offset); - - } - - /* Returns true if the queue is empty, and false otherwise. - */ - this.isEmpty = function(){ - - // return whether the queue is empty - return (queue.length == 0); - - } - - /* Enqueues the specified item. The parameter is: - * - * item - the item to enqueue - */ - this.enqueue = function(item){ - - // enqueue the item - queue.push(item); - - } - - /* Dequeues an item and returns it. If the queue is empty then undefined is - * returned. - */ - this.dequeue = function(){ - - // if the queue is empty, return undefined - if (queue.length == 0) return undefined; - - // store the item at the front of the queue - var item = queue[offset]; - - // increment the offset and remove the free space if necessary - if (++ offset * 2 >= queue.length){ - queue = queue.slice(offset); - offset = 0; - } - - // return the dequeued item - return item; - - } - - /* Returns the item at the front of the queue (without dequeuing it). If the - * queue is empty then undefined is returned. - */ - this.peek = function(){ - - // return the item at the front of the queue - return (queue.length > 0 ? queue[offset] : undefined); - - } - -} diff --git a/assets/www/javascripts/3rdParty/childbrowser.js b/assets/www/libs/childbrowser.js similarity index 100% rename from assets/www/javascripts/3rdParty/childbrowser.js rename to assets/www/libs/childbrowser.js diff --git a/assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.datebox.js b/assets/www/libs/datebox/jqm-datebox-1.4.0.comp.datebox.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.datebox.js rename to assets/www/libs/datebox/jqm-datebox-1.4.0.comp.datebox.js diff --git a/assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.datebox.min.js b/assets/www/libs/datebox/jqm-datebox-1.4.0.comp.datebox.min.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.datebox.min.js rename to assets/www/libs/datebox/jqm-datebox-1.4.0.comp.datebox.min.js diff --git a/assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.flipbox.js b/assets/www/libs/datebox/jqm-datebox-1.4.0.comp.flipbox.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.flipbox.js rename to assets/www/libs/datebox/jqm-datebox-1.4.0.comp.flipbox.js diff --git a/assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.flipbox.min.js b/assets/www/libs/datebox/jqm-datebox-1.4.0.comp.flipbox.min.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jqm-datebox-1.4.0.comp.flipbox.min.js rename to assets/www/libs/datebox/jqm-datebox-1.4.0.comp.flipbox.min.js diff --git a/assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox-1.0.1.js b/assets/www/libs/datebox/jquery.mobile.datebox-1.0.1.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox-1.0.1.js rename to assets/www/libs/datebox/jquery.mobile.datebox-1.0.1.js diff --git a/assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox-1.0.1.min.js b/assets/www/libs/datebox/jquery.mobile.datebox-1.0.1.min.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox-1.0.1.min.js rename to assets/www/libs/datebox/jquery.mobile.datebox-1.0.1.min.js diff --git a/assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox.i18n.de.utf8.js b/assets/www/libs/datebox/jquery.mobile.datebox.i18n.de.utf8.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox.i18n.de.utf8.js rename to assets/www/libs/datebox/jquery.mobile.datebox.i18n.de.utf8.js diff --git a/assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox.i18n.en.utf8.js b/assets/www/libs/datebox/jquery.mobile.datebox.i18n.en.utf8.js similarity index 100% rename from assets/www/javascripts/3rdParty/datebox/jquery.mobile.datebox.i18n.en.utf8.js rename to assets/www/libs/datebox/jquery.mobile.datebox.i18n.en.utf8.js diff --git a/assets/www/javascripts/3rdParty/facebook.js b/assets/www/libs/facebook.js similarity index 100% rename from assets/www/javascripts/3rdParty/facebook.js rename to assets/www/libs/facebook.js diff --git a/assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.extensions.js b/assets/www/libs/googleMap/jquery.ui.map.extensions.js similarity index 100% rename from assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.extensions.js rename to assets/www/libs/googleMap/jquery.ui.map.extensions.js diff --git a/assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.js b/assets/www/libs/googleMap/jquery.ui.map.js similarity index 100% rename from assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.js rename to assets/www/libs/googleMap/jquery.ui.map.js diff --git a/assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.services.js b/assets/www/libs/googleMap/jquery.ui.map.services.js similarity index 100% rename from assets/www/javascripts/3rdParty/googleMap/jquery.ui.map.services.js rename to assets/www/libs/googleMap/jquery.ui.map.services.js diff --git a/assets/www/javascripts/3rdParty/jquery-ui-1.10.3.js b/assets/www/libs/jquery-ui-1.10.3.js similarity index 100% rename from assets/www/javascripts/3rdParty/jquery-ui-1.10.3.js rename to assets/www/libs/jquery-ui-1.10.3.js diff --git a/assets/www/mmirf/env/media/cordovaAudioOutput.js b/assets/www/mmirf/env/media/cordovaAudioOutput.js new file mode 100644 index 0000000..290b6d1 --- /dev/null +++ b/assets/www/mmirf/env/media/cordovaAudioOutput.js @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +newMediaPlugin = { + initialize: function(callBack){ + var counter = 0; + var callbackArray = new Array(); + callBack({ + playWav: function(blob, successCallback, failureCallback){ + try { + var blobURL = window.URL.createObjectURL(blob); + var my_media = new Media( + blobURL, + function(){ + console.log('WAV Audio created'); + + my_media.release();//TODO if my_media object is to be re-used, do not release immediately... + if(successCallback){ + successCallback(); + } + },failureCallback + ); + + my_media.play(); + + } catch (e){ + if(failureCallback){ + failureCallback(e); + } + } + }, + playURL: function(url, successCallback, failureCallback){ + try { + console.log(url); + var my_media = new Media( + url, + function(){ + console.log('Audio created'); + + my_media.release();//TODO if my_media object is to be re-used, do not release immediately... + if(successCallback){ + successCallback(); + } + } , + failureCallback + ); + + my_media.play(); + } catch (e){ + if(failureCallback){ + failureCallback(e); + } + } + }, + getURLAsAudio: function(url, onEnd, failureCallback, onCanPlay){ + //if (onCanPlay) onCanPlay(); + //successCallBack = function (){console.log("this isgetURLAsAudio"); successCallBack();}; + // console.log(successCallBack); + // var onCanPlay = function (){ console.log("oncanplay "); + // successCallBack(); + // }; + try { + var onEndId = counter++; + var onCanPlayId = counter++; + var onFailureId = counter++; + callbackArray.push(onEnd); + callbackArray.push(onCanPlay); + callbackArray.push(failureCallback); + // var playOnReady = false; + console.log(url); + var my_media = null; + + my_media = new Media( + url,function(){console.log('native onReady CB');} + , + failureCallback, + function(status){ + console.log("status change!"+status); + //status = state; + if (status==1){ + var onCanPlay = mobileDS.MediaManager.getInstance().getCallback(onCanPlayId); + if (onCanPlay) onCanPlay(); + } else if (status==2) + { + console.log("Audio starting"); + } + else if(status == 4){ + var onEnd = mobileDS.MediaManager.getInstance().getCallback(onEndId); + if (onEnd) onEnd(); + } + } + ); + var enabled = true; + return { + play: function(){ + if (enabled){ + my_media.play(); + }; + }, + enable: function(){ + enabled = true; + }, + disable: function(){ + my_media.stop(); + enabled = false; + }, + release: function(){ + enabled= false; + callbackArray[onEndId] = null; + callbackArray[onCanPlayId] = null; + callbackArray[onFailureId] = null; + + } + }; + } catch (e){ + console.log(e); + if(failureCallback){ + failureCallback(e); + } + } + }, + getCallback: function(id){ + return callbackArray[id]; + } + }); + } +} \ No newline at end of file diff --git a/assets/www/javascripts/mediators/cordovaGoogleAudioOutput.js b/assets/www/mmirf/env/media/cordovaGoogleAudioOutput.js similarity index 100% rename from assets/www/javascripts/mediators/cordovaGoogleAudioOutput.js rename to assets/www/mmirf/env/media/cordovaGoogleAudioOutput.js diff --git a/assets/www/mmirf/env/media/html5AudioInput.js b/assets/www/mmirf/env/media/html5AudioInput.js new file mode 100644 index 0000000..f3951c8 --- /dev/null +++ b/assets/www/mmirf/env/media/html5AudioInput.js @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +newMediaPlugin = { + + initialize: function(callBack){ + + function htmlAudioConstructor(){ + // variable that describes if recording is in process + var recording = false; + var webSocket = null; + var nonFunctional = false; + var inputId = 1; + var audio_context=null; + var stream = null; + var recorder=null; + //the function that is called on the recognized text that came back from the server + var textProcessor = function(e,id){}; + var silenceDetection = null; + var silenceDetectionInput = null; + + //for gathering partial ASR results when using startRecord: + var recordAsrResultCache = []; + var recordAsrResultSorter = function(a,b){return a.id - b.id;}; + var asrResultCacheToString = function(cache){ + var size = cache.length; + var sb = new Array(size);//use "StringBuffer" for concatenating partial results + for(var i = 0; i < size; ++i){ + sb[i] = cache[i].text; + } + return sb.join(''); + }; + var recordAsrResultAggregator = function printResult(res,id){ + recordAsrResultCache.push({ + text: res, + id:id + }); + recordAsrResultCache.sort(recordAsrResultSorter); + + //FIXME debug output: + console.debug( asrResultCacheToString(recordAsrResultCache) ); + }; + + /** initializes the connection to the googleMediator-server, + * where the audio will be sent in order to be recognized. **/ + function initializeWebSocket(){ + webSocket = new WebSocket(mobileDS.ConfigurationManager.getInstance().get("HTML5InputWebSocketAddress")); + webSocket.onopen = function () { + if(IS_DEBUG_ENABLED) console.log("Openened connection to websocket"); + }; + + webSocket.onmessage = function(e) { + var id = e.data.substring(0,e.data.indexOf("_")); + var jsonText = e.data.substring(e.data.indexOf("_")+1, e.data.length); + var jsonResponse = jQuery.parseJSON(jsonText ); + if (jsonResponse.hypotheses.length>0){ + if(textProcessor){ + textProcessor(jsonResponse.hypotheses[0].utterance, id); + } + + //aggregate / gather text-parts into the recordAsrResultCache: + recordAsrResultAggregator(jsonResponse.hypotheses[0].utterance, id); + } + }; + webSocket.onerror = function(e) { + console.log('Websocket Error: '+e); + // initializeWebSocket(); + }; + } + /** + * creates a new AudioNode, that communicates sound to the silence detector + */ + function startNewInputNode(){ + if (silenceDetectionInput) { + silenceDetectionInput.onaudioprocess= function(e){}; + } + var input = audio_context.createMediaStreamSource(stream); + silenceDetectionInput = input.context.createJavaScriptNode(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSoundPackageSize"), 2, 2); + silenceDetectionInput.onaudioprocess = function(e){ + if (recording){ + silenceDetection.postMessage({ + command: 'isSilent', + buffer: e.inputBuffer.getChannelData(0) + }); + } + }; + input.connect(silenceDetectionInput); + silenceDetectionInput.connect(input.context.destination); + + } + + /** + * creates Silence detector and recorder and connects them to the input stream + * @param inputstream + */ + function startUserMedia(inputstream){ + stream = inputstream; + var input = audio_context.createMediaStreamSource(stream); + recorder = new Recorder(input); + silenceDetection = new Worker(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceDetectorPath")); + silenceDetection.onmessage = function (e){ + if(IS_DEBUG_ENABLED) console.log(e.data); + if (e.data=='Silence detected!'){ + // send record to server! + recorder && recorder.exportWAV(function(blob, id){ + if(IS_DEBUG_ENABLED) console.log("wav exported"); + if(blob.size>2000000) { + console.log("Message too large. You need to pause from time to time."); + } else + { + //mobileDS.MediaManager.getInstance().playWAV(blob,function(){},function(){alert("could not play blob");}); + webSocket.send("clear"); + webSocket.send("language "+mobileDS.ConfigurationManager.getInstance().getLanguage()); + webSocket.send("start "+inputId); + webSocket.send(blob); + webSocket.send("analyze "+inputId++); + } + }, mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceBuffer"),inputId); + } + if (e.data=='clear'){ + recorder.clear(mobileDS.ConfigurationManager.getInstance().get("HTML5InputSilenceBuffer")); + } + }; + silenceDetection.postMessage({ + command: 'init', + config: { + sampleRate: input.context.sampleRate, + noiseTreshold : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorNoiseTreshold"), + pauseCount : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorPauseCount"), + resetCount : mobileDS.ConfigurationManager.getInstance().get("SilenceDetectorResetCount") + } + }); + }//END: startUserMedia + + try { + // unify the different kinds of HTML5 implementations + //window.AudioContext = window.AudioContext || window.webkitAudioContext; + html5Navigator.getUserMedia = html5Navigator.getUserMedia || html5Navigator.webkitGetUserMedia || html5Navigator.mozGetUserMedia; + //window.URL = window.URL || window.webkitURL; + audio_context = new webkitAudioContext; + } + catch (e) { + console.error('No web audio support in this browser!'); + nonFunctional = true; + } + + if( nonFunctional !== true ) try { + initializeWebSocket(); + } catch (e) { + console.error('Could not reach the voice recognition server!'); + nonFunctional = true; + } + + if (nonFunctional) { + return {};///////////////////////////// EARLY EXIT ////////////////////////////// + } + + // get audioInputStream + html5Navigator.webkitGetUserMedia({audio: true}, startUserMedia, function(e) {}); + + return { + startRecord: function(callBack){ + textProcessor = callBack; + silenceDetection && startNewInputNode(); + recording=true; + recorder && recorder.clear(); + recorder && recorder.record(); + silenceDetection && silenceDetection.postMessage({command: 'start'}); + }, + stopRecord: function(successCallBack,failureCallBack){//blobHandler){ + recording=false; + recorder && recorder.stop(); + recorder && recorder.exportWAV(function (blob) { + webSocket.send("clear"); + webSocket.send("start "+inputId); + webSocket.send(blob); + webSocket.send("stop"); + webSocket.send("analyze "+inputId++); + webSocket.send("clear"); +// blobHandler(blob); + if(successCallBack){ + successCallBack( recordAsrResultCache.join('') ); + } + + //reset result-cache: + recordAsrResultCache = []; + }); + silenceDetection && silenceDetection.postMessage({command: 'stop'}); + }, + recognize: function(successCallBack,failureCallBack){ + textProcessor = successCallBack; + recorder && recorder.stop(); + silenceDetection && silenceDetection.postMessage({command: 'stop'}); + recorder && recorder.exportWAV(function(blob){ + webSocket.send("clear"); + webSocket.send("start "+ inputId); + webSocket.send(blob); + webSocket.send("stop"); + webSocket.send("analyze "+ inputId++); + webSocket.send("clear"); + }); + } + };//END: return + };//END: htmlAudioConstructor() + + // the code starts here, loads the necessary scripts and then calls htmlAudioConstructor + mobileDS.CommonUtils.getInstance().loadScript(mobileDS.constants.getInstance().getWorkerPath()+'recorderWorker.js',function(){ + mobileDS.CommonUtils.getInstance().loadScript('mmirf/env/media/recorder.js', function(){ + callBack(htmlAudioConstructor()); + }); + }); + }//END: initialize() + +}; \ No newline at end of file diff --git a/assets/www/mmirf/env/media/html5AudioOutput.js b/assets/www/mmirf/env/media/html5AudioOutput.js new file mode 100644 index 0000000..e37d36f --- /dev/null +++ b/assets/www/mmirf/env/media/html5AudioOutput.js @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +newMediaPlugin = { + initialize: function(callBack){ + + var audio_context=null; + try { + // unify the different kinds of HTML5 implementations + //window.AudioContext = window.AudioContext || window.webkitAudioContext; + //window.URL = window.URL || window.webkitURL; + audio_context = new webkitAudioContext; + } + catch (e) { + console.error('No web audio support in this browser!'); + } + + callBack({ + playWAV: function(blob, successCallback, failureCallback){ + try { + blobURL = window.webkitURL.createObjectURL(blob); + var my_audio = new Audio(blobURL,null,failureCallback); + if(successCallback){ + my_audio.addEventListener('ended', successCallack, false); + } + my_audio.play(); + } catch (e){ + if(failureCallBack){ + failureCallBack(e); + } + } + }, + playURL: function(url, onEnd, failureCallBack, successCallback){ + try { + + var my_media = new Audio(url,null,failureCallback); + my + if(successCallback){ + my_media.addEventListener('ended', onEnd, false); + my_media.addEventListener('canplay', successCallback, false); + } + my_media.play(); + } catch (e){ + if(failureCallback){ + failureCallback(e); + } + } + }, + getURLAsAudio: function(url, onEnd, failureCallback, successCallback){ + try { + var ready = false; + var my_media = new Audio(url,null,failureCallback); + if (onEnd){ + my_media.addEventListener('ended', onEnd, false); + } + + my_media.addEventListener('canplay', function(){ + ready = true; + console.log("sound is ready!"); + if (successCallback) successCallback(); + }, false); + var enabled = true; + return { + play: function(){ + if (enabled){ + // if (ready){ + my_media.play(); + // } else { + // my_media.addEventListener('canplay', my_media.play, false); + // } + + }; + }, + enable: function(){ + enabled = true; + }, + disable: function(){ + my_media.stop(); + enabled = false; + }, + release: function(){ + enabled= false; + my_media=null; + } + }; + } catch (e){ + if(failureCallback){ + failureCallback(e); + } + } + } + }); + } +}; + diff --git a/assets/www/mmirf/env/media/maryTextToSpeech.js b/assets/www/mmirf/env/media/maryTextToSpeech.js new file mode 100644 index 0000000..1a9b9fa --- /dev/null +++ b/assets/www/mmirf/env/media/maryTextToSpeech.js @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +newMediaPlugin = { + initialize: function(callBack){ + var onEndCallBack= null; + var currentFailureCallBack = null; + var isReady= true; + var ttsMedia = null; + var playIndex = 0; + var firstSentence = true; + var loadIndex = 0; + var isLoading = false; + var bufferSize = 3; + var audioArray = []; + var sentenceArray = []; + var pauseDuration = 1000; + var defaultSplitter = function(text){ + text = text.replace(/\.\s|\?\s|\!\s/g,"#"); + return text.split("#"); + } + var generateTTSURL = function(text){ + text = text.replace(/\s/g, '%20'); + var speaker = window.mobileDS.LanguageManager.getInstance().getSpeaker(); + var lang = speaker["lang_simple"]; + var voice = speaker["speaker"]; + return window.mobileDS.ConfigurationManager.getInstance().get("HTML5OutputServerBasePath")+'process?INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&INPUT_TEXT=' + text + '&LOCALE='+lang+'&VOICE='+voice+'&AUDIO=WAVE_FILE'; + }; + + var playNext = function playNext(){ + playIndex++; + if (playIndex<(audioArray.length)){ + ttsMedia=audioArray[playIndex]; + console.log("LongTTS playing "+playIndex+ " "+sentenceArray[playIndex]); + audioArray[playIndex].play(); + loadNext(); + } + else { + if (onEndCallBack){ + onEndCallBack(); + } + isReady = true; + } + }; + var ttsSingleSentence = function(text, onEnd, failureCallBack, onLoad){ + { + try { + isReady = false; + ttsMedia = mobileDS.MediaManager.getInstance().getURLAsAudio(generateTTSURL(text), + function(){ + isReady = true; + if(onEnd){ + onEnd(); + }; + }, + function(){ + isReady = true; + if (failureCallBack){ + failureCallBack(); + }; + }, + function(){ + if(onLoad){ + onLoad(); + }; + }); + ttsMedia.play(); + } catch (e){ + isReady=true; + console.log('error!'+e); + if (failureCallBack){ + failureCallBack(); + } + } + } + }; + var ttsSentenceArray = function(sentences, onEnd, failureCallBack){ + { + try { + firstSentence = true; + + //"clean up" texts in sentence array (ignore empty texts) + var size = sentences.length; + var theText = null; + + sentenceArray= []; + for(var i=0; i < size; ++i){ + if(sentences[i] && sentences[i].length > 0){ + theText = sentences[i].trim(); + if(theText.length > 0){ + sentenceArray.push(theText); + } + } + } + + onEndCallBack = onEnd; + currentFailureCallBack = failureCallBack; + playIndex = -1; + loadIndex = -1; + audioArray = new Array(sentences.length); + isLoading = false; + loadNext(); + } catch (e){ + isReady=true; + console.log('error! '+e); + if (failureCallBack){ + failureCallBack(); + } + } + } + }; + var loadNext = function loadNext(){ + if (isLoading) return null; + isLoading = true; + if (((loadIndex-playIndex)<= bufferSize) && (loadIndex<(audioArray.length-1))){ + var currIndex = ++loadIndex; + console.log("LongTTS loading "+currIndex+ " "+sentenceArray[currIndex]); + audioArray[currIndex] = mobileDS.MediaManager.getInstance().getURLAsAudio(generateTTSURL(sentenceArray[currIndex]), + function(){ + console.log("LongTTS done playing "+currIndex+ " "+sentenceArray[currIndex]); + audioArray[currIndex].release(); + setTimeout(playNext, pauseDuration); + }, + + function(){ + isReady = true; + if (currentFailureCallBack){ + currentFailureCallBack(); + }; + }, + function(){ + console.log("LongTTS done loading "+currIndex+ " "+sentenceArray[currIndex]); + isLoading = false; + loadNext(); + + }); + if (currIndex==0){ + playNext(); + } + loadNext(); + } + }; + + callBack({ + textToSpeech: function(parameter, successCallback, failureCallback){ + if (!isReady) { + if(failureCallback){ + failureCallback("TTS is already used at the moment."); + } + return; + } + isReady = false; + if ((typeof parameter) == 'string'){ + if(parameter.length === 0){ + isReady = true; + if(failureCallback){ + failureCallback("Aborted TTS: no text supplied (string has length 0)"); + } + return;/////////////////////////////////// EARLY EXIT ///////////////////////////// + } + ttsSingleSentence(parameter, successCallback, failureCallback); + } else if((typeof parameter !== 'undefined')&& mobileDS.CommonUtils.getInstance().isArray(parameter) ){ + ttsSentenceArray(parameter, successCallback, failureCallback); + } else if ((typeof parameter == 'object')){ + if (parameter.pauseDuration!== null && parameter.pauseDuration>=0){ + pauseDuration = parameter.pauseDuration; + console.log("PauseDuration: "+pauseDuration); + } else { + var configPause = mobileDS.ConfigurationManager.getInstance().get('pauseDurationBetweenSentences'); + if (configPause) { + pauseDuration = configPause; + } + else pauseDuration = 1000; + } + if ((typeof parameter.text !== 'undefined')&& mobileDS.CommonUtils.getInstance().isArray(parameter.text) ){ + if (parameter.forceSingleSentence){ + ttsSingleSentence(mobileDS.CommonUtils.getInstance().concatArray(parameter.text),successCallback, failureCallback); + } else { + ttsSentenceArray(parameter.text, successCallback, failureCallback); + } + } + if ((typeof parameter.text)== 'string'){ + if (parameter.split || parameter.splitter){ + var splitter = parameter.splitter || defaultSplitter; + ttsSentenceArray(splitter(parameter.text), successCallback, failureCallback); + } else { + ttsSingleSentence(parameter.text, successCallback, failureCallback); + } + } + } + }, + cancelSpeech: function(successCallBack, failureCallBack){ + try { + if (!isReady){ + ttsMedia.disable(); + } + audioArray.forEach(function (audio){ + if (audio) { + audio.stop(); + audio.release; + } + }); + isReady = true; + successCallBack(); + }catch (e){ + isReady = true; + if (failureCallBack) + failureCallBack(); + } + } + }); + } +}; \ No newline at end of file diff --git a/assets/www/javascripts/mediators/nuanceAudioInput.js b/assets/www/mmirf/env/media/nuanceAudioInput.js similarity index 96% rename from assets/www/javascripts/mediators/nuanceAudioInput.js rename to assets/www/mmirf/env/media/nuanceAudioInput.js index 4d11ddb..d80fd23 100644 --- a/assets/www/javascripts/mediators/nuanceAudioInput.js +++ b/assets/www/mmirf/env/media/nuanceAudioInput.js @@ -25,7 +25,7 @@ */ -newAudioInput = { +newMediaPlugin = { initialize: function(callBack){ callBack ({ startRecord: function(successCallBack, failureCallBack){ diff --git a/assets/www/javascripts/mediators/nuanceAudioOutput.js b/assets/www/mmirf/env/media/nuanceTextToSpeech.js similarity index 52% rename from assets/www/javascripts/mediators/nuanceAudioOutput.js rename to assets/www/mmirf/env/media/nuanceTextToSpeech.js index 517eb81..c80aad9 100644 --- a/assets/www/javascripts/mediators/nuanceAudioOutput.js +++ b/assets/www/mmirf/env/media/nuanceTextToSpeech.js @@ -25,8 +25,9 @@ */ -newAudioOutput = { +newMediaPlugin = { initialize: function(callBack){ + callBack({ textToSpeech: function (text, successCallBack, failureCallBack, startCallBack){ try{ @@ -54,75 +55,9 @@ newAudioOutput = { // -> switch back, when NuancePlugin returns PluginResults correctly... window.plugins.nuancePlugin.cancel(failureCallBack, successCallBack); }, - playWav: function(blob, successCallback, failureCallBack){ - try { - var blobURL = window.URL.createObjectURL(blob); - var my_media = new Media( - blobURL, - function(){ - console.log('WAV Audio created'); - - my_media.release();//TODO if my_media object is to be re-used, do not release immediately... - if(successCallback){ - successCallback(); - } - },failureCallBack - ); - - my_media.play(); - - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - }, - playURL: function(url, successCallback, failureCallBack){ - try { - console.log(url); - var my_media = new Media( - url, - function(){ - console.log('Audio created'); - - my_media.release();//TODO if my_media object is to be re-used, do not release immediately... - if(successCallback){ - successCallback(); - } - } , - failureCallBack - ); - - my_media.play(); - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - }, - getURLAsAudio: function(url, successCallback, failureCallBack){ - try { - console.log(url); - var my_media = new Media( - url, - function(){ - console.log('Audio created'); - -// my_media.release();//TODO if my_media object is to be re-used, do not release immediately... - if(successCallback){ - successCallback(); - } - } , - failureCallBack - ); - - return my_media; - } catch (e){ - if(failureCallBack){ - failureCallBack(e); - } - } - } - }); + longTTS: function(sentences, onEnd, failureCallBack){ + + } + }); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/assets/www/javascripts/mediators/recorder.js b/assets/www/mmirf/env/media/recorder.js similarity index 85% rename from assets/www/javascripts/mediators/recorder.js rename to assets/www/mmirf/env/media/recorder.js index 44ce5c7..eaee898 100644 --- a/assets/www/javascripts/mediators/recorder.js +++ b/assets/www/mmirf/env/media/recorder.js @@ -27,7 +27,7 @@ (function(window){ - var WORKER_PATH = 'javascripts/mediators/recorderWorker.js'; + var WORKER_PATH = 'mmirf/workers/recorderWorker.js'; var Recorder = function(source, cfg){ var config = cfg || {}; @@ -71,12 +71,8 @@ recording = false; } - this.clear = function(silenceBuffer){ - silenceBuffer = silenceBuffer || 0; - worker.postMessage({ - command: 'clear', - silenceBuffer: silenceBuffer - }); + this.clear = function(){ + worker.postMessage({ command: 'clear' }); } this.getBuffer = function(cb) { @@ -84,23 +80,19 @@ worker.postMessage({ command: 'getBuffer' }) } - this.exportWAV = function(cb, silenceBuffer, id, type){ + this.exportWAV = function(cb, type){ currCallback = cb || config.callback; - type = type || config.type || 'audio/wav'; - id = id || 0; - silenceBuffer = silenceBuffer || -1; + type = type || config.type || 'audio/wav'; if (!currCallback) throw new Error('Callback not set'); worker.postMessage({ command: 'exportWAV', - type: type, - silenceBuffer: silenceBuffer, - id: id + type: type }); } worker.onmessage = function(e){ - var blob = e.data.blob; - currCallback(blob, e.data.id); + var blob = e.data; + currCallback(blob); } source.connect(this.node); diff --git a/assets/www/javascripts/mediators/silenceDetection.js b/assets/www/mmirf/env/media/silenceDetection.js similarity index 90% rename from assets/www/javascripts/mediators/silenceDetection.js rename to assets/www/mmirf/env/media/silenceDetection.js index 593d35d..c48bbc3 100644 --- a/assets/www/javascripts/mediators/silenceDetection.js +++ b/assets/www/mmirf/env/media/silenceDetection.js @@ -30,6 +30,7 @@ var silenceCount = 0, //how many silent blobs have there been in a row now? lastInput = 0, // how long has there been no good loud input? recording= false, noiseTreshold = 0.1, //the bigger, the more is counted as silent + sampleRate = 0, pauseCount = 3, resetCount = 15; @@ -54,15 +55,10 @@ self.onmessage = function(e){ * @param config */ function init(config){ - if (config.noiseTreshold){ - noiseTreshold = config.noiseTreshold; - } - if (config.pauseCount) { - pauseCount = config.pauseCount; - } - if (config.resetCount) { - resetCount = config.resetCount; - } + if (config.sampleRate)sampleRate = config.sampleRate; + if (config.noiseTreshold) noiseTreshold = config.noiseTreshold; + if (config.pauseCount) pauseCount = config.pauseCount; + if (config.resetCount) resetCount = config.restCount; self.postMessage('Silence Detection initialized'); } diff --git a/assets/www/javascripts/gen/parser/ES3.tokens b/assets/www/mmirf/gen/parser/ES3.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/ES3.tokens rename to assets/www/mmirf/gen/parser/ES3.tokens diff --git a/assets/www/javascripts/gen/parser/ES3Lexer.js b/assets/www/mmirf/gen/parser/ES3Lexer.js similarity index 100% rename from assets/www/javascripts/gen/parser/ES3Lexer.js rename to assets/www/mmirf/gen/parser/ES3Lexer.js diff --git a/assets/www/javascripts/gen/parser/ES3Parser.js b/assets/www/mmirf/gen/parser/ES3Parser.js similarity index 100% rename from assets/www/javascripts/gen/parser/ES3Parser.js rename to assets/www/mmirf/gen/parser/ES3Parser.js diff --git a/assets/www/javascripts/gen/parser/MmirES3Walker.js b/assets/www/mmirf/gen/parser/MmirES3Walker.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirES3Walker.js rename to assets/www/mmirf/gen/parser/MmirES3Walker.js diff --git a/assets/www/javascripts/gen/parser/MmirES3Walker.tokens b/assets/www/mmirf/gen/parser/MmirES3Walker.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/MmirES3Walker.tokens rename to assets/www/mmirf/gen/parser/MmirES3Walker.tokens diff --git a/assets/www/javascripts/gen/parser/MmirScriptBlock.tokens b/assets/www/mmirf/gen/parser/MmirScriptBlock.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptBlock.tokens rename to assets/www/mmirf/gen/parser/MmirScriptBlock.tokens diff --git a/assets/www/javascripts/gen/parser/MmirScriptBlockLexer.js b/assets/www/mmirf/gen/parser/MmirScriptBlockLexer.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptBlockLexer.js rename to assets/www/mmirf/gen/parser/MmirScriptBlockLexer.js diff --git a/assets/www/javascripts/gen/parser/MmirScriptBlockParser.js b/assets/www/mmirf/gen/parser/MmirScriptBlockParser.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptBlockParser.js rename to assets/www/mmirf/gen/parser/MmirScriptBlockParser.js diff --git a/assets/www/javascripts/gen/parser/MmirScriptContent.tokens b/assets/www/mmirf/gen/parser/MmirScriptContent.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptContent.tokens rename to assets/www/mmirf/gen/parser/MmirScriptContent.tokens diff --git a/assets/www/javascripts/gen/parser/MmirScriptContentLexer.js b/assets/www/mmirf/gen/parser/MmirScriptContentLexer.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptContentLexer.js rename to assets/www/mmirf/gen/parser/MmirScriptContentLexer.js diff --git a/assets/www/javascripts/gen/parser/MmirScriptContentParser.js b/assets/www/mmirf/gen/parser/MmirScriptContentParser.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptContentParser.js rename to assets/www/mmirf/gen/parser/MmirScriptContentParser.js diff --git a/assets/www/javascripts/gen/parser/MmirScriptStatement.tokens b/assets/www/mmirf/gen/parser/MmirScriptStatement.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptStatement.tokens rename to assets/www/mmirf/gen/parser/MmirScriptStatement.tokens diff --git a/assets/www/javascripts/gen/parser/MmirScriptStatementLexer.js b/assets/www/mmirf/gen/parser/MmirScriptStatementLexer.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptStatementLexer.js rename to assets/www/mmirf/gen/parser/MmirScriptStatementLexer.js diff --git a/assets/www/javascripts/gen/parser/MmirScriptStatementParser.js b/assets/www/mmirf/gen/parser/MmirScriptStatementParser.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirScriptStatementParser.js rename to assets/www/mmirf/gen/parser/MmirScriptStatementParser.js diff --git a/assets/www/javascripts/gen/parser/MmirTemplate.tokens b/assets/www/mmirf/gen/parser/MmirTemplate.tokens similarity index 100% rename from assets/www/javascripts/gen/parser/MmirTemplate.tokens rename to assets/www/mmirf/gen/parser/MmirTemplate.tokens diff --git a/assets/www/javascripts/gen/parser/MmirTemplateLexer.js b/assets/www/mmirf/gen/parser/MmirTemplateLexer.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirTemplateLexer.js rename to assets/www/mmirf/gen/parser/MmirTemplateLexer.js diff --git a/assets/www/javascripts/gen/parser/MmirTemplateParser.js b/assets/www/mmirf/gen/parser/MmirTemplateParser.js similarity index 100% rename from assets/www/javascripts/gen/parser/MmirTemplateParser.js rename to assets/www/mmirf/gen/parser/MmirTemplateParser.js diff --git a/assets/www/javascripts/gesture/accelerometerGestureDetector.js b/assets/www/mmirf/gesture/accelerometerGestureDetector.js similarity index 96% rename from assets/www/javascripts/gesture/accelerometerGestureDetector.js rename to assets/www/mmirf/gesture/accelerometerGestureDetector.js index 8c40549..c41649c 100644 --- a/assets/www/javascripts/gesture/accelerometerGestureDetector.js +++ b/assets/www/mmirf/gesture/accelerometerGestureDetector.js @@ -57,7 +57,7 @@ mobileDS.AccelerometerGestureDetector = (function(){ /** - * A Timer object to repeatedly execute a specific function - in this case: the method {@link mobileDS.AccelerometerGestureDetector-constructor.startWatch} of {@link mobileDS.AccelerometerGestureDetector-constructor}. + * A Timer object to repeatedly execute a specific function - in this case: the method {@link mobileDS.AccelerometerGestureDetector#startWatch} of {@link mobileDS.AccelerometerGestureDetector-constructor}. * * @property restartTimer * @type Timer|Object @@ -330,17 +330,17 @@ mobileDS.AccelerometerGestureDetector = (function(){ if ((SHAKE_DURATION <= deltaT && Math.abs(deltaY) >= 4.1) || (Math.abs(deltaX) + Math.abs(deltaY)) > 20) { if(IS_DEBUG_ENABLED) console.debug("Shake");//debug - // mobileDS.DialogEngine.getInstance().raiseEvent("exit"); + // mobileDS.DialogEngine.getInstance().raise("exit"); } // else if ((deltaX > 1 && startZ >= 0) || (deltaX < -1 && startZ <= 0)) { if(IS_DEBUG_ENABLED) console.debug("tilt to the right");//debug - //mobileDS.DialogEngine.getInstance().raiseEvent("next"); + //mobileDS.DialogEngine.getInstance().raise("next"); } else if ((deltaX < -1 && startZ >= 0) || (deltaX > 1 && startZ <= 0)) { if(IS_DEBUG_ENABLED) console.debug("tilt to the left");//debug - mobileDS.DialogEngine.getInstance().raiseEvent("back"); + mobileDS.DialogEngine.getInstance().raise("back"); } else { if(IS_DEBUG_ENABLED) console.debug("could not specify motion mode " + deltaX + ":" + deltaZ);//debug diff --git a/assets/www/javascripts/gesture/compassHandler.js b/assets/www/mmirf/gesture/compassHandler.js similarity index 97% rename from assets/www/javascripts/gesture/compassHandler.js rename to assets/www/mmirf/gesture/compassHandler.js index df189e8..876080e 100644 --- a/assets/www/javascripts/gesture/compassHandler.js +++ b/assets/www/mmirf/gesture/compassHandler.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.gesture + * @module mobileDS.gesture * */ var mobileDS = window.mobileDS || @@ -55,7 +55,7 @@ mobileDS.CompassHandler = (function(){ var instance; /** - * A Timer object to repeatedly execute a specific function - in this case: the method {@link mobileDS.CompassHandler-constructor.startWatch}. + * A Timer object to repeatedly execute a specific function - in this case: the method {@link mobileDS.CompassHandler#startWatch}. * * @property restartTimer * @type Timer|Object diff --git a/assets/www/javascripts/gesture/locationObserver.js b/assets/www/mmirf/gesture/locationObserver.js similarity index 98% rename from assets/www/javascripts/gesture/locationObserver.js rename to assets/www/mmirf/gesture/locationObserver.js index 28c65a8..c79a168 100644 --- a/assets/www/javascripts/gesture/locationObserver.js +++ b/assets/www/mmirf/gesture/locationObserver.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.gesture + * @module mobileDS.gesture * */ var mobileDS = window.mobileDS || diff --git a/assets/www/javascripts/main.js b/assets/www/mmirf/main.js similarity index 60% rename from assets/www/javascripts/main.js rename to assets/www/mmirf/main.js index c2e8e08..dd99881 100644 --- a/assets/www/javascripts/main.js +++ b/assets/www/mmirf/main.js @@ -83,112 +83,99 @@ function initializeApplication(){ console.log("initialize Application."); commonUtils = mobileDS.CommonUtils.getInstance(); - if (!forBrowser){ - - // Check if a network connection is established. - if (mobileDS.CommonUtils.getInstance().checkNetworkConnection() == false){ - alert("No network connection enabled.\nPlease enable network access."); -// return false; - } else { - if(IS_DEBUG_ENABLED) console.log("Network access is available."); - } - - mobileDS.CommonUtils.getInstance().loadAllPhonegapPlugins(mobileDS.constants.getInstance(forBrowser).getPluginsPath(), function(){ - try { - for (var prop in window.plugins) { - console.log("Loaded plugin '" + prop + "'"); - } - } - catch (e) { - console.log("Exception: " + e); - } - loadManagers(); - }); - } - else { - loadManagers(); - } + + commonUtils.loadCompiledGrammars(mobileDS.constants.getInstance(forBrowser).getGeneratedGrammarsPath(), function(){ + + + if (!forBrowser){ + + // Check if a network connection is established. + if (mobileDS.CommonUtils.getInstance().checkNetworkConnection() == false){ + alert("No network connection enabled.\nPlease enable network access."); + // return false; + } else { + if(IS_DEBUG_ENABLED) console.log("Network access is available."); + } + + mobileDS.CommonUtils.getInstance().loadAllPhonegapPlugins(mobileDS.constants.getInstance(forBrowser).getPluginsPath(), function(){ + try { + for (var prop in window.plugins) { + console.log("Loaded plugin '" + prop + "'"); + } + } + catch (e) { + console.log("Exception: " + e); + } + loadManagers(); + }); + } + else { + loadManagers(); + } + }); } function loadManagers(){ -// applicationLanguage = "de"; mobileDS.ConfigurationManager.getInstance(); - langManager = mobileDS.LanguageManager.getInstance(mobileDS.ConfigurationManager.getInstance().getLanguage());//applicationLanguage); + langManager = mobileDS.LanguageManager.getInstance(mobileDS.ConfigurationManager.getInstance().getLanguage()); semanticInterpreter = mobileDS.SemanticInterpreter.getInstance(); - if (forBrowser){ - mobileDS.AudioInput.loadFile('javascripts/mediators/html5AudioInput.js', function(){ - audioInput = mobileDS.AudioInput.getInstance; - console.log('AudioInput loaded'); - }); - mobileDS.AudioOutput.loadFile('javascripts/mediators/html5AudioOutput.js', function(){ - audioOutput = mobileDS.AudioOutput.getInstance; - console.log('AudioOutput loaded'); - }); - mobileDS.ConcurrentSCION.loadFile('javascripts/mediators/html5ConcurrentSCION.js', function(){ - console.log('ConcurrentSCION loaded'); - loadInputManager(); - }); - } - else { - mobileDS.AudioInput.loadFile(mobileDS.constants.getInstance(forBrowser).getBasePath()+'javascripts/mediators/nuanceAudioInput.js', function(){ - audioInput = mobileDS.AudioInput.getInstance; - console.log('AudioInput loaded'); - }); - mobileDS.AudioOutput.loadFile(mobileDS.constants.getInstance(forBrowser).getBasePath()+'javascripts/mediators/nuanceAudioOutput.js', function(){ - audioOutput = mobileDS.AudioOutput.getInstance; - console.log('AudioOutput loaded'); - }); - mobileDS.ConcurrentSCION.loadFile('javascripts/mediators/nativeConcurrentSCION.js', function(){ - console.log('ConcurrentSCION loaded'); - loadInputManager(); - }); - } - -// controllerManager = //NOTE: initializeControllers() has no return value any more! -> set controllerManager variable in callback - mobileDS.ControllerManager.initializeControllers(afterLoadingControllers); - + mobileDS.MediaManager.create(function(){ + console.log('All Media-Plugins Loaded'); + mobileDS.SCIONExtension.getInstance(); + +// controllerManager = //NOTE: create() has no return value any more! -> set controllerManager variable in callback + mobileDS.ControllerManager.create(afterLoadingControllers); + }, function (e) { + console.log('Error loading Media plugins'); + if (e) console.log(e); + }); + + } -function loadInputManager(){ - inputManager = mobileDS.InputManager.getInstance(); - inputManager.initializeDialog(); - - console.log("initialization finished"); - /// callback end - - var cm = mobileDS.CompassHandler.getInstance(); - // cm.startWatch(); +function loadInputEngine(){ + + mobileDS.InputEngine.create(function(engineInstance){ + inputManager = engineInstance; + inputManager.startEngine(); + + console.log("initialization finished"); + /// callback end + +// var cm = mobileDS.CompassHandler.getInstance(); +// cm.startWatch(); + }); } function backKeyDown(event){ if(!forBrowser || (forBrowser && event.state)){//if(IS_BACK_ACTIVE){ - //FIX for browser-env.: to popstate-event is triggered not only when back-button is pressend in browser (however, in this case it seems, that the event.state is empty...) + //FIX for browser-env.: to popstate-event is triggered not only when back-button is pressed in browser (however, in this case it seems, that the event.state is empty...) if(forBrowser && !event.state){ return; /////////////////////////// EARLY EXIT /////////////////////////////////// } triggerClickFeedback({haptic : false});//vibration is already triggered by system for this back-button... - mobileDS.DialogEngine.getInstance().raiseEvent('back', { nativeBackButton : 'true'}); + mobileDS.DialogEngine.getInstance().raise('back', { nativeBackButton : 'true'}); } } function showLoader(){ - mobileDS.DialogEngine.getInstance().show_wait_dialog(); + mobileDS.DialogEngine.getInstance().showWaitDialog(); // $('.ui-loader').css('display', 'block'); } function hideLoader(){ - mobileDS.DialogEngine.getInstance().close_wait_dialog(); + mobileDS.DialogEngine.getInstance().hideWaitDialog(); // $('.ui-loader').css('display', 'none'); } function afterLoadingControllers(ctrlManager){ - + loadInputEngine(); controllerManager = ctrlManager; //$.mobile.page.prototype.options.backBtnText = "zurück"; @@ -198,15 +185,22 @@ function afterLoadingControllers(ctrlManager){ $.mobile.defaultPageTransition = 'slide'; pm = mobileDS.PresentationManager.getInstance(); - dialogManager = mobileDS.DialogEngine.getInstance(); - dialogManager.set_on_page_loaded(exectueAfterEachPageIsLoaded); - dialogManager.initializeDialog(); - var appLayout = pm.getLayout("application"); - var headerContents = appLayout.getHeaderContents(); - var header = $("head"); - header.append(headerContents); - $('#applications_dialogs').appendTo($.mobile.pageContainer).css({}); - modelManager = mobileDS.ModelManager.getInstance(null); + + mobileDS.DialogEngine.create(function(engineInstance){ + dialogManager = engineInstance; + + mobileDS.ModelManager.create(function(modelManagerInstance){ + modelManager = modelManagerInstance; + + dialogManager.setOnPageRenderedHandler(exectueAfterEachPageIsLoaded); + dialogManager.startEngine(); + var appLayout = pm.getLayout("Application"); + var headerContents = appLayout.getHeaderContents(); + var header = $("head"); + header.append(headerContents); + $('#applications_dialogs').appendTo($.mobile.pageContainer).css({}); + }); + }); } @@ -218,19 +212,20 @@ function exectueAfterEachPageIsLoaded(ctrlName,viewName,data){ tis.bind('vmousedown', function(event){ tis.parent().addClass('ui-focus ui-btn-active ui-btn-down-a'); eventName = "touch_start_on_" + tis.attr("name"); - mobileDS.InputManager.getInstance().raiseEvent("touch_input_event"); - mobileDS.InputManager.getInstance().raiseEvent(eventName); + mobileDS.InputEngine.getInstance().raise("touch_input_event"); + mobileDS.InputEngine.getInstance().raise(eventName); }); - tis.bind('click', function(event){ + tis.bind('vclick', function(event){ + triggerClickFeedback(); eventName = "click_on_" + tis.attr("name"); - mobileDS.InputManager.getInstance().raiseEvent("touch_input_event"); - mobileDS.InputManager.getInstance().raiseEvent(eventName); + mobileDS.InputEngine.getInstance().raise("touch_input_event"); + mobileDS.InputEngine.getInstance().raise(eventName); }); tis.bind('vmouseup', function(event){ tis.parent().removeClass('ui-focus ui-btn-active ui-btn-down-a'); eventName = "touch_end_on_" + tis.attr("name"); - mobileDS.InputManager.getInstance().raiseEvent("touch_input_event"); - mobileDS.InputManager.getInstance().raiseEvent(eventName); + mobileDS.InputEngine.getInstance().raise("touch_input_event"); + mobileDS.InputEngine.getInstance().raise(eventName); }); }); } @@ -305,20 +300,13 @@ function micClick(){ asr_result = res['result']; } - setTimeout(function(){ - mobileDS.AudioOutput.getInstance().textToSpeech(asr_result, function(){}, function(){}); - }, 1000); + mobileDS.MediaManager.getInstance().textToSpeech(asr_result, function(){}, function(){}); - var result = mobileDS.SemanticInterpreter.getInstance().get_asr_semantic(asr_result); + var result = mobileDS.SemanticInterpreter.getInstance().getASRSemantic(asr_result); var semantic; $('#mic_button').removeClass('footer_button_clicked'); - -// //next 2 line only required when recognizing with end-of-speech-detection: -// if(isUseEndOfSpeechDetection){ -// mobileDS.AudioInput.getInstance().stopRecord(function (status){}, function (err){}); -// } - + if (result.semantic != null) { semantic = JSON.parse(result.semantic); semantic.phrase = res; @@ -327,7 +315,7 @@ function micClick(){ else { semantic = JSON.parse('{ "NoMatch": { "phrase": "'+asr_result+'" }}'); } - inputManager.raiseEvent("speech_input_event", semantic); + inputManager.raise("speech_input_event", semantic); if(ACTIVE_TEXT_ELEMENT && semantic && semantic.value){ var str = semantic.value; var child = semantic.title; @@ -343,6 +331,10 @@ function micClick(){ var errorFunc = function recognizeError (err){ $('#mic_button').removeClass('footer_button_clicked'); console.error('[AudioInput] Error while finishing recoginition: '+JSON.stringify(err)); + + + var msg = JSON.stringify(err);//mobileDS.LanguageManager.getInstance().getText('did_not_understand_msg'); + mobileDS.MediaManager.getInstance().textToSpeech(msg, null, null); }; if(isUseEndOfSpeechDetection === false){ @@ -352,16 +344,17 @@ function micClick(){ //WITHOUT end-of-speech-detection (i.e. manual stop by user interaction): if ($('#mic_button').hasClass('footer_button_clicked')){ - mobileDS.AudioInput.getInstance().stopRecord(successFunc, errorFunc); + mobileDS.MediaManager.getInstance().stopRecord(successFunc, errorFunc); } else { $('#mic_button').addClass('footer_button_clicked'); - mobileDS.AudioInput.getInstance().startRecord( + mobileDS.MediaManager.getInstance().startRecord( function printResult(res){ console.log("[AudioInput] start recoginition: " + res); }, function(err){ $('#mic_button').removeClass('footer_button_clicked'); + setTimeout(function(){errorFunc(err);}, 0); alert('tts failed: '+err); } ); @@ -371,29 +364,32 @@ function micClick(){ else { //WITH end-of-speech-detection (i.e. automatic stop by silence detection): - console.log("[AudioInput] start recoginition with automtic END OF SPEECH detection"); + console.log("[AudioInput] start recoginition with automatic END OF SPEECH detection"); if ($('#mic_button').hasClass('footer_button_clicked')){ console.log("[AudioInput] start recoginition with automtic END OF SPEECH detection: already in progress, stopping now..."); - $('#mic_button').removeClass('footer_button_clicked'); - mobileDS.AudioInput.getInstance().stopRecord( + + mobileDS.MediaManager.getInstance().stopRecord( function printResult(res){ - console.log("[AudioInput] stopped recoginition: " + res); + console.log("[AudioInput] MANUALLY stopped recoginition: " + JSON.stringify(res)); + successFunc(res); }, function(err){ - console.log("[AudioInput] failed to stop recoginition: " + err); + console.log("[AudioInput] failed to MANUALLY stop recoginition: " + err); + setTimeout(function(){errorFunc(err);}, 0); + alert('tts failed: '+err); } ); } else { - console.log("[AudioInput] starting recoginition with automtic END OF SPEECH detection now..."); + console.log("[AudioInput] starting recoginition with automatic END OF SPEECH detection now..."); $('#mic_button').addClass('footer_button_clicked'); setTimeout(function(){ - mobileDS.AudioInput.getInstance().recognize(successFunc, errorFunc); + mobileDS.MediaManager.getInstance().recognize(successFunc, errorFunc); }, 1000); } } diff --git a/assets/www/javascripts/manager/controllerManager.js b/assets/www/mmirf/manager/controllerManager.js similarity index 71% rename from assets/www/javascripts/manager/controllerManager.js rename to assets/www/mmirf/manager/controllerManager.js index 5badd56..edf4b86 100644 --- a/assets/www/javascripts/manager/controllerManager.js +++ b/assets/www/mmirf/manager/controllerManager.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.manager + * @module mobileDS.manager * */ var mobileDS = window.mobileDS || @@ -62,20 +62,20 @@ mobileDS.ControllerManager = (function(){ * Array of controller-instances * * @property controllers - * @type Array + * @type Dictionary * @private */ - var controllers = new Array(); + var controllers = new Dictionary();//Array(); - /** - * Index for the array of controller-instances - * - * @property controller_index - * @type Integer - * @private - */ - var controller_index = 0; +// /** +// * Index for the array of controller-instances +// * +// * @property controller_index +// * @type Integer +// * @private +// */ +// var controller_index = 0; /** @@ -108,10 +108,17 @@ mobileDS.ControllerManager = (function(){ mobileDS.CommonUtils.getInstance().getLocalScript(tmpView["path"], function(data, textStatus, jqxhr){ var controller = new Controller(tmpView["name"], tmpView); - var helperPath = tmpView["path"].replace(mobileDS.constants.getInstance().getControllerPath().replace(/\/$/,""), mobileDS.constants.getInstance().getHelperPath().replace(/\/$/,"")); - helperPath = helperPath.replace(".js", mobileDS.constants.getInstance().getHelperSuffix() + ".js"); - controller.loadHelper(tmpView["name"]+mobileDS.constants.getInstance().getHelperSuffix(),helperPath); - controllers[controller_index++] = controller; + +// var helperPath = tmpView["path"].replace(mobileDS.constants.getInstance().getControllerPath().replace(/\/$/,""), mobileDS.constants.getInstance().getHelperPath().replace(/\/$/,"")); +// helperPath = helperPath.replace(".js", mobileDS.constants.getInstance().getHelperSuffix() + ".js"); + if(tmpView["helper"]){ + var helperPath = tmpView["helper"]["path"]; + var helperName = tmpView["helper"]["name"]; + controller.loadHelper(helperName,helperPath); + } + + controllers.put(controller.getName(), controller);//[controller_index++] = controller; + // create the next controller in list - or better: process the rest of the controller-list foundControllersAndViewsAndPartials = foundControllersAndViewsAndPartials.slice(1); foundControllersCallBack(foundControllersAndViewsAndPartials, myCallbackFunction); @@ -172,35 +179,39 @@ mobileDS.ControllerManager = (function(){ * @private */ function getViewsAndPartialsForController(controllerName, controllerPath){ - var tmpJSON = Object();; - var tmpViewPath = mobileDS.constants.getInstance(forBrowser).getViewPath() + controllerName.replace(/\.[^.]+$/g,""); + var tmpJSON = Object(); + controllerPath = controllerPath + controllerName; - controllerName=controllerName[0].toUpperCase()+controllerName.substr(1).replace(/\.[^.]+$/g,""); + + controllerName=controllerName.replace(/\.[^.]+$/g,"");//remove file-extension + tmpJSON["fileName"]=controllerName; + var tmpViewPath = mobileDS.constants.getInstance(forBrowser).getViewPath() + controllerName; + controllerName=controllerName[0].toUpperCase()+controllerName.substr(1); tmpJSON["name"]=controllerName; tmpJSON["path"]=controllerPath; - var tmpViewArray = Array(); - var tmpPartialArray = Array(); - - var tmpPartialJSON = Object(); - var tmpViewJSON = Object(); // tmpViews = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, "[^"+mobileDS.CommonUtils.getInstance().getPartialsPrefix()+"]*.ehtml"); - tmpViews = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, "(?!"+mobileDS.CommonUtils.getInstance().getPartialsPrefix()+")*.ehtml"); - -// tmpPartials = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, mobileDS.CommonUtils.getInstance().getPartialsPrefix()+"*.ehtml"); - tmpPartials = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, mobileDS.CommonUtils.getInstance().getPartialsPrefix()+"*.ehtml"); - - for (var i in tmpViews){ + var tmpViews = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, "(?!"+mobileDS.CommonUtils.getInstance().getPartialsPrefix()+")*.ehtml"); + + var tmpViewArray = Array(); + var tmpViewJSON = null; + var i, size; + for (i=0, size = tmpViews.length; i < size; ++i){ tmpViewJSON = Object(); tmpViewJSON["name"]=tmpViews[i].replace(/\.[^.]+$/g,""); tmpViewJSON["path"]=tmpViewPath+"/"+tmpViews[i]; tmpViewArray.push(tmpViewJSON); } tmpJSON["views"]=tmpViewArray; - - for (var i in tmpPartials){ + +// tmpPartials = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, mobileDS.CommonUtils.getInstance().getPartialsPrefix()+"*.ehtml"); + var tmpPartials = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpViewPath, mobileDS.CommonUtils.getInstance().getPartialsPrefix()+"*.ehtml"); + + var tmpPartialArray = Array(); + var tmpPartialJSON = null; + for (i=0, size = tmpPartials.length; i < size; ++i){ tmpPartialJSON = Object(); // remove leading "$" indicating it is a partial tmpPartialJSON["name"]=tmpPartials[i].replace(mobileDS.CommonUtils.getInstance().getPartialsPrefix(),"").replace(/\.[^.]+$/g,""); @@ -208,6 +219,41 @@ mobileDS.ControllerManager = (function(){ tmpPartialArray.push(tmpPartialJSON); } tmpJSON["partials"]=tmpPartialArray; + + + + var tmpHelperPath = mobileDS.constants.getInstance(forBrowser).getHelperPath(); + tmpHelperPath = tmpHelperPath.substring(0, tmpHelperPath.length-1);//remove trailing slash + var tmpHelpers = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpHelperPath, "(?!"+mobileDS.CommonUtils.getInstance().getPartialsPrefix()+")*.js"); + + var tmpHelperJSON = null; + for(i=0, size = tmpHelpers.length; i < size; ++i){ + if(tmpHelpers[i].startsWith(tmpJSON["fileName"], true) && tmpHelpers[i].endsWith(mobileDS.constants.getInstance().getHelperSuffix()+'.js', true)){ + tmpHelperJSON = {}; + tmpHelperJSON["fileName"]= tmpHelpers[i].replace(/\.[^.]+$/g,""); + tmpHelperJSON["name"] = tmpHelperJSON["fileName"][0].toUpperCase()+tmpHelperJSON["fileName"].substr(1); + tmpHelperJSON["path"]=tmpHelperPath+"/"+tmpHelpers[i]; + } + } + tmpJSON["helper"]=tmpHelperJSON; + + + + var tmpLayoutPath = mobileDS.constants.getInstance(forBrowser).getLayoutPath(); + tmpLayoutPath = tmpLayoutPath.substring(0, tmpLayoutPath.length-1);//remove trailing slash + var tmpLayouts = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(tmpLayoutPath, "(?!"+mobileDS.CommonUtils.getInstance().getPartialsPrefix()+")*.ehtml"); + + var tmpLayoutJSON = null; + for(i=0, size = tmpLayouts.length; i < size; ++i){ + if( tmpLayouts[i].startsWith(tmpJSON["fileName"], true) ){ + tmpLayoutJSON = {}; + tmpLayoutJSON["fileName"]= tmpLayouts[i].replace(/\.[^.]+$/g,""); + tmpLayoutJSON["name"] = tmpLayoutJSON["fileName"]; + tmpLayoutJSON["path"]=tmpLayoutPath+"/"+tmpLayouts[i]; + } + } + tmpJSON["layout"]=tmpLayoutJSON; + return tmpJSON; } @@ -233,47 +279,51 @@ mobileDS.ControllerManager = (function(){ */ getController: function(ctrlName){ var ctrl = null; - $.each(controllers, function(index, controller){ - if (controller.getName() == ctrlName) { - ctrl = controller; - // ends the function inside each-statement - return false; - } - }); +// $.each(controllers, function(index, controller){ +// if (controller.getName() == ctrlName) { +// ctrl = controller; +// // ends the function inside each-statement +// return false; +// } +// }); + ctrl = controllers.get(ctrlName); + if(!ctrl){ + return null; + } return ctrl; }, /** - * This function returns all loaded controllers. + * This function returns names of all loaded controllers. * - * @function getControllers - * @returns {Array} All loaded controllers + * @function getControllerNames + * @returns {Array} Names of all loaded controllers * @public */ - getControllers: function(){ + getControllerNames: function(){ - return controllers; + return controllers.getKeys(); }, /** * This function performs an action of a controller. * - * @function performAction + * @function perform * @param {String} ctrlName Name of the controller to which the action belongs * @param {String} actionName Name of the action that should be performed * @param {Object} data optional data that can be submitted to the action * @returns {Object} the return object of the performed action * @public */ - performAction: function(ctrlName, actionName, data){ + perform: function(ctrlName, actionName, data){ var ctrl = mobileDS.ControllerManager.getInstance().getController(ctrlName); if (ctrl != null) { - return ctrl.performAction(actionName, data); + return ctrl.perform(actionName, data); } else { - console.error('ControllerManager.performAction: the controller could not be found "'+ctrlName+'"'); + console.error('ControllerManager.perform: the controller could not be found "'+ctrlName+'"'); } }, @@ -281,23 +331,21 @@ mobileDS.ControllerManager = (function(){ /** * This function performs an action of a helper-class for a controller. * - * @function performHelperAction + * @function performHelper * @param {String} ctrlName Name of the controller to which the helper action belongs * @param {String} actionName Name of the action that should be performed by the helper * @param {Object} data optional data that can be submitted to the action * @returns {Object} the return object of the performed action * @public */ - performHelperAction: function(ctrlName, actionName, data){ - ctrlName = ctrlName.toLowerCase(); - actionName = actionName.toLowerCase(); + performHelper: function(ctrlName, actionName, data){ var ctrl = mobileDS.ControllerManager.getInstance().getController(ctrlName); if (ctrl != null) { - return ctrl.performHelperAction(actionName, data); + return ctrl.performHelper(actionName, data); } else { - console.error('ControllerManager.performHelperAction: the controller could not be found "'+ctrlName+'"'); + console.error('ControllerManager.performHelper: the controller could not be found "'+ctrlName+'"'); } } }; @@ -309,9 +357,9 @@ mobileDS.ControllerManager = (function(){ * *
* Note: - * The ControllerManager must first be initialized {@link mobileDS.ControllerManager#initializeControllers}; + * The ControllerManager must first be initialized {@link mobileDS.ControllerManager#create}; * the instance of the singleton ControllerManager is available, when the callback (i.e. the argument - * for the initializeControllers function) is invoked. + * for the create function) is invoked. *
* * @function getInstance @@ -320,7 +368,7 @@ mobileDS.ControllerManager = (function(){ */ getInstance: function(){ if (instance === null) { - alert("Error: Controllers not initialized!\nCall initializeControllers(CallbackFunction)"); + alert("Error: Controllers not initialized!\nCall create(CallbackFunction)"); return null; } return instance; @@ -341,17 +389,17 @@ mobileDS.ControllerManager = (function(){ * callbackFunction(controllerManagerInstance) *
* - * @function initializeControllers + * @function create * @param {Function} [callbackFunction] The function which should be called after loading all controllers * @example * function afterLoadingControllers(controllerManagerInstance){ - * var appCtrl = controllerManagerInstance.getController('application'); + * var appCtrl = controllerManagerInstance.getController('Application'); * //do something... * } - * mobileDS.ControllerManager.initializeControllers(afterLoadingControllers); + * mobileDS.ControllerManager.create(afterLoadingControllers); * @public */ - initializeControllers: function(callbackFunction){ + create: function(callbackFunction){ if (instance === null) { loadControllers(function(){ diff --git a/assets/www/javascripts/manager/dialog/DialogEngine.js b/assets/www/mmirf/manager/dialog/dialogEngine.js similarity index 71% rename from assets/www/javascripts/manager/dialog/DialogEngine.js rename to assets/www/mmirf/manager/dialog/dialogEngine.js index 5d024a8..fb865c8 100644 --- a/assets/www/javascripts/manager/dialog/DialogEngine.js +++ b/assets/www/mmirf/manager/dialog/dialogEngine.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.scxml + * @module mobileDS.scxml * */ var mobileDS = window.mobileDS || @@ -78,7 +78,7 @@ mobileDS.DialogEngine = (function(){ * A function that is executed after a page was loaded. * The on_page_loade(string,string,object) function is executed after the view's on_page_load() function. */ - var onPageLoaded; + var onPageRenderedFunc; /** * Writes a log entry to the log-file @@ -143,14 +143,14 @@ mobileDS.DialogEngine = (function(){ * @memberOf mobileDS.DialogEngine.prototype */ // listener for transitions / state-changes: - function constructor(){ + function constructor(callbackFunction){ var interpreter = null; var eventGenerator = null; var isInitialized = false; var scion = require('scion'); - scion.urlToModel("config/statedef/dialogDescription.xml",function(err,model){ + scion.urlToModel("config/statedef/dialogDescriptionSCXML.xml",function(err,model){ if(err) throw err; @@ -180,8 +180,13 @@ mobileDS.DialogEngine = (function(){ } }; interpreter.registerListener(listener); - eventGenerator = mobileDS.ConcurrentSCION.getInstance().newConcurrentSCION(interpreter, - function(e){console.log('ERROR creating concurrentSCION');}); + eventGenerator = mobileDS.SCIONExtension.getInstance().newSCIONExtension(interpreter, + function(e){console.log('ERROR creating SCIONExtension');} + ); + + if(typeof callbackFunction !== 'undefined' && callbackFunction !== null){ + callbackFunction(instance); + } }); /** @lends mobileDS.DialogEngine.prototype */ @@ -189,13 +194,13 @@ mobileDS.DialogEngine = (function(){ /** * This function initializes the statechart automata instance and then raises the 'init' event. * - * @function initializeDialog + * @function startEngine * @public */ - initializeDialog: function(){ + startEngine: function(){ if(isInitialized){ - if(IS_DEBUG_ENABLED) console.warn('DialogEngine.initializeDialog(): already initialized!'+' '+new Error().stack);//debug (use Error for retrieving call-hierarchy using its stack-trace) + if(IS_DEBUG_ENABLED) console.warn('DialogEngine.startEngine(): already initialized!'+' '+new Error().stack);//debug (use Error for retrieving call-hierarchy using its stack-trace) return; ////////////////////// EARLY EXIT ////////////////////////////////// } @@ -203,7 +208,7 @@ mobileDS.DialogEngine = (function(){ isInitialized = true; interpreter.start(); // console.error('DialogEngine init: '+(new Date() - startUpTime));//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! - this.raiseEvent('init'); + this.raise('init'); } else { var isTimeout = false; @@ -223,7 +228,7 @@ mobileDS.DialogEngine = (function(){ isInitialized = true; interpreter.start(); // console.error('DialogEngine init: '+(new Date() - startUpTime));//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! - self.raiseEvent('init'); + self.raise('init'); } else { if(confirm){ @@ -251,12 +256,12 @@ mobileDS.DialogEngine = (function(){ /** * This function raises an event. * - * @function raiseEvent + * @function raise * @param {String} eventName The name of the event which is to be raised * @param {Object} data Data belonging to the event * @public */ - raiseEvent: function(eventName, data){ + raise: function(eventName, data){ if ((typeof data !== 'undefined') && (typeof data.Data === 'undefined')) { // Has data but didn't go through inputmanager @@ -336,7 +341,7 @@ mobileDS.DialogEngine = (function(){ /** * This function performs an action of a controller - * by calling the method {@link mobileDS.ControllerManager-constructor.performAction} of the {@link mobileDS.ControllerManager} + * by calling the method {@link mobileDS.ControllerManager#perform} of the {@link mobileDS.ControllerManager} * * @function perform * @param {String} ctrlName Name of the controller to which the action belongs @@ -348,37 +353,37 @@ mobileDS.DialogEngine = (function(){ perform: function(ctrlName, actionName, data){ if(IS_DEBUG_ENABLED) console.debug("going to perform ('" + ctrlName + "','" + actionName + "')");//debug - return mobileDS.ControllerManager.getInstance().performAction(ctrlName.toLowerCase(), actionName.toLowerCase(), data); + return mobileDS.ControllerManager.getInstance().perform(ctrlName, actionName, data); }, /** * This function performs an action of a helper-class for a controller - * by calling the method {@link mobileDS.ControllerManager-constructor.performHelperAction} of the {@link mobileDS.ControllerManager} + * by calling the method {@link mobileDS.ControllerManager#performHelper} of the {@link mobileDS.ControllerManager} * - * @function perform_helper_method + * @function performHelper * @param {String} ctrlName Name of the controller to which the helper action belongs * @param {String} helper_method_name Name of the action that should be performed by the helper * @param {Object} data optional data that can be submitted to the action * @returns {Object} the return object of the performed action * @public */ - perform_helper_method: function(ctrlName, helper_method_name, data){ - return mobileDS.ControllerManager.getInstance().performHelperAction(ctrlName.toLowerCase(), helper_method_name.toLowerCase(), data); + performHelper: function(ctrlName, helper_method_name, data){ + return mobileDS.ControllerManager.getInstance().performHelper(ctrlName, helper_method_name, data); }, /** * This function displays a dialog of a controller - * by calling the method {@link mobileDS.PresentationManager-constructor.show_dialog} of the {@link mobileDS.PresentationManager} + * by calling the method {@link mobileDS.PresentationManager#showDialog} of the {@link mobileDS.PresentationManager} * - * @function show_dialog + * @function showDialog * @param {String} ctrlName Name of the controller to which the dialog belongs * @param {String} dialogId Id of the dialog that should be displayed * @param {Object} data Optional data that can be submitted to the dialog * @public */ - show_dialog: function(ctrlName, dialogId, data){ + showDialog: function(ctrlName, dialogId, data){ var eventData; if(data){ @@ -392,25 +397,33 @@ mobileDS.DialogEngine = (function(){ } // writeLogEntry('showDialog_'+ctrlName+'_'+dialogId, eventData); FIXME disabled logging for BROWSER (how could this be accomplished in Browser?) - mobileDS.PresentationManager.getInstance().show_dialog(ctrlName.toLowerCase(), dialogId, data); + mobileDS.PresentationManager.getInstance().showDialog(ctrlName, dialogId, data); }, /** * This function closes a dialog of a controller - * by calling the method {@link mobileDS.PresentationManager-constructor.close_current_dialog} of the {@link mobileDS.PresentationManager} + * by calling the method {@link mobileDS.PresentationManager#hideCurrentDialog} of the {@link mobileDS.PresentationManager} * - * @function close_current_dialog + * @function hideCurrentDialog * @public */ - close_current_dialog: function(){ + hideCurrentDialog: function(){ -// writeLogEntry('closeCurrentDialog'); FIXME disabled logging for BROWSER (how could this be accomplished in Browser?) +// writeLogEntry('hideCurrentDialog'); FIXME disabled logging for BROWSER (how could this be accomplished in Browser?) - mobileDS.PresentationManager.getInstance().close_current_dialog(); - } , - - show_wait_dialog : function(){ + mobileDS.PresentationManager.getInstance().hideCurrentDialog(); + } , + /** + * Show a "wait" dialog, indicating work-in-progress. + * + * @function showWaitDialog + * @public + * @requires jQuery Mobile + * + * @see mobileDS.DialogEngine#hideWaitDialog + */ + showWaitDialog : function(){ if($('.ui-loading').length == 0){ @@ -434,7 +447,17 @@ mobileDS.DialogEngine = (function(){ // CSS spin-animator class $('.ui-loader .ui-icon-loading').addClass('spin'); }, - close_wait_dialog : function(){ + + /** + * Hides / closes the "wait" dialog. + * + * @function hideWaitDialog + * @public + * @requires jQuery Mobile + * + * @see mobileDS.DialogEngine#showWaitDialog + */ + hideWaitDialog : function(){ if($('.ui-loading').length > 0){ //only write log-entry, if waiting-dialog is currently open @@ -447,7 +470,7 @@ mobileDS.DialogEngine = (function(){ /** * This function displays a view of a controller - * by calling the method {@link mobileDS.PresentationManager-constructor.renderView} of the {@link mobileDS.PresentationManager}.
+ * by calling the method {@link mobileDS.PresentationManager#renderView} of the {@link mobileDS.PresentationManager}.
* And after rendering binds event listeners to all buttons of the view. * * @function render @@ -457,56 +480,93 @@ mobileDS.DialogEngine = (function(){ * @public */ render: function(ctrlName, viewName, data){ - mobileDS.PresentationManager.getInstance().renderView(ctrlName.toLowerCase(), viewName.toLowerCase(), data); + mobileDS.PresentationManager.getInstance().renderView(ctrlName, viewName, data); - if(typeof onPageLoaded === 'function'){ - onPageLoaded(ctrlName, viewName, data); + if(typeof onPageRenderedFunc === 'function'){ + onPageRenderedFunc(ctrlName, viewName, data); } }, /** - * Get the current on_page_loaded function (if it was set). + * Get the current on-page-rendered hook function (if it was set). * - * @function get_on_page_loaded - * @param {Function} the onPageLoadedCallback property (NOTE: this may not be set) + * @function getOnPageRenderedHandler + * @param {Function} the onPageRendered handler (NOTE: this may not be set, i.e. undefined) */ - get_on_page_loaded : function(){ - return onPageLoaded; + getOnPageRenderedHandler : function(){ + return onPageRenderedFunc; }, /** * Set the on_page_loaded callback function. * - * If onPageLoadedCallback is a function object, it will be executed after a view is rendered. + * If onPageRenderedHook is a function object, it will be executed after a view is rendered and + * after the view's controller on_page_load function(s) has/have been executed. * - * This function will be executed after the view's on_page_load()-function. - * The onPageLoadedCallback function takes 3 arguments that + *

This function will be executed after the view's on_page_load()-function.
+ * The onPageRenderedHook function takes 3 arguments that * refer to the parameters with which the render-function was invoked: - * ctrlName {String} Name of the controller to which the view belongs - * viewName {String} Name of the view that should be rendered - * data {Object} [Optional] data that can be submitted to the generation of the view + *
{String} ctrlName Name of the controller to which the view belongs + *
{String} viewName Name of the view that should be rendered + *
{Object} [data] Optional data that can be submitted to the generation of the view * - * @function set_on_page_loaded - * @param onPageLoadedCallback {Function} a callback function that will be executed after a view was rendered + * @function setOnPageRenderedHandler + * @param {Function} onPageRenderedHook a callback function that will be executed after a view was rendered * i.e. after a page was loaded. */ - set_on_page_loaded : function(onPageLoadedCallback){ - onPageLoaded = onPageLoadedCallback; + setOnPageRenderedHandler : function(onPageRenderedHook){ + onPageRenderedFunc = onPageRenderedHook; } }; } return { - /** - * Get the object containing the instance of the class {@link mobileDS.DialogManager} - * - * @function getInstance - * @returns {Object} Object containing the instance of the class {@link mobileDS.DialogManager} - * @public - */ - getInstance: function(){ - if (instance===null) { - instance = constructor(); - } + /** + * Get the object containing the instance of the class {@link mobileDS.DialogEngine} + * + *

+ * Note: + * The DialogEngine must first be initialized {@link mobileDS.DialogEngine#create}; + * the instance of the singleton DialogEngine is available, when the callback (i.e. the argument + * for the create function) is invoked. + *
+ * + * @function getInstance + * @returns {Object} Object containing the instance of the class {@link mobileDS.DialogEngine} + * @public + */ + getInstance: function(){ + if (instance === null) { + alert("Error: DialogEngine not initialized!\nCall create(CallbackFunction)"); + return null; + } return instance; + }, + /** + * This function must be called before using the {@link mobileDS.DialogEngine}. The Initialization process is asynchronous, + * because file resources must be loaded.
+ * + *
+ * Note: + * The callback function should contain all (!) instructions which require the prior loading of the DialogEngine.
+ * The callback mechanism is necessary, because loading the DialogDescription is asynchronous.

+ * If provided, the callback function is invoked with 1 argument, the DialogEngine instance:
+ * callbackFunction(dialogEngineInstance) + *
+ * + * @function create + * @param {Function} [callbackFunction] The function which should be called after initialization has finished + * @example + * function afterCreatingDialogEngine(dialogEngineInstance){ + * var appCtrl = dialogEngineInstance.perform('Application','getPropertyX'); + * //do something... + * } + * mobileDS.DialogEngine.create(afterCreatingDialogEngine); + * @public + */ + create: function(callbackFunction){ + if (instance === null) { + instance = constructor(callbackFunction); + } + return instance; } }; })(); \ No newline at end of file diff --git a/assets/www/javascripts/manager/dialog/input_manager_engine.js b/assets/www/mmirf/manager/dialog/inputEngine.js similarity index 52% rename from assets/www/javascripts/manager/dialog/input_manager_engine.js rename to assets/www/mmirf/manager/dialog/inputEngine.js index 1cc9e47..42f590b 100644 --- a/assets/www/javascripts/manager/dialog/input_manager_engine.js +++ b/assets/www/mmirf/manager/dialog/inputEngine.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.manager.input + * @module mobileDS.manager.input * */ var mobileDS = window.mobileDS || @@ -40,13 +40,13 @@ var mobileDS = window.mobileDS || * This "class" is structured as a singleton - so that only one instance is in use.
* You can access the instance of the class via * @example mobileDS.ControllerManager.getInstance() - * @class InputManager + * @class InputEngine * @category core */ -mobileDS.InputManager = (function(){ +mobileDS.InputEngine = (function(){ /** - * Object containing the instance of the class {@link mobileDS.InputManager} + * Object containing the instance of the class {@link mobileDS.InputEngine} * * @property instance * @type Object @@ -63,20 +63,20 @@ mobileDS.InputManager = (function(){ var stateHistory = new Array(); /** - * Constructor-Method of Class {@link mobileDS.InputManager}
+ * Constructor-Method of Class {@link mobileDS.InputEngine}
* It instantiates a state-machine handling every input. * * @constructor - * @augments mobileDS.InputManager - * @memberOf mobileDS.InputManager.prototype + * @augments mobileDS.InputEngine + * @memberOf mobileDS.InputEngine.prototype */ - function constructor(){ + function constructor(callbackFunction){ var interpreter = null; var eventGenerator = null; var isInitialized = false; var scion = require('scion'); - scion.urlToModel("config/statedef/input_manager_scxml.xml",function(err,model){ + scion.urlToModel("config/statedef/inputDescriptionSCXML.xml",function(err,model){ if(err) throw err; @@ -86,47 +86,51 @@ mobileDS.InputManager = (function(){ var listener = { onEntry : function(stateName) { stateHistory.push(stateName); - if(IS_DEBUG_ENABLED) console.debug('InputManager State Entry: "' + stateName + '"');//debug + if(IS_DEBUG_ENABLED) console.debug('InputEngine State Entry: "' + stateName + '"');//debug }, onExit : function(stateName) { stateHistory.pop(); - if(IS_DEBUG_ENABLED) console.debug('InputManager State Exit: "' + stateName + '"');//debug + if(IS_DEBUG_ENABLED) console.debug('InputEngine State Exit: "' + stateName + '"');//debug }, onTransition : function(sourceState, targetStatesArray) { - if(IS_DEBUG_ENABLED) console.debug('InputManager State Transition: "' + sourceState + '"->"' + targetStatesArray + '"');//debug + if(IS_DEBUG_ENABLED) console.debug('InputEngine State Transition: "' + sourceState + '"->"' + targetStatesArray + '"');//debug //currently, only 1-target transitions are supported: if(targetStatesArray && targetStatesArray.length > 1){ - console.warn('InputManager State Transition: multiple target states!'); + console.warn('InputEngine State Transition: multiple target states!'); } } }; interpreter.registerListener(listener); - eventGenerator = mobileDS.ConcurrentSCION.getInstance().newConcurrentSCION(interpreter, - function(e){console.log('ERROR creating concurrentSCION');}); - + eventGenerator = mobileDS.SCIONExtension.getInstance().newSCIONExtension(interpreter, + function(e){console.log('ERROR creating SCIONExtension');} + ); + + if(typeof callbackFunction !== 'undefined' && callbackFunction !== null){ + callbackFunction(instance); + } }); - /** @lends mobileDS.InputManager.prototype */ + /** @lends mobileDS.InputEngine.prototype */ return { /** * This function initializes the state-machine, which will handle the input. * - * @function initializeDialog + * @function startEngine * @public */ - initializeDialog: function(){ + startEngine: function(){ if(isInitialized){ - if(IS_DEBUG_ENABLED) console.warn('InputManager.initializeDialog(): already initialized!'+' '+new Error().stack);//debug (use Error for retrieving call-hierarchy using its stack-trace) + if(IS_DEBUG_ENABLED) console.warn('InputEngine.startEngine(): already initialized!'+' '+new Error().stack);//debug (use Error for retrieving call-hierarchy using its stack-trace) return; ////////////////////// EARLY EXIT ////////////////////////////////// } if(interpreter){ isInitialized = true; interpreter.start(); -// console.error('InputManager init: '+(new Date() - startUpTime)+' '+new Error().stack);//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! +// console.error('InputEngine init: '+(new Date() - startUpTime)+' '+new Error().stack);//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! } else { var isTimeout = false; @@ -143,21 +147,21 @@ mobileDS.InputManager = (function(){ else if(interpreter){ isInitialized = true; interpreter.start(); -// console.error('InputManager init: '+(new Date() - startUpTime)+' '+new Error().stack);//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! +// console.error('InputEngine init: '+(new Date() - startUpTime)+' '+new Error().stack);//debug : for testing, must initialize startUpTime with new Date(), first thing in index.html! } else { if(confirm){ - var result = confirm('Could not initialize InputManager (time out).\nContinue to wait another\n '+ (timeout/1000).toFixed(3) +' seconds?'); + var result = confirm('Could not initialize InputEngine (time out).\nContinue to wait another\n '+ (timeout/1000).toFixed(3) +' seconds?'); if(result){ startTime = new Date(); setTimeout(function(){waitForInit();},50); } else{ - console.error('Could not initialize InputManager (time out).'); + console.error('Could not initialize InputEngine (time out).'); } } else { - console.error('Could not initialize InputManager (time out).'); + console.error('Could not initialize InputEngine (time out).'); } } }; @@ -169,17 +173,17 @@ mobileDS.InputManager = (function(){ /** * This function raises an arbitrary Event. * - * @function raiseEvent + * @function raise * @param {String} eventName Name of the event to be raised * @param {Object} data Data of the event * @public */ - raiseEvent: function(eventName, data){ + raise: function(eventName, data){ - if(IS_DEBUG_ENABLED) console.debug("InputManager raising event : '" + eventName + "'");//debug + if(IS_DEBUG_ENABLED) console.debug("InputEngine raising event : '" + eventName + "' in state '"+ stateHistory[stateHistory.length-1] + "' with data "+JSON.stringify(data));//debug -// if (!(typeof input_manager_state_chart_instance[eventName] === "undefined")) { -// input_manager_state_chart_instance[eventName](data); +// if (!(typeof InputDescription_instance[eventName] === "undefined")) { +// InputDescription_instance[eventName](data); // } // else { // console.warn("no possible transition for " + eventName); @@ -194,15 +198,52 @@ mobileDS.InputManager = (function(){ return { /** - * Object containing the instance of the class {@link mobileDS.InputManager} + * Object containing the instance of the class {@link mobileDS.InputEngine} + * * + *
+ * Note: + * The InputEngine must first be initialized {@link mobileDS.InputEngine#create}; + * the instance of the singleton InputEngine is available, when the callback (i.e. the argument + * for the create function) is invoked. + *
+ * * @function getInstance - * @returns {Object} Object containing the instance of the class {@link mobileDS.InputManager} + * @returns {Object} Object containing the instance of the class {@link mobileDS.InputEngine} * @public */ getInstance: function(){ - if (!instance) { - instance = constructor(); + if (instance === null) { + alert("Error: InputEngine not initialized!\nCall create(CallbackFunction)"); + return null; + } + return instance; + }, + /** + * This function must be called before using the {@link mobileDS.InputEngine}. The Initialization process is asynchronous, + * because file resources must be loaded.
+ * + *
+ * Note: + * The callback function should contain all (!) instructions which require the prior loading of the InputEngine.
+ * The callback mechanism is necessary, because loading the DialogDescription is asynchronous.

+ * If provided, the callback function is invoked with 1 argument, the InputEngine instance:
+ * callbackFunction(inputEngineInstance) + *
+ * + * @function create + * @param {Function} [callbackFunction] The function which should be called after initialization has finished + * @example + * function afterCreatingInputEngine(inputEngineInstance){ + * inputEngineInstance.raise('someEvent',{data: 'value'}); + * //do something... + * } + * mobileDS.InputEngine.create(afterCreatingInputEngine); + * @public + */ + create: function(callbackFunction){ + if (instance === null) { + instance = constructor(callbackFunction); } return instance; } diff --git a/assets/www/mmirf/manager/mediaManager.js b/assets/www/mmirf/manager/mediaManager.js new file mode 100644 index 0000000..80c4c20 --- /dev/null +++ b/assets/www/mmirf/manager/mediaManager.js @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +var mobileDS = window.mobileDS || +{}; + +/** + * + * + * This "class" is structured as a singleton - so that only one instance is in use.
+ * You can access the instance of the class via + */ +mobileDS.MediaManager = (function(){ + + var instance = null; + var pluginsToLoad = { + 'browser': new Array('html5AudioOutput.js', + 'html5AudioInput.js', + 'maryTextToSpeech.js'), + 'android': new Array('cordovaAudioOutput.js', + 'nuanceAudioInput.js', + 'maryTextToSpeech.js') + }; + var loadPlugin = function loadPlugin (filePath, successCallback, failureCallback){ + try { + mobileDS.CommonUtils.getInstance().loadScript(mobileDS.constants.getMediaPluginPath()+filePath, function(){ + //TODO keine globale Variable + if (typeof newMediaPlugin !== 'undefined' && newMediaPlugin){ + newMediaPlugin.initialize(function(functions){ + jQuery.extend(true,instance,functions); + newMediaPlugin = null; + if (successCallback) successCallback(); + }); + } + }); + }catch (e){ + console.log('Error loading MediaPlugin '+filePath); + console.log(e); + if (failureCallback) failureCallback(); + } + + }; + //those are the standard audioInput procedures, that should be implemented by a loaded file + function constructor(){ + return { + //TODO add API documentation + + //audio input API: + recognize: function(blob, successCallBack, failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Input: Speech Recognition is not supported."); + } + else { + console.error("Audio Input: Speech Recognition is not supported."); + } + }, + startRecord: function(successCallBack,failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Input: Speech Recognition (recording) is not supported."); + } + else { + console.error("Audio Input: Speech Recognition (recording) is not supported."); + } + }, + stopRecord: function(successCallBack,failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Input: Speech Recognition (recording) is not supported."); + } + else { + console.error("Audio Input: Speech Recognition (recording) is not supported."); + } + }, + //audio output API: + playWAV: function(blob, successCallBack, failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Output: play audio is not supported."); + } + else { + console.error("Audio Output: play audio is not supported."); + } + }, + /** + * parameter: string OR string Array OR object with attributes: + * text: string OR string Array, text that should be read aloud + * pauseLength: Length of the pauses between sentences in milliseconds + * forceSingleSentence: boolean, if true, a string Array will be turned into a single string + * split: boolean, if true and the text is a single string, it will be split using a splitter function + * splitter: function, replaces the default splitter-function. It takes a simple string as input and gives a string Array as output + */ + textToSpeech: function(parameter, successCallBack,failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Output: Text To Speech is not supported."); + } + else { + console.error("Audio Output: Text To Speech is not supported."); + } + }, + + //ADDITIONAL functions: + cancelSpeech: function(successCallBack,failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Output: canceling Text To Speech is not supported."); + } + else { + console.error("Audio Output: canceling Text To Speech is not supported."); + } + }, + playURL: function(url, successCallback, failureCallBack){ + if(failureCallBack){ + failureCallBack("Audio Output: play audio from URL is not supported."); + } + else { + console.error("Audio Output: play audio from URL is not supported."); + } + }, + getURLAsAudio: function(url, successCallback, failureCallBack, onLoadedCallBack){ + if(failureCallBack){ + failureCallBack("Audio Output: create audio from URL is not supported."); + } + else { + console.error("Audio Output: create audio from URL is not supported."); + } + } + }; + }; + function getPluginsToLoad(){ + var env = null; + var pluginArray = new Array(); + if (forBrowser) { + env = 'browser'; + } else { + env = 'android'; + } + var dataFromConfig = mobileDS.ConfigurationManager.getInstance().get('mediaPlugins'); + if (dataFromConfig && dataFromConfig[env]){ + pluginArray = pluginArray.concat(dataFromConfig[env]); + } else{ + pluginArray = pluginArray.concat(pluginsToLoad[env]); + } + return pluginArray; + } + + function loadAllPlugins(pluginArray, successCallback,failureCallback){ + if (pluginArray == null || pluginArray.length<1){ + if (successCallback) { + successCallback(); + } + return; + } + var newPluginName = pluginArray.pop(); + loadPlugin(newPluginName, function (){console.log(newPluginName+' loaded!');loadAllPlugins(pluginArray,successCallback, failureCallback);}, failureCallback); + } + + + return { + /** + * Object containing the instance of the class {{#crossLink "audioInput"}}{{/crossLink}} + * + * @method getInstance + * @return {Object} Object containing the instance of the class {{#crossLink "MediaManager"}}{{/crossLink}} + * @public + */ + create: function(successCallback, failureCallback){ + if (instance === null) { + jQuery.extend(true,this,constructor()); + instance = this; + var pluginArray = getPluginsToLoad(); + loadAllPlugins(pluginArray,successCallback, failureCallback); + + } + return this; + }, + getInstance: function(){ + return this.create(null, null); + }, + /** + * loads a file. If the file implements a function initialize(f) + * where the function f is called with a set of functions e, then those functions in e + * are added to the visibility of audioInput, and will from now on be applicable by calling + * mobileDS.MediaManager.getInstance().. + */ + loadFile: function(filePath,successCallback, failureCallback){ + if (instance=== null) { + this.create(); + } + + loadPlugin(filePath,sucessCallback, failureCallback); + + } + }; +}) (); diff --git a/assets/www/mmirf/manager/modelManager.js b/assets/www/mmirf/manager/modelManager.js new file mode 100644 index 0000000..7c86498 --- /dev/null +++ b/assets/www/mmirf/manager/modelManager.js @@ -0,0 +1,385 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * @module mobileDS.manager + * + */ +var mobileDS = window.mobileDS || +{}; + +/** + * + * A class for managing the models of the application (MVC-Component).
+ * It's purpose is to load the models automatically. + * + * This "class" is structured as a singleton - so that only one instance is in use.
+ * You can access the instance of the class via + * + * TODO add example for usage (models as "class" / models as "singleton") + * + * @example mobileDS.ModelManager.getInstance() + * @class ModelManager + * @category core + * + * @see mobileDS.ModelManager#constructor + */ +mobileDS.ModelManager = (function(){ + + + /** + * Object containing the instance of the class {@link mobileDS.ModelManager} + * + * @property instance + * @type Object + * @private + */ + var instance = null; + + /** + * Constructor-Method of Class {@link mobileDS.ModelManager}.
+ * This class is similar to the class {@link mobileDS.ControllerManager}. + * + *
+ * Note: + * The callback function should contain all (!) instructions which require the prior loading of the models.
+ * A callback function is used, because the loading process is asynchronous. + *
+ * + * @param {Function} callbackFunction A callback function + * @constructor + * @augments mobileDS.ModelManager + * @memberOf mobileDS.ModelManager.prototype + */ + function constructor(callbackFunction){ + // private members + /** + * Array of models + * + * @property models + * @type Dictionary + * @private + */ + var models = new Dictionary(); + + var MODEL_DEFAULT_NAMESPACE_NAME = 'mobileDS'; + var GLOBAL_NAMESPACE = window; + + /** + * + * This function returns the fully qualified model name (incl. namespace(s)). + * + * @function getFullModelName + * @param {String} modelClassName the model's class-name (i.e. without namespace) + * @returns {String} fully qualified name for the model + * @private + */ + function getFullModelName(modelClassName){ + if( ! MODEL_DEFAULT_NAMESPACE_NAME){ + return modelClassName; + } + else { + return MODEL_DEFAULT_NAMESPACE_NAME + '.' + modelClassName; + } + } + + /** + * + * This function returns the fully qualified model name (incl. namespace(s)). + * + * @function getModelByName + * @param {String|Array} fullModelName the fully qualified model name (i.e. with namespace(s)) + * Note, if {String} components/namespaces are separated by a . (dot) + * If {Array} the entries correspond to the namespace components (without dots), + * where the last entry corresponds to the class/singleton name + * @returns {Object} the "raw" model object (may be a constructor or the main-singleton-namespace). + * Or null if there is no Model with the name. + * @private + * + * @requires mobileDS.CommonUtils#isArray + * + * @see mobileDS.ModelManager#getFullModelName + * @see mobileDS.ModelManager#doGetModelInstance + */ + function getModelByName(fullModelName){ + var components; + if(mobileDS.CommonUtils.getInstance().isArray(fullModelName)){ + components = fullModelName; + } + else { + components = fullModelName.split('.'); + } + + var currentNameSpace = GLOBAL_NAMESPACE; + for(var i=0, size = components.length; i < size; ++i){ + currentNameSpace = currentNameSpace[components[i]]; + if(typeof currentNameSpace !== 'undefined' ){ + if(i === size-1){ + return currentNameSpace; + } + } + else { + console.error('ModelManager.getModelByName: could not find model "' + +(components.join('.')) + +'": invalid namespace/class: ' + +components[i] + ); + break; + } + } + return null; + } + + /** + * Returns the instance for a model implementation: + * + * If the model-object is a constructor (i.e. a function), + * a new instance is created and returned. + * + * Otherwise the model-object itself is returned (e.g. for + * singleton pattern models). + * + * @function doGetModelInstance + * @private + * + * @see mobileDS.ModelManager#getModelByName + */ + function doGetModelInstance(modelImplObject){ + if(typeof modelImplObject === 'function'){ + return new modelImplObject(); + } +// else if(typeof modelImplObject.getInstance === 'function'){ +// return modelImplObject.getInstance(); +// } +// else if(typeof modelImplObject.create === 'function'){ +// return modelImplObject.create(); +// } + else{ + return modelImplObject; + } + } + +// /** +// * Index for the array of models +// * +// * @property mod_i +// * @type Integer +// * @private +// */ +// var mod_i = 0; + + /** + * + * This function returns all loaded models. + * + * @function getModels + * @returns {Array} all loaded model names + * @public + */ + function getModelNames(){ + return models.getKeys(); + } + + + /** + * This function loads the models one after another.
+ * The function is first called by {@link mobileDS.ControllerManager-constructor-loadControllers} + * + * @function foundModelsCallBack + * @param {Array} foundModels This parameter contains all model-filenames + * @param {Function} myCallbackFunction A callback function which shall be called after the completion of the model loading process + * @private + */ + function foundModelsCallBack(foundModels, myCallbackFunction, isRecursiveCall){ + if (foundModels.length < 1){ + if(!isRecursiveCall){ + console.warn("Load Model: no models found in "+mobileDS.constants.getInstance(forBrowser).getModelPath()+"/"); + } + if (typeof myCallbackFunction == 'function'){ + myCallbackFunction(instance); + } + } else { + var tmpModel = foundModels[0]; + + if(IS_DEBUG_ENABLED) console.debug("Load Model: "+mobileDS.constants.getInstance(forBrowser).getModelPath() + "/" + tmpModel);//debug + + // Create Controller after (!!!!) the adequate controller-js-file is loaded. + // or else there is no constructor and the controller-contructor fails. + + mobileDS.CommonUtils.getInstance().getLocalScript(mobileDS.constants.getInstance(forBrowser).getModelPath() + tmpModel, + function(){ + // save Modelname in models-array - starting with an upper-case character and + // cutting of the extension of the file containing the model. +// models[mod_i++] = tmpModel.charAt(0).toUpperCase() + tmpModel.slice(1).replace(/\.[^.]+$/g,""); + var modelName = tmpModel.charAt(0).toUpperCase() + tmpModel.slice(1).replace(/\.[^.]+$/g,""); + var fullName = getFullModelName(modelName); + var modelImpl = getModelByName(fullName); + var modelInstance; + if(modelImpl){ + modelInstance = doGetModelInstance(modelImpl); + } + else { + //TODO throw error in this case? + console.error('ModelManager.load: Could not find implementation for Model "'+modelName+'" ('+fullName+') for file '+tmpModel); + modelInstance = modelName; + } + //TODO implement mechanism for multiple/configurable model namespaces + models.put(fullName, modelInstance); + + foundModels = foundModels.slice(1); + foundModelsCallBack(foundModels, myCallbackFunction, true); + }, + function(exception) { + // print out an error message + console.error("[ERROR] " + exception); //failure + }); + + } + return 0; + } + + /** + * This function invokes the method {@link mobileDS.ModelManager-constructor-foundModelsCallBack} to load all models in the path specified by *modelPath*. + * + * @function loadModels + * @param {Function} myCallbackFunction The callback function from the constructor which shall be called after the initialization of the {@link mobileDS.ModelManager}. + * @private + */ + function loadModels(myCallbackFunction){ + // Load application's models. + +// console.log("[MODELS] " + mobileDS.constants.getInstance(forBrowser).getModelPath()); + var foundModels = mobileDS.CommonUtils.getInstance().getDirectoryContentsWithFilter(mobileDS.constants.getInstance(forBrowser).getModelPath(), "*.js"); + foundModelsCallBack(foundModels, myCallbackFunction); + } + + loadModels(callbackFunction); + + /** @lends mobileDS.ModelManager.prototype */ + return { // public members + /** + * This function gets the model by name. + * + * @function getModel + * @param {String} modelName Name of the model which should be returned + * @returns {Object} The model if found, null else + * @public + */ + getModel: function(modelName){ + var retModel = null; +// $.each(models, function(index, model){ +// if (model.getName() == modelName) { +// retModel = model; +// return false; +// } +// }); + + //TODO implement mechanism for multiple/configurable model namespaces + // (add optional namespace argument to getModel) + var fullModelName = getFullModelName(modelName); + + retModel = models.get(fullModelName); + if(!retModel){ + console.error('Could not find Model "'+modelName+'" at '+fullModelName); + return null; + } + return retModel; + }, + + + /** + * This function returns all loaded models. + * + * @function getModels + * @returns {Array} All loaded models + * @public + */ + getModels: function(){ + return models; + } + }; + } + + return { + + /** + * Get the object containing the instance of the class {@link mobileDS.ModelManager} + * + *
+ * Note: + * The ModelManager must first be initialized {@link mobileDS.ModelManager#create}; + * the instance of the singleton ModelManager is available, when the callback (i.e. the argument + * for the create function) is invoked. + *
+ * + * @function getInstance + * @returns {Object} Object containing the instance of the class {@link mobileDS.ModelManager} + * @public + */ + getInstance: function(){ + if (instance === null) { + alert("Error: Models not initialized!\nCall create(CallbackFunction)"); + return null; + } + return instance; + }, + + /** + * This function must be called before using the {@link mobileDS.ModelManager}. The Initialization process is asynchronous, + * because javascript-files must be loaded (the models), so it forces a synchronous behavior by using + * a callback function containing the instructions, which rely on the presence of the loaded models.
+ * + * It loads the models and then calls the callback functions and returns the instance of this class. + * + *
+ * Note: + * The callback function should contain all (!) instructions which require the prior loading of the models.
+ * The callback mechanism is necessary, because loading the models is asynchronous.

+ * If provided, the callback function is invoked with 1 argument, the ModelManager instance:
+ * callbackFunction(modelManagerInstance) + *
+ * + * @function create + * @param {Function} [callbackFunction] The function which should be called after loading all controllers + * @example + * function afterLoadingModels(modelManagerInstance){ + * var userModel = modelManagerInstance.getModel('User'); + * //do something... + * } + * mobileDS.ModelManager.create(afterLoadingModels); + * @public + */ + create: function(callbackFunction){ + if (instance === null) { + instance = constructor(callbackFunction); + } + return instance; + } + + }; + +})(); \ No newline at end of file diff --git a/assets/www/javascripts/manager/presentationManager.js b/assets/www/mmirf/manager/presentationManager.js similarity index 64% rename from assets/www/javascripts/manager/presentationManager.js rename to assets/www/mmirf/manager/presentationManager.js index e2e4751..631bc75 100644 --- a/assets/www/javascripts/manager/presentationManager.js +++ b/assets/www/mmirf/manager/presentationManager.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.manager + * @module mobileDS.manager * * Dependencies: * TODO add entries for used JS files @@ -66,6 +66,19 @@ mobileDS.PresentationManager = (function(){ */ var instance = null; + /** + * Name of the default controller. + * + *

Note, that there must be (1) a controller and (2) a layout definition for this name, + * otherwise the framework will not be able to start. + * + * @property DEFAULT_CONTROLLER_NAME + * @type String + * @private + * @constant + */ + var DEFAULT_CONTROLLER_NAME = 'Application'; + /** * Constructor-Method of Class {@link mobileDS.PresentationManager}
* It invokes the loading of layouts, views and partials. @@ -81,82 +94,81 @@ mobileDS.PresentationManager = (function(){ * Array of layouts of the application * * @property layouts - * @type Array + * @type Dictionary * @private */ - var layouts = new Array(); + var layouts = new Dictionary(); /** * Array of all the views of the application * * @property views - * @type Array + * @type Dictionary * @private */ - var views = new Array(); + var views = new Dictionary(); /** * Array of all the partials of the application * * @property partials - * @type Array + * @type Dictionary * @private */ - var partials = new Array(); + var partials = new Dictionary(); - /** - * JQuery object of the 'body' element - * - * @property body - * @type Object - * @private - * @deprecated unused - */ - var body = $('body'); +// /** +// * JQuery object of the 'body' element +// * +// * @property body +// * @type Object +// * @private +// * @deprecated unused +// */ +// var body = $('body'); + +// /** +// * Unused variable. +// * +// * @property lastPage +// * @type String +// * @private +// * @deprecated unused +// */ +// var lastPage = null; - /** - * Unused variable. - * - * @property lastPage - * @type String - * @private - * @deprecated unused - */ - var lastPage = null; +// /** +// * Index for the array of layouts +// * +// * @property layoutIndex +// * @type Integer +// * @private +// */ +// var layoutIndex = 0; - /** - * Index for the array of layouts - * - * @property layoutIndex - * @type Integer - * @private - */ - var layoutIndex = 0; +// /** +// * Index for the array of views +// * +// * @property viewIndex +// * @type Integer +// * @private +// */ +// var viewIndex = 0; - /** - * Index for the array of views - * - * @property viewIndex - * @type Integer - * @private - */ - var viewIndex = 0; - - - /** - * Index for the array of partials - * - * @property partialIndex - * @type Integer - * @private - */ - var partialIndex = 0; +// /** +// * Index for the array of partials +// * +// * @property partialIndex +// * @type Integer +// * @private +// */ +// var partialIndex = 0; /** @@ -193,6 +205,25 @@ mobileDS.PresentationManager = (function(){ //helper for rendering the HTML templates (i.e. the parsed template files) var renderer = mobileDS.parser.RenderUtils.getInstance(); + var viewSeparator = '#'; + var partialSeparator = mobileDS.CommonUtils.getInstance().getPartialsPrefix(); + function createLookupKey(ctrl, viewObj, separator){ + if(typeof ctrl.getName !== 'undefined'){ + ctrl = ctrl.getName(); + } + if(typeof viewObj.getName !== 'undefined'){ + viewObj = viewObj.getName(); + } + //TODO remove all >partialSeparator< from partial-string beginning + return ctrl+separator+viewObj; + } + function createViewKey(ctrl, view){ + return createLookupKey(ctrl, view, viewSeparator); + } + function createPartialKey(ctrl, partial){ + return createLookupKey(ctrl, partial, partialSeparator); + } + /** * This function loads the layouts for every controller and puts the name of the layouts into the layouts array. * @@ -203,18 +234,21 @@ mobileDS.PresentationManager = (function(){ // Load application's layouts. // get all controllers in an array - var tmpControllers = mobileDS.ControllerManager.getInstance().getControllers(); - for (var prop in tmpControllers) { - ctrlFileName = tmpControllers[prop].def.json.name.toLowerCase(); - $.ajax({ - async: false, - dataType: "text", - url: mobileDS.constants.getInstance(forBrowser).getLayoutPath() + ctrlFileName + '.ehtml', - success: function(data){ - var layout = new Layout(ctrlFileName, data); - layouts[layoutIndex++] = layout; - } - }); + var ctrlNames = mobileDS.ControllerManager.getInstance().getControllerNames(); + for(var i=0, size = ctrlNames.length; i < size; ++i){ + var ctrl = mobileDS.ControllerManager.getInstance().getController( ctrlNames[i] ); + var layoutDef = ctrl.def.json.layout; + if(layoutDef){ + $.ajax({ + async: false, + dataType: "text", + url: mobileDS.constants.getInstance(forBrowser).getLayoutPath() + layoutDef["fileName"] + '.ehtml', + success: function(data){ + var layout = new Layout(ctrl.getName(), data); + layouts.put(layout.getName(), layout);//[layoutIndex++] = layout; + } + }); + } } } @@ -223,7 +257,7 @@ mobileDS.PresentationManager = (function(){ * This function actually loads the views for every controller, creates an instance of a view class and puts the view instance in the views array.
* It uses a asynchronous way of loading the view-files one after another.
* If you want to make sure, that all views are indeed loaded, before proceeding with the subsequent instructions, you could look at the function - * {@link mobileDS.ControllerManager-constructor.foundControllersCallBack} for reference of a function which loads the files one after another - not asynchronous. + * {@link mobileDS.ControllerManager#foundControllersCallBack} for reference of a function which loads the files one after another - not asynchronous. * * @function loadViews * @private @@ -233,7 +267,7 @@ mobileDS.PresentationManager = (function(){ function getViewPath(name, controller){ var returnpath = ""; $.each(controller.def.query("views"), function(index, view){ - if (name.toLowerCase() === view["name"].toLowerCase()) { + if (name === view["name"]) { returnpath = view["path"]; return false; } @@ -241,8 +275,8 @@ mobileDS.PresentationManager = (function(){ return returnpath; } - $.each(mobileDS.ControllerManager.getInstance().getControllers(), function(ctrlIndex, controller){ - + $.each(mobileDS.ControllerManager.getInstance().getControllerNames(), function(ctrlIndex, controllerName){ + var controller = mobileDS.ControllerManager.getInstance().getController(controllerName); $.each(controller.getViews(), function(index, view){ $.ajax({ @@ -250,8 +284,8 @@ mobileDS.PresentationManager = (function(){ dataType: "text", url: getViewPath(view, controller), success: function(data){ - var ctrlView = new View(controller, controller.getName() + "#" + view, data); - views[viewIndex++] = ctrlView; + var ctrlView = new View(controller, view , data); + views.put( createViewKey( controller.getName(), view), ctrlView);//[viewIndex++] = ctrlView; } }).fail(function(jqxhr, settings, err){ // print out an error message @@ -271,7 +305,7 @@ mobileDS.PresentationManager = (function(){ * This function actually loads the partials for every controller, creates an instance of a partial class and puts the partial instance in the partials array.
* It uses a asynchronous way of loading the partials-files one after another.
* If you want to make sure, that all partials are indeed loaded, before proceeding with the subsequent instructions, you could look at the function - * {@link mobileDS.ControllerManager-constructor.foundControllersCallBack} for reference of a function which loads the files one after another - not asynchronous. + * {@link mobileDS.ControllerManager#foundControllersCallBack} for reference of a function which loads the files one after another - not asynchronous. * * @function loadPartials * @private @@ -281,7 +315,7 @@ mobileDS.PresentationManager = (function(){ function getPartialPath(name, controller){ var returnpath = ""; $.each(controller.def.query("partials"), function(index, partial){ - if (name.toLowerCase() === partial["name"].toLowerCase()) { + if (name === partial["name"]) { returnpath = partial["path"]; return false; } @@ -289,15 +323,16 @@ mobileDS.PresentationManager = (function(){ return returnpath; } - $.each(mobileDS.ControllerManager.getInstance().getControllers(), function(ctrlIndex, controller){ + $.each(mobileDS.ControllerManager.getInstance().getControllerNames(), function(ctrlIndex, controllerName){ + var controller = mobileDS.ControllerManager.getInstance().getController(controllerName); $.each(controller.getPartials(), function(index, partial){ $.ajax({ async: false, dataType: "text", url: getPartialPath(partial, controller), success: function(data){ - var ctrlPartial = new Partial(controller, controller.getName() + mobileDS.CommonUtils.getInstance().getPartialsPrefix() + partial, data); - partials[partialIndex++] = ctrlPartial; + var ctrlPartial = new Partial(controller, partial, data); + partials.put(createPartialKey( controller.getName(), partial), ctrlPartial);//[partialIndex++] = ctrlPartial; } }).fail(function(jqxhr, settings, err){ // print out an error message @@ -315,86 +350,91 @@ mobileDS.PresentationManager = (function(){ /** @lends mobileDS.PresentationManager.prototype */ - return { //public members - /** - * This function returns a visualComponent by id.
- * Only Problem is: there is no such thing as a visualComponent. - * - * @function getVisualComponent - * @param {String} compId Id of the visual component - * @returns {Object} visualComponents - * @public - * @deprecated unused and wrong - */ - getVisualComponent: function(compId){ - return visualComponents[compId]; - }, - + return { + //public members addLayout: function(layout){ - var layout_replaced = false; - $.each(layouts, function(index, l){ - if (layouts[index].getName() == layout.getName()) { - layouts[index] = layout; - layout_replaced = true; - return false; - } - }); - if (layout_replaced == false){ - layouts.push(layout); - } +// var layout_replaced = false; +// $.each(layouts, function(index, l){ +// if (layouts[index].getName() == layout.getName()) { +// layouts[index] = layout; +// layout_replaced = true; +// return false; +// } +// }); +// if (layout_replaced == false){ +// layouts.push(layout); +// } + layouts.put(layout.getName(), layout); }, /** * This function returns a layout object by name.
* * @function getLayout * @param {String} layoutName Name of the layout which should be returned + * @param {Boolean} [doUseDefaultIfMissing] if supplied and true, the default controller's layout will be used as a fallback, in case no corresponding layout could be found * @returns {Object} The requested layout, "false" if not found * @public */ - getLayout: function(layoutName){ - var layout; - $.each(layouts, function(index, l){ - if (l.getName() == layoutName) { - layout = l; - return false; - } - }); + getLayout: function(layoutName, doUseDefaultIfMissing){ + var layout = false; +// $.each(layouts, function(index, l){ +// if (l.getName() == layoutName) { +// layout = l; +// return false; +// } +// }); + layout = layouts.get(layoutName); + if(!layout){ + if(doUseDefaultIfMissing){ + layout = instance.getLayout(DEFAULT_CONTROLLER_NAME, false); + } + else { + console.error('[PresentationManager.getLayout]: could not find layout "'+layoutName);//+'" for controller "'+ (controller?controller.name:'undefined') +'"!'); + return false; + } + } return layout; }, - addView: function(view){ - var view_replaced = false; - $.each(views, function(index, v){ - if (views[index].getName() == view.getName()) { - views[index] = view; - view_replaced = true; - return false; - } - }); - if (view_replaced == false){ - views.push(view); - } + addView: function(ctrlName, view){ +// var view_replaced = false; +// $.each(views, function(index, v){ +// if (views[index].getName() == view.getName()) { +// views[index] = view; +// view_replaced = true; +// return false; +// } +// }); +// if (view_replaced == false){ +// views.push(view); +// } + views.put(createViewKey(ctrlName, view), view); }, /** * This function returns a view object by name.
* * @function getView + * @param {String} controllerName Name of the controller for the view * @param {String} viewName Name of the view which should be returned - * @returns {Object} The requested view, "false" if not found + * @returns {Object} The requested view, false if not found * @public */ - getView: function(viewName){ - var view; -// console.log("[PresentationManager] looking for " + viewName); - $.each(views, function(index, v){ -// console.log("ViewName: " + v.getName()); - if (v.getName() == viewName) { -// console.log("found " + v.getName()); - view = v; - return false; - } - }); + getView: function(controllerName, viewName){ + viewName = createViewKey(controllerName, viewName); + var view = false; +// $.each(views, function(index, v){ +// if (v.getName() == viewName) { +// view = v; +// return false; +// } +// }); + view = views.get(viewName); + + if(!view){ + console.error('[PresentationManager.getView]: could not find view "'+viewName);//+'" for controller "'+ (controller?controller.name:'undefined') +'"!'); + return false; + } return view; }, @@ -403,32 +443,36 @@ mobileDS.PresentationManager = (function(){ * This function returns a partial object by name.
* * @function getPartial + * @param {String} controllerName Name of the controller for the view * @param {String} viewName Name of the partial which should be returned * @returns {Object} The requested partial, "false" if not found * @public */ - getPartial: function(partialName, controller){ + getPartial: function(controllerName, partialName){ var partial = false; - partialName = partialName.toLowerCase();//TODO remove conversion to lower case (this has to be done in all locations that write/access the partial's name!) - - if(controller){ - if(typeof controller.getName !== 'undefined'){ - partialName = controller.getName() + mobileDS.CommonUtils.getInstance().getPartialsPrefix() + partialName; - } - else { - partialName = controller + mobileDS.CommonUtils.getInstance().getPartialsPrefix() + partialName; - } + var partialKey = null; + if(controllerName){ + partialKey = createPartialKey(controllerName, partialName); + } + else { + console.error('[PresentationManager.getPartial]: requested partial "'+partialName+'" for unknown controller: "'+ (controllerName?controllerName.getName():'undefined') +'"'); + return false; } // console.log("[PresentationManager] looking for " + partialName); - for(var i=0, size = partials.length; i < size; ++i){ -// console.log("partialName: " + p.getName()); - if (partials[i].getName() == partialName.toLowerCase()) { -// console.log("found " + partials[i].getName()); - partial = partials[i]; - break; - } +// for(var i=0, size = partials.length; i < size; ++i){ +//// console.log("partialName: " + p.getName()); +// if (partials[i].getName() == partialName) { +//// console.log("found " + partials[i].getName()); +// partial = partials[i]; +// break; +// } +// } + partial = partials.get(partialKey); + if(!partial){ + console.error('[PresentationManager.getPartial]: could not find partial "'+partialName+'" for controller "'+ (controllerName?controllerName.getName():'undefined') +'"!'); + return false; } return partial; }, @@ -437,10 +481,15 @@ mobileDS.PresentationManager = (function(){ /** * Closes a modal window - in this case a dialog.
* - * @function close_current_dialog + *
+ * TODO needs to be "settable", depending on the currently used (modal) dialog library + * + * @requires jQuery Mobile SimpleModal + * + * @function hideCurrentDialog * @public */ - close_current_dialog: function (){ + hideCurrentDialog: function (){ /*if (current_dialog != null){ current_dialog.close(); current_dialog = null; @@ -454,15 +503,20 @@ mobileDS.PresentationManager = (function(){ /** * Function opens requested dialog.
* - * @function show_dialog + *
+ * TODO needs to be "settable", depending on the currently used (modal) dialog library + * + * @requires jQuery Mobile SimpleModal + * + * @function showDialog * @param {String} ctrlName Name of the controller * @param {String} dialogId Id of the dialog * @param {Object} data Optionally data - not used * @public */ - show_dialog : function(ctrlName, dialogId, data) { + showDialog : function(ctrlName, dialogId, data) { - this.close_current_dialog(); + this.hideCurrentDialog(); var ctrl = mobileDS.ControllerManager.getInstance().getController(ctrlName); @@ -496,7 +550,7 @@ mobileDS.PresentationManager = (function(){ /** * Gets the view for a controller, then executes helper methods on the view data. - * The Rendering of the view is done by the {@link mobileDS.PresentationManager-constructor.render_view_successor} method. + * The Rendering of the view is done by the {@link mobileDS.PresentationManager#doRenderView} method. * Also stores the previous and current view with parameters.
* * @function renderView @@ -509,13 +563,13 @@ mobileDS.PresentationManager = (function(){ var ctrl = mobileDS.ControllerManager.getInstance().getController(ctrlName); if (ctrl != null) { - var view = mobileDS.PresentationManager.getInstance().getView(ctrlName + "#" + viewName); + var view = mobileDS.PresentationManager.getInstance().getView(ctrlName, viewName); //DISABLED helper methods are now handled differently -> invoked during rendering where they are specified in the template/view definition // //execute the helper-scripts that were referenced in the view: // view.executeHelperMethods(data); - mobileDS.PresentationManager.getInstance().render_view_successor(ctrlName, viewName, view, ctrl, data); + mobileDS.PresentationManager.getInstance().doRenderView(ctrlName, viewName, view, ctrl, data); // Only overwrite previous state if and only if the view is not rerendered! if (ctrlName != currentView["ctrlName"] || viewName != currentView["viewName"] || data != currentView["data"]){ @@ -532,12 +586,12 @@ mobileDS.PresentationManager = (function(){ /** - * Renders the current view again, using the {@link mobileDS.PresentationManager-constructor.render} method. + * Renders the current view again, using the {@link mobileDS.PresentationManager#render} method. * - * @function rerenderView + * @function reRenderView * @public */ - rerenderView: function(){ + reRenderView: function(){ if (currentView){ if (currentView["ctrlName"] && currentView["viewName"]){ dialogManager.render(currentView["ctrlName"], currentView["viewName"], currentView["data"]); @@ -547,7 +601,7 @@ mobileDS.PresentationManager = (function(){ /** - * Renders the previous view again, using the {@link mobileDS.DialogEngine-constructor.render} method. + * Renders the previous view again, using the {@link mobileDS.DialogEngine#render} method. * * @function renderPreviousView * @public @@ -565,26 +619,22 @@ mobileDS.PresentationManager = (function(){ * Actually renders the View.
* Fetches the layout for the controller, then fills the layout-template with the view content, while incorporating * partials and contents that helper methods have provided. Then Dialogs are created and the pageContainer id is updated. - * At last all the content is localized using {@link mobileDS.LanguageManager-constructor.translateHTML}, and appended to the + * At last all the content is localized using {@link mobileDS.LanguageManager#translateHTML}, and appended to the * HTML document of the application, while the old one is removed - is probably not a good idea to use '$("div[data-role='page']").first().remove()' to * remove the old page content: it's not robust.
* At the end the on_page_load action is performed. * - * @function render_view_successor + * @function doRenderView * @param {String} ctrlName Name of the controller * @param {String} viewName Name of the view to render * @param {Object} view View object that is to be rendered * @param {Object} ctrl Controller object of the view to render - * @param {Object} data Optionally data for the view + * @param {Object} [data] optional data for the view * @public */ - render_view_successor: function(ctrlName, viewName, view, ctrl, data){ - var layout = mobileDS.PresentationManager.getInstance().getLayout(ctrlName); - - if (typeof layout === "undefined") { - console.warn("could not find layout-defintion for '"+ctrlName+"'"); - layout = mobileDS.PresentationManager.getInstance().getLayout('application'); - } + doRenderView: function(ctrlName, viewName, view, ctrl, data){ + var layout = instance.getLayout(ctrlName, true); + var layoutBody = layout.getBodyContents(); var layoutDialogs = layout.getDialogsContents(); @@ -631,15 +681,15 @@ mobileDS.PresentationManager = (function(){ if(oldContent.length < 1 && oldId == '#pageContainer0'){ //the ID of the first page (pageIndex 0) may have no number postfix // -> try without numer: - if(IS_DEBUG_ENABLED) console.debug('PresentationManager.render_view_successor: removing old content: no old centent found for old ID "'+oldId+'", trying "#pageContainer" instead...');//debug + if(IS_DEBUG_ENABLED) console.debug('PresentationManager.doRenderView: removing old content: no old centent found for old ID "'+oldId+'", trying "#pageContainer" instead...');//debug oldContent = $('#pageContainer'); } oldContent.remove(); - ctrl.performAction('on_page_load', data); + ctrl.perform('on_page_load', data); - ctrl.performActionIfPresent('on_page_load_'+viewName, data); + ctrl.performIfPresent('on_page_load_'+viewName, data); // ===================================================================== var debug = 0;//debug: set >= 1 for debugging diff --git a/assets/www/javascripts/manager/settings/configurationManager.js b/assets/www/mmirf/manager/settings/configurationManager.js similarity index 91% rename from assets/www/javascripts/manager/settings/configurationManager.js rename to assets/www/mmirf/manager/settings/configurationManager.js index b240fb7..600e311 100644 --- a/assets/www/javascripts/manager/settings/configurationManager.js +++ b/assets/www/mmirf/manager/settings/configurationManager.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.manager.settings + * @module mobileDS.manager.settings * */ var mobileDS = window.mobileDS || @@ -100,6 +100,9 @@ mobileDS.ConfigurationManager = (function(){ return { // public members /** * Returns the currently used language. + * + *

This does not return the language of the configuration, but is a + * shortcut for {@link mobileDS.LanguageManager#getLanguage}. * * @function getLanguage * @returns {String} The currently used language @@ -109,7 +112,10 @@ mobileDS.ConfigurationManager = (function(){ return mobileDS.LanguageManager.getInstance().getLanguage(); }, /** - * Sets the currently used language. + * Sets the currently used language. + * + *

This does not set the language of the configuration, but is a + * shortcut for {@link mobileDS.LanguageManager#setLanguage}. * * @function setLanguage * @param {String} lang The language which is to be used diff --git a/assets/www/javascripts/manager/settings/languageManager.js b/assets/www/mmirf/manager/settings/languageManager.js similarity index 68% rename from assets/www/javascripts/manager/settings/languageManager.js rename to assets/www/mmirf/manager/settings/languageManager.js index fa914fc..43b27cd 100644 --- a/assets/www/javascripts/manager/settings/languageManager.js +++ b/assets/www/mmirf/manager/settings/languageManager.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.manager + * @module mobileDS.manager * */ var mobileDS = window.mobileDS || @@ -120,12 +120,11 @@ mobileDS.LanguageManager = (function(){ */ function constructor(lang){ if ((!lang || lang.length < 1) && (!currentLanguage || currentLanguage.length < 1)){ - // var appLang = mobileDS.ConfigurationManager.getInstance().getLanguage(); + var appLang = mobileDS.constants.getInstance().getLanguage(); - if (appLang && appLang.length > 0){//applicationLanguage.length > 0){ - lang = appLang;//applicationLanguage; - // console.info("[LanguageManager] No language specified. Using language from mobileDS.ConfigurationManager '" + appLang +"'.");//applicationLanguage + "'."); - console.info("[LanguageManager] No language specified. Using language from mobileDS.constants '" + appLang +"'.");//applicationLanguage + "'."); + if (appLang && appLang.length > 0){ + lang = appLang; + console.info("[LanguageManager] No language specified. Using language from mobileDS.constants '" + appLang +"'."); } else { if (languages.length > 0){ console.info("[LanguageManager] No language specified. Using first language in directory '"+mobileDS.constants.getInstance(forBrowser).getLanguagePath()+"': '" + languages[0] + "'."); @@ -154,14 +153,14 @@ mobileDS.LanguageManager = (function(){ } - function doCheckExistsGrammarForLanguage(lang){ + function doCheckExistsGrammar(lang){ var langFiles = null; var retValue = false; if (lang != null){ langFiles = mobileDS.CommonUtils.getInstance().getDirectoryContents(mobileDS.constants.getInstance(forBrowser).getLanguagePath() + lang); if (langFiles != null){ - if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getGrammarFilename()) > -1){ + if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getGrammarFileName()) > -1){ retValue = true; } } @@ -189,12 +188,50 @@ mobileDS.LanguageManager = (function(){ * @async * @private */ - function requestGrammar(lang){ + function requestGrammar(lang, doSetNextBestAlternative){ - if(mobileDS.SemanticInterpreter.getInstance().hasGrammar(lang) || doCheckExistsGrammarForLanguage(lang)){ + if(mobileDS.SemanticInterpreter.getInstance().hasGrammar(lang) || doCheckExistsGrammar(lang)){ mobileDS.SemanticInterpreter.getInstance().setCurrentGrammar(lang); return lang; } + else if(doSetNextBestAlternative) { + //try to find a language, for which a grammar is available + var grammarLang = null; + if(languages.length > 0){ + //first: try to find a language with COMPILED grammar + for(var i=0, size = languages.length; i < size; ++i){ + grammarLang = languages[i]; + if( mobileDS.SemanticInterpreter.getInstance().hasGrammar(grammarLang) ){ + break; + } + else { + grammarLang = null; + } + } + + //... otherwise: try to find a language with JSON grammar: + if( ! grammarLang){ + for(var i=0, size = languages.length; i < size; ++i){ + grammarLang = languages[i]; + if( doCheckExistsGrammar(grammarLang) ){ + break; + } + else { + grammarLang = null; + } + } + } + } + + if(grammarLang){ + console.warn('Could not find grammar for selected language '+lang+', using grammar for language '+grammarLang+' instead.'); + mobileDS.SemanticInterpreter.getInstance().setCurrentGrammar(grammarLang); + } + else { + console.warn('Could not find any grammar for one of ['+languages.join(', ')+'], disabling SemanticInterpret.'); + mobileDS.SemanticInterpreter.getInstance().setEnabled(false); + } + } return mobileDS.SemanticInterpreter.getInstance().getCurrentGrammar(); } @@ -215,7 +252,7 @@ mobileDS.LanguageManager = (function(){ $.ajax({ async: false, dataType: "json", - url: mobileDS.constants.getInstance(forBrowser).getLanguagePath()+lang+"/"+mobileDS.constants.getInstance(forBrowser).getSpeakerFilename(), // languagePath + lang + "/dictionary.dic", + url: mobileDS.constants.getInstance(forBrowser).getLanguagePath()+lang+"/"+mobileDS.constants.getInstance(forBrowser).getSpeakerFileName(), // languagePath + lang + "/dictionary.dic", success: function(data){ // console.log("[LanguageManager] Success. " + data); currentSpeaker = data;//jQuery.parseJSON(data); @@ -246,7 +283,7 @@ mobileDS.LanguageManager = (function(){ $.ajax({ async: false, dataType: "json", - url: mobileDS.constants.getInstance(forBrowser).getLanguagePath()+lang+"/"+mobileDS.constants.getInstance(forBrowser).getDictionaryFilename(), // languagePath + lang + "/dictionary.dic", + url: mobileDS.constants.getInstance(forBrowser).getLanguagePath()+lang+"/"+mobileDS.constants.getInstance(forBrowser).getDictionaryFileName(), // languagePath + lang + "/dictionary.dic", success: function(data){ // console.log("[LanguageManager] Success. " + data); dictionary = data;//jQuery.parseJSON(data); @@ -267,7 +304,7 @@ mobileDS.LanguageManager = (function(){ loadDictionary(lang); loadSpeaker(lang); - requestGrammar(lang); + requestGrammar(lang, true);//2nd argument TRUE: if no grammar is available for lang, try to find/set any available grammar /** * Translates a keyword using the current dictionary and returns the translation. @@ -297,11 +334,10 @@ mobileDS.LanguageManager = (function(){ /** @lends mobileDS.LanguageManager.prototype */ return { /** - * unused
* Returns the dictionary of the currently used language. * * @function getDictionary - * @returns {Array} The dictionary of the currently used language + * @returns {Object} The JSON object for the dictionary of the currently used language * @public */ getDictionary: function(){ @@ -312,19 +348,19 @@ mobileDS.LanguageManager = (function(){ * If a dictionary exists for the given language, 'true' is returned. Else * the method returns 'false'. * - * @function existsDictionaryForLanguage + * @function existsDictionary * @returns {Boolean} True if a dictionary exists for given language. * @param {String} Language String, i.e.: en, de * @public */ - existsDictionaryForLanguage: function(lang){ + existsDictionary: function(lang){ var langFiles = null; var retValue = false; if (lang != null){ langFiles = mobileDS.CommonUtils.getInstance().getDirectoryContents(mobileDS.constants.getInstance(forBrowser).getLanguagePath() + lang); if (langFiles != null){ - if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getDictionaryFilename()) > -1){ + if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getDictionaryFileName()) > -1){ retValue = true; } } @@ -336,19 +372,19 @@ mobileDS.LanguageManager = (function(){ * If a Speaker exists for the given language, 'true' is returned. Else * the method returns 'false'. * - * @function existsDictionaryForLanguage + * @function existsDictionary * @returns {Boolean} True if a Speaker exists for given language. * @param {String} Language String, i.e.: en, de * @public */ - existsSpeakerForLanguage: function(lang){ + existsSpeaker: function(lang){ var langFiles = null; var retValue = false; if (lang != null){ langFiles = mobileDS.CommonUtils.getInstance().getDirectoryContents(mobileDS.constants.getInstance(forBrowser).getLanguagePath() + lang); if (langFiles != null){ - if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getSpeakerFilename()) > -1){ + if (langFiles.indexOf(mobileDS.constants.getInstance(forBrowser).getSpeakerFileName()) > -1){ retValue = true; } } @@ -357,28 +393,37 @@ mobileDS.LanguageManager = (function(){ }, /** - * If a grammar exists for the given language, 'true' is returned. Else + * If a JSON grammar file exists for the given language, 'true' is returned. Else * the method returns 'false'. * - * @function existsGrammarForLanguage + * @function existsGrammar * @returns {Boolean} True if a grammar exists for given language. * @param {String} Language String, i.e.: en, de * @public */ - existsGrammarForLanguage: doCheckExistsGrammarForLanguage, + existsGrammar: doCheckExistsGrammar, /** - * Chooses a language for the application: - * 1) check if a default language exists + * Chooses a language for the application. + * + *

The language selection is done as follows: + *

    + *
  1. check if a default language exists
    * if it does and if both (!) grammar and dictionary exist for this language, return this language - * 2) walk through all languages alphabetically - * 2.1) if for a language both (!) grammar and dictionary exist, return this language + *
  2. + *
  3. walk through all languages alphabetically + *
      + *
    1. if for a language both (!) grammar and dictionary exist, return this language * memorize the first language with a grammar (do not care, if a dictionary exists) - * 3) test if a grammar exists for the default language - do not care about dictionaries - if it does, return the default language - * 4) If a language was found (in Step 2.1) return this language - * 5) If still no language is returned take the default language if it has a dictionary - * 6) If a language exists, take it (the first one) - * 7) Take the default language - no matter what + *
    2. + *
    + *
  4. test if a grammar exists for the default language - do not care about dictionaries - if it does, return the default language + *
  5. If a language was found (in Step 2.1) return this language + *
  6. If still no language is returned take the default language if it has a dictionary + *
  7. If a language exists, take it (the first one) + *
  8. Take the default language - no matter what + *
  9. + *
* * @function determineLanguage * @returns {String} The determined language @@ -391,7 +436,7 @@ mobileDS.LanguageManager = (function(){ // first check, if language - given in parameter - exists if (tempLanguage != null) { // check if both grammar and dictionary exist for given language - if (mobileDS.LanguageManager.getInstance().existsGrammarForLanguage(tempLanguage) && mobileDS.LanguageManager.getInstance().existsDictionaryForLanguage(tempLanguage)){ + if (mobileDS.LanguageManager.getInstance().existsGrammar(tempLanguage) && mobileDS.LanguageManager.getInstance().existsDictionary(tempLanguage)){ return tempLanguage; } } @@ -400,7 +445,7 @@ mobileDS.LanguageManager = (function(){ // then check, if default language exists if (tempLanguage != null) { // check if both grammar and dictionary exist for default language - if (mobileDS.LanguageManager.getInstance().existsGrammarForLanguage(tempLanguage) && mobileDS.LanguageManager.getInstance().existsDictionaryForLanguage(tempLanguage)){ + if (mobileDS.LanguageManager.getInstance().existsGrammar(tempLanguage) && mobileDS.LanguageManager.getInstance().existsDictionary(tempLanguage)){ return tempLanguage; } } @@ -408,14 +453,14 @@ mobileDS.LanguageManager = (function(){ for (var i=0; i - * Note: - * At the moment this function is used by controllers/application.js:available_languages which in turn is - * used by helpers/applicationHelper.js to generate the language menu.
- * This process shall be replaced by a version using a partial as a language menu template! - *
* Gets an array of all for the translation available languages.
* - * * @function getLanguages * @returns {String} An array of all for the translation available languages * @public @@ -513,12 +540,12 @@ mobileDS.LanguageManager = (function(){ /** * Cycles through the available languages. * - * @function cycleLanguages + * @function setNextLanguage * @returns {String} The (new) current language * @public * @deprecated unused */ - cycleLanguages: function(){ + setNextLanguage: function(){ var indexCurrentLanguage = languages.indexOf(currentLanguage); if(IS_DEBUG_ENABLED) console.debug("[LanguageManager] Current language is " + currentLanguage);//debug @@ -534,28 +561,9 @@ mobileDS.LanguageManager = (function(){ loadSpeaker(currentLanguage); return loadDictionary(currentLanguage); } + return currentLanguage; }, - /** - * This function is used to localize the view description (ehtml) before they are displayed. - * - * @function translateHTML - * @param {String} html The (HTML) string which is to be localized into the currently used language - * @returns {String} The localized (HTML) string - * @public - */ - translateHTML: function(html){ - var translationRegExp = mobileDS.CommonUtils.getInstance().getTranslationRegExp(); - if (html.match(translationRegExp)){ - while (tre = translationRegExp.exec(html)) { - var translated = internalGetText(tre[1]); - html = html.replace(tre[0], translated); - } - } - return html; - }, - - /** * Looks up a keyword in the current dictionary and returns the translation. * @@ -573,36 +581,95 @@ mobileDS.LanguageManager = (function(){ */ getSpeaker: function(){ return currentSpeaker; - }, - - /** - *
- * Note: - * Momentarily this function is used by 'helpers/applicationHelper.js' to generate a menu to choose the application language.
- * This should better be implemented as a partial. - *
- * - * This function changes the application language and if wanted renders the current view again, so that - * the change of the language is applied to the currently displayed view. - * And after that an event "language_choosen" (typo) is raised.
+ } + + /** + * Set to "backwards compatibility mode" (for pre version 2.0). + * + * This function re-adds deprecated and removed functions and properties to the CommonUtils instance. + * + * NOTE that once set to compatibility mode, it cannot be reset to non-compatibility mode. + * + * TODO move into separate extensions file + * + * @functionOf mobileDS.LanguageManager.prototype + * @constructor * - * @function changeLanguage - * @param {String} newLang The new language which is to be used henceforth - * @param {Boolean} rerenderview Should the currently displayed view be rendered again in the new language? - * @returns {String} The translation of the keyword - * @public - */ - changeLanguage: function(newLang, rerenderview) { - - if(IS_DEBUG_ENABLED) console.debug("[Language] selected " + newLang);//debug - - mobileDS.LanguageManager.getInstance().setLanguage(newLang); -// applicationLanguage = mobileDS.LanguageManager.getInstance().setLanguage(newLang); + * @borrows mobileDS.LanguageManager#getLanguage as this.getCurrentLanguage + * @borrows mobileDS.LanguageManager#existsGrammar as this.existsGrammarForLanguage + * @borrows mobileDS.LanguageManager#existsDictionary as this.existsDictionaryForLanguage + * @borrows mobileDS.LanguageManager#existsSpeaker as this.existsSpeakerForLanguage + * @borrows mobileDS.LanguageManager#setNextLanguage as this.cycleLanguages + */ + , setToCompatibilityMode: function(){ + /** + * The instance that holds the extensions for compatibility mode, + * which really is the LanguageManager instance. + * + * @property compatibilitySelf + * @type mobileDS.LanguageManager + * @private + */ + var compatibilitySelf = this; + + /** + * This function is used to localize the view description (ehtml) before they are displayed. + * + * @function translateHTML + * @param {String} html The (HTML) string which is to be localized into the currently used language + * @returns {String} The localized (HTML) string + * @public + * @deprecated used for old template format + * + * @requires requires that CommonUtils is set to setToCompatibilityMode: {@link mobileDS.CommonUtils#setToCompatibilityMode} + */ + var translateHTML= function(html){ + var translationRegExp = mobileDS.CommonUtils.getInstance().getTranslationRegExp(); + if (html.match(translationRegExp)){ + while (tre = translationRegExp.exec(html)) { + var translated = internalGetText(tre[1]); + html = html.replace(tre[0], translated); + } + } + return html; + }; + compatibilitySelf.translateHTML = translateHTML; - if (rerenderview == true){ - mobileDS.PresentationManager.getInstance().rerenderView(); - } - //mobileDS.DialogEngine.getInstance().raiseEvent("language_choosen"); + /** + * + * + * This function changes the application language and, if requested, renders the current view again, so that + * the change of the language is applied to the currently displayed view. + * After changing the language (and re-rendering the view) an event "language_choosen" is raised + * on the DialogEngine.
+ * + *
+ * Note: + * Momentarily this function is used by 'controllers/application.js' to generate a menu to choose the application language.
+ * This should better be implemented as a partial. + *
+ * + * @function changeLanguage + * @param {String} newLang The new language which is to be used henceforth + * @param {Boolean} doReRenderView Should the currently displayed view be rendered again in the new language? + * @returns {String} The translation of the keyword + * @public + */ + var changeLanguage = function(newLang, doReRenderView) { + + if(IS_DEBUG_ENABLED) console.debug("[Language] selected " + newLang);//debug + + mobileDS.LanguageManager.getInstance().setLanguage(newLang); + + if (doReRenderView == true){ + mobileDS.PresentationManager.getInstance().reRenderView(); + } + mobileDS.DialogEngine.getInstance().raise("language_choosen", newLang); + }; + compatibilitySelf.changeLanguage = changeLanguage; + + compatibilitySelf.getCurrentLanguage = compatibilitySelf.getLanguage; + compatibilitySelf.cycleLanguages = compatibilitySelf.setNextLanguage; } }; } diff --git a/assets/www/javascripts/mvc/controllers/controller.js b/assets/www/mmirf/mvc/controllers/controller.js similarity index 90% rename from assets/www/javascripts/mvc/controllers/controller.js rename to assets/www/mmirf/mvc/controllers/controller.js index b0b4294..be91ede 100644 --- a/assets/www/javascripts/mvc/controllers/controller.js +++ b/assets/www/mmirf/mvc/controllers/controller.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.controllers + * @module mobileDS.mvc.controllers * */ var mobileDS = window.mobileDS || @@ -74,7 +74,7 @@ function Controller(name, jsonDef){ * @type String * @public */ - this.name = name.toLowerCase(); + this.name = name; var viewDefs = this.def.query('views'); @@ -182,13 +182,13 @@ Controller.prototype.loadHelper = function(name, helperPath){ * This function performs an action of a controller - which is represented by this instance of the Controller
* class - by calling the method from the corresponding controller, e.g. assets/www/controllers/application.js * - * @function performAction + * @function perform * @param {String} actionName Name of the method to be executed * @param {Object} data Data to pass to the method of the controller as argument * @returns {Object} The return value of the executed method * @public */ -Controller.prototype.performAction = function(actionName, data){ +Controller.prototype.perform = function(actionName, data){ if(IS_DEBUG_ENABLED) console.debug("should perform '" + actionName + "' of '" + this.name + "'"+ ((typeof data !== 'undefined' && data !== null)? " with data: "+JSON.stringify(data): ""));//debug @@ -199,16 +199,16 @@ Controller.prototype.performAction = function(actionName, data){ * * This function performs an action of a controller, but only if an action with this name exists; otherwise nothing is done. * - * In difference to performAction(..), the method does not trigger an ERROR, if the action does not exist / is not implemented. - * As a consequence, this method refers to "optionally" implemented functions, whereas performAction(..) refers to mandatory functions. + * In difference to perform(..), the method does not trigger an ERROR, if the action does not exist / is not implemented. + * As a consequence, this method refers to "optionally" implemented functions, whereas perform(..) refers to mandatory functions. * - * @function performAction + * @function perform * @param {String} actionName Name of the method to be executed * @param {Object} data Data to pass to the method of the controller as argument * @returns {Object} The return value of the executed method * @public */ -Controller.prototype.performActionIfPresent = function(actionName, data){ +Controller.prototype.performIfPresent = function(actionName, data){ if(typeof this.script[actionName] === 'function'){ if(IS_DEBUG_ENABLED) console.debug("performing '" + actionName + "' of '" + this.name + "'"+ ((typeof data !== 'undefined' && data !== null)? " with data: "+JSON.stringify(data): ""));//debug @@ -224,17 +224,17 @@ Controller.prototype.performActionIfPresent = function(actionName, data){ /** * This function performs a helper action of a controller by calling the appropriate method
- * {@link Helper#performAction} of the instance of the helper class associated with the controller. + * {@link Helper#perform} of the instance of the helper class associated with the controller. * - * @function performHelperAction + * @function performHelper * @param {String} actionName Name of the helper method to be executed * @param {Object} data Data to pass to the helper method as argument * @returns {Object} The return value of the executed method * @public */ -Controller.prototype.performHelperAction = function(actionName, data){ +Controller.prototype.performHelper = function(actionName, data){ - return this.helper.performAction(actionName, data); + return this.helper.perform(actionName, data); }; diff --git a/assets/www/javascripts/mvc/controllers/helper.js b/assets/www/mmirf/mvc/controllers/helper.js similarity index 92% rename from assets/www/javascripts/mvc/controllers/helper.js rename to assets/www/mmirf/mvc/controllers/helper.js index 2650430..727401b 100644 --- a/assets/www/javascripts/mvc/controllers/helper.js +++ b/assets/www/mmirf/mvc/controllers/helper.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.controllers + * @module mobileDS.mvc.controllers * */ var mobileDS = window.mobileDS || @@ -80,13 +80,13 @@ function Helper(ctrl, name){ /** * This function performs an action of a helper.
* - * @function performAction + * @function perform * @param {String} actionName Name of the method to be executed * @param {Object} data Data to pass to the method of the helper as argument * @returns {Object} The return value of the executed method * @public */ -Helper.prototype.performAction = function(actionName, data){ +Helper.prototype.perform = function(actionName, data){ if(IS_DEBUG_ENABLED) console.debug("should perform '" + actionName + "' of '" + this.name + "'" + ((typeof data !== 'undefined' && data !== null)? " with data: "+JSON.stringify(data): ""));//debug diff --git a/assets/www/javascripts/mvc/parser/antlr/ES3.g3 b/assets/www/mmirf/mvc/parser/antlr/ES3.g3 similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/ES3.g3 rename to assets/www/mmirf/mvc/parser/antlr/ES3.g3 diff --git a/assets/www/javascripts/mvc/parser/antlr/ES3_license.txt b/assets/www/mmirf/mvc/parser/antlr/ES3_license.txt similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/ES3_license.txt rename to assets/www/mmirf/mvc/parser/antlr/ES3_license.txt diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirES3Walker.g b/assets/www/mmirf/mvc/parser/antlr/MmirES3Walker.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirES3Walker.g rename to assets/www/mmirf/mvc/parser/antlr/MmirES3Walker.g diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirScript.g b/assets/www/mmirf/mvc/parser/antlr/MmirScript.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirScript.g rename to assets/www/mmirf/mvc/parser/antlr/MmirScript.g diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirScriptBlock.g b/assets/www/mmirf/mvc/parser/antlr/MmirScriptBlock.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirScriptBlock.g rename to assets/www/mmirf/mvc/parser/antlr/MmirScriptBlock.g diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirScriptContent.g b/assets/www/mmirf/mvc/parser/antlr/MmirScriptContent.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirScriptContent.g rename to assets/www/mmirf/mvc/parser/antlr/MmirScriptContent.g diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirScriptStatement.g b/assets/www/mmirf/mvc/parser/antlr/MmirScriptStatement.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirScriptStatement.g rename to assets/www/mmirf/mvc/parser/antlr/MmirScriptStatement.g diff --git a/assets/www/javascripts/mvc/parser/antlr/MmirTemplate.g b/assets/www/mmirf/mvc/parser/antlr/MmirTemplate.g similarity index 100% rename from assets/www/javascripts/mvc/parser/antlr/MmirTemplate.g rename to assets/www/mmirf/mvc/parser/antlr/MmirTemplate.g diff --git a/assets/www/javascripts/mvc/parser/parseElementTypes.js b/assets/www/mmirf/mvc/parser/parseElementTypes.js similarity index 96% rename from assets/www/javascripts/mvc/parser/parseElementTypes.js rename to assets/www/mmirf/mvc/parser/parseElementTypes.js index 93c04e1..9388ace 100644 --- a/assets/www/javascripts/mvc/parser/parseElementTypes.js +++ b/assets/www/mmirf/mvc/parser/parseElementTypes.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.tools + * @module mobileDS.tools * */ var mobileDS = window.mobileDS || {}; diff --git a/assets/www/javascripts/mvc/parser/parsingResult.js b/assets/www/mmirf/mvc/parser/parsingResult.js similarity index 96% rename from assets/www/javascripts/mvc/parser/parsingResult.js rename to assets/www/mmirf/mvc/parser/parsingResult.js index a46f7bf..d02adb5 100644 --- a/assets/www/javascripts/mvc/parser/parsingResult.js +++ b/assets/www/mmirf/mvc/parser/parsingResult.js @@ -31,7 +31,7 @@ * * mobileDS.parser.element (parseElementTypes.js) * * ANTLR TokenStream (antlr3-all.js) * - * @module mobileDS.javascripts.tools + * @module mobileDS.tools * */ var mobileDS = window.mobileDS || {}; diff --git a/assets/www/javascripts/mvc/parser/templateParseUtils.js b/assets/www/mmirf/mvc/parser/templateParseUtils.js similarity index 100% rename from assets/www/javascripts/mvc/parser/templateParseUtils.js rename to assets/www/mmirf/mvc/parser/templateParseUtils.js diff --git a/assets/www/javascripts/mvc/parser/templateProcessor.js b/assets/www/mmirf/mvc/parser/templateProcessor.js similarity index 100% rename from assets/www/javascripts/mvc/parser/templateProcessor.js rename to assets/www/mmirf/mvc/parser/templateProcessor.js diff --git a/assets/www/javascripts/mvc/parser/templateRenderUtils.js b/assets/www/mmirf/mvc/parser/templateRenderUtils.js similarity index 97% rename from assets/www/javascripts/mvc/parser/templateRenderUtils.js rename to assets/www/mmirf/mvc/parser/templateRenderUtils.js index 79186c8..dc6e4c8 100644 --- a/assets/www/javascripts/mvc/parser/templateRenderUtils.js +++ b/assets/www/mmirf/mvc/parser/templateRenderUtils.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.tools + * @module mobileDS.tools * */ var mobileDS = window.mobileDS || {}; @@ -390,7 +390,7 @@ mobileDS.parser.RenderUtils = (function(){ function renderIncludeScript(elem, renderingMode, rawTemplateText, renderingBuffer, data){ renderingBuffer = getRenderingBuffer(renderingBuffer); - renderingBuffer.push(''); @@ -442,7 +442,7 @@ mobileDS.parser.RenderUtils = (function(){ data[PARAM_ARGS_NAME] = elem.argsEval(data); } - var text = containingContentElement.getController().performHelperAction(name, data[PARAM_DATA_NAME], data[PARAM_ARGS_NAME]); + var text = containingContentElement.getController().performHelper(name, data[PARAM_DATA_NAME], data[PARAM_ARGS_NAME]); if(!text){ console.warn('RenderUtils.renderHelper: no result for '+containingContentElement.getController().getName()+'-helper >'+name+'<'); } diff --git a/assets/www/javascripts/mvc/views/contentElement.js b/assets/www/mmirf/mvc/views/contentElement.js similarity index 96% rename from assets/www/javascripts/mvc/views/contentElement.js rename to assets/www/mmirf/mvc/views/contentElement.js index 1ba6f6a..5688964 100644 --- a/assets/www/javascripts/mvc/views/contentElement.js +++ b/assets/www/mmirf/mvc/views/contentElement.js @@ -424,7 +424,7 @@ ContentElement.prototype.hasDynamicContent = function(){ //ContentElement.prototype.doGetStringForHelper = function(helperElement, data){ // //TODo handle case, when .helper is not a String // //TODo handle arguments for helper -// var text = this.getController().performHelperAction(helperElement.helper, data); +// var text = this.getController().performHelper(helperElement.helper, data); // if(!text){ // console.warn('ContentElement.render(helper): no result for '+this.getController().getName()+'-helper >'+helperElement.helper+'<'); // text = ''; diff --git a/assets/www/javascripts/mvc/views/layout.js b/assets/www/mmirf/mvc/views/layout.js similarity index 96% rename from assets/www/javascripts/mvc/views/layout.js rename to assets/www/mmirf/mvc/views/layout.js index caf6cfd..e1eb6ca 100644 --- a/assets/www/javascripts/mvc/views/layout.js +++ b/assets/www/mmirf/mvc/views/layout.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.views + * @module mobileDS.mvc.views */ var mobileDS = window.mobileDS || {}; @@ -67,7 +67,7 @@ function Layout(name, definition, remote){ * @type Object * @public */ - this.def = definition.replace(mobileDS.CommonUtils.getInstance().html_comment_regex, '');//remove HTML comments! + this.def = definition.replace(mobileDS.CommonUtils.getInstance().regexHTMLComment, '');//remove HTML comments! /** * The name of the layout. @@ -76,7 +76,7 @@ function Layout(name, definition, remote){ * @type String * @public */ - this.name = name.toLowerCase();//TODO remove toLowerCase conversion for all controller, view etc. names! + this.name = name; /** * This variable holds the contents of the header part of the layout. @@ -448,14 +448,14 @@ Layout.prototype.parseHead = function(jsonDef){ var stylesheetPaths = jsonDef.query('/stylesheets/path'); - var jsPaths = jsonDef.query('/javascripts/path'); + var jsPaths = jsonDef.query('//path'); $.each(stylesheetPaths, function(index, stPath){ head += ""; }); $.each(jsPaths, function(index, jsPath){ - head += ""; + head += ""; }); } diff --git a/assets/www/javascripts/mvc/views/partial.js b/assets/www/mmirf/mvc/views/partial.js similarity index 92% rename from assets/www/javascripts/mvc/views/partial.js rename to assets/www/mmirf/mvc/views/partial.js index 8521524..1e5826a 100644 --- a/assets/www/javascripts/mvc/views/partial.js +++ b/assets/www/mmirf/mvc/views/partial.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.views + * @module mobileDS.mvc.views * */ var mobileDS = window.mobileDS || @@ -45,10 +45,10 @@ var mobileDS = window.mobileDS || function Partial(ctrl, name, definition){ // var HTMLCommentRegExp = //g; - definition = definition.replace(mobileDS.CommonUtils.getInstance().html_comment_regex, '');//remove HTML comments! .replace(HTMLCommentRegExp,""); + definition = definition.replace(mobileDS.CommonUtils.getInstance().regexHTMLComment, '');//remove HTML comments! .replace(HTMLCommentRegExp,""); this.controller = ctrl; this.def = definition; - this.name = name.toLowerCase(); + this.name = name; // console.log("[Partial] parsed Partial '" +this.controller + "-"+this.name+ "'."); var parser = mobileDS.parser.ParserUtils.getInstance(); diff --git a/assets/www/javascripts/mvc/views/view.js b/assets/www/mmirf/mvc/views/view.js similarity index 91% rename from assets/www/javascripts/mvc/views/view.js rename to assets/www/mmirf/mvc/views/view.js index 16866a8..2b8545d 100644 --- a/assets/www/javascripts/mvc/views/view.js +++ b/assets/www/mmirf/mvc/views/view.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.views + * @module mobileDS.mvc.views * */ var mobileDS = window.mobileDS || @@ -48,7 +48,7 @@ function View(ctrl, name, definition){ // console.log("[View] '" + name + "' loaded."); // remove HTML comments from View - definition = definition.replace(mobileDS.CommonUtils.getInstance().html_comment_regex, '');//remove HTML comments! .replace(HTMLCommentRegExp,""); + definition = definition.replace(mobileDS.CommonUtils.getInstance().regexHTMLComment, '');//remove HTML comments! .replace(HTMLCommentRegExp,""); /** * The controller to which this view belongs. @@ -75,7 +75,7 @@ function View(ctrl, name, definition){ * @type String * @public */ - this.name = name.toLowerCase(); + this.name = name; /** @@ -124,16 +124,16 @@ function View(ctrl, name, definition){ */ View.prototype.executeHelperMethods = function(data){ for(var i=0, size = this.getHelperMethods().length; i < size ; ++i){ - this.controller.performHelperAction(this.getHelperMethods()[i], data); + this.controller.performHelper(this.getHelperMethods()[i], data); } // var self = this; // $.each(self.getHelperMethods(), function(index, h_method){ // //if(index == self.getHelperMethods().length -1){ // // console.log("calling an action in view : " + h_method ); -// // self.controller.performHelperAction(h_method, data, mobileDS.PresentationManager.getInstance().render_view_successor(self.controller.getName(), self.name, self, self.controller)); +// // self.controller.performHelper(h_method, data, mobileDS.PresentationManager.getInstance().doRenderView(self.controller.getName(), self.name, self, self.controller)); // // console.log("action berformed : " + h_method); // //}else{ -// self.controller.performHelperAction(h_method, data); +// self.controller.performHelper(h_method, data); // //} // // }); diff --git a/assets/www/javascripts/mvc/views/yield.js b/assets/www/mmirf/mvc/views/yield.js similarity index 96% rename from assets/www/javascripts/mvc/views/yield.js rename to assets/www/mmirf/mvc/views/yield.js index 37dc022..c95eb03 100644 --- a/assets/www/javascripts/mvc/views/yield.js +++ b/assets/www/mmirf/mvc/views/yield.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.mvc.views + * @module mobileDS.mvc.views */ var mobileDS = window.mobileDS || {}; diff --git a/assets/www/javascripts/notification.js b/assets/www/mmirf/notification.js similarity index 91% rename from assets/www/javascripts/notification.js rename to assets/www/mmirf/notification.js index 05f44ac..5a720eb 100644 --- a/assets/www/javascripts/notification.js +++ b/assets/www/mmirf/notification.js @@ -49,17 +49,25 @@ mobileDS.Notification = (function(){ function constructor(){ function createAudio(url, success, fail){ - return mobileDS.AudioOutput.getInstance().getURLAsAudio(url, success, fail); + return mobileDS.MediaManager.getInstance().getURLAsAudio(url, success, fail); } var beepAudio = null; + var timesToPlay = 0; function playBeepAudio(times){ //create beep-audio-object, if not existing yet + if (times<1) { + // beepAudio.release(); + // beepAudio = null; + return; + } + timesToPlay = times if(beepAudio === null){ beepAudio = createAudio( mobileDS.constants.getInstance().getBeepUrl(), - function(){ mobileDS.Notification.getInstance().beep(times-1);}, + function(){ + playBeepAudio(--timesToPlay);}, function(e){console.log('Error playing the beep: '+e);} ); } @@ -124,7 +132,6 @@ mobileDS.Notification = (function(){ */ beep: function(times){ if (times>0){ - console.warn('BEEP, repeat '+times); playBeepAudio(times); } } diff --git a/assets/www/javascripts/plugins/beepPlugin.js b/assets/www/mmirf/plugins/beepPlugin.js similarity index 100% rename from assets/www/javascripts/plugins/beepPlugin.js rename to assets/www/mmirf/plugins/beepPlugin.js diff --git a/assets/www/javascripts/plugins/cookiePlugin.js b/assets/www/mmirf/plugins/cookiePlugin.js similarity index 100% rename from assets/www/javascripts/plugins/cookiePlugin.js rename to assets/www/mmirf/plugins/cookiePlugin.js diff --git a/assets/www/javascripts/plugins/directoryListing.js b/assets/www/mmirf/plugins/directoryListing.js similarity index 97% rename from assets/www/javascripts/plugins/directoryListing.js rename to assets/www/mmirf/plugins/directoryListing.js index 1267787..0d99778 100644 --- a/assets/www/javascripts/plugins/directoryListing.js +++ b/assets/www/mmirf/plugins/directoryListing.js @@ -26,7 +26,7 @@ /** - * @module mobileDS.javascripts.plugins + * @module mobileDS.plugins * */ @@ -128,7 +128,7 @@ DirectoryListing.prototype.getDirectoryStructure = function(directories, success if(IS_DEBUG_ENABLED) console.log("[getDirectoryStructure] called, reading directory structure file..."); // the URL to the configuration file (in JSON format) TODO this should come from constants.js - var directoryFileUrl = "config/parsed_directories.json"; + var directoryFileUrl = "config/directories.json"; //load configuration file asynchronously: $.ajax({ diff --git a/assets/www/javascripts/plugins/multitouchPlugin.js b/assets/www/mmirf/plugins/multitouchPlugin.js similarity index 100% rename from assets/www/javascripts/plugins/multitouchPlugin.js rename to assets/www/mmirf/plugins/multitouchPlugin.js diff --git a/assets/www/javascripts/plugins/nativeTTS.js b/assets/www/mmirf/plugins/nativeTTS.js similarity index 100% rename from assets/www/javascripts/plugins/nativeTTS.js rename to assets/www/mmirf/plugins/nativeTTS.js diff --git a/assets/www/javascripts/plugins/nuance.js b/assets/www/mmirf/plugins/nuance.js similarity index 100% rename from assets/www/javascripts/plugins/nuance.js rename to assets/www/mmirf/plugins/nuance.js diff --git a/assets/www/javascripts/plugins/queuePlugin.js b/assets/www/mmirf/plugins/queuePlugin.js similarity index 100% rename from assets/www/javascripts/plugins/queuePlugin.js rename to assets/www/mmirf/plugins/queuePlugin.js diff --git a/assets/www/javascripts/plugins/softkeyboard.js b/assets/www/mmirf/plugins/softkeyboard.js similarity index 100% rename from assets/www/javascripts/plugins/softkeyboard.js rename to assets/www/mmirf/plugins/softkeyboard.js diff --git a/assets/www/javascripts/plugins/video.js b/assets/www/mmirf/plugins/video.js similarity index 100% rename from assets/www/javascripts/plugins/video.js rename to assets/www/mmirf/plugins/video.js diff --git a/assets/www/javascripts/3rdParty/antlr3-all-min.js b/assets/www/mmirf/res/libs/antlr3-all-min.js similarity index 100% rename from assets/www/javascripts/3rdParty/antlr3-all-min.js rename to assets/www/mmirf/res/libs/antlr3-all-min.js diff --git a/assets/www/javascripts/3rdParty/antlr3-all.js b/assets/www/mmirf/res/libs/antlr3-all.js similarity index 100% rename from assets/www/javascripts/3rdParty/antlr3-all.js rename to assets/www/mmirf/res/libs/antlr3-all.js diff --git a/assets/www/javascripts/3rdParty/cordova-2.8.1.js b/assets/www/mmirf/res/libs/cordova-2.8.1.js similarity index 100% rename from assets/www/javascripts/3rdParty/cordova-2.8.1.js rename to assets/www/mmirf/res/libs/cordova-2.8.1.js diff --git a/assets/www/mmirf/res/libs/easyXDM-2.4.17.1.debug.js b/assets/www/mmirf/res/libs/easyXDM-2.4.17.1.debug.js new file mode 100644 index 0000000..1668ccb --- /dev/null +++ b/assets/www/mmirf/res/libs/easyXDM-2.4.17.1.debug.js @@ -0,0 +1,2877 @@ +/** + * easyXDM + * http://easyxdm.net/ + * Copyright(c) 2009-2011, Øyvind Sean Kinsey, oyvind@kinsey.no. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +(function (window, document, location, setTimeout, decodeURIComponent, encodeURIComponent) { +/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/ +/*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */ +// +// easyXDM +// http://easyxdm.net/ +// Copyright(c) 2009-2011, Øyvind Sean Kinsey, oyvind@kinsey.no. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +var global = this; +var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded +var emptyFn = Function.prototype; +var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4) +var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression +var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol +var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global) +var easyXDM = {}; +var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite +var IFRAME_PREFIX = "easyXDM_"; +var HAS_NAME_PROPERTY_BUG; +var useHash = false; // whether to use the hash over the query +var flashVersion; // will be set if using flash +var HAS_FLASH_THROTTLED_BUG; +var _trace = emptyFn; + + +// http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting +function isHostMethod(object, property){ + var t = typeof object[property]; + return t == 'function' || + (!!(t == 'object' && object[property])) || + t == 'unknown'; +} + +function isHostObject(object, property){ + return !!(typeof(object[property]) == 'object' && object[property]); +} + +// end + +// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ +function isArray(o){ + return Object.prototype.toString.call(o) === '[object Array]'; +} + +// end +function hasFlash(){ + var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash"; + + if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") { + // adapted from the swfobject code + var description = navigator.plugins[name].description; + if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) { + flashVersion = description.match(/\d+/g); + } + } + if (!flashVersion) { + var flash; + try { + flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); + flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1); + flash = null; + } + catch (notSupportedException) { + } + } + if (!flashVersion) { + return false; + } + var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10); + HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0; + return true; +} + +/* + * Cross Browser implementation for adding and removing event listeners. + */ +var on, un; +if (isHostMethod(window, "addEventListener")) { + on = function(target, type, listener){ + _trace("adding listener " + type); + target.addEventListener(type, listener, false); + }; + un = function(target, type, listener){ + _trace("removing listener " + type); + target.removeEventListener(type, listener, false); + }; +} +else if (isHostMethod(window, "attachEvent")) { + on = function(object, sEvent, fpNotify){ + _trace("adding listener " + sEvent); + object.attachEvent("on" + sEvent, fpNotify); + }; + un = function(object, sEvent, fpNotify){ + _trace("removing listener " + sEvent); + object.detachEvent("on" + sEvent, fpNotify); + }; +} +else { + throw new Error("Browser not supported"); +} + +/* + * Cross Browser implementation of DOMContentLoaded. + */ +var domIsReady = false, domReadyQueue = [], readyState; +if ("readyState" in document) { + // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and + // 'interactive' (HTML5 specs, recent WebKit builds) states. + // https://bugs.webkit.org/show_bug.cgi?id=45119 + readyState = document.readyState; + domIsReady = readyState == "complete" || (~ navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive")); +} +else { + // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately + // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not. + // We only need a body to add elements to, so the existence of document.body is enough for us. + domIsReady = !!document.body; +} + +function dom_onReady(){ + if (domIsReady) { + return; + } + domIsReady = true; + _trace("firing dom_onReady"); + for (var i = 0; i < domReadyQueue.length; i++) { + domReadyQueue[i](); + } + domReadyQueue.length = 0; +} + + +if (!domIsReady) { + if (isHostMethod(window, "addEventListener")) { + on(document, "DOMContentLoaded", dom_onReady); + } + else { + on(document, "readystatechange", function(){ + if (document.readyState == "complete") { + dom_onReady(); + } + }); + if (document.documentElement.doScroll && window === top) { + var doScrollCheck = function(){ + if (domIsReady) { + return; + } + // http://javascript.nwbox.com/IEContentLoaded/ + try { + document.documentElement.doScroll("left"); + } + catch (e) { + setTimeout(doScrollCheck, 1); + return; + } + dom_onReady(); + }; + doScrollCheck(); + } + } + + // A fallback to window.onload, that will always work + on(window, "load", dom_onReady); +} +/** + * This will add a function to the queue of functions to be run once the DOM reaches a ready state. + * If functions are added after this event then they will be executed immediately. + * @param {function} fn The function to add + * @param {Object} scope An optional scope for the function to be called with. + */ +function whenReady(fn, scope){ + if (domIsReady) { + fn.call(scope); + return; + } + domReadyQueue.push(function(){ + fn.call(scope); + }); +} + +/** + * Returns an instance of easyXDM from the parent window with + * respect to the namespace. + * + * @return An instance of easyXDM (in the parent window) + */ +function getParentObject(){ + var obj = parent; + if (namespace !== "") { + for (var i = 0, ii = namespace.split("."); i < ii.length; i++) { + if (!obj) { + throw new Error(ii.slice(0, i + 1).join('.') + ' is not an object'); + } + obj = obj[ii[i]]; + } + } + if (!obj || !obj.easyXDM) { + throw new Error('Could not find easyXDM in parent.' + namespace); + } + return obj.easyXDM; +} + +/** + * Removes easyXDM variable from the global scope. It also returns control + * of the easyXDM variable to whatever code used it before. + * + * @param {String} ns A string representation of an object that will hold + * an instance of easyXDM. + * @return An instance of easyXDM + */ +function noConflict(ns){ + if (typeof ns != "string" || !ns) { + throw new Error('namespace must be a non-empty string'); + } + _trace("Settings namespace to '" + ns + "'"); + + window.easyXDM = _easyXDM; + namespace = ns; + if (namespace) { + IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_"; + } + return easyXDM; +} + +/* + * Methods for working with URLs + */ +/** + * Get the domain name from a url. + * @param {String} url The url to extract the domain from. + * @return The domain part of the url. + * @type {String} + */ +function getDomainName(url){ + if (!url) { + throw new Error("url is undefined or empty"); + } + return url.match(reURI)[3]; +} + +/** + * Get the port for a given URL, or "" if none + * @param {String} url The url to extract the port from. + * @return The port part of the url. + * @type {String} + */ +function getPort(url){ + if (!url) { + throw new Error("url is undefined or empty"); + } + return url.match(reURI)[4] || ""; +} + +/** + * Returns a string containing the schema, domain and if present the port + * @param {String} url The url to extract the location from + * @return {String} The location part of the url + */ +function getLocation(url){ + if (!url) { + throw new Error("url is undefined or empty"); + } +// if (/^file/.test(url)) { +// throw new Error("The file:// protocol is not supported"); +// } + var m = url.toLowerCase().match(reURI); + if(!m){ + m = url.toLocaleLowerCase().match(/^((file:)\/\/\/?([^\/\s]*))/); + if(m){ + m[3] = ''; + } + } + var proto = m[2], domain = m[3], port = m[4] || ""; + if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) { + port = ""; + } + return proto + "//" + domain + port; +} + +/** + * Resolves a relative url into an absolute one. + * @param {String} url The path to resolve. + * @return {String} The resolved url. + */ +function resolveUrl(url){ + if (!url) { + throw new Error("url is undefined or empty"); + } + + // replace all // except the one in proto with / + url = url.replace(reDoubleSlash, "$1/"); + + // If the url is a valid url we do nothing + if (!url.match(/^(http||https):\/\//)) { + // If this is a relative path + var path = (url.substring(0, 1) === "/") ? "" : location.pathname; + if (path.substring(path.length - 1) !== "/") { + path = path.substring(0, path.lastIndexOf("/") + 1); + } + + url = location.protocol + "//" + location.host + path + url; + } + + // reduce all 'xyz/../' to just '' + while (reParent.test(url)) { + url = url.replace(reParent, ""); + } + + _trace("resolved url '" + url + "'"); + return url; +} + +/** + * Appends the parameters to the given url.
+ * The base url can contain existing query parameters. + * @param {String} url The base url. + * @param {Object} parameters The parameters to add. + * @return {String} A new valid url with the parameters appended. + */ +function appendQueryParameters(url, parameters){ + if (!parameters) { + throw new Error("parameters is undefined or null"); + } + + var hash = "", indexOf = url.indexOf("#"); + if (indexOf !== -1) { + hash = url.substring(indexOf); + url = url.substring(0, indexOf); + } + var q = []; + for (var key in parameters) { + if (parameters.hasOwnProperty(key)) { + q.push(key + "=" + encodeURIComponent(parameters[key])); + } + } + return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash; +} + + +// build the query object either from location.query, if it contains the xdm_e argument, or from location.hash +var query = (function(input){ + input = input.substring(1).split("&"); + var data = {}, pair, i = input.length; + while (i--) { + pair = input[i].split("="); + data[pair[0]] = decodeURIComponent(pair[1]); + } + return data; +}(/xdm_e=/.test(location.search) ? location.search : location.hash)); + +/* + * Helper methods + */ +/** + * Helper for checking if a variable/property is undefined + * @param {Object} v The variable to test + * @return {Boolean} True if the passed variable is undefined + */ +function undef(v){ + return typeof v === "undefined"; +} + +/** + * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works. + * @return {JSON} A valid JSON conforming object, or null if not found. + */ +var getJSON = function(){ + var cached = {}; + var obj = { + a: [1, 2, 3] + }, json = "{\"a\":[1,2,3]}"; + + if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) { + // this is a working JSON instance + return JSON; + } + if (Object.toJSON) { + if (Object.toJSON(obj).replace((/\s/g), "") === json) { + // this is a working stringify method + cached.stringify = Object.toJSON; + } + } + + if (typeof String.prototype.evalJSON === "function") { + obj = json.evalJSON(); + if (obj.a && obj.a.length === 3 && obj.a[2] === 3) { + // this is a working parse method + cached.parse = function(str){ + return str.evalJSON(); + }; + } + } + + if (cached.stringify && cached.parse) { + // Only memoize the result if we have valid instance + getJSON = function(){ + return cached; + }; + return cached; + } + return null; +}; + +/** + * Applies properties from the source object to the target object.
+ * @param {Object} target The target of the properties. + * @param {Object} source The source of the properties. + * @param {Boolean} noOverwrite Set to True to only set non-existing properties. + */ +function apply(destination, source, noOverwrite){ + var member; + for (var prop in source) { + if (source.hasOwnProperty(prop)) { + if (prop in destination) { + member = source[prop]; + if (typeof member === "object") { + apply(destination[prop], member, noOverwrite); + } + else if (!noOverwrite) { + destination[prop] = source[prop]; + } + } + else { + destination[prop] = source[prop]; + } + } + } + return destination; +} + +// This tests for the bug in IE where setting the [name] property using javascript causes the value to be redirected into [submitName]. +function testForNamePropertyBug(){ + var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input")); + input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues + HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name]; + document.body.removeChild(form); + _trace("HAS_NAME_PROPERTY_BUG: " + HAS_NAME_PROPERTY_BUG); +} + +/** + * Creates a frame and appends it to the DOM. + * @param config {object} This object can have the following properties + *
    + *
  • {object} prop The properties that should be set on the frame. This should include the 'src' property.
  • + *
  • {object} attr The attributes that should be set on the frame.
  • + *
  • {DOMElement} container Its parent element (Optional).
  • + *
  • {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
  • + *
+ * @return The frames DOMElement + * @type DOMElement + */ +function createFrame(config){ + _trace("creating frame: " + config.props.src); + if (undef(HAS_NAME_PROPERTY_BUG)) { + testForNamePropertyBug(); + } + var frame; + // This is to work around the problems in IE6/7 with setting the name property. + // Internally this is set as 'submitName' instead when using 'iframe.name = ...' + // This is not required by easyXDM itself, but is to facilitate other use cases + if (HAS_NAME_PROPERTY_BUG) { + frame = document.createElement("') + .css($.extend(s.o.iframeCss, { + display: 'none', + opacity: 0, + position: 'fixed', + height: w[0], + width: w[1], + zIndex: s.o.zIndex, + top: 0, + left: 0 + })) + .appendTo(s.o.appendTo); + } + + // create the overlay + s.d.overlay = $('
') + .attr('id', s.o.overlayId) + .addClass('simplemodal-overlay') + .css($.extend(s.o.overlayCss, { + display: 'none', + opacity: s.o.opacity / 100, + height: s.o.modal ? d[0] : 0, + width: s.o.modal ? d[1] : 0, + position: 'fixed', + left: 0, + top: 0, + zIndex: s.o.zIndex + 1 + })) + .appendTo(s.o.appendTo); + + // create the container + s.d.container = $('
') + .attr('id', s.o.containerId) + .addClass('simplemodal-container') + .css($.extend( + {position: s.o.fixed ? 'fixed' : 'absolute'}, + s.o.containerCss, + {display: 'none', zIndex: s.o.zIndex + 2} + )) + .append(s.o.close && s.o.closeHTML + ? $(s.o.closeHTML).addClass(s.o.closeClass) + : '') + .appendTo(s.o.appendTo); + + s.d.wrap = $('
') + .attr('tabIndex', -1) + .addClass('simplemodal-wrap') + .css({height: '100%', outline: 0, width: '100%'}) + .appendTo(s.d.container); + + // add styling and attributes to the data + // append to body to get correct dimensions, then move to wrap + s.d.data = data + .attr('id', data.attr('id') || s.o.dataId) + .addClass('simplemodal-data') + .css($.extend(s.o.dataCss, { + display: 'none' + })) + .appendTo('body'); + data = null; + + s.setContainerDimensions(); + s.d.data.appendTo(s.d.wrap); + + // fix issues with IE + if (browser.ie6 || browser.ieQuirks) { + s.fixIE(); + } + }, + /* + * Bind events + */ + bindEvents: function () { + var s = this; + + // bind the close event to any element with the closeClass class + $('.' + s.o.closeClass).bind('click.simplemodal', function (e) { + e.preventDefault(); + s.close(); + }); + + // bind the overlay click to the close function, if enabled + if (s.o.modal && s.o.close && s.o.overlayClose) { + s.d.overlay.bind('click.simplemodal', function (e) { + e.preventDefault(); + s.close(); + }); + } + + // bind keydown events + doc.bind('keydown.simplemodal', function (e) { + if (s.o.modal && e.keyCode === 9) { // TAB + s.watchTab(e); + } + else if ((s.o.close && s.o.escClose) && e.keyCode === 27) { // ESC + e.preventDefault(); + s.close(); + } + }); + + // update window size + wndw.bind('resize.simplemodal orientationchange.simplemodal', function () { + // redetermine the window width/height + s.getDimensions(); + + // reposition the dialog + s.o.autoResize ? s.setContainerDimensions() : s.o.autoPosition && s.setPosition(); + + if (browser.ie6 || browser.ieQuirks) { + s.fixIE(); + } + else if (s.o.modal) { + // update the iframe & overlay + s.d.iframe && s.d.iframe.css({height: w[0], width: w[1]}); + s.d.overlay.css({height: d[0], width: d[1]}); + } + }); + }, + /* + * Unbind events + */ + unbindEvents: function () { + $('.' + this.o.closeClass).unbind('click.simplemodal'); + doc.unbind('keydown.simplemodal'); + wndw.unbind('.simplemodal'); + this.d.overlay.unbind('click.simplemodal'); + }, + /* + * Fix issues in IE6 and IE7 in quirks mode + */ + fixIE: function () { + var s = this, p = s.o.position; + + // simulate fixed position - adapted from BlockUI + $.each([s.d.iframe || null, !s.o.modal ? null : s.d.overlay, s.d.container.css('position') === 'fixed' ? s.d.container : null], function (i, el) { + if (el) { + var bch = 'document.body.clientHeight', bcw = 'document.body.clientWidth', + bsh = 'document.body.scrollHeight', bsl = 'document.body.scrollLeft', + bst = 'document.body.scrollTop', bsw = 'document.body.scrollWidth', + ch = 'document.documentElement.clientHeight', cw = 'document.documentElement.clientWidth', + sl = 'document.documentElement.scrollLeft', st = 'document.documentElement.scrollTop', + s = el[0].style; + + s.position = 'absolute'; + if (i < 2) { + s.removeExpression('height'); + s.removeExpression('width'); + s.setExpression('height','' + bsh + ' > ' + bch + ' ? ' + bsh + ' : ' + bch + ' + "px"'); + s.setExpression('width','' + bsw + ' > ' + bcw + ' ? ' + bsw + ' : ' + bcw + ' + "px"'); + } + else { + var te, le; + if (p && p.constructor === Array) { + var top = p[0] + ? typeof p[0] === 'number' ? p[0].toString() : p[0].replace(/px/, '') + : el.css('top').replace(/px/, ''); + te = top.indexOf('%') === -1 + ? top + ' + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"' + : parseInt(top.replace(/%/, '')) + ' * ((' + ch + ' || ' + bch + ') / 100) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"'; + + if (p[1]) { + var left = typeof p[1] === 'number' ? p[1].toString() : p[1].replace(/px/, ''); + le = left.indexOf('%') === -1 + ? left + ' + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"' + : parseInt(left.replace(/%/, '')) + ' * ((' + cw + ' || ' + bcw + ') / 100) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"'; + } + } + else { + te = '(' + ch + ' || ' + bch + ') / 2 - (this.offsetHeight / 2) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"'; + le = '(' + cw + ' || ' + bcw + ') / 2 - (this.offsetWidth / 2) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"'; + } + s.removeExpression('top'); + s.removeExpression('left'); + s.setExpression('top', te); + s.setExpression('left', le); + } + } + }); + }, + /* + * Place focus on the first or last visible input + */ + focus: function (pos) { + var s = this, p = pos && $.inArray(pos, ['first', 'last']) !== -1 ? pos : 'first'; + + // focus on dialog or the first visible/enabled input element + var input = $(':input:enabled:visible:' + p, s.d.wrap); + setTimeout(function () { + input.length > 0 ? input.focus() : s.d.wrap.focus(); + }, 10); + }, + getDimensions: function () { + // fix a jQuery bug with determining the window height - use innerHeight if available + var s = this, + h = typeof window.innerHeight === 'undefined' ? wndw.height() : window.innerHeight; + + d = [doc.height(), doc.width()]; + w = [h, wndw.width()]; + }, + getVal: function (v, d) { + return v ? (typeof v === 'number' ? v + : v === 'auto' ? 0 + : v.indexOf('%') > 0 ? ((parseInt(v.replace(/%/, '')) / 100) * (d === 'h' ? w[0] : w[1])) + : parseInt(v.replace(/px/, ''))) + : null; + }, + /* + * Update the container. Set new dimensions, if provided. + * Focus, if enabled. Re-bind events. + */ + update: function (height, width) { + var s = this; + + // prevent update if dialog does not exist + if (!s.d.data) { + return false; + } + + // reset orig values + s.d.origHeight = s.getVal(height, 'h'); + s.d.origWidth = s.getVal(width, 'w'); + + // hide data to prevent screen flicker + s.d.data.hide(); + height && s.d.container.css('height', height); + width && s.d.container.css('width', width); + s.setContainerDimensions(); + s.d.data.show(); + s.o.focus && s.focus(); + + // rebind events + s.unbindEvents(); + s.bindEvents(); + }, + setContainerDimensions: function () { + var s = this, + badIE = browser.ie6 || browser.ie7; + + // get the dimensions for the container and data + var ch = s.d.origHeight ? s.d.origHeight : browser.opera ? s.d.container.height() : s.getVal(badIE ? s.d.container[0].currentStyle['height'] : s.d.container.css('height'), 'h'), + cw = s.d.origWidth ? s.d.origWidth : browser.opera ? s.d.container.width() : s.getVal(badIE ? s.d.container[0].currentStyle['width'] : s.d.container.css('width'), 'w'), + dh = s.d.data.outerHeight(true), dw = s.d.data.outerWidth(true); + + s.d.origHeight = s.d.origHeight || ch; + s.d.origWidth = s.d.origWidth || cw; + + // mxoh = max option height, mxow = max option width + var mxoh = s.o.maxHeight ? s.getVal(s.o.maxHeight, 'h') : null, + mxow = s.o.maxWidth ? s.getVal(s.o.maxWidth, 'w') : null, + mh = mxoh && mxoh < w[0] ? mxoh : w[0], + mw = mxow && mxow < w[1] ? mxow : w[1]; + + // moh = min option height + var moh = s.o.minHeight ? s.getVal(s.o.minHeight, 'h') : 'auto'; + if (!ch) { + if (!dh) {ch = moh;} + else { + if (dh > mh) {ch = mh;} + else if (s.o.minHeight && moh !== 'auto' && dh < moh) {ch = moh;} + else {ch = dh;} + } + } + else { + ch = s.o.autoResize && ch > mh ? mh : ch < moh ? moh : ch; + } + + // mow = min option width + var mow = s.o.minWidth ? s.getVal(s.o.minWidth, 'w') : 'auto'; + if (!cw) { + if (!dw) {cw = mow;} + else { + if (dw > mw) {cw = mw;} + else if (s.o.minWidth && mow !== 'auto' && dw < mow) {cw = mow;} + else {cw = dw;} + } + } + else { + cw = s.o.autoResize && cw > mw ? mw : cw < mow ? mow : cw; + } + + s.d.container.css({height: ch, width: cw}); + s.d.wrap.css({overflow: (dh > ch || dw > cw) ? 'auto' : 'visible'}); + s.o.autoPosition && s.setPosition(); + }, + setPosition: function () { + var s = this, top, left, + hc = (w[0]/2) - (s.d.container.outerHeight(true)/2), + vc = (w[1]/2) - (s.d.container.outerWidth(true)/2), + st = s.d.container.css('position') !== 'fixed' ? wndw.scrollTop() : 0; + + if (s.o.position && Object.prototype.toString.call(s.o.position) === '[object Array]') { + top = st + (s.o.position[0] || hc); + left = s.o.position[1] || vc; + } else { + top = st + hc; + left = vc; + } + s.d.container.css({left: left, top: top}); + }, + watchTab: function (e) { + var s = this; + + if ($(e.target).parents('.simplemodal-container').length > 0) { + // save the list of inputs + s.inputs = $(':input:enabled:visible:first, :input:enabled:visible:last', s.d.data[0]); + + // if it's the first or last tabbable element, refocus + if ((!e.shiftKey && e.target === s.inputs[s.inputs.length -1]) || + (e.shiftKey && e.target === s.inputs[0]) || + s.inputs.length === 0) { + e.preventDefault(); + var pos = e.shiftKey ? 'last' : 'first'; + s.focus(pos); + } + } + else { + // might be necessary when custom onShow callback is used + e.preventDefault(); + s.focus(); + } + }, + /* + * Open the modal dialog elements + * - Note: If you use the onOpen callback, you must "show" the + * overlay and container elements manually + * (the iframe will be handled by SimpleModal) + */ + open: function () { + var s = this; + // display the iframe + s.d.iframe && s.d.iframe.show(); + + if ($.isFunction(s.o.onOpen)) { + // execute the onOpen callback + s.o.onOpen.apply(s, [s.d]); + } + else { + // display the remaining elements + s.d.overlay.show(); + s.d.container.show(); + s.d.data.show(); + } + + s.o.focus && s.focus(); + + // bind default events + s.bindEvents(); + }, + /* + * Close the modal dialog + * - Note: If you use an onClose callback, you must remove the + * overlay, container and iframe elements manually + * + * @param {boolean} external Indicates whether the call to this + * function was internal or external. If it was external, the + * onClose callback will be ignored + */ + close: function () { + var s = this; + + // prevent close when dialog does not exist + if (!s.d.data) { + return false; + } + + // remove the default events + s.unbindEvents(); + + if ($.isFunction(s.o.onClose) && !s.occb) { + // set the onClose callback flag + s.occb = true; + + // execute the onClose callback + s.o.onClose.apply(s, [s.d]); + } + else { + // if the data came from the DOM, put it back + if (s.d.placeholder) { + var ph = $('#simplemodal-placeholder'); + // save changes to the data? + if (s.o.persist) { + // insert the (possibly) modified data back into the DOM + ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display', s.display)); + } + else { + // remove the current and insert the original, + // unmodified data back into the DOM + s.d.data.hide().remove(); + ph.replaceWith(s.d.orig); + } + } + else { + // otherwise, remove it + s.d.data.hide().remove(); + } + + // remove the remaining elements + s.d.container.hide().remove(); + s.d.overlay.hide(); + s.d.iframe && s.d.iframe.hide().remove(); + s.d.overlay.remove(); + + // reset the dialog object + s.d = {}; + } + } + }; +})); diff --git a/assets/www/mmirf/res/libs/jquery.simplemodal.1.4.4.min.js b/assets/www/mmirf/res/libs/jquery.simplemodal.1.4.4.min.js new file mode 100644 index 0000000..382c736 --- /dev/null +++ b/assets/www/mmirf/res/libs/jquery.simplemodal.1.4.4.min.js @@ -0,0 +1,26 @@ +/* + * SimpleModal 1.4.4 - jQuery Plugin + * http://simplemodal.com/ + * Copyright (c) 2013 Eric Martin + * Licensed under MIT and GPL + * Date: Sun, Jan 20 2013 15:58:56 -0800 + */ +(function(b){"function"===typeof define&&define.amd?define(["jquery"],b):b(jQuery)})(function(b){var j=[],n=b(document),k=navigator.userAgent.toLowerCase(),l=b(window),g=[],o=null,p=/msie/.test(k)&&!/opera/.test(k),q=/opera/.test(k),m,r;m=p&&/msie 6./.test(k)&&"object"!==typeof window.XMLHttpRequest;r=p&&/msie 7.0/.test(k);b.modal=function(a,h){return b.modal.impl.init(a,h)};b.modal.close=function(){b.modal.impl.close()};b.modal.focus=function(a){b.modal.impl.focus(a)};b.modal.setContainerDimensions= +function(){b.modal.impl.setContainerDimensions()};b.modal.setPosition=function(){b.modal.impl.setPosition()};b.modal.update=function(a,h){b.modal.impl.update(a,h)};b.fn.modal=function(a){return b.modal.impl.init(this,a)};b.modal.defaults={appendTo:"body",focus:!0,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:!1,autoPosition:!0,zIndex:1E3, +close:!0,closeHTML:'',closeClass:"simplemodal-close",escClose:!0,overlayClose:!1,fixed:!0,position:null,persist:!1,modal:!0,onOpen:null,onShow:null,onClose:null};b.modal.impl={d:{},init:function(a,h){if(this.d.data)return!1;o=p&&!b.support.boxModel;this.o=b.extend({},b.modal.defaults,h);this.zIndex=this.o.zIndex;this.occb=!1;if("object"===typeof a){if(a=a instanceof b?a:b(a),this.d.placeholder=!1,0").attr("id", +"simplemodal-placeholder").css({display:"none"})),this.d.placeholder=!0,this.display=a.css("display"),!this.o.persist))this.d.orig=a.clone(!0)}else if("string"===typeof a||"number"===typeof a)a=b("
").html(a);else return alert("SimpleModal Error: Unsupported data type: "+typeof a),this;this.create(a);this.open();b.isFunction(this.o.onShow)&&this.o.onShow.apply(this,[this.d]);return this},create:function(a){this.getDimensions();if(this.o.modal&&m)this.d.iframe=b('').css(b.extend(this.o.iframeCss, +{display:"none",opacity:0,position:"fixed",height:g[0],width:g[1],zIndex:this.o.zIndex,top:0,left:0})).appendTo(this.o.appendTo);this.d.overlay=b("
").attr("id",this.o.overlayId).addClass("simplemodal-overlay").css(b.extend(this.o.overlayCss,{display:"none",opacity:this.o.opacity/100,height:this.o.modal?j[0]:0,width:this.o.modal?j[1]:0,position:"fixed",left:0,top:0,zIndex:this.o.zIndex+1})).appendTo(this.o.appendTo);this.d.container=b("
").attr("id",this.o.containerId).addClass("simplemodal-container").css(b.extend({position:this.o.fixed? +"fixed":"absolute"},this.o.containerCss,{display:"none",zIndex:this.o.zIndex+2})).append(this.o.close&&this.o.closeHTML?b(this.o.closeHTML).addClass(this.o.closeClass):"").appendTo(this.o.appendTo);this.d.wrap=b("
").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(this.d.container);this.d.data=a.attr("id",a.attr("id")||this.o.dataId).addClass("simplemodal-data").css(b.extend(this.o.dataCss,{display:"none"})).appendTo("body");this.setContainerDimensions(); +this.d.data.appendTo(this.d.wrap);(m||o)&&this.fixIE()},bindEvents:function(){var a=this;b("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()});a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});n.bind("keydown.simplemodal",function(b){a.o.modal&&9===b.keyCode?a.watchTab(b):a.o.close&&a.o.escClose&&27===b.keyCode&&(b.preventDefault(),a.close())});l.bind("resize.simplemodal orientationchange.simplemodal", +function(){a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();m||o?a.fixIE():a.o.modal&&(a.d.iframe&&a.d.iframe.css({height:g[0],width:g[1]}),a.d.overlay.css({height:j[0],width:j[1]}))})},unbindEvents:function(){b("."+this.o.closeClass).unbind("click.simplemodal");n.unbind("keydown.simplemodal");l.unbind(".simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this.o.position;b.each([this.d.iframe||null,!this.o.modal?null:this.d.overlay, +"fixed"===this.d.container.css("position")?this.d.container:null],function(b,e){if(e){var f=e[0].style;f.position="absolute";if(2>b)f.removeExpression("height"),f.removeExpression("width"),f.setExpression("height",'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"'),f.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"');else{var c,d;a&&a.constructor=== +Array?(c=a[0]?"number"===typeof a[0]?a[0].toString():a[0].replace(/px/,""):e.css("top").replace(/px/,""),c=-1===c.indexOf("%")?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',a[1]&&(d="number"===typeof a[1]? +a[1].toString():a[1].replace(/px/,""),d=-1===d.indexOf("%")?d+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(d.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"')):(c='(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"', +d='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"');f.removeExpression("top");f.removeExpression("left");f.setExpression("top",c);f.setExpression("left",d)}}})},focus:function(a){var h=this,a=a&&-1!==b.inArray(a,["first","last"])?a:"first",e=b(":input:enabled:visible:"+a,h.d.wrap);setTimeout(function(){0c?c:bc?c:this.o.minHeight&&"auto"!==i&&ed?d:ad?d:this.o.minWidth&&"auto"!==c&&fb||f>a?"auto":"visible"});this.o.autoPosition&&this.setPosition()},setPosition:function(){var a,b;a=g[0]/2-this.d.container.outerHeight(!0)/2;b=g[1]/2-this.d.container.outerWidth(!0)/2;var e="fixed"!==this.d.container.css("position")?l.scrollTop():0;this.o.position&&"[object Array]"===Object.prototype.toString.call(this.o.position)?(a=e+(this.o.position[0]||a),b=this.o.position[1]||b): +a=e+a;this.d.container.css({left:b,top:a})},watchTab:function(a){if(0W}T3JSey8bdW6%n8v zjsPI~>ER4hG5KrZpYfjz{96XZ|NCh}cWoIg3uA%{xVVDad%!_vwL$9!6D%t77uyX1 z0Az=#$C2vk+2be-JuB!Ja!dQV1x`7-k#hkL4y%oiQkS_sU1XmB0C{H#lSkeR0S0wq z*m2)h-jCHCIe&Ry;X>QW1x0;YgI~{uvATq*DbY`jqthFaKS$DsP5$F#wVMaD#u@K3 z(b6*B7h_;#5_8Aa+C;Wtdf*B0A~e`fWMNCM`fxuNfZ+WxRGQE=1tQPzOU}I?TW>k8X#3#VOl^95Hc&4Q|gJ+&RInsL3aP|anyKE!={btdaDz17Q z9AKgwlb{K+_mEvWP9tjCY{QD@SR6DUk_G`75HA(KX%9+PQH)CKQYQ&O+5iUuCV{9R zvJBd;sU+vqFb<9Sa5Y)ViDcC2YQ*C0GJ4_&kOm!MDU~XmI?0N?LCsX(t(WYi;$BHI z?q9MTYHT}dr>wVDc)@dIls@RdAL7P7CZ}MtvX=nep41)14l>%M8SCfW3`=@h{wB z3-yah(o8a!SHD|Iais7CmX{sMkL==OvH@lxk177%1(na{&pGbVI0FEjIV<@kI)E*b zQrY`vper1AEOQ+f53?r|hgl|z?Qgv((MLBDkBf8}Hd>@%hT*l=#+`02(<@9DG+}He zA%^pcH!40q`SQ%9$w1qf-A>(ahSSkawm06lFf@+n?tWHV6aKh5?MxF(<<9RGIR;rR z!BdB4%zbAqzIS~@dudeTDtB^=F7OF!iUoNi3Xj8&YcgV7MOK3k3ovDfb;hvr-v zuX$Umk(<09FjZLj=RDPCw@;?)?MyiG#kr|MhIwo}r9e+hU?|hxH_N3(?dZw9_=T-RYrB6-1(XD%< zHxwGG?|qsT`*hTpO`N<%#N)g{PD*Y#b2n4++vcDuc%hvADUJXN!~i;=YXC(;9;A$d z0I!MrQCnsUAWwH|!SBk)K&XiB1?bG?X|>`IE+5%J|@Xek3JwgK4hjewVu{7Wv&LnoyWcbL@-px=VXBVF4N1#tThS4GMb0?`G6%#4m`G(1 zXDb^{rYcKJZD+fN(by`9pOnpb>1;)gjrwlwK~V0$j&>=fh8FBhNO!pXRDqrk9w`#` zK>gF2oi5+|lPaY~vAz+vz`KUeE8p00$KV*u334*|RhhW=rQI;g1501G9#zl9m~EfS z!OIX8vsQ$ryH*QjR(f*I#3#Mr}<3 zkWndy>bL^IWM;Ly^wfkC5=M>sf|vWzN=Qm?(!Ps$lW$S6eOMuk`#og>gE<&IWJw=3 z-zOD*Z@x=l!Lt{yGz4XYwHkfCfI|mC+D)EEUev zM5A(zg$m>dwBGPe>R`XDYp19*8-bCcf-ry}M^%SYoj+d$gIA_7g>hITsg(Sr3sCOe zH+m@#!MxN+g+xkXYOo*3RW{W+F%o(|UJ}GlRstnqwO(1U{|K>6XgPey>x$u3386(v z-Z2Rm7QrAu-q^~?*0Dm7JzzE8FhUIaTpblk^nP~zeog+51D0#C2V8v?jIK$R46#wP zchsta_YNGJ*!LO-I|k33{hrXiNC(7EAhPu^BV)`o!srC4SP`Pc8#i`AKC((}HUn?# z*5Im}afvbNLp4U>uxY8t4w5Bu8p4UPeIrw@RZS2)1bC)=e(U9F*a6E#P?8~K4LaW= zhbmJ8l%e>qVE|_=36hr@#omfYdXPtN_kVo|8O-D69zG(TU$7O2rfEk#V&ruZ2z|06 ze3UkJZ+?r5O8SI;?W1kb8`aOH+-gUVtM%*Fm;O9-o4XmGy_=PdkDXgoQ^Nu83&4;;_%AitxmdMm|0KDi}7+MdrO56|*b zA+v4DIVS+yV0>rb4k`*n@8Y7UL}nEaprPYZ-1+%+()VOyyP!TOP`%$xNr2u)ss(=r zGp$M15C?#R0|PuJ_-EPHU`nJ|3(C&mft%^x@^uVA$;yr#-_Ha;-Tp?#iUbT?q0p5H zJ8yv}D?@j=pFoaH40dsI$O{xQn3VRUas3YQMz8sNgkgmK z?H?-%4<8-%`X!|3l*=#oOd6s$%yn-VUmBmAwl!o;jG9-kpI&a=*mAkrE4sYNl6JY| z$zqv02i&ZQR!myv)hnWj9eYi;Jc@P`Z9V16{CaFDu zfs!jjb5{dha*feUT#D2^6cogw{c_1!Rpdb@B=#bQqR%bMpK@30l2`VLgy47N`rF+` zo$^$@XDo=Cs)js~c6UE7UaQZ1k%rzHy+svb7`7?r%eHaD4i3!1QoB3EogaZJUj*53 z(|W_58HWf0@DQ_hO4(bVXpX{ZPR3;N5?C%tOXtEl$c-#Y&B3_`dubSEZuU9k%y8+? zvaKkyqVDs+?kE$?MR~uQCjevs#NBMaHd`=LCICP)HC+NOu*Re_DRUQH^qPV)GZ&<@ zS;NsY56|d@ncc{If4A)qbKlmbai8an{GO1u`!9o{@;*<5913md<&xpAzQL0< zwTHq2ntCr8-tu{Jxz=a3)@R8(`rY&|wcnb;nwx5)Dn?5-7w&}GyCTgo`{|Qd?4|*v zYOC@5i;d; zMhJ%j9W`0CNaYd!uF4=e-4pIv{(I{@MBO8TcRUiehR2 literal 0 HcmV?d00001 diff --git a/assets/www/content/images/ajax-loader.gif b/assets/www/mmirf/res/styles/images/ajax-loader.gif similarity index 100% rename from assets/www/content/images/ajax-loader.gif rename to assets/www/mmirf/res/styles/images/ajax-loader.gif diff --git a/assets/www/mmirf/res/styles/images/datebox.png b/assets/www/mmirf/res/styles/images/datebox.png new file mode 100644 index 0000000000000000000000000000000000000000..fe3ffba823b06e2ca6648075e314efbe6590c6ca GIT binary patch literal 2424 zcmbVOcTf}g9#0SjL_nmdDBhYV;Y5;bLP*FEYC<~`Fth{|2w@=sQb-{|5EM}nr0Q8X z)Q5V?c}TGU4$a0PiiNY#pwnpKtxm>@Gi+r@?%S z`3MBUz}t(?hQ~$lW3M|8eqVpvs)C253I<2vFNs#Dcrpm#8YPK@0B;d524X|JsHB8e z$Ps~<6D+m^2k|&O0S6LnK{Ay{pyKhs*9!$( zlSM^S*>sPuw%`>FB~U1&R2)vFQejm@tV9-r105V3W;6%{TNq(0PZBG5YFn`!J*z;6 zst`)Vz>FdKkt4Cn5j4b1>yZ>YX9AzTz*JYB+9iXgGVn@&T)U$9Za zD5{48*#iX0c6c%YZ%+Y12Rjcs10>POZVq&Jkl`?^@jWhs;z}XAf_8311{nkypc~17 z6^|s_;AZJzW1+++Vm+|4+_vurs)s=J>B> zncadraAx|g_2I?0!vl%o6C;C<#<9Em<{%JrOTFo?0qX9d;P7?+!ONXK#Dt!EmefpY8`(hWHo9A{9j|*5V7FrZvOeB$%izr1!MX_^)J=LNf^IFO;1!c4j@F&krP#NMi+FPp<@5gl+6Y0YB6K zMA!OMuqH-F-|sCbC>iRhshHcVY-ng`vch0?J{hUyaJf}m*Y+jWg}O|NRH_NGnVH!! z;APa)Xi}Sm-NQl_juERdx)u=JL?BE8sDV112-Ew zD#Aapxm+&BJuWWp24};Db9b0a_y>kuIfj4uR;_GAAe9PWol$-E`rNKAu77fJaw6*7 z-o1M%Pe>LyT49`J78VvOPd(gn{yeFq>o6^Opg!fD3~le;ZLMdXW0gszQXgE9g@hD6 zJhUGdp0%+q(Hqyt<-E#j7x2{!x$}27GptPuGxShpu{#nhAOFmE%QtzU#|BdRE^b{j zu<)8jM+>R{Ha9zcRgyp;K(Hw$bo`Rb{gnhFk*HM>ROO$po*EUl4)@fg{cFX3?8Y|> zjEttMR*tf_+{^uKzPUZ-O{T@dcEP6Tur(acAYgPWwNrfA-Tq- zX~Pj-Nx1jIDtD7So}bPOlWR9_OzXb(7YJ&O>gCN%+K_Ro_lU({!_kX_gM*j*r5xkK z{-N4+Fa9`=%vgGf<&7GiT;-TvJ74F@lG|-=^3>E+FCX`g!;VRhFLnuA zlBN%Y{(ky$>*x-CY4!tOlu!TIrsVAG>}6S5S*d&IuQSGJ6#4dRmfQE7+vY>a@iJK& zbNj%dL#LNh6$0I-*%vNckkF=Z-RA9I?oYX1PE>NA=^gzIomYcScB@H)qGdXNcJ59` zE`Bz_%%mQ1PGj}V>1$|0Px&PEG`4JW-u?SxufTo=XkNm!eA^ptd}!W-$?CaTE_OTP zbahL0`wgx%q9QCgS}d(ZT0u-oN{YdGAUF&81LExSTZjCyVfCfO&S_!&G`GWnqAIj! zuJ!ADe%h*?>+d@r`}Nmmc1Xze=_P&02uX=3^S2$Y#WLbZE`6=5V4#&DYyh;4> z<;&|VQ{yu9Jo46>ZmE(uG^^T+Uaw8WZ>p6LFT1vDSlcWCP^6` zqayO zRy$8A^e9|2_R%S#y{pjG9uI<`?okD$yv!z=s!I!kTbf<`@$TXfU!U%gvVlb65|H?zI#5_1Fje)HzduTGq>`q)%5F0?H-<4>J>aQ!y2tQ_+O zIfh{s-#JX2cV1(O8rJtmX93}DKy34e3~_|t>O0+m8%^Jpj<#X<+Z 0){ grammar_utterance += "\n|"; } var phrase = phrases[index]; - var semantic_interpretation = self.get_semantic_interpretationt_of_phrase( + var semantic_interpretation = self.doCreateSemanticInterpretationForPhrase( utterance_name.toLowerCase(), utterance_def, phrase, semantic ); grammar_utterance += phrase + semantic_interpretation; @@ -275,11 +293,11 @@ GrammarConverter.prototype.parse_utterance = function(utterance_name, utterance_ }; -GrammarConverter.prototype.get_semantic_interpretationt_of_utterance = function(utterance_name, utterance_def){ +GrammarConverter.prototype.doCreateSemanticInterpretationForUtterance = function(utterance_name, utterance_def){ var semantic = utterance_def.semantic, variable_index, variable_name; - if(IS_DEBUG_ENABLED) console.debug('get_semantic_interpretationt_of_utterance: '+semantic);//debug + if(IS_DEBUG_ENABLED) console.debug('doCreateSemanticInterpretationForUtterance: '+semantic);//debug var semantic_as_string = JSON.stringify(semantic); if( semantic_as_string != null){ @@ -313,7 +331,7 @@ GrammarConverter.prototype.get_semantic_interpretationt_of_utterance = function( return semantic_as_string; }; -GrammarConverter.prototype.get_semantic_interpretationt_of_phrase = function(utterance_name, utterance_def, phrase, semantic_as_string){ +GrammarConverter.prototype.doCreateSemanticInterpretationForPhrase = function(utterance_name, utterance_def, phrase, semantic_as_string){ var splitted_phrase = phrase.split(/\s+/), length = splitted_phrase.length, duplicate_helper = {}; @@ -349,6 +367,27 @@ GrammarConverter.prototype.get_semantic_interpretationt_of_phrase = function(utt return result; }; -GrammarConverter.prototype.set_compiled_grammar = function(func){ - this.compiled_grammar = func; +/** + * Set the executable grammar function. + * + * The grammar function takes 1 String argument: the text that should be parsed. + * The result is written to the GrammarConverter's property semanticAnnotationResult + * + * @param {Function} func the executable grammar function + */ +GrammarConverter.prototype.setGrammarFunction = function(func){ + this.executeGrammar = func; +}; + +/** + * Execute the grammar. + * + * NOTE: do not use directly, but {@link mobileDS.SemanticInterpreter.getASRSemantic} instead, + * since that function applies some pre- and post-processing to the text (stopword removal + * en-/decoding of special characters etc.). + * + * @param {String} text the text String that should be parse. + */ +GrammarConverter.prototype.executeGrammar = function(text){ + console.warn('GrammarConverter.executeGrammar: this is only a stub. No grammar implementation set yet...'); }; diff --git a/assets/www/mmirf/semantic/grammarParserTemplate.js b/assets/www/mmirf/semantic/grammarParserTemplate.js new file mode 100644 index 0000000..a11dcb4 --- /dev/null +++ b/assets/www/mmirf/semantic/grammarParserTemplate.js @@ -0,0 +1 @@ +GrammarConverter.prototype.PARSER_TEMPLATE = "\n var theGrammarConverterInstance = this;\n\n ##HEADER##\n\n/*\n\tJS/CC: A LALR(1) Compiler-Compiler written in JavaScript\n\tCopyright (C) 2007, 2008 by J.M.K S.F. Software Technologies, Jan Max Meyer\n\thttp://www.jmksf.com ++ jscc<-AT->jmksf.com\n\t\n\tFile:\tjscc.html\n\tAuthor:\tJan Max Meyer\n\tUsage:\tModified parser template for the Web Environment Module\n\t\t\tBased on \"driver_web.js_\" parser template, but NOT in the public domain!\n\t\n\tYou may use, modify and distribute this software under the terms and conditions\n\tof the Artistic License. Please see ARTISTIC for more information.\n\n\tDriver for the JS/CC Web Environment with integrated HTML parse tree generator!\n\t\n\tFeatures:\n\t- Parser trace messages\n\t- Integrated panic-mode error recovery\n\t- Parse tree construction for the JS/CC web environment\n*/\n\nvar ##PREFIX##_dbg_withtrace\t\t= false;\nvar ##PREFIX##_dbg_string\t\t\t= new String();\n\nfunction __##PREFIX##dbg_print( text )\n{\n\t##PREFIX##_dbg_string += text + \"\\n\";\n}\n\nfunction __##PREFIX##lex( info )\n{\n\tvar state\t\t= 0;\n\tvar match\t\t= -1;\n\tvar match_pos\t= 0;\n\tvar start\t\t= 0;\n\tvar pos\t\t\t= info.offset + 1;\n\n\tdo\n\t{\n\t\tpos--;\n\t\tstate = 0;\n\t\tmatch = -2;\n\t\tstart = pos;\n\n\t\tif( info.src.length <= start )\n\t\t\treturn ##EOF##;\n\n\t\tdo\n\t\t{\n\n##DFA##\n\t\t\tpos++;\n\n\t\t}\n\t\twhile( state > -1 );\n\n\t}\n\twhile( ##WHITESPACE## > -1 && match == ##WHITESPACE## );\n\n\tif( match > -1 )\n\t{\n\t\tinfo.att = info.src.substr( start, match_pos - start );\n\t\tinfo.offset = match_pos;\n\t\t\n##TERMINAL_ACTIONS##\n\t}\n\telse\n\t{\n\t\tinfo.att = new String();\n\t\tmatch = -1;\n\t}\n\n\treturn match;\n}\n\n\nfunction __##PREFIX##parse( src, err_off, err_la )\n{ theGrammarConverterInstance.semanticAnnotationResult={};\n\tvar\t\tsstack\t\t\t= new Array();\n\tvar\t\tvstack\t\t\t= new Array();\n\tvar \terr_cnt\t\t\t= 0;\n\tvar\t\tact;\n\tvar\t\tgo;\n\tvar\t\tla;\n\tvar\t\trval;\n\tvar \tparseinfo\t\t= new Function( \"\", \"var offset; var src; var att;\" );\n\tvar\t\tinfo\t\t\t= new parseinfo();\n\t\n\t//Visual parse tree generation\n\tvar \ttreenode\t\t= new Function( \"\", \"var sym; var att; var child;\" );\n\tvar\t\ttreenodes\t\t= new Array();\n\tvar\t\ttree\t\t\t= new Array();\n\tvar\t\ttmptree\t\t\t= null;\n\t\n##TABLES##\n\n##LABELS##\n\t\n\tinfo.offset = 0;\n\tinfo.src = src;\n\tinfo.att = new String();\n\t\n\tif( !err_off )\n\t\terr_off\t= new Array();\n\tif( !err_la )\n\terr_la = new Array();\n\t\n\tsstack.push( 0 );\n\tvstack.push( 0 );\n\t\n\tla = __##PREFIX##lex( info );\n\n\twhile( true )\n\t{\n\t\tact = ##ERROR##;\n\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t{\n\t\t\tif( act_tab[sstack[sstack.length-1]][i] == la )\n\t\t\t{\n\t\t\t\tact = act_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif( ##PREFIX##_dbg_withtrace && sstack.length > 0 )\n\t\t{\n\t\t\t__##PREFIX##dbg_print( \"\\nState \" + sstack[sstack.length-1] + \"\\n\" +\n\t\t\t\t\t\t\t\"\\tLookahead: \" + labels[la] + \" (\\\"\" + info.att + \"\\\")\\n\" +\n\t\t\t\t\t\t\t\"\\tAction: \" + act + \"\\n\" + \n\t\t\t\t\t\t\t\"\\tSource: \\\"\" + info.src.substr( info.offset, 30 ) + ( ( info.offset + 30 < info.src.length ) ?\n\t\t\t\t\t\t\t\t\t\"...\" : \"\" ) + \"\\\"\\n\" +\n\t\t\t\t\t\t\t\"\\tStack: \" + sstack.join() + \"\\n\" +\n\t\t\t\t\t\t\t\"\\tValue stack: \" + vstack.join() + \"\\n\" );\n\t\t}\n\t\t\n\t\t\t\n\t\t//Panic-mode: Try recovery when parse-error occurs!\n\t\tif( act == ##ERROR## )\n\t\t{\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Error detected: There is no reduce or shift on the symbol \" + labels[la] );\n\t\t\t\n\t\t\terr_cnt++;\n\t\t\terr_off.push( info.offset - info.att.length );\t\t\t\n\t\t\terr_la.push( new Array() );\n\t\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t\terr_la[err_la.length-1].push( labels[act_tab[sstack[sstack.length-1]][i]] );\n\t\t\t\n\t\t\t//Remember the original stack!\n\t\t\tvar rsstack = new Array();\n\t\t\tvar rvstack = new Array();\n\t\t\tfor( var i = 0; i < sstack.length; i++ )\n\t\t\t{\n\t\t\t\trsstack[i] = sstack[i];\n\t\t\t\trvstack[i] = vstack[i];\n\t\t\t}\n\t\t\t\n\t\t\twhile( act == ##ERROR## && la != ##EOF## )\n\t\t\t{\n\t\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery\\n\" +\n\t\t\t\t\t\t\t\t\t\"Current lookahead: \" + labels[la] + \" (\" + info.att + \")\\n\" +\n\t\t\t\t\t\t\t\t\t\"Action: \" + act + \"\\n\\n\" );\n\t\t\t\tif( la == -1 )\n\t\t\t\t\tinfo.offset++;\n\t\t\t\t\t\n\t\t\t\twhile( act == ##ERROR## && sstack.length > 0 )\n\t\t\t\t{\n\t\t\t\t\tsstack.pop();\n\t\t\t\t\tvstack.pop();\n\t\t\t\t\t\n\t\t\t\t\tif( sstack.length == 0 )\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tact = ##ERROR##;\n\t\t\t\t\tfor( var i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( act_tab[sstack[sstack.length-1]][i] == la )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tact = act_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif( act != ##ERROR## )\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tfor( var i = 0; i < rsstack.length; i++ )\n\t\t\t\t{\n\t\t\t\t\tsstack.push( rsstack[i] );\n\t\t\t\t\tvstack.push( rvstack[i] );\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tla = __##PREFIX##lex( info );\n\t\t\t}\n\t\t\t\n\t\t\tif( act == ##ERROR## )\n\t\t\t{\n\t\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery failed, terminating parse process...\" );\n\t\t\t\tbreak;\n\t\t\t}\n\n\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tError recovery succeeded, continuing\" );\n\t\t}\n\t\t\n\t\t/*\n\t\tif( act == ##ERROR## )\n\t\t\tbreak;\n\t\t*/\n\t\t\n\t\t\n\t\t//Shift\n\t\tif( act > 0 )\n\t\t{\n\t\t\t//Parse tree\n\t\t\tvar node = new treenode();\n\t\t\tnode.sym = labels[ la ];\n\t\t\tnode.att = info.att;\n\t\t\tnode.child = new Array();\n\t\t\ttree.push( treenodes.length );\n\t\t\ttreenodes.push( node );\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Shifting symbol: \" + labels[la] + \" (\" + info.att + \")\" );\n\t\t\n\t\t\tsstack.push( act );\n\t\t\tvstack.push( info.att );\n\t\t\t\n\t\t\tla = __##PREFIX##lex( info );\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tNew lookahead symbol: \" + labels[la] + \" (\" + info.att + \")\" );\n\t\t}\n\t\t//Reduce\n\t\telse\n\t\t{\t\t\n\t\t\tact *= -1;\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"Reducing by producution: \" + act );\n\t\t\t\n\t\t\trval = void(0);\n\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPerforming semantic action...\" );\n\t\t\t\n##ACTIONS##\n\n\t\t\ttmptree = new Array();\n\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPopping \" + pop_tab[act][1] + \" off the stack...\" );\n\t\t\t\t\n\t\t\tfor( var i = 0; i < pop_tab[act][1]; i++ )\n\t\t\t{\t\t\t\n\t\t\t\ttmptree.push( tree.pop() );\n\n\t\t\t\tsstack.pop();\n\t\t\t\tvstack.pop();\n\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\tgo = -1;\n\t\t\tfor( var i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 )\n\t\t\t{\n\t\t\t\tif( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] )\n\t\t\t\t{\n\t\t\t\t\tgo = goto_tab[sstack[sstack.length-1]][i+1];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Parse tree\n\t\t\tvar node = new treenode();\n\t\t\tnode.sym = labels[ pop_tab[act][0] ];\n\t\t\tnode.att = rval;\n\t\t\tnode.child = tmptree.reverse();\n\t\t\ttree.push( treenodes.length );\n\t\t\ttreenodes.push( node );\n\t\t\t\n\t\t\tif( act == 0 )\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t\t\t__##PREFIX##dbg_print( \"\\tPushing non-terminal \" + labels[ pop_tab[act][0] ] );\n\t\t\t\t\n\t\t\tsstack.push( go );\n\t\t\tvstack.push( rval );\t\t\t\n\t\t}\n\t\t\n\t\tif( ##PREFIX##_dbg_withtrace )\n\t\t{\t\t\n\t\t\talert( ##PREFIX##_dbg_string );\n\t\t\t##PREFIX##_dbg_string = new String();\n\t\t}\n\t}\n\n\tif( ##PREFIX##_dbg_withtrace )\n\t{\n\t\t__##PREFIX##dbg_print( \"\\nParse complete.\" );\n\t\talert( ##PREFIX##_dbg_string );\n\t}\n\t\n\tif( err_cnt == 0 )\n\t{}\n\t\n\treturn err_cnt;\n}\n\nfunction __##PREFIX##dbg_image( name )\n{\n\treturn \"\";\n}\n\nfunction __##PREFIX##dbg_get_tree_depth( nodes, tree, max )\n{\n\tvar\t\ttmp\t\t= 0;\n\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tif( max < ( tmp = __dbg_get_tree_depth( nodes, nodes[ tree[i] ].child, max+1 ) ) )\n\t\t\t\tmax = tmp;\n\t}\n\t\n\treturn max;\n}\n\nfunction __##PREFIX##dbg_parsetree( prev, cnt, depth, nodes, tree )\n{\n\tvar str = new String();\n\t\n\tif( cnt == 0 )\n\t\tstr += \"\";\n\t\n\tif( !prev )\n\t\tprev = new Array();\n\t\t\n\tif( cnt > 0 )\n\t\tprev[cnt-1] = true;\n\t\t\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tstr += \"\";\n\n\t\tfor( var j = 0; j < cnt; j++ )\n\t\t{\n\t\t\tstr += \"\";\n\t\t}\n\t\t\n\t\tif( cnt > 0 && i == tree.length - 1 )\n\t\t\tprev[cnt-1] = false;\n\n\t\tstr += \"\";\n\t\t\n\t\tstr += \"\";\n\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tstr += __##PREFIX##dbg_parsetree( prev, cnt+1, depth, nodes, nodes[ tree[i] ].child );\n\t}\n\t\n\tif( cnt == 0 )\n\t\tstr += \"
\";\n\n\t\t\tif( prev[j] )\n\t\t\t{\n\t\t\t\tif( j == cnt - 1 && i == tree.length - 1 )\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"ll\" );\n\t\t\t\telse if( j == cnt - 1 )\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"la\" );\n\t\t\t\telse\n\t\t\t\t\tstr += __##PREFIX##dbg_image( \"l\" );\n\t\t\t}\n\t\t\telse\n\t\t\t\tstr += __##PREFIX##dbg_image( \"e\" );\n\t\t\t\t\n\t\t\tstr += \"\";\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tif( cnt == 0 )\n\t\t\t\tstr += __##PREFIX##dbg_image( \"rn\" );\n\t\t\telse\n\t\t\t\tstr += __##PREFIX##dbg_image( \"n\" );\t\n\t\telse\n\t\t\tstr += __##PREFIX##dbg_image( \"t\" );\n\t\tstr += \"\" + nodes[ tree[i] ].sym ;\n\t\tif( nodes[ tree[i] ].att && nodes[ tree[i] ].att != \"\" )\n\t\t\tstr += \":\" + nodes[ tree[i] ].att + \"\" ;\n\t\t\t\n\t\tstr += \"
\";\n\t\n\treturn str;\n}\n\nfunction __##PREFIX##dbg_parsetree_phpSyntaxTree( nodes, tree )\n{\n\tvar str = new String();\n\t\n\tfor( var i = 0; i < tree.length; i++ )\n\t{\n\t\tstr += \" [ \";\n\n\t\tstr += nodes[ tree[i] ].sym;\n\t\tif( nodes[ tree[i] ].att && nodes[ tree[i] ].att != \"\" )\n\t\t{\n\t\t\tvar attr = new String( nodes[ tree[i] ].att );\n\t\t\tstr += \":\\\"\" + attr.replace( / |\\t|\\r|\\n|\\[|\\]/g, \"_\" ) + \"\\\"\";\n\t\t}\n\t\t\t\n\t\tstr += \" \";\n\n\t\tif( nodes[ tree[i] ].child.length > 0 )\n\t\t\tstr += __##PREFIX##dbg_parsetree_phpSyntaxTree( nodes, nodes[ tree[i] ].child );\n\n\t\tstr += \" ] \";\n\t}\n\t\n\treturn str;\n}\n\n\n##FOOTER##"; diff --git a/assets/www/javascripts/semantic/semantic_interpreter.js b/assets/www/mmirf/semantic/semanticInterpreter.js similarity index 79% rename from assets/www/javascripts/semantic/semantic_interpreter.js rename to assets/www/mmirf/semantic/semanticInterpreter.js index 6387e74..df2635e 100644 --- a/assets/www/javascripts/semantic/semantic_interpreter.js +++ b/assets/www/mmirf/semantic/semanticInterpreter.js @@ -53,13 +53,13 @@ mobileDS.SemanticInterpreter = (function(){ /** - * @param doRecompile (OPTIONAL) IF {Boolean}: if true, the JSON grammar in content\grammar.json will be recompiled (needs to be accessable through ajax!) + * @param doRecompile (OPTIONAL) IF {Boolean}: if true, the JSON grammar in content\grammar.json will be recompiled (needs to be accessible via AJAX!) * IF {String}: the String's contents will be used as a String-representation of the JSON grammar * IF {Object}: the Object will be used as JSON representation for the grammar * - * @param generatedParserLanguageCode (OPTIONAL) {String} if param doRecompile is used, this String specifies the - * language for the generated grammatic-parser. If omitted, the default "de" (German) will be used. - * NOTE: this must be a valid ISO language code! + * @param {String} [generatedParserLanguageCode] if param doRecompile is used, this String specifies the + * language for the generated grammar-parser. + * NOTE: this should be a valid ISO language code! * * @constructor * @augments mobileDS.SemanticInterpreter @@ -70,7 +70,7 @@ mobileDS.SemanticInterpreter = (function(){ /** * "map" for grammar implementations (e.g. for different languages) * - * @property + * @property grammarImplMap * @private */ var grammarImplMap = {}; @@ -79,7 +79,7 @@ mobileDS.SemanticInterpreter = (function(){ * * This list contains the "keys" of all current entries in grammarImplMap. * - * @property + * @property grammarImplList * @private */ var grammarImplList = []; @@ -88,23 +88,52 @@ mobileDS.SemanticInterpreter = (function(){ * id (i.e. the key for map grammarImplMap) for currently used * grammar. * - * If for invocations of get_asr_semantic(..) etc. function the ID/languageCode + * If for invocations of getASRSemantic(..) etc. function the ID/languageCode * argument is missing/omitted, then this id will be used. * * NOTE: if not NULL, the grammar must be available, either * as compiled JS file (which must be already loaded, i.e. already present in grammarImplMap), or * as JSON grammar file (which must be available at /config/languages/[ID]/grammar.json + * + * @property currentGrammarId + * @private */ var currentGrammarId = null; + /** + * Flag for enabling/disabling processing of SemanticInterpreter. + * + * If disabled, getASRSemantic(), removeStopwords() etc. (+ _alt versions) will return null values. + * + * NOTE: if no grammar for any language is available, the SemanticInterpreter should be disabled. + * + * Setting a language, automatically enables the the SemanticInterpreter. + * + * @property _isEnabled + * @type Boolean + * @private + */ + var _isEnabled = false; + + var doSetEnabled = function(isEnabled){ + _isEnabled = isEnabled; + }; + var doCheckIsEnabled = function(){ + return _isEnabled; + }; + /** * - * NOTE: if no other grammar is available yet, currentGrammarId will be set to id + * NOTE: if no other grammar is available yet, currentGrammarId will be set to id. * + * NOTE: if currently disabled, calling this function automatically enables ( setEnabled(TRUE) ), + * the semantic interpreter. + * + * @function * @param id {String} ID for the grammar (e.g. an ISO-639 language code) * @param grammarImpl {GrammarConverter|Function} the executable JavaScript grammar implementation - * IF {GrammarConverter}: the impl. with valid member {Function} {@link GrammarConverter.compiled_grammar()} - * IF {Function}: the {Function} {@link GrammarConverter.compiled_grammar()} - + * IF {GrammarConverter}: the impl. with valid member {Function} {@link GrammarConverter.executeGrammar()} + * IF {Function}: the {Function} {@link GrammarConverter.executeGrammar()} - * In this case, if no GrammarConverter instance fo id is present, a new one will be created; * The stopwords must already be set, or must additionally be set for the GrammarConverter instance * (e.g. using {@link mobileDS.SemanticInterpreter.setStopwords}) @@ -117,12 +146,12 @@ mobileDS.SemanticInterpreter = (function(){ if(!gc){ gc = new GrammarConverter(); } - gc.set_compiled_grammar(grammarImpl); + gc.setGrammarFunction(grammarImpl); grammarImpl = gc; } - else { - - } +// else { +// +// } var isAlreadyPresent = checkHasGrammar(id); grammarImplMap[id] = grammarImpl; @@ -133,10 +162,12 @@ mobileDS.SemanticInterpreter = (function(){ } grammarImplList.push(id); } + + doSetEnabled(true); }; var doSetStopwords = function(id, stopwordArray){ - doGetGrammar(id).set_stop_words(stopwordArray); + doGetGrammar(id).setStopWords(stopwordArray); }; var doGetGrammar = function(id, doNotResolve){//NOTE: this should stay private @@ -152,7 +183,7 @@ mobileDS.SemanticInterpreter = (function(){ if(!doNotResolve && ! checkHasGrammar(id) ){ var jsonGrammarUrl = instance.get_json_grammar_url(id); - createAndAddGrammar(jsonGrammarUrl, id, function(){console.error('created!');}); + createAndAddGrammar(jsonGrammarUrl, id, function(){console.info('created executable grammar for "'+id+'" from source '+jsonGrammarUrl);}); } return grammarImplMap[id]; @@ -200,8 +231,8 @@ mobileDS.SemanticInterpreter = (function(){ function build_grammar(theConverterInstance){ - theConverterInstance.convert_json_grammar(); - var grammarDefinition = theConverterInstance.get_jscc_grammar(); + theConverterInstance.convertJSONGrammar(); + var grammarDefinition = theConverterInstance.getJSCCGrammar(); // grammarDefinitionText = grammarDefinition; @@ -230,7 +261,7 @@ mobileDS.SemanticInterpreter = (function(){ if (errors > 0 || warnings > 0 && error_output != "") console.error(''+error_output); - console.debug("before replace " + theConverterInstance.PARSER_TEMPLATE);//debug +// console.debug("before replace " + theConverterInstance.PARSER_TEMPLATE);//debug var grammarParser = new String(theConverterInstance.PARSER_TEMPLATE); grammarParser = grammarParser.replace(/##PREFIX##/gi, ""); @@ -255,11 +286,11 @@ mobileDS.SemanticInterpreter = (function(){ + '\n});\n\n' + 'mobileDS.SemanticInterpreter.getInstance().setStopwords("' +generatedParserLanguageCode+'",' - +JSON.stringify(theConverterInstance.get_stop_words()) + +JSON.stringify(theConverterInstance.getStopWords()) + ');\n' ; - theConverterInstance.set_js_grammar(addGrammarParserExec); + theConverterInstance.setJSGrammar(addGrammarParserExec); doAddGrammar(generatedParserLanguageCode, theConverterInstance); @@ -273,17 +304,17 @@ mobileDS.SemanticInterpreter = (function(){ }//END function build_grammar if(doRecompile === true || doRecompile === 'true'){//FIXME this option must be re-implemented (there is no 'default' grammar any more!) - gc.load_grammar(build_grammar, function(){ throw 'Could not find JSON grammar file at default location'; } ); + gc.loadGrammar(build_grammar, function(){ throw 'Could not find JSON grammar file at default location'; } ); } else if(typeof doRecompile === 'string'){ //previously: STRING was interpreted as "stringified" JSON-grammar, now: as URL for the JSON grammar // gc.json_grammar_definition = JSON.parse(doRecompile); // build_grammar(gc); - gc.load_grammar(build_grammar, function(){ throw 'Could not find JSON grammar file at "'+doRecompile+'"'; } , doRecompile); + gc.loadGrammar(build_grammar, function(){ throw 'Could not find JSON grammar file at "'+doRecompile+'"'; } , doRecompile); } else if(typeof doRecompile === 'object'){ gc.json_grammar_definition = doRecompile; build_grammar(gc); } else { - gc.load_grammar(); + gc.loadGrammar(); doAddGrammar(generatedParserLanguageCode, gc); if(callback){ callback(); @@ -339,6 +370,11 @@ mobileDS.SemanticInterpreter = (function(){ var process_asr_semantic = function(phrase, stopwordFunc, langCode){//grammarParserCode){ + if(!doCheckIsEnabled()){ + console.warn('SemanticInterpreter.getASRSemantic: currently disabled!'); + return null; + } + var grammarConverter = doGetGrammar(langCode); if(!grammarConverter){ @@ -350,24 +386,24 @@ mobileDS.SemanticInterpreter = (function(){ if(IS_DEBUG_ENABLED) console.debug('SemanticInterpreter.process_asr_semantic('+langCode+'): removed stopwords, now parsing phrase "'+asr_recognized_text+'"');//debug - grammarConverter.compiled_grammar(asr_recognized_text); + grammarConverter.executeGrammar(asr_recognized_text); - grammarConverter.asr_semantic_annotation = decodeSpecialChars(grammarConverter.asr_semantic_annotation); -// JSON.parse((JSON.stringify(grammarConverter.asr_semantic_annotation).replace(/__oe__/g,'ö').replace(/__ae__/g,'ä').replace(/__ue__/g,'ü').replace(/__ss__/g,'ß'))); + grammarConverter.semanticAnnotationResult = decodeSpecialChars(grammarConverter.semanticAnnotationResult); +// JSON.parse((JSON.stringify(grammarConverter.semanticAnnotationResult).replace(/__oe__/g,'ö').replace(/__ae__/g,'ä').replace(/__ue__/g,'ü').replace(/__ss__/g,'ß'))); - return grammarConverter.asr_semantic_annotation;//TODO return copy instead of original instance? + return grammarConverter.semanticAnnotationResult;//TODO return copy instead of original instance? }; var removeStopwordsFunc = function(thePhrase, lang){ var gc = doGetGrammar(lang); - var stop_words_regexp = gc.get_stop_words_regexp(); + var stop_words_regexp = gc.getStopWordsRegExpr(); return thePhrase.replace(stop_words_regexp, '').trim(); }; var removeStopwordsAltFunc = function(thePhrase, lang){ var gc = doGetGrammar(lang); - var stop_words_regexp = gc.get_stop_words_regexp_alt(); + var stop_words_regexp = gc.getStopWordsRegExpr_alt(); while (thePhrase.match(stop_words_regexp)) { thePhrase = thePhrase.replace(stop_words_regexp, ' '); @@ -382,40 +418,48 @@ mobileDS.SemanticInterpreter = (function(){ /** * NOTE: now uses the modified implementation for stopwords. */ - get_asr_semantic: function(phrase, langCode){ + getASRSemantic: function(phrase, langCode){ return process_asr_semantic(phrase, removeStopwordsFunc, langCode); }, // get_curr_asr_semantic: function(id){ -// return doGetGrammar(id).asr_semantic_annotation; +// return doGetGrammar(id).semanticAnnotationResult; // }, /** * NOTE: uses the original implementation for stopwords (has some problems for stopwords at the * end of a sentence) */ - get_asr_semantic_alt: function(phrase, langCode){ + getASRSemantic_alt: function(phrase, langCode){ return process_asr_semantic(phrase, removeStopwordsAltFunc, langCode); }, removeStopwords: function(thePhrase, lang){ + if(!doCheckIsEnabled()){ + console.warn('SemanticInterpreter.removeStopwords: currently disabled!'); + return null; + } var str = encodeSpecialChars(thePhrase, true); str = removeStopwordsFunc(str, lang); return decodeSpecialChars(str, true); }, - removeStopwordsAlt: function(thePhrase, lang){ + removeStopwords_alt: function(thePhrase, lang){ + if(!doCheckIsEnabled()){ + console.warn('SemanticInterpreter.removeStopwords_alt: currently disabled!'); + return null; + } var str = encodeSpecialChars(thePhrase, true); str = removeStopwordsAltFunc(str, lang); return decodeSpecialChars(str, true); }, /** NOTE: the grammar must be compiled first, see getNewInstance(true) */ getGrammarDefinitionText: function(id){ - return doGetGrammar(id).get_jscc_grammar();//grammarDefinitionText; + return doGetGrammar(id).getJSCCGrammar();//grammarDefinitionText; }, /** NOTE: the grammar must be compiled first, see getNewInstance(true) */ getGrammarParserText: function(id){ - return doGetGrammar(id).get_js_grammar();//grammarParser; + return doGetGrammar(id).getJSGrammar();//grammarParser; }, getGrammarConverter: function(id){ return doGetGrammar(id); @@ -441,7 +485,7 @@ mobileDS.SemanticInterpreter = (function(){ /** * Sets the current grammar. * - * If in invocations of get_asr_semantic(..) the grammar ID (e.g. language code) is missing, + * If in invocations of getASRSemantic(..) the grammar ID (e.g. language code) is missing, * then this grammar that is set here is used. * * The id must reference either a grammar that was compiled (i.e. generated JavaScript file) @@ -460,10 +504,17 @@ mobileDS.SemanticInterpreter = (function(){ return currentGrammarId; }, + setEnabled: function(isEnabled){ + doSetEnabled(isEnabled); + }, + isEnabled: function(){ + return doCheckIsEnabled(); + }, + //FIXME rename/move functions get_json_grammar_url: function(id){ var configLangPath = mobileDS.constants.getInstance().getLanguagePath(); - var jsonGrammarFileName = mobileDS.constants.getInstance().getGrammarFilename(); + var jsonGrammarFileName = mobileDS.constants.getInstance().getGrammarFileName(); return configLangPath + id + '/' +jsonGrammarFileName; } diff --git a/assets/www/mmirf/semantic/stemmer.js b/assets/www/mmirf/semantic/stemmer.js new file mode 100644 index 0000000..868cfd2 --- /dev/null +++ b/assets/www/mmirf/semantic/stemmer.js @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +var mobileDS = window.mobileDS || +{}; + +if(typeof mobileDS.SnowballSimple === 'undefined'){ + mobileDS.SnowballSimple = {}; +} + +/* + Really simple JavaScript stemmer based on the Snowball stemmer + http://snowball.tartarus.org/algorithms/german/stemmer.html + Some simplifications were made, e.g. ignoring R2 and the special + provision for words ending in -isse- +*/ + +mobileDS.SnowballSimple.stem = (function(){ + /* Definitions */ + + // var vowel = /[aeiouyäöüUY]/; + // var cons = /[^aeiouyäöüUY]/; + var sEnding = "[bdfghklmnrt]"; + var stEnding = "[bdfghklmnt]"; + + var prefix = "^((.[aeiouyäöüUY][^aeiouyäöüUY])|([aeiouyäöüUY][^aeiouyäöüUY].))"; + + + var stem_word = function simpleStemmer(word){ + + word = word.toLowerCase(); + word = word.replace(/ß/g, "ss"); + + if (word.length < 4) { + return word; + } + + word = word.replace(/([aeiouyäöü])y([aeiouyäöü])/g, "$1Y$2"); // replace y between vowels with Y + word = word.replace(/([aeiouyäöü])u([aeiouyäöü])/g, "$1U$2"); // replace u between vowels with U + /* Step 1 */ + + if (word.match(prefix + "(.*)" + "ern$")) { + word = word.slice(0, -3); + } + else + if (word.match(prefix + "(.*)" + "(em$|en$|er$|es$)")) { + word = word.slice(0, -2); + } + else + if (word.match(prefix + "(.*)" + "(e$)")) { + word = word.slice(0, -1); + } + else + if (word.match(sEnding + "s$") && word.match(prefix + "(.*)" + "(s$)")) { + word = word.slice(0, -1); + } + + + + /* Step 2 */ + + if (word.match(prefix + "(.*)" + "est$")) { + word = word.slice(0, -3); + } + else + if (word.match(prefix + "(.*)" + "(en$|er$)")) { + word = word.slice(0, -2); + } + else + if (word.match(prefix + "(.*)" + stEnding + "(st$)")) { + word = word.slice(0, -2); + } + + + + /* Step 3 */ + // simplified!! Really these should be in R2 not R1 + + if (word.match(prefix + "(.*)" + "keit$")) { + word = word.slice(0, -4); + } + if (word.match(prefix + "(.*)" + "(lich$|heit$)")) { + word = word.slice(0, -4); + if (word.match(prefix + "(.*)" + "(er$|en$)")) { + word = word.slice(0, -2); + } + } + else + if (word.match(prefix + "(.*)" + "(isch$)")) { + if (!word.match("eisch$")) { + word = word.slice(0, -4); + } + } + else + if (word.match(prefix + "(.*)" + "(ig$|ik$)")) { + if (!word.match("e..$")) { + word = word.slice(0, -2); + } + } + else + if (word.match(prefix + "(.*)" + "(end$|ung$)")) { + word = word.slice(0, -3); + } + + + + /* Clean up */ + + word = word.replace(/([aeiouyäöü])Y/g, "$1y"); // replace Y with y + word = word.replace(/([aeiouyäöü])U/g, "$1u"); // replace U with u + word = word.replace(/ä/g, "a"); + word = word.replace(/ö/g, "o"); + word = word.replace(/ü/g, "u"); + + + return word; + + }; + + return stem_word; +})(); diff --git a/assets/www/javascripts/tools/ant/AntScriptFileHandler.js b/assets/www/mmirf/tools/build/ant/AntScriptFileHandler.js similarity index 100% rename from assets/www/javascripts/tools/ant/AntScriptFileHandler.js rename to assets/www/mmirf/tools/build/ant/AntScriptFileHandler.js diff --git a/assets/www/javascripts/tools/ant/AntScriptFileListGenerator.js b/assets/www/mmirf/tools/build/ant/AntScriptFileListGenerator.js similarity index 90% rename from assets/www/javascripts/tools/ant/AntScriptFileListGenerator.js rename to assets/www/mmirf/tools/build/ant/AntScriptFileListGenerator.js index 902e0eb..2510133 100644 --- a/assets/www/javascripts/tools/ant/AntScriptFileListGenerator.js +++ b/assets/www/mmirf/tools/build/ant/AntScriptFileListGenerator.js @@ -41,12 +41,12 @@ "/views/calendar" : ["create_appointment.ehtml"], "/views/layouts" : ["application.ehtml"], "/models" : ["calendarmodel.js", "user.js"], - "/config" : ["languages", "statedef", "configuration.json", "parsed_directories.json"], + "/config" : ["languages", "statedef", "configuration.json", "directories.json"], "/config/languages" : ["de", "en"], "/config/languages/de" : ["dictionary.dic", "grammar.json", "speaker.json"], "/config/languages/en" : ["dictionary.dic", "speaker.json"], - "/config/statedef" : ["dialogDescription.xml", "dialogDescription.xml.MD5", "input_manager_scxml.xml", "input_manager_scxml.xml.MD5", "readme.txt"], - "/javascripts/plugins" : ["beepPlugin.js", "cookiePlugin.js", "directoryListing.js", "multitouchPlugin.js", "nativeTTS.js", "nuance.js", "queuePlugin.js", "softkeyboard.js", "video.js"], + "/config/statedef" : ["dialogDescriptionSCXML.xml", "dialogDescriptionSCXML.xml.MD5", "inputDescriptionSCXML.xml", "inputDescriptionSCXML.xml.MD5", "readme.txt"], + "/mmirf/plugins" : ["beepPlugin.js", "cookiePlugin.js", "directoryListing.js", "multitouchPlugin.js", "nativeTTS.js", "nuance.js", "queuePlugin.js", "softkeyboard.js", "video.js"], "/helpers" : ["applicationHelper.js"] } * diff --git a/assets/www/javascripts/tools/ant/AntScriptGrammarLanguageList.js b/assets/www/mmirf/tools/build/ant/AntScriptGrammarLanguageList.js similarity index 100% rename from assets/www/javascripts/tools/ant/AntScriptGrammarLanguageList.js rename to assets/www/mmirf/tools/build/ant/AntScriptGrammarLanguageList.js diff --git a/assets/www/javascripts/tools/ant/InitForAntDefaultScriptEnv.js b/assets/www/mmirf/tools/build/ant/InitForAntDefaultScriptEnv.js similarity index 100% rename from assets/www/javascripts/tools/ant/InitForAntDefaultScriptEnv.js rename to assets/www/mmirf/tools/build/ant/InitForAntDefaultScriptEnv.js diff --git a/assets/www/javascripts/tools/ant/StandaloneSemanticParserCompileExec.js b/assets/www/mmirf/tools/build/ant/StandaloneSemanticParserCompileExec.js similarity index 100% rename from assets/www/javascripts/tools/ant/StandaloneSemanticParserCompileExec.js rename to assets/www/mmirf/tools/build/ant/StandaloneSemanticParserCompileExec.js diff --git a/assets/www/javascripts/tools/nodejs/InitForAntNodeJsScriptEnv.js b/assets/www/mmirf/tools/build/nodejs/InitForAntNodeJsScriptEnv.js similarity index 100% rename from assets/www/javascripts/tools/nodejs/InitForAntNodeJsScriptEnv.js rename to assets/www/mmirf/tools/build/nodejs/InitForAntNodeJsScriptEnv.js diff --git a/assets/www/javascripts/tools/nodejs/NodeJsFileHandler.js b/assets/www/mmirf/tools/build/nodejs/NodeJsFileHandler.js similarity index 100% rename from assets/www/javascripts/tools/nodejs/NodeJsFileHandler.js rename to assets/www/mmirf/tools/build/nodejs/NodeJsFileHandler.js diff --git a/assets/www/javascripts/tools/rhino/InitForAntRhinoScriptEnv.js b/assets/www/mmirf/tools/build/rhino/InitForAntRhinoScriptEnv.js similarity index 100% rename from assets/www/javascripts/tools/rhino/InitForAntRhinoScriptEnv.js rename to assets/www/mmirf/tools/build/rhino/InitForAntRhinoScriptEnv.js diff --git a/assets/www/mmirf/tools/commonUtils.js b/assets/www/mmirf/tools/commonUtils.js new file mode 100644 index 0000000..55b6ea8 --- /dev/null +++ b/assets/www/mmirf/tools/commonUtils.js @@ -0,0 +1,1419 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * @module mobileDS.tools + * + */ +var mobileDS = window.mobileDS || +{}; + +/** + * A Utility class to support various functions.
+ * It contains nearly all regular expressions used in the application - so that changes can be arranged inside this file.
+ * This "class" is structured as a singleton - so that only one instance is in use.
+ * You can access the instance of the class via + * @example mobileDS.CommonUtils.getInstance() + * @class CommonUtils + * @category core + * + * @see mobileDS.CommonUtils#constructor + */ +mobileDS.CommonUtils = (function(){ + + /** + * Object containing the instance of the class CommonUtils + * + * @property instance + * @type Object + * @private + */ + var instance = null; + + /** + * JSON-Object containing the directory Structure of the application. Only directories defined by the Property + * {@link mobileDS.CommonUtils-constructor-directoriesToParse} are contained within the JSON-Object. + * + * @property directoryStructure + * @type JSON + * @private + */ + this.directoryStructure; + + /** + * This function is used by {@link mobileDS.CommonUtils#getDirectoryContents} and {@link mobileDS.CommonUtils#getDirectoryContentsWithFilter} to strip the pathname parameter + * @function stripPathName + * @private + * @param {string} pathname The path that should be stripped of "file://" and a beginning or trailing "/" + * @returns {String} The stripped pathname - devoid of beginning "file://" or "/" and trailing "/" + */ + function stripPathName(pathname){ + + //FIXME this is a HACK; TODO handle this in a general way! + var basePath = mobileDS.constants.getInstance(forBrowser).getBasePath(); + + if(pathname.startsWith(basePath)){ + pathname = pathname.substring(basePath.length); + } + + if (pathname.indexOf("file://") != -1){ + pathname = pathname.replace("file://", ""); + } + if (pathname[pathname.length-1] == "/"){ + pathname = pathname.substring(0,pathname.length-1); + } + if (pathname[0] != "/"){ + pathname = "/" + pathname; + } + + return pathname; + } + + /** + * This helper initializes a function for detecting if an Object is an Array. + * + * The helper tries to find functions of JavaScript libraries for this; if none can be found, + * a custom implementation is used. + * + * The returned function is used by {@link mobileDS.CommonUtils#isArray} + * + * NOTE: The current implementation checks jQuery.isArray for presences + * + * @function isArrayHelper + * @private + * @returns {Function} a function that takes one parameter (Object) and returns true if this parameter is an Array (false otherwise) + */ + var isArrayHelper = function(obj){ + + //this is the initializer: the following will overwrite the isArray-function + // with the appropriate version (use jQuery method, if present, otherwise use alternative) + + //if present, use jQuery method: + if(typeof jQuery !== 'undefined' && typeof jQuery.isArray === 'function'){ + isArrayHelper = jQuery.isArray; + } + else { + //use the toString method with well-defined return-value from Object: + var staticToString = Object.prototype.toString; + + isArrayHelper = function(obj){ + return staticToString.call(obj) === '[object Array]'; + }; + } + }; + //initialize the isArray-function + isArrayHelper(); + + /** + * Constructor-Method of Class {@link mobileDS.CommonUtils} + * + * @param {jQuery} [$] the jQuery instance/object (OPTIONAL); some few function need jQuery to work correctly (see requires annotations) + * + * @constructor + * @augments mobileDS.CommonUtils + * + * @memberOf mobileDS.CommonUtils.prototype + */ + function constructor($){ + //private members. + + /** + * The Prefix for the file names of partial-files.
+ * Files named <PARTIAL-PREFIX>filename.ehtml inside a views-directory + * are recognized as partials. + * + * @property partialsPrefix + * @type String + * @private + */ + var partialsPrefix = '~'; + + /** + * Array of Directories (Strings) to parse at the starting process
+ * those directories are then accessable by the functions {@link mobileDS.CommonUtils#getDirectoryContents} and {@link mobileDS.CommonUtils#getDirectoryContentsWithFilter} + * + * TODO read from properties (implement mechanism such that \build.settings and this refer to the same resource) + * + * @property directoriesToParse + * @type Array + * @private + */ + var directoriesToParse = [ + "www/controllers", + "www/views", + "www/models", + "www/config", + "www/mmirf/plugins", + "www/helpers" + ]; + + + /** + * Array of strings for the conversion of month represented by integers to strings + * Default Language for months is english, 'en' + * @property months + * @type Object + * @private + */ + this.months = new Object(); + this.months['01'] = 'January'; + this.months['02'] = 'February'; + this.months['03'] = 'March'; + this.months['04'] = 'April'; + this.months['05'] = 'May'; + this.months['06'] = 'June'; + this.months['07'] = 'July'; + this.months['08'] = 'August'; + this.months['09'] = 'September'; + this.months['10'] = 'October'; + this.months['11'] = 'November'; + this.months['12'] = 'December'; + + this.months['de'] = new Object(); + this.months['de']['01'] = 'Januar'; + this.months['de']['02'] = 'Februar'; + this.months['de']['03'] = 'März'; + this.months['de']['04'] = 'April'; + this.months['de']['05'] = 'Mai'; + this.months['de']['06'] = 'Juni'; + this.months['de']['07'] = 'Juli'; + this.months['de']['08'] = 'August'; + this.months['de']['09'] = 'September'; + this.months['de']['10'] = 'Oktober'; + this.months['de']['11'] = 'November'; + this.months['de']['12'] = 'Dezember'; + + /** @lends mobileDS.CommonUtils.prototype */ + return { + //public members. + /** + * @function getPartialsPrefix + * @public + * @returns {String} The Prefix for the file names of partial-files + */ + getPartialsPrefix: function(){ + return partialsPrefix; + }, + + /** + * @function getDirectoryStructure + * @public + * @returns {Object} Directory structure as json object + */ + getDirectoryStructure: function(){ + return this.directoryStructure; + }, + /** + * extracts all the strings from a string Array into a single string + * @function concatArray + * @public + * @returns {string} text + */ + concatArray: function(array){ + var text = ""; + array.forEach(function (e){ + text = text + ', '+e; + }); + return text; + }, + /** + * Regular Expression for matching HTML comments.
+ * + * This RegExp also matches multi-line comments. + * + * Note upon using the RegExp that it does not consider + * if a HTML comment is specified within a String or data-definition + * (i.e. the comment is matched regardless were its defined). + * + * @example + * @property regexHTMLComment + * @type String|RegExp + * @public + */ + regexHTMLComment: //igm, + + /** + * Similar to the jQuery.getScript() function - appending a url of a javascript-source to the header of the main document.
+ * This function also calls a callback if the script was loaded. + * @function loadScript + * @param {String} url source of javascript-file + * @param {Function} callback callback function + * @public + * @async + * @deprecated superseded by getLocalScript + */ + loadScript: function (url, callback){ + var script = document.createElement("script"); + script.type = "text/javascript"; + script.src = url; + + if (typeof callback === 'function'){ + script.onload = function(){ + callback(); + }; + } + document.getElementsByTagName("head")[0].appendChild(script); + }, + + /** + * Load all plugins (i.e. JavaScript interfaces for Cordova/Java-Impl. plugins). + * + * @function loadAllPhonegapPlugins + * @param {String} pluginsPath Path of the plugins which should be loaded, e.g. file:///android_asset/www/mmirf/plugins/ + * @param {Function} cbFunction The function that should be executed after the plugins are loaded. + * If the execution of following functions is dependent on the present of plugins, + * they should be triggered from inside the callback-function + * @async + * @public + */ + loadAllPhonegapPlugins: function (pluginsPath, cbFunction){ + + // reads all *.js files in /assets/www/mmirf/plugins + // and loads them dynamically + // IMPORTANT: /assets/www/config/directories.json must be up-to-date! + // (it contains the list of JS-files for the plugins) + // -> use ANT /build.xml for updating + // IMPORTANT: the Java-side implementations of the plugins must be enabled + // by corresponding entries in /res/plugins.xml file! + + instance.loadImpl( + pluginsPath, + false, + cbFunction, + function isPluginAlreadyLoaded(pluginFileName){ + if(window.plugins[pluginFileName.replace(/\.[^.]+$/g,"")]){ + return true; + } + else{ + return false; + } + }, + function(status,fileName,msg){ + if(status==='info'){ + console.info('[loadAllPhonegapPlugins] "'+fileName+'": '+msg); + } + else if(status==='warning'){ + console.warn('[loadAllPhonegapPlugins] "'+fileName+'": '+msg); + } + else if(status==='error'){ + console.error('[loadAllPhonegapPlugins] "'+fileName+'": '+msg); + } + else{ + console.error('[loadAllPhonegapPlugins] '+status+' (UNKNOWN STATUS) -> "'+fileName+'": '+msg); + } + } + ); + }, + + /** + * Load all compiled grammars (executable JavaScript grammars). + * + * @function loadCompiledGrammars + * @param {String} generatedGrammarsPath Path of the grammars which should be loaded, e.g. file:///android_asset/www/gen/grammar/ + * @param {Function} cbFunction The function that should be executed after the plugins are loaded. + * If the execution of following functions is dependent on the presence of the grammars, + * they should be triggered from inside the callback-function. + * @async + * @public + */ + loadCompiledGrammars: function (generatedGrammarsPath, cbFunction){ + + instance.loadImpl( + generatedGrammarsPath, + false, + cbFunction, + function isGrammarAlreadyLoaded(grammarFileName){ + var i = grammarFileName.indexOf('_'); + if(i !== -1){ + return mobileDS.SemanticInterpreter.getInstance().hasGrammar( + grammarFileName.substring(0,i) + ); + } + else{ + return false; + } + }, + function loadCompiledGrammarsStatus(status,fileName,msg){ + if(status==='info'){ + console.info('[loadCompiledGrammars] "'+fileName+'": '+msg); + } + else if(status==='warning'){ + console.warn('[loadCompiledGrammars] "'+fileName+'": '+msg); + } + else if(status==='error'){ + console.error('[loadCompiledGrammars] "'+fileName+'": '+msg); + } + else{ + console.error('[loadCompiledGrammars] '+status+' (UNKNOWN STATUS) -> "'+fileName+'": '+msg); + } + } + ); + + }, + + /** + * Load implementation files (i.e. JavaScript files) from a directory (if librariesPath is a String) or + * or a list of files-names (if librariesPath is an Array of Strings). + * + * + * + * @function loadImpl + * @param {String|Array} librariesPath + * Path (or list of of the plugins which should be loaded, e.g. file:///android_asset/www/mmirf/plugins/ + * NOTE: The (String) path must be an entry in directories.json! + * (directories.json is used to generate/"query" the file-list for the path) + * + * @param {Boolean} isSerial + * Set true if the libraries should be loaded serially, i.e. synchronously, that is "one after the other" (later ones may depend on earlier ones). + * set false if libraries should be loaded in parallel, i.e. "asychronously" (NOTE in this case, the libraries must not depend on each other). + * + * NOTE: The loading process as a hole is asynchronous (regardless of parameter isSerial), + * i.e. loading is completed when completedCallback() is invoked, + * NOT when this function returns! + * + * @param {Function} [completedCallback] + * The function that should be executed after the libraries are loaded. + * If the execution of following functions is dependent on the presence of the libraries, + * they should be capsuled inside this callback-function. + * @param {Function} [checkIsAlreadyLoadedFunc] + * If provided, this function checks (based on the file-name), if the library is already + * loaded. + * The signature for the callback is checkIsAlreadyLoadedFunc(String fileName) return [true|false], + * i.e. the function may check - based on the file-name - if the library is already loaded. + * If the function returns true, the library will not be loaded, and loading continues + * with the next library-file. + * + * NOTE: if isSerial is flase, libraries with lower indices in the list may + * still be loading, when later entries are checked with this callback. In consequence, + * the "is already loaded"-check may not be accurate, in case parallel loading is + * used and the library-list contains "duplicate" entries. + * @param {Function} [statusCallback] + * If provided, this function is invoked, when a library is loaded (INFO) or an + * error occurs. + * The signature for the callback is + * statusCallback(String statusLevel, String fileName, String message) + * where statusLevel is one of info, warning, error, + * fileName is the file-name for the library that this status message concerns, and + * message is a message text with details concerning the status + * @async + * @public + */ + loadImpl: function (librariesPath, isSerial, completedCallback, checkIsAlreadyLoadedFunc, statusCallback){ + + var isPath = true;//TODO use this for creating absolute paths (-> in case librariesPath is an Array)! + var theFileList; + if(typeof librariesPath === 'string'){ + theFileList = instance.getDirectoryContentsWithFilter(librariesPath, "*.js"); + } + else { + isPath = false; + theFileList = librariesPath; + } + + var size = theFileList.length; + var progress = 0; + + var doLoadImplFile = function doLoadImplFile(fileList, index){ + + if( ! index){ + index = 0; + } + + var fileName = fileList[index]; + + if ( checkIsAlreadyLoadedFunc && checkIsAlreadyLoadedFunc(fileName) ){ + + if(statusCallback){ + statusCallback('warning', fileName, 'already loaded ' + librariesPath+fileName); + } + + ++progress; + //synchronous load: load next recursively + if(isSerial){ + doLoadImplFile(fileList, index+1); + } + + } else { + + //handler that is invoked after file has been loaded: + var handleScriptDone = function(){ + //"notify" that this file has been DONE: + ++progress; + + //check: are all entries of the list done? + if (progress < size){ + + if( isSerial ){ + //synchronous load: load next entry recursively, when previous, i.e. this, one has finished: + doLoadImplFile(fileList, index+1); + } + //all entries already have been processed -> stop now. + return; + } + + //ASSERT: all entries of the file-list are DONE -> triggere completedCallback + + if (typeof completedCallback == 'function'){ + completedCallback(); + } else { + if(statusCallback){ + statusCallback('warning', fileName, 'provided callback for COMPLETION is not a function: '+completedCallback); + } + else { + console.warn('[loadImpl] callback for COMPLETION is not a function: '+completedCallback); + } + } + }; + + /// ATTENTION: $.getScript --> mobileDS.CommonUtils.getInstance().getLocalScript + /// under Android 4.0 getScript is not wokring properly + instance.getLocalScript(librariesPath+fileName, + function(){ + + if(statusCallback){ + statusCallback('info', fileName, 'done loading ' + librariesPath+fileName); + } + + handleScriptDone(); + }, + function(exception) { + if(statusCallback){ + statusCallback('error', fileName, 'could not load "' + librariesPath+fileName + '": ' + exception); + } + else { + // print out an error message + console.error('[loadImpl] Could not load "' + librariesPath+fileName + '": ' + exception); + } + + //NOTE: in case of an error, will still try to load the other files from the list: + + handleScriptDone(); + } + );//END: getLocalScript(callbacks) + } + };//END: doLoadImplFile(name,index) + + //console.log('about to load all libraries from path "'+librariesPath+'"...');//FIXM debug + + if( ! isSerial){ + //asynchronous load: trigger loading for all at once: + for(var counter=0; counter < size; ++counter){ + doLoadImplFile(theFileList, counter); + } + } + else { + //synchronous load: start with first (the next one will be loaded recursively, when the first one was loaded) + doLoadImplFile(theFileList); + } + + + }, + + /** + * Detects via the user-agent-string if the application is running on android. + * @function isRunningOnAndroid + * @public + * @returns {Boolean} True if application is running on android, False otherwise + */ + isRunningOnAndroid: function (){ + // Testing if user-Agent-/ or appVersion-String contains 'android' + if ((navigator.userAgent.toLowerCase().indexOf("android")>-1) || (navigator.appVersion.toLowerCase().indexOf("android")>-1)){ + return true; + } else { + return false; + } + }, + + /** + * Should detect - via the user-agent-string - if the application is running on android, symbian or ios; in other words: on a smartphone. + * @function isRunningOnSmartphone + * @public + * @returns {Boolean} True if application is running on smartphone, False otherwise + */ + isRunningOnSmartphone: function (){ + // Testing if user-Agent-/ or appVersion-String contains 'android' or 'iOS' + // at the moment only android-, ios and symbian-strings are 'implemented' + var testString = navigator.userAgent.toLowerCase() + navigator.appVersion.toLowerCase(); + if ((testString.indexOf("android")>-1) || (testString.indexOf("ios")>-1) || (testString.indexOf("symbian")>-1)){ + return true; + } else { + return false; + } + }, + + /** + *
+ * Note: + * On Android 4.0 jQuery.getScript() is not working properly - so use this function instead! + *
+ * + * Similar to the jQuery.getScript() function - appending a url of a javascript-source to the header of the main document.
+ * This function also calls a success-callback if the script was successfully loaded or a fail-callback.
+ * + * + * @function getLocalScript + * @param {String} scriptUrl source of javascript-file + * @param {Function} success success callback function + * @param {Function} fail fail callback function + * @async + * @public + */ + getLocalScript: function (scriptUrl, success, fail){ + var head = document.getElementsByTagName("head")[0]; + script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = scriptUrl; + script.onload = function() { success && success(); }; + script.onerror = function(e) { + if(IS_DEBUG_ENABLED) console.info("Insert Script Failed - " + scriptUrl + ": " + e); + fail && fail(e); + }; + head.appendChild(script); + }, + + /** + * This function returns an array of strings with the contents of a directory. + * @function getDirectoryContents + * @param {String} pathname Path of the directory which contents should be returned + * @public + * @returns {Array} Array of Strings which contains the contents of the directory + */ + getDirectoryContents: function(pathname){ + var retValue; + + pathname=stripPathName(pathname); + + try{ + retValue = this.directoryStructure[pathname]; + } catch(e){ + console.warn(e); + retValue = null; + } + return retValue; + }, + + /** + * This function returns an array of strings with the contents of a directory, giving only those files which match the filter. + * @function getDirectoryContentsWithFilter + * @param {String} pathname Path of the directory which contents should be returned + * @param {String} filter Filter of file-names: *.js, * or *.ehtml + * @public + * @returns {Array} Array of Strings which contains the contents of the directory + */ + getDirectoryContentsWithFilter: function(pathname, filter){ + var retValue = new Array(); + + var tmpfilter="^" + filter.replace(".","\\.").replace("*", ".*").replace("\$", "\\$") + "$"; + + var filterRegExp = new RegExp(tmpfilter, 'gi'); + + pathname=stripPathName(pathname); + + try{ + var tmp=this.directoryStructure[pathname]; + if (tmp == undefined){ + console.warn("["+pathname+" / " + filter + "] not found."); + retValue = null; + } else { + for (var i=0;iArray. + * + *

+ * This function can be savely run in arbirtray contexts, e.g. + * + *

 var checkArray = mobileDS.CommonUtils.getInstance().isArray;
+             * if( checkArray(someObject) ){
+             *   ...
+ * + * @function isArray + * @param {Object} object the Object for checking if it is an Array + * @public + * @returns {Boolean} true if object is an Array, otherwise false. + */ + isArray: function(object){ + return isArrayHelper(object); + }, + + /** + * This function iterates over all elements of a specific class and changes the font-size of the contained text to the maximal possible size - while still being small enough to fit in the element. + * @function resizeFitToSourroundingBox + * @param {String} class_name Name of the class which inner text should be fitted to the size of the element + * + * @requires jQuery + * @public + */ + resizeFitToSourroundingBox: function(class_name){ + // resize the font in box_fit-class, so that it won't overlap its div-box + $(function(){ + + var smallest_font=1000; + $( class_name ).each(function ( i, box ) { + var width = $( box ).width(), + html = '', + line = $( box ).wrapInner( html ).children()[ 0 ], + n = parseInt($( box ).css("font-size"), 10); + + $( box ).css( 'font-size', n ); + + while ( $( line ).width() > width ) { + $( box ).css( 'font-size', --n ); + } + + $( box ).text( $( line ).text() ); + + n = parseInt($( box ).css("font-size"), 10); + + if (n < smallest_font){ + smallest_font = n; + } + }); + + $( class_name ).each(function ( i, box ) { + $( box ).css( 'font-size', smallest_font ); + }); + }); + }, + + /** + * Converts the object to a valid JSON String value. + * + * Ensures that the returned value does not contain (un-escaped) double-quotes, so that + * the returned value can be used as a JSON value, e.g.
+ * @example var jsonValue = toJSONStringValue(someValue); + * var data = JSON.parse('"theValue":"' + jsonValue + '"'); + * @function toJSONStringValue + * @param {Object} theObjectValue the object to convert to a JSON String value. If NULL or UNDEFINED, an EMPTY String will be returned + * @returns {String} the String value + * @public + */ + toJSONStringValue: function(theObjectValue){ + if(typeof theObjectValue !== 'undefined' && theObjectValue !== null){ + if(typeof theObjectValue !== 'string'){ + theObjectValue = theObjectValue.toString(); + } + theObjectValue = theObjectValue.escapeDoubleQuotes(); + } else { + theObjectValue = ''; + } + return theObjectValue; + }, + + + /** + * Converts the object to a valid JSON String value. + * + * Ensures that the returned value does not contain (un-escaped) double-quotes, so that + * the returned value can be used as a JSON value, also does replace all newlines with the + * HTML-equivalent '<br/>', e.g. + * @example var jsonValue = toJSONStringValue(someValue); + * var data = JSON.parse('"theValue":"' + jsonValue + '"'); + * ... + * @function convertJSONStringValueToHTML + * @param {Object} theObjectValue the object to convert to a JSON String value. If NULL or UNDEFINED, an EMPTY String will be returned + * @returns {String} the String value + * @public + */ + convertJSONStringValueToHTML: function(str){ + if(typeof str !== 'undefined' && str !== null){ + if(typeof str !== 'string'){ + str = str.toString(); + } + //escape double-quotes, if necessary + //replace (all variants of) newlines with HTML-newlines + str = str.escapeDoubleQuotes().replaceAll('\r\n','
').replaceAll('\n','
').replaceAll('\r','
'); + } else { + str = ''; + } + return str; + + }, + + /** + * Converts the object's direct properties to a valid JSON String (i.e. no recursion for Object properties). + * + * @function convertJSONStringToHTML + * @param {Object} _o the object to convert to a JSON String. + * @returns {String} the String value + * @public + */ + convertJSONStringToHTML: function(_o){ +// var parse = function(_o){ + var a = new Array(), t; + for(var p in _o){ + if(_o.hasOwnProperty(p)){ + t = _o[p]; + if (t != null){ + if(t && typeof t == "object"){ + a[a.length]= p + ":{ " + arguments.callee(t).join(", ") + "}"; + } else { + if(typeof t == "string"){ + a[a.length] = [ p+ ": \"" + t.toString() + "\"" ]; + } else{ + a[a.length] = [ p+ ": " + t.toString()]; + } + } + } + } + } +// return a; +// }; +// return "{" + parse(o).join(", ") + "}"; + + return "{" + a.join(", ") + "}"; + }, + + /** + * Convert parameter-part of an URL to a "dictionary", containing + * the parameter keys and values + * + * @example ?id=5&name=heinz&name=kunzdict['id']=5, dict['name'] = ['heinz', 'kunz'] + * + * The returnd "dictionary" has the following functions: + *
    + *
  • has(String key): returns true if the dictionary contains an entry for key
  • + *
  • isMultiple(String key): returns true if the entry for key is an Array (i.e. the URL contained multiple values for this key)
  • + *
  • getKeys(): returns an Array with the keys (String) for all entries
  • + *
+ * + * @function parseParamsToDictionary + * @param {String} the parameter-part of the URL, i.e. &... + * @return {Object} an "dictionary" for the parameters + * @public + */ + parseParamsToDictionary: function(urlParamsPartStrings){ + var dict = new Object(); + + dict.has = function(key){ + return typeof dict[key] !== 'undefined'; + }; + dict.isMultiple = function(key){ + //use not-allowed-as-part-of-parameter-name char & as prefix for meta-data 'isMultiple' on field 'key': + return typeof dict['&'+key] !== 'undefined' && dict['&'+key] === true; + }; + //use not-allowed-as-part-of-parameter-name char & as prefix for meta-data 'keys-list': + dict['&&keys'] = new Array(); + dict.getKeys = function(){ + return dict['&&keys']; + }; + + if(urlParamsPartStrings){ + if(typeof urlParamsPartStrings !== 'string'){ + urlParamsPartStrings = urlParamsPartStrings.toString(); + } + if(urlParamsPartStrings.length < 1){ + return dict;//////////////////////// EARLY EXIT /////////////////////////// + } + if(urlParamsPartStrings.charAt(0)==='?'){ + urlParamsPartStrings = urlParamsPartStrings.substring(1); + } + + var params = urlParamsPartStrings.split('&'); + var cur = null; + var keyValue = null; + var theKey = null; + var theValue= null; + for(var i_params = 0, size_params = params.length; i_params < size_params; ++ i_params) { + + cur = params[i_params]; + + //"parse" parameter into key & value: + keyValue = cur.split('='); + theKey = keyValue[0]; + if(keyValue.length > 1){ + theValue = keyValue[1]; + } + else { + theValue = null; + } + + //create entry in dict for the parameter + if(dict.has(theKey)){ + + if(dict.isMultiple(theKey)){ + dict[theKey].push(theValue); + } + else { + //entry already exist, but is not multiple (=Array) yet: + var arr = new Array(2); + arr[0] = dict[theKey]; + arr[1] = theValue; + dict[theKey] = arr; + dict['&'+theKey] = true; + } + } + else { + dict[theKey] = theValue; + dict['&&keys'].push(theKey); + } + } + } + return dict; + }, + /** + * This function is used check whether a network connection is enabled.
+ * This version of checking the network connection is based on the cordova 2.3.0 API. + * + * TODO implement with HTML5 functions (in addition to / instead of cordova)? + * + * @function checkNetworkConnection + * @private + * @returns {Boolean} true if a network connection is enabled + */ + checkNetworkConnection: function() { + console.log("Check network status."); + var networkState = navigator.connection.type; + + var states = {}; + states[Connection.UNKNOWN] = 'Unknown connection'; + states[Connection.ETHERNET] = 'Ethernet connection'; + states[Connection.WIFI] = 'WiFi connection'; + states[Connection.CELL_2G] = 'Cell 2G connection'; + states[Connection.CELL_3G] = 'Cell 3G connection'; + states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.NONE] = 'No network connection'; + + if (Connection.NONE === networkState){ + //alert('Connection type: ' + states[networkState]); + return false; + } + return true; + }, + /** + * Parses the directory structure - paths given by property {@link mobileDS.CommonUtils-constructor-directoriesToParse} - and storing the result in the class-property {@link mobileDS.CommonUtils-directoryStructure} + * @function initialize + * @param {Function} cb The function that should be executed after the diretories are parsed - it's best to include all following functions inside the callback-function. + * @async + * @public + */ + initialize: function(cb){ + var self = this; + + window.plugins.directoryListing.getDirectoryStructure( + directoriesToParse, + function(dirStruct){ + + if(IS_DEBUG_ENABLED) console.debug(JSON.stringify(dirStruct));//debug + + self.directoryStructure = dirStruct; + + if(IS_DEBUG_ENABLED) console.debug("[getDirectoryStructure] finished.");//debug + if(IS_DEBUG_ENABLED) console.debug(JSON.stringify(dirStruct));//debug + + if ((cb) && (typeof cb == 'function')){ + cb.call(); + } + }, + function(e){ + console.error("[ERROR] " + e); + } + ); + } + + /** + * Set to "backwards compatibility mode" (for pre version 2.0). + * + * This function re-adds deprecated and removed functions and properties to the CommonUtils instance. + * + * NOTE that once set to compatibility mode, it cannot be reset to non-compatibility mode. + * + * TODO move into separate extensions file + * + * @functionOf mobileDS.CommonUtils.prototype + * @constructor + * + * @borrows mobileDS.CommonUtils#regexHTMLComment as this.html_comment_regex + * @borrows mobileDS.CommonUtils#resizeFitToSourroundingBox as this.html_resize_font_to_fit_surrounding_box + * @borrows mobileDS.CommonUtils#toJSONStringValue as this.to_json_string_value + * @borrows mobileDS.CommonUtils#convertJSONStringValueToHTML as this.convert_to_json_value_HTML_string + * @borrows mobileDS.CommonUtils#convertJSONStringToHTML as this.convert_json_to_HTML_string + * @borrows mobileDS.CommonUtils#parseParamsToDictionary as this.get_params_as_dict + */ + , setToCompatibilityMode: function(){ + + /** + * The instance that holds the extensions for compatibility mode, + * which really is the CommonUtils instance. + * + * @property compatibilitySelf + * @type mobileDS.CommonUtils + * @private + */ + var compatibilitySelf = this; + + /** + * HTML-Dom-Element for logging directly on the main HTML-Page + * as of now there is no element with the id "log" in the index.html + * + * @property debugNode + * @type Element + * @private + * @deprecated unused + */ + var debugNode = document.getElementById("log"); + + /** + * Regular Expression to identify a styleSheet-tag for the transformation of ehtml to html + * + * @property styleSheetRegExp + * @type String|RegExp + * @private + * @deprecated unused + */ + var styleSheetRegExp = /<(%=\s*stylesheet_link_tag)\s* (\"(.*)\" %)>/; + + /** + * Regular Expression to identify a javascript for the transformation of ehtml to html + * + * @property javaScriptRegExp + * @type String|RegExp + * @private + * @deprecated unused + */ + var javaScriptRegExp = /<(%=\s*javascript_include_tag)\s* (\"(.*)\" %)>/; + + /** + * Regular Expression to identify content for a view-element:
+ * either _header_, _footer_, _dialogs_ or _content_ + * + * @deprecated old template syntax format + * + * @property contentForRegExp + * @type String|RegExp + * @private + */ + var contentForRegExp = /<%\s*content_for\s*:([^\s]*)\s*do\s*%>(([\s|\n]*.*[\s|\n]*)*)<%\s*end\s*%>/i ; + + /** + * Regular Expression to identify if a partial should be rendered inside a view (ehtml-String) + * + * @deprecated old template syntax format + * + * @property renderPartialRegExp + * @type String|RegExp + * @private + */ + var renderPartialRegExp = /<%\s*render\s*([^\s]*)\s*\{\}\s*%>/i ; + + /** + * Regular Expression for matching a translation-tag for the localization of view content (ehtml-String) + * + * @deprecated old template syntax format + * + * @property translationRegExpString + * @type String|RegExp + * @private + */ + var translationRegExpString = '<%t\\s*:([^\\s]*)\\s*%>'; + +// /** +// * The Prefix for the names of view-files - currently unused and deprecated. +// * +// * @property viewsPrefix +// * @type String +// * @private +// * @deprecated has no further value +// */ +// var viewsPrefix = '#'; + + + /** + * See Property: {@link mobileDS.CommonUtils#setToCompatibilityMode-render_partial_regex}
+ * This regular expression is an extension for the parsing of the parameters of the partial (for customization) to get the name of the corresponding controller of the partial.
+ * + * Regular Expression to identify if a partial is to be inserted in a view.
+ * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * @deprecated old template syntax format + * + * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> + * @property partial_name_regex + * @type String|RegExp + * @public + */ + var partial_name_regex= /^([^\/]+)\/(.+)$/i; + compatibilitySelf.partial_name_regex = partial_name_regex; + + /** + * Regular expression for the parsing of partial-files.
+ * This expression detects all variables and data-instructions for the customization of the partial. There are 3 types of variables or instructions: + * + * + if-else-statement, controls which part of the partial will be displayed - depending on the condition + * + data-instruction, which is evaluated, but not displayed + * + variable or javascript-code, which are evaluated and displayed in the view + * + * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * @deprecated old template syntax format + * + * @example {::address = address + " " + {:curr_poi_data}.query('addressBean/housenumber')} + * @property partial_var_pattern_regex + * @type String|RegExp + * @public + */ + var partial_var_pattern_regex= /(\{[^\}\{]+\})|(\{[^\{]*(\{(?=[^\}]*\}).*)\})/gmi; + compatibilitySelf.partial_var_pattern_regex = partial_var_pattern_regex; + + /** + * Regular expression for the parsing of partial-files.
+ * This expression detects all simple variables for the customization of the partial in the form of {:curr_poi_data}.
+ * Form of simple object: {:SIMPLE_OBJECT}
+ * + * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * + * @deprecated old template syntax format + * + * @example {:curr_poi_data} + * @property partial_var_pattern_simpleobject_regex + * @type String|RegExp + * @public + */ + var partial_var_pattern_simpleobject_regex= /\{:([^\}]+)\}/; + compatibilitySelf.partial_var_pattern_simpleobject_regex = partial_var_pattern_simpleobject_regex; + + /** + * Regular expression for the parsing of partial-files.
+ * This expression detects all data objects for the customization of the partial in the form of {::curr_poi_data={:curr_poi_data_jpath}}.
+ * Form of data object: {::DATA_OBJECT}
+ * + * Partials are principally customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * + * @deprecated old template syntax format + * + * @example {::address = address + "<br/>"} + * @property partial_var_pattern_dataobject_regex + * @type String|RegExp + * @public + */ + var partial_var_pattern_dataobject_regex= /\{::([^\}\{]+)\}|\{::([^\{]*(?:\{(?:[^\}]*\}).*))\}/ig; + compatibilitySelf.partial_var_pattern_dataobject_regex = partial_var_pattern_dataobject_regex; + + /** + * Regular expression for detecting an assignment expression in templates, + * e.g. {::theVariable=... }. + * + * + * @deprecated old template syntax format + * + * @example {::address = address + "<br/>"} or {::address = {:anotherVariable} + "<br/>"} + * @property partial_var_pattern_assignment_regex + * @type String|RegExp + * @public + */ + var partial_var_pattern_assignment_regex= /\{::([^\}\{=]+)=([^\}\{]+)\}|\{::([^\}\{=]+)=([^\{]*(?:\{(?:[^\}]*\}).*))\}/ig; + compatibilitySelf.partial_var_pattern_assignment_regex = partial_var_pattern_assignment_regex; + +// /** +// * Deprecated regular expression for partials. +// * @property partial_var_pattern_object_with_function_regex +// * @type String|RegExp +// * @public +// * @deprecated unused +// */ +// var partial_var_pattern_object_with_function_regex = /\{?([^\.]+)([\.\[])([^\s\}]+)()/ig +// compatibilitySelf.partial_var_pattern_object_with_function_regex = partial_var_pattern_object_with_function_regex; + + /** + * Regular Expression to identify content in a view that will be inserted.
+ * The content is generated by a helper function of the controller and usually saved as a JSON-Object with a _helper_ and _content_ part.
+ * If the string is escaped and must be unescaped a second parameter can be given to ensure that the string will be unescaped before the insertion in the view. + * + * @deprecated old template syntax format + * + * @example <%= value_of(languageMenu::header, true) %> + * @property value_of_regex + * @type String|RegExp + * @public + */ + var value_of_regex= /<%=\s*value_of\s*\(([^\)]*)\)\s*%>/igm; + compatibilitySelf.value_of_regex = value_of_regex; + + /** + * See Property: {@link mobileDS.CommonUtils#setToCompatibilityMode-value_of_regex}
+ * This regular expression is an extension to parse the parameters of the value_of-function.
+ * + * Regular Expression to identify content in a view that will be inserted.
+ * The content is generated by a helper function of the controller and usually saved as a JSON-Object with a _helper_ and _content_ part.
+ * If the string is escaped and must be unescaped a second parameter can be given to ensure that the string will be unescaped before the insertion in the view. + * + * @deprecated old template syntax format + * + * @example <%= value_of(languageMenu::header, true) %> + * @property value_of_path_regex + * @type String|RegExp + * @public + */ + var value_of_path_regex= /\(\s*([^\),]*),?\s*([^\)]*)\s*\)/i; + compatibilitySelf.value_of_path_regex = value_of_path_regex; + + /** + * Regular Expression to identify if a partial is to be inserted in a view.
+ * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * @deprecated old template syntax format + * + * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> + * @property render_partial_regex + * @type String|RegExp + * @public + */ + var render_partial_regex= /<%\s*render\s*([^\s]*)\s*\{([^\}]*)\}\s*%>/igm; + compatibilitySelf.render_partial_regex = render_partial_regex; + + /** + * See Property: {@link mobileDS.CommonUtils#setToCompatibilityMode-render_partial_regex}
+ * This regular expression is an extension for the parsing of the parameters of the partial (for customization).
+ * + * Regular Expression to identify if a partial is to be inserted in a view.
+ * Partials are in principle customizable views, which can be used independently from a controller and furthermore accept parameters to customize the partial.
+ * A partial is first processed and then integrated into the view. + * + * @deprecated old template syntax format + * + * @example <% render googlemap/poi_details {:curr_poi_data_jpath => new JPath(mobileDS.ControllerManager.getInstance().getController("googlemap").script['current_poi_meta_data'])} %> + * @property partial_parameter_regex + * @type String|RegExp + * @public + */ + var partial_parameter_regex= /\s*:(\S*)\s*=>\s*(("([\S ]+)")|([^,]+))/i; + compatibilitySelf.partial_parameter_regex = partial_parameter_regex; + + /** + * Appends a log-message to the main document (index.html) and prints it in the console + * @function log + * @param {String} clazz A prefix for the output of the log message in the console + * @param {String} logMessage The log message which should be printed + * @public + * @deprecated + */ + var log = function(clazz,logMessage){ + this.debugNode = document.getElementById("log"); + if (this.debugNode) { + this.debugNode.innerHTML += "
\n" + logMessage + "\n
\n"; + } + console.log(clazz + ":" + logMessage); + }; + compatibilitySelf.log = log; + + /** + * Function which transforms a ehtml string (while parsing views) into html by replacing stylesheet-, javascript- and content_for-tags with corresponding contents. + * + * + * @deprecated used for parsing/rendering old template syntax format + * + * @function ehtml2Html + * @param {String} eHtmlTag A string that should be transformed from ehtml to html + * @public + * @returns {String} From ehtml into html transformed string + */ + var ehtml2Html= function(eHtmlTag){ + + var result; + if (eHtmlTag.match(styleSheetRegExp)) { + var group = eHtmlTag.match(styleSheetRegExp); + result = eHtmlTag.replace(group[1], "link rel=\"stylesheet\" ").replace(group[2], "href=\"content/stylesheets/" + group[3] + ".css\"/"); + }else if (eHtmlTag.match(javaScriptRegExp)) { + var group = eHtmlTag.match(javaScriptRegExp); + result = eHtmlTag.replace(group[1], "script type=\"text/javascript\" charset=\"utf-8\" ").replace(group[2], "src=\"" + group[3] + ".js\">' to header + // thus loading it dynamically + var newScript = document.createElement('script'); + newScript.type="text/javascript"; + newScript.src=scriptSrc; + document.head.appendChild(newScript); + }; + compatibilitySelf.appendJsSrcToHeader = appendJsSrcToHeader; + +// /** +// * Get the prefix for views. +// * @function getViewsPrefix +// * @public +// * @returns {String} The Prefix for the file names of views +// * @deprecated This function is unused and superfluous +// */ +// var compatibilitySelf.getViewsPrefix= function(){ +// return viewsPrefix; +// }; +// compatibilitySelf.getViewsPrefix = getViewsPrefix; + + /** + * Gets the Regular Expression for translation tags. + * @function getTranslationRegExp + * @public + * @returns {String} The regular expression for matching a translation-tag - used inside a ehtml-String + */ + var getTranslationRegExp= function(){ + return new RegExp(translationRegExpString, 'gi'); + }; + compatibilitySelf.getTranslationRegExp = getTranslationRegExp; + + /** + * Reformat the String representation of a date. + * + * @example converts 2012-07-23 16:37:33.0 into → 23. July 2012 + * + * @function get_date_as_string + * @param {String} the date String in format yyyy-mm-dd HH:mm:ss.S + * @param {String} [Optional] the language code (currently used to format the name of the month). Currently supported languages: en, de. If unkown or omitted, default en is used. + * @return {String} a new String representation for the date + * @public + */ + var get_date_as_string= function(date, languageCode){ + var self = this; + var day, month, year; + var date_time = date.split(" "); + var splited_date = date_time[0].split("-"); + year = splited_date[0]; + month = splited_date[1]; + + //add leading zero if necessary + if(month.length == 1){ + month = '0'+month; + } + day = splited_date[2]; + + var theLanguage = typeof languageCode === 'string'? languageCode.toLowerCase() : null; + var monthName; + if(theLanguage !== null && languageCode !== 'en' && self.months[theLanguage]){ + //get language specific name for month, if possible + monthName = self.months[theLanguage][month]; + } else { + //get default name for month + monthName = self.months[month]; + } + return day +". "+monthName+" "+year; + }; + compatibilitySelf.get_date_as_string = get_date_as_string; + + /** + * Convert a duration (in seconds) into a String representation. + * + * @example 2:09:19 h, 12:05 min + * + * @function get_duration_as_string + * @param {Integer} the duration in seconds + * @return {String} a String representation for the duration + * @public + */ + var get_duration_as_string= function (duration){ + var sec = duration % 60; + var min = (duration - sec) / 60; + + var hour = 0; + if(min > 59){ + min = min % 60; + hour = ((duration - (min*60))-sec) / 3600; + } + if(sec < 10 ){ + sec = "0"+sec; + } + if(min < 10){ + min = "0"+min; + } + + if(hour > 0){ + return hour+":"+min+":"+ sec + " h"; + } else { + return min+":"+sec + " min"; + } + + }; + compatibilitySelf.get_duration_as_string = get_duration_as_string; + + ////////////////////////////////////////////////////////////////////////////// + //comp: make renamed functions available under their old name again: + + compatibilitySelf.html_comment_regex = compatibilitySelf.regexHTMLComment; + compatibilitySelf.html_resize_font_to_fit_surrounding_box = compatibilitySelf.resizeFitToSourroundingBox; + compatibilitySelf.to_json_string_value = compatibilitySelf.toJSONStringValue; + compatibilitySelf.convert_to_json_value_HTML_string = compatibilitySelf.convertJSONStringValueToHTML; + compatibilitySelf.convert_json_to_HTML_string = compatibilitySelf.convertJSONStringToHTML; + compatibilitySelf.get_params_as_dict = compatibilitySelf.parseParamsToDictionary; + + }//END: setToCompatibilityMode + + + };//END: return {} + }//END: constructor() + + return { + /** + * Object containing the instance of the class {@link mobileDS.CommonUtils} + * + * @function getInstance + * @returns {Object} Object containing the instance of the class {@link mobileDS.CommonUtils} + * @public + */ + getInstance: function(){ + if (instance === null) { + instance = constructor(); + } + return instance; + } + }; + + +})(); diff --git a/assets/www/javascripts/tools/constants.js b/assets/www/mmirf/tools/constants.js similarity index 67% rename from assets/www/javascripts/tools/constants.js rename to assets/www/mmirf/tools/constants.js index e681342..2a90ebf 100644 --- a/assets/www/javascripts/tools/constants.js +++ b/assets/www/mmirf/tools/constants.js @@ -58,18 +58,23 @@ mobileDS.constants = (function() { var assetPath = "/../"; // Paths - var workerPath = "javascripts/workers/"; + var frameworkBasePath = "mmirf/"; + + var workerPath = frameworkBasePath + "workers/"; + var pluginsPath = frameworkBasePath + "plugins/"; + var extensionsPath = frameworkBasePath + "tools/extensions/"; + var beepURL = frameworkBasePath + "res/sounds/beep-notification.mp3"; var controllerPath = "controllers/"; var helperPath = "helpers/"; var languagePath = "config/languages/"; var modelPath = "models/"; var layoutPath = "views/layouts/"; var viewPath = "views/"; - var pluginsPath = "javascripts/plugins/"; - var speakerFilename = "speaker.json"; - var grammarFilename = "grammar.json"; - var dictionaryFilename = "dictionary.dic"; - var beepURL = "content/sounds/beep-alt.mp3"; + var genGrammarsPath = "gen/grammar/"; + var speakerFileName = "speaker.json"; + var grammarFileName = "grammar.json"; + var dictionaryFileName = "dictionary.dic"; + var mediaPluginPath = "mmirf/env/media/"; var configurationFileUrl = "config/configuration.json"; @@ -185,6 +190,33 @@ mobileDS.constants = (function() { getHelperPath: function(){ return basePath+helperPath; }, + /** + * Returns a string with the path to the extensions. + * @function getExtensionsPath + * @public + * @returns {String} extensions path + */ + getExtensionsPath: function(){ + return basePath + extensionsPath; + }, + /** + * Returns a string with the path to the Media-Plugins. + * @function getMediaPluginPath + * @public + * @returns {String} MediaPlugin path + */ + getMediaPluginPath: function(){ + return basePath + mediaPluginPath; + }, + /** + * Returns a string with the path to the directory that contains the generated/executable grammars. + * @function getGeneratedGrammarsPath + * @public + * @returns {String} path for generated grammars (JavaScript files) + */ + getGeneratedGrammarsPath: function(){ + return basePath + genGrammarsPath; + }, /** * Returns a string with the path to the configuration file. * @function getConfigurationFileUrl @@ -205,30 +237,30 @@ mobileDS.constants = (function() { }, /** * Returns the name of the dictionary filename as string - * @function getDictionaryFilename + * @function getDictionaryFileName * @public * @returns {String} dictionary filename */ - getDictionaryFilename: function(){ - return dictionaryFilename; + getDictionaryFileName: function(){ + return dictionaryFileName; }, /** * Returns the name of the speaker filename as string - * @function getDictionaryFilename + * @function getDictionaryFileName * @public * @returns {String} dictionary filename */ - getSpeakerFilename: function(){ - return speakerFilename; + getSpeakerFileName: function(){ + return speakerFileName; }, /** * Returns the name of the grammar filename as string - * @function grammarFilename + * @function grammarFileName * @public * @returns {String} grammar filename */ - getGrammarFilename: function(){ - return grammarFilename; + getGrammarFileName: function(){ + return grammarFileName; }, /** * Returns the prefix for partial filenames as string @@ -264,20 +296,42 @@ mobileDS.constants = (function() { /** * Object containing the instance of the class {@link mobileDS.constants} * - * @function getInstance - * @returns {Object} Object containing the instance of the class {@link mobileDS.CommonUtils} + * @function create + * @param {Boolean} forBrowserParameter true for browser-environment, if false ANDROID environment is assumed (TODO change type from boolean; support more environments!) + * @param {jQuery} [jQuery] the jQuery object (some functions may not work without this; see requires annotations) + * @returns {Object} Object containing the instance of the class {@link mobileDS.constants} * @public */ - getInstance: function(forBrowserParameter){ - if (instance === null) { - instance = constructor(forBrowserParameter); - } - if (forBrowserParameter && forBrowserParameter != isBrowserEnv){ - setBasePath(forBrowserParameter); - } + create: function(forBrowserParameter, jQuery){ +// if (instance === null) { + instance = constructor(forBrowserParameter, jQuery); + + //remove necessity for using getInstance + mobileDS.constants = instance; + + //replace functions so that after this function returns, + // create and getInstance will always just return the created instance: + var createImpl = function getInstanceDummy(theForBrowserParameter){ + if (theForBrowserParameter && theForBrowserParameter != isBrowserEnv){ + setBasePath(theForBrowserParameter); + } + return instance; + }; + mobileDS.constants.getInstance = createImpl; + mobileDS.constants.create = createImpl; +// } return instance; } + + /** + * @see create + * + * @function + */ + ,getInstance: function(forBrowserParameter, jQuery){ + return this.create(forBrowserParameter, jQuery); + } }; }()); \ No newline at end of file diff --git a/assets/www/mmirf/tools/dictionary.js b/assets/www/mmirf/tools/dictionary.js new file mode 100644 index 0000000..1808393 --- /dev/null +++ b/assets/www/mmirf/tools/dictionary.js @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * A dictionary (or map) for key-value storage and access. + * + * @class Dictionary + */ +function Dictionary(){ + + /** + * "map" for the dictionary + * + * @property map + * @private + */ + var map = {}; + + /** + * This list contains the "keys" of all current entries in map. + * + * @property keyList + * @private + */ + var keyList = []; + + /** + * Prefix for keys in internal MAP object, for avoiding overwrite of existing Object properties/functions + * + * @property KEY_PREFIX + * @static + * @private + */ + var KEY_PREFIX = '$$'; + + /** + * Helper function that creates the actual lookup key. + * + * The "lookup key" is original key with applied key-prefix. + * + * @function lookupKey + * @private + */ + var lookupKey = function(key){ + return KEY_PREFIX + key; + }; + + /** @lends Dictionary.prototype */ + return { + /** + * Put / add an entry to the dictionary. + * + * @function put + * + * @param {String} key the lookup key for the value + * @param {any} value the value to store + * + * @public + */ + put: function(key, value){ + + var isAlreadyPresent = this.containsKey(key); + + var lKey = lookupKey(key); + map[lKey] = value; + + if( ! isAlreadyPresent){ + keyList.push(lKey); + } + }, + /** + * Check if the dictionary contains an entry for a key. + * + * @function containsKey + * + * @param {String} key the lookup key to check + * @returns {Boolean} true if an entry exists, otherwise false + * + * @public + */ + containsKey: function(key){ + return typeof map[lookupKey(key)] !== 'undefined'; + }, + /** + * Check if the dictionary contains an entry with the value. + * + *

+ * NOTE that this function may execute rather slowly, with O(n). + * + * @function containsValue + * + * @param {any} value the value to check + * @param {Boolean} [useStrict] if true entry-values are + * checked against param value with ===. + * If false or omitted, values are compared with + * each other using ==. + * @returns {Boolean} true if an entry exists, otherwise false + * + * @public + */ + containsValue: function(value, useStrict){ + for(var i=0, size = keyList.length; i < size; ++i){ + if(useStrict){ + if(map[keyList[i]] === value){ + return true; + } + } + else { + if(map[keyList[i]] == value){ + return true; + } + } + } + return false; + }, + /** + * Get the value for a key. + * + * @function get + * + * @param {String} key the lookup key with was used to store the entry/value. + * @returns {any} the value for the key, or undefined if + * the dictionary has no entry for the key. + * + * @public + */ + get: function(key){ + return map[lookupKey(key)]; + }, + /** + * Remove an entry from the dictionary. + * + *

+ * NOTE that this may execute rather slowly, with O(n). + * + * @function remove + * + * @param {String} key the lookup key for the entry to remove + * @returns {Boolean} true if the entry was removed. + * If there was no entry for the key and nothing was removed, + * false is returned. + * + * @public + */ + remove: function(key){ + + if( this.containsKey(key) ){ + + var lKey = lookupKey(key); + + //remove from map: + delete map[lKey]; + + //remove from key-list + for(var i=0, size = keyList.length; i < size; ++i){ + if(keyList[i]==lKey){ + keyList.splice(i, 1); + break; + } + } + return true; + } + + return false; + }, + /** + * Get a list of the keys for all entries in the dictionary. + * + *

+ * The returned list has no specific ordering. + * + *

+ * NOTE that this may execute rather slowly, with O(n). + * + *

+ * NOTE that the returned list is no "view" for the keys, i.e. changes + * on this list will not be reflected by the dictionary's key-list. + * + * @returns {Array} a list of all keys + * + * @public + */ + getKeys: function(){ + var prefixLen = KEY_PREFIX.length; + var size = keyList.length; + var list = new Array(size); + //create copy of keyList with removed key-prefixes: + for(var i=0; i < size; ++i){ + list[i] = keyList[i].substring(prefixLen); + } + return list; + }, + /** + * Get the size of the dictionary. + * + * @function size + * @returns {Number} the count of entries in the dictionary + * @public + */ + size: function(){ + return keyList.length; + }, + /** + * Remove all entries from the dictionary. + * + *

+ * NOTE that this may execute rather slowly, with O(n). + * + * @function clear + * @public + */ + clear: function(){ +// var size = keyList.length; +// for(var i=0; i < size; ++i){ +// delete map[keyList[i]]; +// } +// keyList.splice(0, size); + delete map; + map = {}; + keyList.splice(0, keyList.length); + } + }; +}; \ No newline at end of file diff --git a/assets/www/javascripts/tools/ArrayExtensions.js b/assets/www/mmirf/tools/extensions/ArrayExtensions.js similarity index 100% rename from assets/www/javascripts/tools/ArrayExtensions.js rename to assets/www/mmirf/tools/extensions/ArrayExtensions.js diff --git a/assets/www/javascripts/tools/FunctionExtensions.js b/assets/www/mmirf/tools/extensions/FunctionExtensions.js similarity index 100% rename from assets/www/javascripts/tools/FunctionExtensions.js rename to assets/www/mmirf/tools/extensions/FunctionExtensions.js diff --git a/assets/www/mmirf/tools/extensions/SCIONExtension.js b/assets/www/mmirf/tools/extensions/SCIONExtension.js new file mode 100644 index 0000000..2872986 --- /dev/null +++ b/assets/www/mmirf/tools/extensions/SCIONExtension.js @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2012-2013 DFKI GmbH + * Deutsches Forschungszentrum fuer Kuenstliche Intelligenz + * German Research Center for Artificial Intelligence + * http://www.dfki.de + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +var mobileDS = window.mobileDS || +{}; + +/** + * + * + * This "class" is structured as a singleton - so that only one instance is in use.
+ * You can access the instance of the class via + * + * @class mobileDS.SCIONExtension + */ +mobileDS.SCIONExtension = (function(){ + var initializers = { + browser: function(){ + + return { + newSCIONExtension: function(scion, failureCallBack){ + var newWorker = new Worker(mobileDS.constants.getInstance().getWorkerPath()+'ScionQueueWorker.js'); + newWorker.onmessage= function(e){ + if (e.data.command == "toDo"){ + console.log('raising:'+ e.data.toDo.event); + var generatedState = scion.gen(e.data.toDo.event, e.data.toDo.eventData); + newWorker.postMessage({command: 'readyForJob'}); + }; + }; + return {gen: function (event, eventData){ + console.log('new Job:'+ event); + newWorker.postMessage( + {command: 'newJob', + job: {event: event, eventData: eventData} + }); + } + }; + } + }; + }, + android: function(){ + var callBackList = []; + function successCallBackHandler(args){ + if (args.length=2){ + callBackList[args[0]](args[1]); + } + } + return{ + newSCIONExtension: function(scion, failureCallBack){ + var id = callBackList.length; + callBackList.push(function(data){ + // console.log('raising:'+ data.event); + var generatedState = scion.gen(data.event, data.eventData); + plugins.queuePlugin.readyForJob(id, successCallBackHandler, failureCallBack); + }); + plugins.queuePlugin.newQueue(id, function(args){console.log('Queue '+id+' created.');},failureCallBack); + + return { + gen: function (event, eventData){ + // console.log('new Job:'+ event); + plugins.queuePlugin.newJob(id, {event: event, eventData: eventData}, successCallBackHandler,failureCallBack); + } + }; + } + }; + }, + fallBack: function(){ + return { + newSCIONExtension: function(scion, failureCallback){ + return { + gen: function (event, eventData){ + setTimeout(function(){ + scion.gen(event, eventData); + }, 0); + } + }; + } + }; + } + }; + var instance = null; + //those are the standard SCIONExtension procedures, that should be returned by the initialize function of a loaded file + + function constructor() { + var env = 'android'; + if (forBrowser) { + env = 'browser'; + } + try { + instance = initializers[env](); + } catch (e){ + console.log("Error loading SCIONExtension: "+e); + instance = initializers.fallBack(); + console.warn("Loaded default fallback for SCIONExtension"); + } + return instance; + /**return { + newSCIONExtension: function(interpreter, failureCallBack){ + failureCallBack('No SCIONExtension implementation loaded.'); + return { + gen: function(eventName, data){ + interpreter.gen(eventName, data); + } + }; + } + };**/ + }; + + + + return { + /** + * Object containing the instance of the class {{#crossLink "SCIONExtension"}}{{/crossLink}} + * + * @method getInstance + * @return {Object} Object containing the instance of the class {{#crossLink "CommonUtils"}}{{/crossLink}} + * @public + */ + getInstance: function(){ + if (instance === null) { + constructor(); + } + return instance; + }, + /** + * loads a file. If the file implements a function newSCIONExtension.initialize(f) + * where the function f is called with a set of functions e, then those functions in e + * are added to the visibility of SCIONExtension, and will from now on be applicable by calling + * SCIONExtension.getInstance.. + */ + loadFile: function(filePath,callBack){ + mobileDS.CommonUtils.getInstance().loadScript(filePath, function(){ + if (instance === null) { + instance = constructor(); + } + if (newSCIONExtension){ + newSCIONExtension.initialize(function(functions){ + jQuery.extend(true,instance,functions); + callBack(); + }); + } + }); + + } + }; +}) (); diff --git a/assets/www/javascripts/tools/StringExtensions.js b/assets/www/mmirf/tools/extensions/StringExtensions.js similarity index 85% rename from assets/www/javascripts/tools/StringExtensions.js rename to assets/www/mmirf/tools/extensions/StringExtensions.js index 4593966..5e962cc 100644 --- a/assets/www/javascripts/tools/StringExtensions.js +++ b/assets/www/mmirf/tools/extensions/StringExtensions.js @@ -64,6 +64,33 @@ String.prototype.startsWith = function (token, ignoreCase) { return isStarting; }; }//END: if( !String.prototype.startsWith +else { + + //if it already exists, then it is probably startsWith(str [, position]) + String.prototype.startsWithOrig = String.prototype.startsWith; + + //"map" startsWith(str,number) to startsWith(str,boolean): + String.prototype.startsWith = function (token, startIndex, ignoreCase) { + if(typeof ignoreCase === 'undefined' && typeof startIndex === 'boolean' || startIndex === 'true'){ + ignoreCase = startIndex; + startIndex = null; + } + var isIgnoreCase = typeof ignoreCase !== 'undefined' && ignoreCase == true; + + var str = this.toString(), other = token.toString(); + if(isIgnoreCase){ + str = str.toLowerCase(); + other = other.toLowerCase(); + } + + if(startIndex){ + return str.startsWithOrig(other, startIndex); + } + else { + return str.startsWithOrig(other); + } + }; +} @@ -106,7 +133,33 @@ String.prototype.endsWith = function (token, ignoreCase) { return isEnding; }; }//END: if( !String.prototype.endsWith - +else { + + //if it already exists, then it is probably endsWith(str [, position]) + String.prototype.endsWithOrig = String.prototype.endsWith; + + //"map" endsWith(str,number) to endsWith(str,boolean): + String.prototype.endsWith = function (token, startIndex, ignoreCase) { + if(typeof ignoreCase === 'undefined' && typeof startIndex === 'boolean' || startIndex === 'true'){ + ignoreCase = startIndex; + startIndex = null; + } + var isIgnoreCase = typeof ignoreCase !== 'undefined' && ignoreCase == true; + + var str = this.toString(), other = token.toString(); + if(isIgnoreCase){ + str = str.toLowerCase(); + other = other.toLowerCase(); + } + + if(startIndex){ + return str.endsWithOrig(other, startIndex); + } + else { + return str.endsWithOrig(other); + } + }; +} if( !String.prototype.replaceAll ){ /** diff --git a/assets/www/javascripts/tools/InitJSCC.js b/assets/www/mmirf/tools/initJSCC.js similarity index 100% rename from assets/www/javascripts/tools/InitJSCC.js rename to assets/www/mmirf/tools/initJSCC.js diff --git a/assets/www/javascripts/tools/logger.js b/assets/www/mmirf/tools/logger.js similarity index 100% rename from assets/www/javascripts/tools/logger.js rename to assets/www/mmirf/tools/logger.js diff --git a/assets/www/javascripts/tools/ant/AntTestGenerateBrowserParameter.js b/assets/www/mmirf/tools/test/AntTestGenerateBrowserParameter.js similarity index 100% rename from assets/www/javascripts/tools/ant/AntTestGenerateBrowserParameter.js rename to assets/www/mmirf/tools/test/AntTestGenerateBrowserParameter.js diff --git a/assets/www/javascripts/tools/ant/AntTestRunTestdriver.js b/assets/www/mmirf/tools/test/AntTestRunTestdriver.js similarity index 100% rename from assets/www/javascripts/tools/ant/AntTestRunTestdriver.js rename to assets/www/mmirf/tools/test/AntTestRunTestdriver.js diff --git a/assets/www/javascripts/workers/ScionQueueWorker.js b/assets/www/mmirf/workers/ScionQueueWorker.js similarity index 51% rename from assets/www/javascripts/workers/ScionQueueWorker.js rename to assets/www/mmirf/workers/ScionQueueWorker.js index 2b45a43..d0f54d7 100644 --- a/assets/www/javascripts/workers/ScionQueueWorker.js +++ b/assets/www/mmirf/workers/ScionQueueWorker.js @@ -24,10 +24,45 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/** + * This is a Worker script that is used as "threaded queue" for managing SCION event execution: + * + * New events for SCION are queued in order to allow raising new events from within SCION-event-processing. + * + *

+ * This "threaded queue" receives messages from {@link mobileDS.SCIONExtension}. + * + *

+ * The message / work flow is as follows: + *

    + *
  • on receiving newJob: add new event-job to the queue
  • + *
  • on receiving readyForJob: + *
  • if queue is empty: does nothing
  • + *
  • if queue is not empty: take next job from queue and send it as a toDo message to SCION
  • + * + *
+ * + * @see mobileDS.SCIONExtension + * + * @class ScionQueueWorker + * @namespace mobileDS.SCIONExtension + */ +/** + * @private + */ var queue = [], readyForJob = true; +/** + * Handler for received messages. + * + * @function onmessage + * @param {Object} e the message object with
+ * {String} e.data.command the message type / name (e.g. readyForJob)
+ * {Object} [e.data.job] the job object (e.g. in case of command newJob the job that will be queued) + * @public + */ self.onmessage = function(e){ switch(e.data.command){ case 'readyForJob': @@ -41,11 +76,24 @@ self.onmessage = function(e){ } }; +/** + * Handler for sending messages. + * + *

+ * In case of readyForJob: + * take next job and send it to SCION, i.e. post a message e with
+ * + * {String} e.data.command = toDo)
+ * {Object} e.data.toDo the job object (that was added before to the queue with command / message newJob) + * + * + * @function distributeJobs + * @private + */ function distributeJobs(){ if (readyForJob && queue.length>0){ readyForJob = false; - var job = queue.slice(0,1).pop(); - queue = queue.slice(1); + var job = queue.shift(); postMessage({command: 'toDo', toDo : job}); } diff --git a/assets/www/javascripts/mediators/recorderWorker.js b/assets/www/mmirf/workers/recorderWorker.js similarity index 87% rename from assets/www/javascripts/mediators/recorderWorker.js rename to assets/www/mmirf/workers/recorderWorker.js index 22ca843..2bd88be 100644 --- a/assets/www/javascripts/mediators/recorderWorker.js +++ b/assets/www/mmirf/workers/recorderWorker.js @@ -39,13 +39,13 @@ this.onmessage = function(e){ record(e.data.buffer); break; case 'exportWAV': - exportWAV(e.data.type, e.data.silenceBuffer,e.data.id); + exportWAV(e.data.type); break; case 'getBuffer': getBuffer(); break; case 'clear': - clear(e.data.silenceBuffer); + clear(); break; } }; @@ -60,22 +60,14 @@ function record(inputBuffer){ recLength += inputBuffer[0].length; } -function exportWAV(type,silenceBuffer,id){ - var bufferL = mergeBuffers(recBuffersL, recLength); +function exportWAV(type){ + var bufferL = mergeBuffers(recBuffersL, recLength); var bufferR = mergeBuffers(recBuffersR, recLength); var interleaved = interleave(bufferL, bufferR); - var dataview = encodeWAV(interleaved); - if (silenceBuffer>=0) { - clear(silenceBuffer); - } + var dataview = encodeWAV(interleaved); var audioBlob = new Blob([dataview], { type: type }); - this.postMessage( - { - blob: audioBlob, - id: id - } - ); + this.postMessage(audioBlob); } function getBuffer() { @@ -85,14 +77,10 @@ function getBuffer() { this.postMessage(buffers); } -function clear(silenceBuffer){ - if (!silenceBuffer || silenceBuffer<0 || silenceBuffer>recLength) { - silenceBuffer = 0; - } - recBuffersL = recBuffersL.slice(recLength-silenceBuffer); - recBuffersR = recBuffersR.slice(recLength-silenceBuffer); - recLength = silenceBuffer; - +function clear(){ + recLength = 0; + recBuffersL = []; + recBuffersR = []; } function mergeBuffers(recBuffers, recLength){ diff --git a/assets/www/models/calendarmodel.js b/assets/www/models/calendarModel.js similarity index 74% rename from assets/www/models/calendarmodel.js rename to assets/www/models/calendarModel.js index 4513032..bc42994 100644 --- a/assets/www/models/calendarmodel.js +++ b/assets/www/models/calendarModel.js @@ -29,7 +29,7 @@ var mobileDS = window.mobileDS || {}; mobileDS.CalendarModel = (function(){ - var instance; + var instance = null; function constructor(){ var calendar_server_url = 'http//...'; @@ -41,31 +41,38 @@ mobileDS.CalendarModel = (function(){ //via http-post-request to that server. var user_name = mobileDS.User.getInstance().getName(); - $.ajax({ + var options = { type: 'POST', - url: 'calendar_server_url?user_name=' + user_name, + url: 'calendar_server_url?user_name=' + user_name,// calendar_server_url + '?user_name=' + user_name data: data, - success: cb_func() - }); + success: cb_func + }; + +// $.ajax(options); //if you only want to test that you have successfully pass the - //process of adding new model-contrller-view comment out the - //whole - //ajax request and add just call the call back function as - //follow: - - //cb_func(); + // process of adding new model-controller-view comment out the + // whole AJAX request and add just call the call back function as + // follows: + + //MOCKing AJAX request: + console.info('MOCK AJAX request with options: '+JSON.stringify(options)); + if(cb_func){ + cb_func(); + } + //END: MOCKing AJAX request } - } + }; } return { getInstance: function(){ - if (!instance) { + if (instance === null) { instance = constructor(); } return instance; } - } + }; + })(); diff --git a/assets/www/testSemanticInterpreter.html b/assets/www/testSemanticInterpreter.html index b25b081..575e75f 100644 --- a/assets/www/testSemanticInterpreter.html +++ b/assets/www/testSemanticInterpreter.html @@ -31,25 +31,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - - - - - - - - -