Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. function getUserId() {
  4.     return {user_id: SG.core.user.id}
  5. }
  6.  
  7. function getStageId() {
  8.     return {stage_id: SG.tracker.current_stage_id}
  9. }
  10.  
  11. function getScores() {
  12.     return SG.tracker.score
  13. }
  14.  
  15. function addPointsToCriterion(criterion) {
  16.     console.log(addPointsToCriterion), SG.tracker.setCriterionValue(criterion)
  17. }
  18.  
  19. function getPreviousStages() {
  20.     return SG.tracker.stages
  21. }
  22.  
  23. function getPreviousPropositions() {
  24.     return SG.tracker.paths
  25. }
  26.  
  27. function getCharacters() {
  28.     return {player: SG.game.player.id, not_player: SG.game.not_player.id}
  29. }
  30.  
  31. function setWMWindow(url, userid, lang, conn_key, type) {
  32.     window.open(url + "/game/results.php?user=" + userid + "&lang=" + lang + "&key=" + conn_key, type)
  33. }
  34.  
  35. function goToStage(stage_id) {
  36.     console.log("GO TO STAGE from method in serious games communication api"), SG.game.event_controller.nextPhase(stage_id)
  37. }
  38.  
  39. function goToNextStep() {
  40.     goToNextPhase()
  41. }
  42.  
  43. function goToNextPhase() {
  44.     SG.game.event_controller.nextPhase()
  45. }
  46.  
  47. function addQuizzInfo(key, value) {
  48.     SG.player_prefs.setStringByKey(key, value)
  49. }
  50.  
  51. function enableCommunicationAPI(url) {
  52.     createEventListenerOnMessage()
  53. }
  54.  
  55. function disableCommunicationAPI() {
  56.     deleteEventListenerOnMessage()
  57. }
  58.  
  59. function createEventListenerOnMessage() {
  60.     $(window).on("message", listenToMessages)
  61. }
  62.  
  63. function deleteEventListenerOnMessage() {
  64.     $(window).unbind("message")
  65. }
  66.  
  67. function listenToMessages(e) {
  68.     checkOrigin(e) ? messageDecompiler(e.originalEvent.data, e.originalEvent.source) : alert("Error : not the same domain.")
  69. }
  70.  
  71. function checkOrigin(url) {
  72.     return !0
  73. }
  74.  
  75. function getRootUrl(url) {
  76.     var regex = /^(https?:\/\/)?([\da-z\.-]+)\.([\da-z\.]{2,6})/g, result = regex.exec(url);
  77.     return result[0]
  78. }
  79.  
  80. function parseMessage(message) {
  81.     var msg = {}, separator_index = message.indexOf("_");
  82.     if (separator_index == -1) return msg.instruction = message, msg;
  83.     msg.instruction = message.substring(0, separator_index), msg.args = [], msg.args[0] = message.substring(separator_index + 1);
  84.     var args = msg.args[0].split("-");
  85.     for (var i in args) msg.args[i] = args[i];
  86.     return msg
  87. }
  88.  
  89. function messageDecompiler(raw_message, source) {
  90.     var regex = /\[([a-z0-9\_,-]+)\]/g, message = regex.exec(raw_message);
  91.     if (null == message) return void alert("Error : the message is not valid");
  92.     switch (message = message[1], message = parseMessage(message), message.instruction) {
  93.         case"gts":
  94.             var target = message.args[0];
  95.             goToStage(target);
  96.             break;
  97.         case"apt":
  98.             var datas = message.args[0].split(","), criterion_id = parseInt(datas[0], 10), cval = [];
  99.             cval[0] = {level: "0", value: parseInt(datas[1], 10)};
  100.             var criterionResult = new SG.Model.CriterionResults({id: criterion_id, cval: cval});
  101.             addPointsToCriterion(criterionResult);
  102.             break;
  103.         case"setcriterion":
  104.             console.log("setcriterion", message);
  105.             var criterion_id = message.args[0], criterion_value = message.args[1];
  106.             addPointsToCriterion({id: criterion_id, value: criterion_value});
  107.             break;
  108.         case"getscore":
  109.             var score = getScores();
  110.             source.postMessage(score, "*");
  111.             break;
  112.         case"getlaststageid":
  113.             source.postMessage(SG.tracker.getLastStageId(), "*");
  114.             break;
  115.         case"gettracker":
  116.             source.postMessage(SG.tracker.toJsonString().toString(), "*");
  117.             break;
  118.         case"getplayerprefsint":
  119.             var key = message.args[0];
  120.             source.postMessage(SG.player_prefs.getIntByKey(key), "*");
  121.             break;
  122.         case"getplayerprefsfloat":
  123.             var key = message.args[0];
  124.             source.postMessage(SG.player_prefs.getFloatByKey(key), "*");
  125.             break;
  126.         case"getplayerprefsstring":
  127.             var key = message.args[0];
  128.             source.postMessage(SG.player_prefs.getStringByKey(key), "*");
  129.             break;
  130.         case"getplayerprefsbool":
  131.             var key = message.args[0];
  132.             source.postMessage(SG.player_prefs.getBooleanByKey(key), "*");
  133.             break;
  134.         case"setplayerprefsint":
  135.             var player_pref_key = message.args[0], player_pref_value = message.args[1];
  136.             SG.player_prefs.setIntByKey(player_pref_key, player_pref_value);
  137.             break;
  138.         case"setplayerprefsfloat":
  139.             var player_pref_key = message.args[0], player_pref_value = message.args[1];
  140.             SG.player_prefs.setFloatByKey(player_pref_key, player_pref_value);
  141.             break;
  142.         case"setplayerprefsstring":
  143.             var player_pref_key = message.args[0], player_pref_value = message.args[1];
  144.             SG.player_prefs.setStringByKey(player_pref_key, player_pref_value);
  145.             break;
  146.         case"addquizzinfo":
  147.             var player_pref_key = message.args[0], player_pref_value = message.args[1];
  148.             addQuizzInfo(player_pref_key, player_pref_value);
  149.             break;
  150.         case"setplayerprefsbool":
  151.             var player_pref_key = message.args[0], player_pref_value = message.args[1];
  152.             SG.player_prefs.setBooleanByKey(player_pref_key, player_pref_value);
  153.             break;
  154.         case"getuserid":
  155.             source.postMessage(getUserId(), "*");
  156.             break;
  157.         case"getstageid":
  158.             source.postMessage(getStageId(), "*");
  159.             break;
  160.         case"getpreviousstages":
  161.             source.postMessage(getPreviousStages(), "*");
  162.             break;
  163.         case"getpreviouspropositions":
  164.             source.postMessage(getPreviousPropositions(), "*");
  165.             break;
  166.         case"gotonextstep":
  167.             source.postMessage(goToNextStep(), "*");
  168.             break;
  169.         case"gotonextphase":
  170.             source.postMessage(goToNextPhase(), "*");
  171.             break;
  172.         case"getcharacters":
  173.             source.postMessage(getCharacters(), "*");
  174.             break;
  175.         default:
  176.             alert("Error : no function linked to this message.")
  177.     }
  178.     disableCommunicationAPI()
  179. }
  180.  
  181. var pipwerks = {};
  182. pipwerks.UTILS = {}, pipwerks.debug = {isActive: !1}, pipwerks.SCORM = {
  183.     version: null,
  184.     handleCompletionStatus: !0,
  185.     handleExitMode: !0,
  186.     API: {handle: null, isFound: !1},
  187.     connection: {isActive: !1},
  188.     data: {completionStatus: null, exitStatus: null},
  189.     debug: {}
  190. }, pipwerks.SCORM.isAvailable = function () {
  191.     return !0
  192. }, pipwerks.SCORM.API.find = function (win) {
  193.     for (var API = null, findAttempts = 0, findAttemptLimit = 500, traceMsgPrefix = "SCORM.API.find", trace = pipwerks.UTILS.trace, scorm = pipwerks.SCORM; !win.API && !win.API_1484_11 && win.parent && win.parent != win && findAttempts <= findAttemptLimit;) findAttempts++, win = win.parent;
  194.     if (scorm.version) switch (scorm.version) {
  195.         case"2004":
  196.             win.API_1484_11 ? API = win.API_1484_11 : trace(traceMsgPrefix + ": SCORM version 2004 was specified by user, but API_1484_11 cannot be found.");
  197.             break;
  198.         case"1.2":
  199.             win.API ? API = win.API : trace(traceMsgPrefix + ": SCORM version 1.2 was specified by user, but API cannot be found.")
  200.     } else win.API_1484_11 ? (scorm.version = "2004", API = win.API_1484_11) : win.API && (scorm.version = "1.2", API = win.API);
  201.     return API ? (trace(traceMsgPrefix + ": API found. Version: " + scorm.version), trace("API: " + API)) : trace(traceMsgPrefix + ": Error finding API. \nFind attempts: " + findAttempts + ". \nFind attempt limit: " + findAttemptLimit), API
  202. }, pipwerks.SCORM.API.get = function () {
  203.     var API = null, win = window, find = pipwerks.SCORM.API.find, trace = pipwerks.UTILS.trace;
  204.     return win.parent && win.parent != win && (API = find(win.parent)), !API && win.top.opener && (API = find(win.top.opener)), API ? pipwerks.SCORM.API.isFound = !0 : trace("API.get failed: Can't find the API!"), API
  205. }, pipwerks.SCORM.API.getHandle = function () {
  206.     var API = pipwerks.SCORM.API;
  207.     return API.handle || API.isFound || (API.handle = API.get()), API.handle
  208. }, pipwerks.SCORM.connection.initialize = function () {
  209.     var success = !1, scorm = pipwerks.SCORM, completionStatus = pipwerks.SCORM.data.completionStatus, trace = pipwerks.UTILS.trace,
  210.         makeBoolean = pipwerks.UTILS.StringToBoolean, debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.connection.initialize ";
  211.     if (trace("connection.initialize called."), scorm.connection.isActive) trace(traceMsgPrefix + "aborted: Connection already active."); else {
  212.         var API = scorm.API.getHandle(), errorCode = 0;
  213.         if (API) {
  214.             switch (scorm.version) {
  215.                 case"1.2":
  216.                     success = makeBoolean(API.LMSInitialize(""));
  217.                     break;
  218.                 case"2004":
  219.                     success = makeBoolean(API.Initialize(""))
  220.             }
  221.             if (success) if (errorCode = debug.getCode(), null !== errorCode && 0 === errorCode) {
  222.                 if (scorm.connection.isActive = !0, scorm.handleCompletionStatus && (completionStatus = pipwerks.SCORM.status("get"))) switch (completionStatus) {
  223.                     case"not attempted":
  224.                         pipwerks.SCORM.status("set", "incomplete");
  225.                         break;
  226.                     case"unknown":
  227.                         pipwerks.SCORM.status("set", "incomplete")
  228.                 }
  229.             } else success = !1, trace(traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode)); else errorCode = debug.getCode(), trace(null !== errorCode && 0 !== errorCode ? traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode) : traceMsgPrefix + "failed: No response from server.")
  230.         } else trace(traceMsgPrefix + "failed: API is null.")
  231.     }
  232.     return success
  233. }, pipwerks.SCORM.connection.terminate = function () {
  234.     var success = !1, scorm = pipwerks.SCORM, exitStatus = pipwerks.SCORM.data.exitStatus,
  235.         completionStatus = pipwerks.SCORM.data.completionStatus, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
  236.         debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.connection.terminate ";
  237.     if (scorm.connection.isActive) {
  238.         var API = scorm.API.getHandle(), errorCode = 0;
  239.         if (API) {
  240.             if (scorm.handleExitMode && !exitStatus) if ("completed" !== completionStatus && "passed" !== completionStatus) switch (scorm.version) {
  241.                 case"1.2":
  242.                     success = scorm.set("cmi.core.exit", "suspend");
  243.                     break;
  244.                 case"2004":
  245.                     success = scorm.set("cmi.exit", "suspend")
  246.             } else switch (scorm.version) {
  247.                 case"1.2":
  248.                     success = scorm.set("cmi.core.exit", "logout");
  249.                     break;
  250.                 case"2004":
  251.                     success = scorm.set("cmi.exit", "normal")
  252.             }
  253.             switch (scorm.version) {
  254.                 case"1.2":
  255.                     success = makeBoolean(API.LMSFinish(""));
  256.                     break;
  257.                 case"2004":
  258.                     success = makeBoolean(API.Terminate(""))
  259.             }
  260.             success ? scorm.connection.isActive = !1 : (errorCode = debug.getCode(), trace(traceMsgPrefix + "failed. \nError code: " + errorCode + " \nError info: " + debug.getInfo(errorCode)))
  261.         } else trace(traceMsgPrefix + "failed: API is null.")
  262.     } else trace(traceMsgPrefix + "aborted: Connection already terminated.");
  263.     return success
  264. }, pipwerks.SCORM.data.get = function (parameter) {
  265.     var value = null, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, debug = pipwerks.SCORM.debug,
  266.         traceMsgPrefix = "SCORM.data.get(" + parameter + ") ";
  267.     if (scorm.connection.isActive) {
  268.         var API = scorm.API.getHandle(), errorCode = 0;
  269.         if (API) {
  270.             switch (scorm.version) {
  271.                 case"1.2":
  272.                     value = API.LMSGetValue(parameter);
  273.                     break;
  274.                 case"2004":
  275.                     value = API.GetValue(parameter)
  276.             }
  277.             if (errorCode = debug.getCode(), "" !== value && 0 === errorCode) switch (parameter) {
  278.                 case"cmi.core.lesson_status":
  279.                 case"cmi.completion_status":
  280.                     scorm.data.completionStatus = value;
  281.                     break;
  282.                 case"cmi.core.exit":
  283.                 case"cmi.exit":
  284.                     scorm.data.exitStatus = value
  285.             } else trace(traceMsgPrefix + "failed. \nError code: " + errorCode + "\nError info: " + debug.getInfo(errorCode))
  286.         } else trace(traceMsgPrefix + "failed: API is null.")
  287.     } else trace(traceMsgPrefix + "failed: API connection is inactive.");
  288.     return trace(traceMsgPrefix + " value: " + value), String(value)
  289. }, pipwerks.SCORM.data.set = function (parameter, value) {
  290.     var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
  291.         debug = pipwerks.SCORM.debug, traceMsgPrefix = "SCORM.data.set(" + parameter + ") ";
  292.     if (scorm.connection.isActive) {
  293.         var API = scorm.API.getHandle(), errorCode = 0;
  294.         if (API) {
  295.             switch (scorm.version) {
  296.                 case"1.2":
  297.                     success = makeBoolean(API.LMSSetValue(parameter, value));
  298.                     break;
  299.                 case"2004":
  300.                     success = makeBoolean(API.SetValue(parameter, value))
  301.             }
  302.             success ? "cmi.core.lesson_status" !== parameter && "cmi.completion_status" !== parameter || (scorm.data.completionStatus = value) : trace(traceMsgPrefix + "failed. \nError code: " + errorCode + ". \nError info: " + debug.getInfo(errorCode))
  303.         } else trace(traceMsgPrefix + "failed: API is null.")
  304.     } else trace(traceMsgPrefix + "failed: API connection is inactive.");
  305.     return success
  306. }, pipwerks.SCORM.data.save = function () {
  307.     var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, makeBoolean = pipwerks.UTILS.StringToBoolean,
  308.         traceMsgPrefix = "SCORM.data.save failed";
  309.     if (scorm.connection.isActive) {
  310.         var API = scorm.API.getHandle();
  311.         if (API) switch (scorm.version) {
  312.             case"1.2":
  313.                 success = makeBoolean(API.LMSCommit(""));
  314.                 break;
  315.             case"2004":
  316.                 success = makeBoolean(API.Commit(""))
  317.         } else trace(traceMsgPrefix + ": API is null.")
  318.     } else trace(traceMsgPrefix + ": API connection is inactive.");
  319.     return success
  320. }, pipwerks.SCORM.status = function (action, status) {
  321.     var success = !1, scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, traceMsgPrefix = "SCORM.getStatus failed", cmi = "";
  322.     if (null !== action) {
  323.         switch (scorm.version) {
  324.             case"1.2":
  325.                 cmi = "cmi.core.lesson_status";
  326.                 break;
  327.             case"2004":
  328.                 cmi = "cmi.completion_status"
  329.         }
  330.         switch (action) {
  331.             case"get":
  332.                 success = pipwerks.SCORM.data.get(cmi);
  333.                 break;
  334.             case"set":
  335.                 null !== status ? success = pipwerks.SCORM.data.set(cmi, status) : (success = !1, trace(traceMsgPrefix + ": status was not specified."));
  336.                 break;
  337.             default:
  338.                 success = !1, trace(traceMsgPrefix + ": no valid action was specified.")
  339.         }
  340.     } else trace(traceMsgPrefix + ": action was not specified.");
  341.     return success
  342. }, pipwerks.SCORM.debug.getCode = function () {
  343.     var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, code = 0;
  344.     if (API) switch (scorm.version) {
  345.         case"1.2":
  346.             code = parseInt(API.LMSGetLastError(), 10);
  347.             break;
  348.         case"2004":
  349.             code = parseInt(API.GetLastError(), 10)
  350.     } else trace("SCORM.debug.getCode failed: API is null.");
  351.     return code
  352. }, pipwerks.SCORM.debug.getInfo = function (errorCode) {
  353.     var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, result = "";
  354.     if (API) switch (scorm.version) {
  355.         case"1.2":
  356.             result = API.LMSGetErrorString(errorCode.toString());
  357.             break;
  358.         case"2004":
  359.             result = API.GetErrorString(errorCode.toString())
  360.     } else trace("SCORM.debug.getInfo failed: API is null.");
  361.     return String(result)
  362. }, pipwerks.SCORM.debug.getDiagnosticInfo = function (errorCode) {
  363.     var API = pipwerks.SCORM.API.getHandle(), scorm = pipwerks.SCORM, trace = pipwerks.UTILS.trace, result = "";
  364.     if (API) switch (scorm.version) {
  365.         case"1.2":
  366.             result = API.LMSGetDiagnostic(errorCode);
  367.             break;
  368.         case"2004":
  369.             result = API.GetDiagnostic(errorCode)
  370.     } else trace("SCORM.debug.getDiagnosticInfo failed: API is null.");
  371.     return String(result)
  372. }, pipwerks.SCORM.init = pipwerks.SCORM.connection.initialize, pipwerks.SCORM.get = pipwerks.SCORM.data.get, pipwerks.SCORM.set = pipwerks.SCORM.data.set, pipwerks.SCORM.save = pipwerks.SCORM.data.save, pipwerks.SCORM.quit = pipwerks.SCORM.connection.terminate, pipwerks.UTILS.StringToBoolean = function (string) {
  373.     switch (string.toLowerCase()) {
  374.         case"true":
  375.         case"yes":
  376.         case"1":
  377.             return !0;
  378.         case"false":
  379.         case"no":
  380.         case"0":
  381.         case null:
  382.             return !1;
  383.         default:
  384.             return Boolean(string)
  385.     }
  386. }, pipwerks.UTILS.trace = function (msg) {
  387.     if (pipwerks.debug.isActive) if (window.console && window.console.firebug) console.log(msg); else {
  388.         var myTextField = document.getElementById("jsDebug");
  389.         myTextField.innerHTML += "<br/>" + msg
  390.     }
  391. };
  392. var SG = SG || {
  393.     Model: {},
  394.     Game: {},
  395.     Utils: {},
  396.     core: null,
  397.     game: null,
  398.     tracker: null,
  399.     phase_manager: null,
  400.     player_prefs: null,
  401.     scorm: null
  402. };
  403. SG.Model.GlobalScenario = function (datas) {
  404.     var _this = this;
  405.     if (this._global_scenario_json = datas.globalscenario || {}, this._sceneries_json = datas.sceneries || {}, this._criterions_json = datas.criterions || {}, this._id = this._global_scenario_json.id || 0, this._auth = this._global_scenario_json.auth || !1, this._show_in_sg = this._global_scenario_json.show_in_sg || !1, this._subtitle = this._global_scenario_json.subtitle || !0, this._show_criterion_panel = this._global_scenario_json.show_criterion_panel || !1, this._names = {}, this._conceptor_names = [], this._specific_stettings = [], this._sceneries = {}, this._criterions = {}, datas.globalscenario.corner_logo ? this._corner_logo = SG.core._medias_url + "/" + datas.globalscenario.corner_logo : this._corner_logo = !1, this._global_scenario_json.lang && this._global_scenario_json.lang.forEach(function (lang) {
  406.             _this._names[lang.value] = lang.name, _this._conceptor_names[lang.value] = lang.credit
  407.         }), this._criterions_json && this._criterions_json.forEach(function (criterion) {
  408.             _this._criterions[criterion.id] = new SG.Model.Criterion(criterion)
  409.         }), this._sceneries_json) for (var scenery_id in this._sceneries_json) _this._sceneries[scenery_id] = new SG.Model.Scenery(this._sceneries_json[scenery_id][0]);
  410.     if (this._global_scenario_json.phases) {
  411.         var phase_to_set = {};
  412.         this._global_scenario_json.phases.forEach(function (phase) {
  413.             phase.Scenario ? (phase_to_set = new SG.Model.Scenario(phase.Scenario), phase_to_set.name = "Scenario", SG.phase_manager.addPhase(phase_to_set)) : phase.BobSpeech || phase.Context ? (phase_to_set = new SG.Model.BobSpeech(phase.BobSpeech ? phase.BobSpeech : phase.Context), phase_to_set.name = "BobSpeech", SG.phase_manager.addPhase(phase_to_set)) : phase.WebPhase ? (phase_to_set = new SG.Model.WebPhase(phase.WebPhase), phase_to_set.name = "WebPhase", SG.phase_manager.addPhase(phase_to_set)) : phase.KinematicPhase ? (phase_to_set = new SG.Model.KinematicPhase(phase.KinematicPhase), phase_to_set.name = "KinematicPhase", SG.phase_manager.addPhase(phase_to_set)) : phase.Quizz ? (phase_to_set = new SG.Model.Quizz(phase.Quizz), phase_to_set.name = "Quizz", SG.phase_manager.addPhase(phase_to_set)) : phase.EndGame && (phase_to_set = new SG.Model.EndGame(phase.EndGame), phase_to_set.name = "EndGame", SG.phase_manager.addPhase(phase_to_set))
  414.         })
  415.     }
  416. }, SG.Model.GlobalScenario.prototype = {
  417.     getNameByLanguage: function (lang) {
  418.         return this.names[lang] ? this.names[lang] : this.names.French
  419.     }, getSceneryById: function (id) {
  420.         var scenery_to_return = null;
  421.         return this.sceneries.forEach(function (scenery) {
  422.             scenery.id == id && (scenery_to_return = scenery)
  423.         }), scenery_to_return
  424.     }
  425. }, Object.defineProperties(SG.Model.GlobalScenario.prototype, {
  426.     id: {
  427.         get: function () {
  428.             return this._id
  429.         }, set: function (id) {
  430.             this._id = id
  431.         }
  432.     }, auth: {
  433.         get: function () {
  434.             return this._auth
  435.         }, set: function (auth) {
  436.             this._id = auth
  437.         }
  438.     }, show_in_sg: {
  439.         get: function () {
  440.             return this._show_in_sg
  441.         }, set: function (show_in_sg) {
  442.             this._show_in_sg = show_in_sg
  443.         }
  444.     }, show_criterion_panel: {
  445.         get: function () {
  446.             return this._show_criterion_panel
  447.         }, set: function (isDisplayed) {
  448.             this._show_criterion_panel = isDisplayed
  449.         }
  450.     }, subtitle: {
  451.         get: function () {
  452.             return this._subtitle
  453.         }, set: function (subtitle) {
  454.             this._subtitle = subtitle
  455.         }
  456.     }, names: {
  457.         get: function () {
  458.             return this._names
  459.         }, set: function (names) {
  460.             this._names = names
  461.         }
  462.     }, conceptor_names: {
  463.         get: function () {
  464.             return this._conceptor_names
  465.         }, set: function (conceptor_names) {
  466.             this._conceptor_names = conceptor_names
  467.         }
  468.     }, specific_settings: {
  469.         get: function () {
  470.             return this._specific_stettings
  471.         }, set: function (specific_stettings) {
  472.             this._specific_stettings = specific_stettings
  473.         }
  474.     }, sceneries: {
  475.         get: function () {
  476.             return this._sceneries
  477.         }, set: function (sceneries) {
  478.             this._sceneries = sceneries
  479.         }
  480.     }, criterions: {
  481.         get: function () {
  482.             return this._criterions
  483.         }, set: function (criterions) {
  484.             this._criterions = criterions
  485.         }
  486.     }, corner_logo: {
  487.         get: function () {
  488.             return this._corner_logo
  489.         }, set: function (value) {
  490.             this._corner_logo = value
  491.         }
  492.     }
  493. }), SG.Model.User = function (id, key, customer_id, access) {
  494.     this._id = id || 0, this._key = key || "", this._customer_id = customer_id || 0, this._access = access || []
  495. }, Object.defineProperties(SG.Model.User.prototype, {
  496.     id: {
  497.         get: function () {
  498.             return this._id
  499.         }, set: function (id) {
  500.             this._id = id
  501.         }
  502.     }, key: {
  503.         get: function () {
  504.             return this._key
  505.         }, set: function (key) {
  506.             this._key = key
  507.         }
  508.     }, customer_id: {
  509.         get: function () {
  510.             return this._customer_id
  511.         }, set: function (customer_id) {
  512.             this._customer_id = customer_id
  513.         }
  514.     }, access: {
  515.         get: function () {
  516.             return this._access
  517.         }, set: function (access) {
  518.             this._access = access
  519.         }
  520.     }
  521. }), SG.Model.Character = function (character, scenario_id) {
  522.     var _this = this;
  523.     this._id = character.id || 0, this._descriptions = [], this._names = [], this._names_to_display = [], this._playables = [], this._not_playables = [], this.cloth_ids = [], this._moves = [], character.lang.forEach(function (lang) {
  524.         _this._names[lang.value] = lang.name, _this._descriptions[lang.value] = lang.description, lang.name_to_display.forEach(function (name) {
  525.             _this._names_to_display[lang.value] = name.value
  526.         }), lang.playable.forEach(function (playable) {
  527.             _this._playables[lang.value] = playable
  528.         }), lang.npcs.forEach(function (not_playable) {
  529.             _this._not_playables[lang.value] = not_playable.scenario_binomial[0]
  530.         })
  531.     })
  532. }, SG.Model.Character.prototype = {
  533.     getMoveByReference: function (reference) {
  534.         var moveToReturn = null;
  535.         return this._moves.forEach(function (move) {
  536.             move.reference == reference && (moveToReturn = move)
  537.         }), moveToReturn
  538.     }, getMovesByAttitudeId: function (attitude_id, active) {
  539.         var moves_to_return = [], type = active ? "active" : "passive";
  540.         return this._moves.forEach(function (move) {
  541.             move.attitude_id == attitude_id && move.type == type && moves_to_return.push(move)
  542.         }), moves_to_return
  543.     }
  544. }, Object.defineProperties(SG.Model.Character.prototype, {
  545.     id: {
  546.         get: function () {
  547.             return this._id
  548.         }
  549.     }, descriptions: {
  550.         get: function () {
  551.             return this._descriptions
  552.         }
  553.     }, names: {
  554.         get: function () {
  555.             return this._names
  556.         }
  557.     }, names_to_display: {
  558.         get: function () {
  559.             return this._names_to_display
  560.         }, set: function (name) {
  561.             this._names_to_display = name
  562.         }
  563.     }, playables: {
  564.         get: function () {
  565.             return this._playables
  566.         }
  567.     }, not_playables: {
  568.         get: function () {
  569.             return this._not_playables
  570.         }
  571.     }, moves: {
  572.         get: function () {
  573.             return this._moves
  574.         }, set: function (moves) {
  575.             this._moves = moves
  576.         }
  577.     }
  578. }), SG.Model.Phase = function (phase) {
  579.     this._id = phase.id || 0, this._order = phase.order || 0, this._name = phase.name, this._is_loaded = !1
  580. }, SG.Model.Phase.prototype = {
  581.     loadAssets: function (callback) {
  582.         this.is_loaded = !0, callback()
  583.     }
  584. }, Object.defineProperties(SG.Model.Phase.prototype, {
  585.     id: {
  586.         get: function () {
  587.             return this._id
  588.         }, set: function (id) {
  589.             this._id = id
  590.         }
  591.     }, order: {
  592.         get: function () {
  593.             return this._order
  594.         }, set: function (order) {
  595.             this._order = order
  596.         }
  597.     }, name: {
  598.         get: function () {
  599.             return this._name
  600.         }, set: function (name) {
  601.             this._name = name
  602.         }
  603.     }, is_loaded: {
  604.         get: function () {
  605.             return this._is_loaded
  606.         }, set: function (is_loaded) {
  607.             this._is_loaded = is_loaded
  608.         }
  609.     }
  610. }), SG.Model.KinematicPhase = function (kinematic) {
  611.     if (SG.Model.Phase.call(this, kinematic), this._image, this._urlMP4, console.log(kinematic), "video" == kinematic.mediatype) {
  612.         var urlBase = SG.core.base_url + "/", urlSpecific = kinematic.url.substring(0, kinematic.url.lastIndexOf(".")),
  613.             url = urlBase.concat(urlSpecific);
  614.         this._urlMP4 = url.concat(".mp4")
  615.     } else {
  616.         var urlBase = SG.core.base_url + "/", url = urlBase.concat(kinematic.url);
  617.         this._image = url
  618.     }
  619. }, SG.Model.KinematicPhase.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.KinematicPhase.prototype.constructor = SG.Model.KinematicPhase, Object.defineProperties(SG.Model.KinematicPhase.prototype, {
  620.     urlMP4: {
  621.         get: function () {
  622.             return this._urlMP4
  623.         }, set: function (url) {
  624.             this._urlMP4 = url
  625.         }
  626.     }, image: {
  627.         get: function () {
  628.             return this._image
  629.         }, set: function (url) {
  630.             this._image = url
  631.         }
  632.     }
  633. }), SG.Model.Scenario = function (scenario) {
  634.     var _this = this;
  635.     SG.Model.Phase.call(this, scenario), this._first_stage = scenario.firststage || 0, params.stage_to_test > 0 && (this._first_stage = params.stage_to_test), this._dialog_theme = scenario.dialogTheme || null, this._bob_url = scenario.bobUrl || "", this._scopes = [], this._names = [], this._backgrounds = [], this._stages = [], this._acts = [], scenario.bg && scenario.bg.forEach(function (background) {
  636.         _this._backgrounds.push(new SG.Model.Background(background))
  637.     }), scenario.stages && scenario.stages.forEach(function (stage) {
  638.         _this._stages.push(new SG.Model.Stage(stage))
  639.     }), scenario.acts && scenario.acts.forEach(function (act) {
  640.         _this._acts.push(new SG.Model.Act(act))
  641.     }), scenario.lang && scenario.lang.forEach(function (lang) {
  642.         _this._names[lang.value] = lang.name, _this._scopes[lang.value] = lang.scope
  643.     })
  644. }, SG.Model.Scenario.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.Scenario.prototype.constructor = SG.Model.Scenario, SG.Model.Scenario.prototype.loadAssets = function (callback) {
  645.     this.is_loaded = !0, callback()
  646. }, SG.Model.Scenario.prototype.getStageById = function (id) {
  647.     var stageToReturn = null;
  648.     return this.stages.forEach(function (stage) {
  649.         stage.id == id && (stageToReturn = stage)
  650.     }), stageToReturn
  651. }, SG.Model.Scenario.prototype.getActById = function (id) {
  652.     var actToReturn = null;
  653.     return this.acts.forEach(function (act) {
  654.         act.id == id && (actToReturn = act)
  655.     }), actToReturn
  656. }, Object.defineProperties(SG.Model.Scenario.prototype, {
  657.     first_stage: {
  658.         get: function () {
  659.             return this._first_stage
  660.         }, set: function (first_stage) {
  661.             this._first_stage = first_stage
  662.         }
  663.     }, dialog_theme: {
  664.         get: function () {
  665.             return this._dialog_theme
  666.         }
  667.     }, bob_url: {
  668.         get: function () {
  669.             return this._bob_url
  670.         }
  671.     }, scopes: {
  672.         get: function () {
  673.             return this._scopes
  674.         }
  675.     }, names: {
  676.         get: function () {
  677.             return this._scopes
  678.         }
  679.     }, backgrounds: {
  680.         get: function () {
  681.             return this._backgrounds
  682.         }, set: function (backgrounds) {
  683.             this._backgrounds = backgrounds
  684.         }
  685.     }, stages: {
  686.         get: function () {
  687.             return this._stages
  688.         }
  689.     }, acts: {
  690.         get: function () {
  691.             return this._acts
  692.         }
  693.     }
  694. }), SG.Model.BobSpeech = function (bobspeech) {
  695.     SG.Model.Phase.call(this, bobspeech);
  696.     var _this = this;
  697.     this._speech_path = {}, this._text = {}, this._picture = bobspeech.picture, this._sound, this._type = bobspeech.type, bobspeech.speechpath.forEach(function (speech_path) {
  698.         _this._speech_path[speech_path.lang] = speech_path.path
  699.     }), bobspeech.text.forEach(function (text) {
  700.         _this._text[text.lang] = {}, _this._text[text.lang].value = text.value, _this._text[text.lang].display = text.display, _this._text[text.lang].user_sens = text.user_sens
  701.     })
  702. }, SG.Model.BobSpeech.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.BobSpeech.prototype.constructor = SG.Model.BobSpeech, SG.Model.BobSpeech.prototype.loadAssets = function (callback) {
  703.     var audio, url, _this = this;
  704.     this.speech_path[SG.core.lang] ? (url = SG.core.medias_url + "" + this.speech_path[SG.core.lang], audio = new Audio, audio.src = url, audio.load(), audio.addEventListener("canplaythrough", function () {
  705.         _this.is_loaded = !0, callback()
  706.     }, !1), this.sound = audio) : callback()
  707. }, Object.defineProperties(SG.Model.BobSpeech.prototype, {
  708.     speech_path: {
  709.         get: function () {
  710.             return this._speech_path
  711.         }, set: function (value) {
  712.             this._speech_path = value
  713.         }
  714.     }, text: {
  715.         get: function () {
  716.             return this._text
  717.         }, set: function (value) {
  718.             this._text = value
  719.         }
  720.     }, picture: {
  721.         get: function () {
  722.             return this._picture
  723.         }, set: function (value) {
  724.             this._picture = value
  725.         }
  726.     }, sound: {
  727.         get: function () {
  728.             return this._sound
  729.         }, set: function (value) {
  730.             this._sound = value
  731.         }
  732.     }, type: {
  733.         get: function () {
  734.             return this._type
  735.         }, set: function (value) {
  736.             this._type = value
  737.         }
  738.     }
  739. }), SG.Model.WebPhase = function (web_phase) {
  740.     SG.Model.Phase.call(this, web_phase), this._label = web_phase.label, this._close_visible = web_phase.close_visible, this._fullscreen = web_phase.fullscreen, this._gamesettings = web_phase.gamesettings, this._height = web_phase.height, this._width = web_phase.width, this._horizontal_align = web_phase.horizontal_align, this._vertical_align = web_phase.vertical_align, this._offset_package = web_phase.offset_package, this._pause_game = web_phase.pause_game, this._position = web_phase.position, this._type = web_phase.type, this._url = web_phase.url, this._url_valid = web_phase.url_valid, this._iframe = {}, this.position_enum = {
  741.         0: "left",
  742.         1: "center",
  743.         2: "right"
  744.     }, this.type_enum = {0: "web", 1: "", 2: "zip", 3: ""}, this.loadAssets()
  745. }, SG.Model.WebPhase.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.WebPhase.prototype.constructor = SG.Model.WebPhase, SG.Model.WebPhase.prototype.loadAssets = function (callback) {
  746. }, Object.defineProperties(SG.Model.WebPhase.prototype, {
  747.     label: {
  748.         get: function () {
  749.             return this._label
  750.         }, set: function (label) {
  751.             this._label = label
  752.         }
  753.     }, close_visible: {
  754.         get: function () {
  755.             return this._close_visible
  756.         }, set: function (close_visible) {
  757.             this._close_visible = close_visible
  758.         }
  759.     }, fullscreen: {
  760.         get: function () {
  761.             return this._fullscreen
  762.         }, set: function (fullscreen) {
  763.             this._fullscreen = fullscreen
  764.         }
  765.     }, gamesettings: {
  766.         get: function () {
  767.             return this._gamesettings
  768.         }, set: function (gamesettings) {
  769.             this._gamesettings = gamesettings
  770.         }
  771.     }, height: {
  772.         get: function () {
  773.             return this._height
  774.         }, set: function (height) {
  775.             this._heightl = height
  776.         }
  777.     }, width: {
  778.         get: function () {
  779.             return this._width
  780.         }, set: function (width) {
  781.             this._width = width
  782.         }
  783.     }, horizontal_align: {
  784.         get: function () {
  785.             return this._horizontal_align
  786.         }, set: function (horizontal_align) {
  787.             this._horizontal_align = horizontal_align
  788.         }
  789.     }, vertical_align: {
  790.         get: function () {
  791.             return this._vertical_align
  792.         }, set: function (vertical_align) {
  793.             this._vertical_align = vertical_align
  794.         }
  795.     }, offset_package: {
  796.         get: function () {
  797.             return this._offset_package
  798.         }, set: function (offset_package) {
  799.             this._offset_package = offset_package
  800.         }
  801.     }, pause_game: {
  802.         get: function () {
  803.             return this._pause_game
  804.         }, set: function (pause_game) {
  805.             this._pause_game = pause_game
  806.         }
  807.     }, position: {
  808.         get: function () {
  809.             return this._position
  810.         }, set: function (position) {
  811.             this._position = position
  812.         }
  813.     }, type: {
  814.         get: function () {
  815.             return this._type
  816.         }, set: function (type) {
  817.             this._type = type
  818.         }
  819.     }, url: {
  820.         get: function () {
  821.             return this._url
  822.         }, set: function (url) {
  823.             this._url = url
  824.         }
  825.     }, url_valid: {
  826.         get: function () {
  827.             return this._url_valid
  828.         }, set: function (url_valid) {
  829.             this._url_valid = url_valid
  830.         }
  831.     }, iframe: {
  832.         get: function () {
  833.             return this._iframe
  834.         }, set: function (iframe) {
  835.             this._iframe = iframe
  836.         }
  837.     }
  838. }), SG.Model.Quizz = function (quizz) {
  839.     SG.Model.Phase.call(this, quizz);
  840.     this._free = quizz.free_movement, this._correction = quizz.show_correction, this._quizzname = quizz.name, this._questions = {};
  841.     for (var i in quizz.questions) this._questions[i] = new SG.Model.Question(quizz.questions[i]);
  842.     this._index = 0
  843. }, SG.Model.Quizz.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.Quizz.prototype.constructor = SG.Model.Quizz, Object.defineProperties(SG.Model.Quizz.prototype, {
  844.     free: {
  845.         get: function () {
  846.             return this._free
  847.         }
  848.     }, correction: {
  849.         get: function () {
  850.             return this._correction
  851.         }
  852.     }, quizzname: {
  853.         get: function () {
  854.             return this._quizzname
  855.         }
  856.     }, questions: {
  857.         get: function () {
  858.             return this._questions
  859.         }
  860.     }, index: {
  861.         get: function () {
  862.             return this._index
  863.         }, set: function () {
  864.             this._index = value
  865.         }
  866.     }
  867. }), SG.Model.Question = function (question) {
  868.     var _this = this;
  869.     this._type = question.type, this._text = question.label, this._right_criterions = [], this._wrong_criterions = [], this._answers = {};
  870.     for (var i in question.answers) this._answers[i] = new SG.Model.Answer(question.answers[i]);
  871.     for (var i in question.right_criterions) {
  872.         var criterion_data = _this._getCriterionData(question.right_criterions[i]);
  873.         this._right_criterions.push(new SG.Model.CriterionResults(criterion_data))
  874.     }
  875.     for (var i in question.wrong_criterions) {
  876.         var criterion_data = _this._getCriterionData(question.wrong_criterions[i]);
  877.         this._wrong_criterions.push(new SG.Model.CriterionResults(criterion_data))
  878.     }
  879. }, SG.Model.Question.prototype._getCriterionData = function (criterion) {
  880.     var criterion_data = {id: criterion.criterion_id, name: criterion.name, cval: [{level: 0, value: criterion.points}]};
  881.     return criterion_data
  882. }, Object.defineProperties(SG.Model.Question.prototype, {
  883.     type: {
  884.         get: function () {
  885.             return this._type
  886.         }
  887.     }, text: {
  888.         get: function () {
  889.             return this._text
  890.         }
  891.     }, answers: {
  892.         get: function () {
  893.             return this._answers
  894.         }
  895.     }, right_criterions: {
  896.         get: function () {
  897.             return this._right_criterions
  898.         }
  899.     }, wrong_criterions: {
  900.         get: function () {
  901.             return this._wrong_criterions
  902.         }
  903.     }
  904. }), SG.Model.Answer = function (answer) {
  905.     this._correct = answer.is_correct, this._text = answer.label, this._id = answer.id, this._user_check = !1, this._user_value = ""
  906. }, Object.defineProperties(SG.Model.Answer.prototype, {
  907.     correct: {
  908.         get: function () {
  909.             return this._correct
  910.         }
  911.     }, text: {
  912.         get: function () {
  913.             return this._text
  914.         }
  915.     }, id: {
  916.         get: function () {
  917.             return this._id
  918.         }
  919.     }, user_check: {
  920.         get: function () {
  921.             return this._user_check
  922.         }, set: function (value) {
  923.             this._user_check = value
  924.         }
  925.     }, user_value: {
  926.         get: function () {
  927.             return this._user_value
  928.         }, set: function (value) {
  929.             this._user_value = value
  930.         }
  931.     }
  932. }), SG.Model.EndGame = function (endgame) {
  933.     SG.Model.Phase.call(this, endgame), this._param = endgame.param || "", this._custom_message = endgame.custom_message || ""
  934. }, SG.Model.EndGame.prototype = Object.create(SG.Model.Phase.prototype), SG.Model.EndGame.prototype.constructor = SG.Model.EndGame, Object.defineProperties(SG.Model.EndGame.prototype, {
  935.     param: {
  936.         get: function () {
  937.             return this._param
  938.         }, set: function (param) {
  939.             this._param = param
  940.         }
  941.     }, custom_message: {
  942.         get: function () {
  943.             return this._custom_message
  944.         }, set: function (custom_message) {
  945.             this._custom_message = custom_message
  946.         }
  947.     }
  948. }), SG.Model.Act = function (act) {
  949.     this._id = act.id || 0, this._scenery_id = act.scenery_id || 0, this._playable_characters_ids = act.actpcs || [], this._not_playable_characters_ids = act.actnpcs || []
  950. }, Object.defineProperties(SG.Model.Act.prototype, {
  951.     id: {
  952.         get: function () {
  953.             return this._id
  954.         }, set: function (id) {
  955.             this._id = id
  956.         }
  957.     }, scenery_id: {
  958.         get: function () {
  959.             return this._scenery_id
  960.         }, set: function (id) {
  961.             this._scenery_id = id
  962.         }
  963.     }, playable_character_ids: {
  964.         get: function () {
  965.             return this._playable_characters_ids
  966.         }, set: function (ids) {
  967.             this._playable_characters_ids = ids
  968.         }
  969.     }, not_playable_characters_ids: {
  970.         get: function () {
  971.             return this._not_playable_characters_ids
  972.         }, set: function (ids) {
  973.             this._not_playable_characters_ids = ids
  974.         }
  975.     }
  976. }), SG.Model.Item = function (item) {
  977.     var _this = this;
  978.     this._id = item.id || 0, this._position = [], item.pos.forEach(function (pos) {
  979.         _this._position[pos.cam] = pos
  980.     })
  981. }, Object.defineProperties(SG.Model.Item.prototype, {
  982.     id: {
  983.         get: function () {
  984.             return this._id
  985.         }
  986.     }, position: {
  987.         get: function () {
  988.             return this._position
  989.         }
  990.     }
  991. }), SG.Model.Camera = function (camera) {
  992.     this._id = camera.id || 0, this._background_id = camera.id || 0, this._path = camera.value || "/"
  993. }, Object.defineProperties(SG.Model.Camera.prototype, {
  994.     id: {
  995.         get: function () {
  996.             return this._id
  997.         }
  998.     }, background_id: {
  999.         get: function () {
  1000.             return this._background_id
  1001.         }
  1002.     }, path: {
  1003.         get: function () {
  1004.             return this._path
  1005.         }
  1006.     }
  1007. }), SG.Model.Stage = function (stage) {
  1008.     var _this = this;
  1009.     switch (this._id = stage.id || 0, this._act_id = stage.act || 0, this._preload = stage.preload || {}, this._back_later_enabled = stage.backlaterenabled || !1, this._scenario_id = stage.scenarioid || 0, this._condition = stage.cond || "", this._cam_auto = stage.camauto || !0, this._phase_id = stage.phase_id || 0, this._type = stage.stage_type || "", this._phase_description = stage.phase_description || "", this._short_descriptions = {}, this._comments = [], this._transition_content = [], this._stage_bob_pictures = [], this._sounds = [], this._criterions_results = [], this._paths = [], stage.criterions && stage.criterions.forEach(function (criterion) {
  1010.         _this._criterions_results.push(new SG.Model.CriterionResults(criterion))
  1011.     }), stage.paths && stage.paths.forEach(function (path) {
  1012.         _this._paths.push(new SG.Model.StagePath(path.path))
  1013.     }), stage.lang && stage.lang.forEach(function (lang) {
  1014.         _this._short_descriptions[lang.value] = lang.short_description, _this._transition_content[lang.value] = lang.transition_content, _this._comments[lang.value] = lang.comment, _this._stage_bob_pictures[lang.value] = lang.stage_bob_picture, _this._sounds[lang.value] = [], lang.sounds.user.forEach(function (sound) {
  1015.             _this._sounds[lang.value].push(new SG.Model.Sound(sound))
  1016.         })
  1017.     }), stage.stage_type) {
  1018.         case"WebPhase":
  1019.             this._phase_description = new SG.Model.WebPhase(stage.phase_description);
  1020.             break;
  1021.         case"Quizz":
  1022.             this._phase_description = new SG.Model.Quizz(stage.phase_description);
  1023.             break;
  1024.         case"KinematicPhase":
  1025.             this._phase_description = new SG.Model.KinematicPhase(stage.phase_description);
  1026.             break;
  1027.         case"AnimationPhase":
  1028.             this._phase_description = new SG.Model.KinematicPhase(stage.phase_description);
  1029.             break;
  1030.         case"Bobspeech":
  1031.             this._phase_description = new SG.Model.Bobspeech(stage.phase_description)
  1032.     }
  1033. }, Object.defineProperties(SG.Model.Stage.prototype, {
  1034.     id: {
  1035.         get: function () {
  1036.             return this._id
  1037.         }, set: function (id) {
  1038.             this._id = id
  1039.         }
  1040.     }, act_id: {
  1041.         get: function () {
  1042.             return this._act_id
  1043.         }, set: function (act_id) {
  1044.             this._act_id = act_id
  1045.         }
  1046.     }, preload: {
  1047.         get: function () {
  1048.             return this._preload
  1049.         }, set: function (preload) {
  1050.             this._preload = preload
  1051.         }
  1052.     }, back_later_enabled: {
  1053.         get: function () {
  1054.             return this._back_later_enabled
  1055.         }, set: function (isEnabled) {
  1056.             this._back_later_enabled = isEnabled
  1057.         }
  1058.     }, scenario_id: {
  1059.         get: function () {
  1060.             return this._scenario_id
  1061.         }, set: function (scenario_id) {
  1062.             this._scenario_id = scenario_id
  1063.         }
  1064.     }, condition: {
  1065.         get: function () {
  1066.             return this._condition
  1067.         }, set: function (condition) {
  1068.             this._condition = condition
  1069.         }
  1070.     }, cam_auto: {
  1071.         get: function () {
  1072.             return this._cam_auto
  1073.         }, set: function (cam_auto) {
  1074.             this._cam_auto = cam_auto
  1075.         }
  1076.     }, phase_id: {
  1077.         get: function () {
  1078.             return this._phase_id
  1079.         }, set: function (phase_id) {
  1080.             this._phase_id = phase_id
  1081.         }
  1082.     }, type: {
  1083.         get: function () {
  1084.             return this._type
  1085.         }, set: function (type) {
  1086.             this._type = type
  1087.         }
  1088.     }, phase_description: {
  1089.         get: function () {
  1090.             return this._phase_description
  1091.         }, set: function (phase_description) {
  1092.             this._phase_description = phase_description
  1093.         }
  1094.     }, short_descriptions: {
  1095.         get: function () {
  1096.             return this._short_descriptions
  1097.         }, set: function (short_description) {
  1098.             this._short_descriptions = short_description
  1099.         }
  1100.     }, comments: {
  1101.         get: function () {
  1102.             return this._comments
  1103.         }, set: function (comments) {
  1104.             this._comments = comments
  1105.         }
  1106.     }, transition_content: {
  1107.         get: function () {
  1108.             return this._transition_content
  1109.         }, set: function (transition_content) {
  1110.             this._transition_content = transition_content
  1111.         }
  1112.     }, stage_bob_pictures: {
  1113.         get: function () {
  1114.             return this._stage_bob_pictures
  1115.         }, set: function (stage_bob_pictures) {
  1116.             this._stage_bob_pictures = stage_bob_pictures
  1117.         }
  1118.     }, sounds: {
  1119.         get: function () {
  1120.             return this._sounds
  1121.         }, set: function (sounds) {
  1122.             this._sounds = sounds
  1123.         }
  1124.     }, criterions_results: {
  1125.         get: function () {
  1126.             return this._criterions_results
  1127.         }, set: function (criterions_results) {
  1128.             this._criterions_results = criterions_results
  1129.         }
  1130.     }, paths: {
  1131.         get: function () {
  1132.             return this._paths
  1133.         }, set: function (paths) {
  1134.             this._paths = paths
  1135.         }
  1136.     }
  1137. }), SG.Model.StagePath = function (path) {
  1138.     var _this = this;
  1139.     this._id = path.id, this._order = path.o, this._sp = path.sp, this._parent_id = path.parent_id, this._source = path.source, this._target = path.target, this._condition = path.cond, this._type = path.type, this._short_descriptions = [], this._long_descriptions = [], this._sounds = [], this._criterions_results = [], this._is_display = !0, path.criterions && path.criterions.forEach(function (criterion) {
  1140.         _this._criterions_results.push(new SG.Model.CriterionResults(criterion))
  1141.     }), path.lang && path.lang.forEach(function (lang) {
  1142.         _this._short_descriptions[lang.value] = lang.shortD, _this._long_descriptions[lang.value] = lang.longD, _this._sounds[lang.value] = [], lang.sounds && lang.sounds.forEach(function (sound) {
  1143.             _this._sounds[lang.value][sound.id] = sound.file_size
  1144.         })
  1145.     })
  1146. }, Object.defineProperties(SG.Model.StagePath.prototype, {
  1147.     id: {
  1148.         get: function () {
  1149.             return this._id
  1150.         }, set: function (id) {
  1151.             this._id = id
  1152.         }
  1153.     }, order: {
  1154.         get: function () {
  1155.             return this._order
  1156.         }, set: function (order) {
  1157.             this._order = order
  1158.         }
  1159.     }, sp: {
  1160.         get: function () {
  1161.             return this._sp
  1162.         }, set: function (sp) {
  1163.             this._sp = sp
  1164.         }
  1165.     }, parent_id: {
  1166.         get: function () {
  1167.             return this._parent_id
  1168.         }
  1169.     }, source: {
  1170.         get: function () {
  1171.             return this._source
  1172.         }, set: function (source) {
  1173.             this._source = source
  1174.         }
  1175.     }, target: {
  1176.         get: function () {
  1177.             return this._target
  1178.         }, set: function (target) {
  1179.             this._target = target
  1180.         }
  1181.     }, condition: {
  1182.         get: function () {
  1183.             return this._condition
  1184.         }, set: function (condition) {
  1185.             this._condition = condition
  1186.         }
  1187.     }, type: {
  1188.         get: function () {
  1189.             return this._type
  1190.         }, set: function (type) {
  1191.             this._type = type
  1192.         }
  1193.     }, short_descriptions: {
  1194.         get: function () {
  1195.             return this._short_descriptions
  1196.         }, set: function (short_descriptions) {
  1197.             this._short_descriptions = short_descriptions
  1198.         }
  1199.     }, long_descriptions: {
  1200.         get: function () {
  1201.             return this._long_descriptions
  1202.         }, set: function (long_descriptions) {
  1203.             this._long_descriptions = long_descriptions
  1204.         }
  1205.     }, sounds: {
  1206.         get: function () {
  1207.             return this._sounds
  1208.         }, set: function (sounds) {
  1209.             this._sounds = sounds
  1210.         }
  1211.     }, criterions_results: {
  1212.         get: function () {
  1213.             return this._criterions_results
  1214.         }, set: function (criterions_results) {
  1215.             this._criterions_results = criterions_results
  1216.         }
  1217.     }, is_display: {
  1218.         get: function () {
  1219.             return this._is_display
  1220.         }, set: function (is_display) {
  1221.             this._is_display = is_display
  1222.         }
  1223.     }
  1224. }), SG.Model.Sound = function (sound) {
  1225.     this._character_id = sound.id || 0, this._part = sound.part || 0, this._role_id = sound.r || 0, this._file_size = sound.files_size || 0, this._file_path = sound.file_name || 0
  1226. }, Object.defineProperties(SG.Model.Sound.prototype, {
  1227.     character_id: {
  1228.         get: function () {
  1229.             return this._character_id
  1230.         }, set: function (character_id) {
  1231.             this._character_id = character_id
  1232.         }
  1233.     }, part: {
  1234.         get: function () {
  1235.             return this._part
  1236.         }, set: function (part) {
  1237.             this._part = part
  1238.         }
  1239.     }, role_id: {
  1240.         get: function () {
  1241.             return this._role_id
  1242.         }, set: function (role_id) {
  1243.             this._role_id = role_id
  1244.         }
  1245.     }, file_size: {
  1246.         get: function () {
  1247.             return this._file_size
  1248.         }
  1249.     }, file_path: {
  1250.         get: function () {
  1251.             return this._file_path
  1252.         }, set: function (file_path) {
  1253.             this._file_path = file_path
  1254.         }
  1255.     }
  1256. }), SG.Model.Scenery = function (scenery) {
  1257.     var _this = this;
  1258.     this._id = scenery.id, this._nb_cams = scenery.nbcam, this._scenarios_ids = scenery.scenarios, this._bg_urls = [], this._bg_urls_filesizes = [], this._users_urls = [], this._users_urls_filesize = [], this._users_urls_filescount = [], this._users_urls_coordinates = [], this._users_moves = [], this._items = {}, this._cameras = [], scenery.media.cam.forEach(function (cam) {
  1259.         _this._bg_urls[cam.id] = cam.value, _this._bg_urls_filesizes[cam.id] = cam.filesize
  1260.     }), scenery.media.cam.forEach(function (cam) {
  1261.         _this._cameras.push(new SG.Model.Camera(cam))
  1262.     }), scenery.media.items.forEach(function (item) {
  1263.         _this._items[item.id] = new SG.Model.Item(item)
  1264.     }), scenery.media.users.forEach(function (character) {
  1265.         _this._users_urls[character.id] = {}, _this._users_urls_filesize[character.id] = {}, _this._users_urls_filescount[character.id] = {}, _this._users_urls_coordinates[character.id] = {}, _this._users_moves[character.id] = {}, character.views.forEach(function (view) {
  1266.             _this._users_urls[character.id][view.position + "_" + view.cam] = view.folder, _this._users_urls_filesize[character.id][view.position + "_" + view.cam] = view.filesize, _this._users_urls_filescount[character.id][view.position + "_" + view.cam] = view.filescount, _this._users_urls_coordinates[character.id][view.position + "_" + view.cam] = view, _this._users_moves[character.id][character.id + "_" + view.position + "_" + view.cam] = {}, view.movements_references.forEach(function (movement) {
  1267.                 movement.nbpics > 0 && (_this._users_moves[character.id][character.id + "_" + view.position + "_" + view.cam][movement.id] = new SG.Model.Movement(movement, view.cam))
  1268.             })
  1269.         })
  1270.     })
  1271. }, SG.Model.Scenery.prototype = {
  1272.     getBasicMovesForUser: function (user_id, role) {
  1273.         var key, user_moves_front = this.users_moves[user_id][user_id + "_" + role + "_1"],
  1274.             user_moves_back = this.users_moves[user_id][user_id + "_" + role + "_2"], moves_to_return = [];
  1275.         for (key in user_moves_front) 1 != user_moves_front[key].attitude_id && 3 != user_moves_front[key].attitude_id || moves_to_return.push(user_moves_front[key]);
  1276.         for (key in user_moves_back) 1 != user_moves_back[key].attitude_id && 3 != user_moves_back[key].attitude_id || moves_to_return.push(user_moves_back[key]);
  1277.         return moves_to_return
  1278.     }, getSpecificMovesForUser: function (user_id, role, reference) {
  1279.         role = 1 == role ? 2 : 1;
  1280.         var speak_id, pause_id, key, moves_to_return = [], user_moves = this.users_moves[user_id][user_id + "_" + role + "_" + role];
  1281.         for (key in user_moves) user_moves[key].reference == reference && (moves_to_return.push(user_moves[key]), speak_id = user_moves[key].speak_id, pause_id = user_moves[key].pause_id);
  1282.         for (key in user_moves) user_moves[key].attitude_id != speak_id && user_moves[key].attitude_id != pause_id || 1 == user_moves[key].attitude_id || 3 == user_moves[key].attitude_id || moves_to_return.push(user_moves[key]);
  1283.         return moves_to_return
  1284.     }, getUrlForUser: function (user_id, role, cam_position) {
  1285.         return this.users_urls[user_id][role + "_" + cam_position]
  1286.     }
  1287. }, Object.defineProperties(SG.Model.Scenery.prototype, {
  1288.     id: {
  1289.         get: function () {
  1290.             return this._id
  1291.         }
  1292.     }, nb_cams: {
  1293.         get: function () {
  1294.             return this._nb_cams
  1295.         }
  1296.     }, scenarios_ids: {
  1297.         get: function () {
  1298.             return this._scenarios_ids
  1299.         }
  1300.     }, bg_urls: {
  1301.         get: function () {
  1302.             return this._bg_urls
  1303.         }
  1304.     }, bg_urls_filesizes: {
  1305.         get: function () {
  1306.             return this._bg_urls_filesizes
  1307.         }
  1308.     }, users_urls: {
  1309.         get: function () {
  1310.             return this._users_urls
  1311.         }
  1312.     }, users_urls_filesize: {
  1313.         get: function () {
  1314.             return this._users_urls_filesize
  1315.         }
  1316.     }, users_urls_filescount: {
  1317.         get: function () {
  1318.             return this._users_urls_filescount
  1319.         }
  1320.     }, users_urls_coordinates: {
  1321.         get: function () {
  1322.             return this._users_urls_coordinates
  1323.         }
  1324.     }, users_moves: {
  1325.         get: function () {
  1326.             return this._users_moves
  1327.         }
  1328.     }, items: {
  1329.         get: function () {
  1330.             return this._items
  1331.         }
  1332.     }, cameras: {
  1333.         get: function () {
  1334.             return this._cameras
  1335.         }
  1336.     }
  1337. }), SG.Model.Criterion = function (criterion) {
  1338.     var _this = this;
  1339.     this._id = criterion.id, this._name = criterion.name, this._color = criterion.color, this._checked_in_tree = criterion.checkedInTree, this._min = {}, this._max = {}, criterion.levels_list && criterion.levels_list.forEach(function (value) {
  1340.         _this._min[value.val] = value.min, _this._max[value.val] = value.max
  1341.     })
  1342. }, SG.Model.Criterion.prototype = {
  1343.     getMinForLevel: function (level) {
  1344.         return this.min[level]
  1345.     }, getMaxForLevel: function (level) {
  1346.         return this.max[level]
  1347.     }
  1348. }, Object.defineProperties(SG.Model.Criterion.prototype, {
  1349.     id: {
  1350.         get: function () {
  1351.             return this._id
  1352.         }, set: function (id) {
  1353.             this._id = id
  1354.         }
  1355.     }, name: {
  1356.         get: function () {
  1357.             return this._name
  1358.         }, set: function (name) {
  1359.             this._name = name
  1360.         }
  1361.     }, color: {
  1362.         get: function () {
  1363.             return this._color
  1364.         }, set: function (value) {
  1365.             this._color = value
  1366.         }
  1367.     }, checked_in_tree: {
  1368.         get: function () {
  1369.             return this._checked_in_tree
  1370.         }, set: function (check_in_tree) {
  1371.             this._checked_in_tree = check_in_tree
  1372.         }
  1373.     }, min: {
  1374.         get: function () {
  1375.             return this._min
  1376.         }, set: function (min) {
  1377.             this._min = min
  1378.         }
  1379.     }, max: {
  1380.         get: function () {
  1381.             return this._max
  1382.         }, set: function (max) {
  1383.             this._max = max
  1384.         }
  1385.     }
  1386. }), SG.Model.CriterionResults = function (criterion_data) {
  1387.     var _this = this;
  1388.     this._id = criterion_data.id || -1, this._value = [], criterion_data.cval && criterion_data.cval.forEach(function (crit) {
  1389.         _this._value[crit.level] = crit.value
  1390.     })
  1391. }, Object.defineProperties(SG.Model.CriterionResults.prototype, {
  1392.     id: {
  1393.         get: function () {
  1394.             return this._id
  1395.         }, set: function (id) {
  1396.             this._id = id
  1397.         }
  1398.     }, value: {
  1399.         get: function () {
  1400.             return this._value
  1401.         }, set: function (value) {
  1402.             this._value = value
  1403.         }
  1404.     }
  1405. }), SG.Model.Background = function (bg) {
  1406.     this._id = bg.id || 0, this._name = bg.name || "", this._path = bg.path || ""
  1407. }, Object.defineProperties(SG.Model.Background.prototype, {
  1408.     id: {
  1409.         get: function () {
  1410.             return this._id
  1411.         }, set: function (id) {
  1412.             this._id = id
  1413.         }
  1414.     }, name: {
  1415.         get: function () {
  1416.             return this._name
  1417.         }, set: function (name) {
  1418.             this._name = name
  1419.         }
  1420.     }, path: {
  1421.         get: function () {
  1422.             return this._path
  1423.         }, set: function (path) {
  1424.             this._path = path
  1425.         }
  1426.     }
  1427. }), SG.Model.Movement = function (movement, cam) {
  1428.     this._id = movement.id || 0, this._speak_move = movement.sm || null, this._proba = movement.p || 0, this._x = movement.x || 0, this._y = movement.y || 0, this._position = movement.pos || null, this._reverse = movement.rv || !1, this._attitude_id = movement.attitude_id, this._type = movement.type, this._reference = movement.ref, this._speak_id = movement.speak_aid, this._pause_id = movement.pause_aid, this._nb_pics = movement.nbpics, this._size = movement.size, this._cam = cam
  1429. }, SG.Model.Movement.ACTIVE = "active", SG.Model.Movement.PASSIVE = "passive", Object.defineProperties(SG.Model.Movement.prototype, {
  1430.     id: {
  1431.         get: function () {
  1432.             return this._id
  1433.         }, set: function (id) {
  1434.             this._id = id
  1435.         }
  1436.     }, speak_move: {
  1437.         get: function () {
  1438.             return this._speak_move
  1439.         }, set: function (speak_move) {
  1440.             this._speak_move = speak_move
  1441.         }
  1442.     }, proba: {
  1443.         get: function () {
  1444.             return this._proba
  1445.         }, set: function (proba) {
  1446.             this._proba = proba
  1447.         }
  1448.     }, x: {
  1449.         get: function () {
  1450.             return this._x
  1451.         }, set: function (x) {
  1452.             this._x = x
  1453.         }
  1454.     }, y: {
  1455.         get: function () {
  1456.             return this._y
  1457.         }, set: function (y) {
  1458.             this._y = y
  1459.         }
  1460.     }, position: {
  1461.         get: function () {
  1462.             return this._position
  1463.         }, set: function (position) {
  1464.             this._position = position
  1465.         }
  1466.     }, reverse: {
  1467.         get: function () {
  1468.             return this._reverse
  1469.         }, set: function (reverse) {
  1470.             this._reverse = reverse
  1471.         }
  1472.     }, attitude_id: {
  1473.         get: function () {
  1474.             return this._attitude_id
  1475.         }, set: function (attitude_id) {
  1476.             this._attitude_id = attitude_id
  1477.         }
  1478.     }, type: {
  1479.         get: function () {
  1480.             return this._type
  1481.         }, set: function (type) {
  1482.             this._type = type
  1483.         }
  1484.     }, reference: {
  1485.         get: function () {
  1486.             return this._reference
  1487.         }, set: function (reference) {
  1488.             this._reference = reference
  1489.         }
  1490.     }, speak_id: {
  1491.         get: function () {
  1492.             return this._speak_id
  1493.         }, set: function (speak_id) {
  1494.             this._speak_id = speak_id
  1495.         }
  1496.     }, pause_id: {
  1497.         get: function () {
  1498.             return this._pause_id
  1499.         }, set: function (pause_id) {
  1500.             this._pause_id = pause_id
  1501.         }
  1502.     }, nb_pics: {
  1503.         get: function () {
  1504.             return this._nb_pics
  1505.         }, set: function (nb_pics) {
  1506.             this._nb_pics = nb_pics
  1507.         }
  1508.     }, size: {
  1509.         get: function () {
  1510.             return this._size
  1511.         }, set: function (size) {
  1512.             this._size = size
  1513.         }
  1514.     }, cam: {
  1515.         get: function () {
  1516.             return this._cam
  1517.         }, set: function (cam) {
  1518.             this._cam = cam
  1519.         }
  1520.     }
  1521. }), SG.Model.DialogPart = function (type, datas) {
  1522.     this._type = type, this._datas = datas
  1523. }, Object.defineProperties(SG.Model.DialogPart.prototype, {
  1524.     type: {
  1525.         get: function () {
  1526.             return this._type
  1527.         }, set: function (type) {
  1528.             this._type = type
  1529.         }
  1530.     }, datas: {
  1531.         get: function () {
  1532.             return this._datas
  1533.         }, set: function (datas) {
  1534.             this._datas = datas
  1535.         }
  1536.     }
  1537. }), SG.Model.DialogPart.TYPE_SPEECH = "type_speech", SG.Model.DialogPart.TYPE_CINEMATIC = "type_cinematic", SG.Model.DialogPart.TYPE_PICTURE = "type_picture", SG.Model.DialogPart.TYPE_SWF = "type_swf", SG.Model.DialogPart.TYPE_BGS = "type_bgs", SG.Model.DialogPart.TYPE_MOVE = "type_move", SG.Model.DialogPart.TYPE_DOC = "type_doc", SG.Model.DialogPart.TYPE_BLUR = "type_blur", SG.Model.DialogPart.TYPE_ITEM = "type_item", SG.Model.DialogPart.TYPE_CAMERA = "type_camera", SG.Model.DialogPart.NONE = "type_none";
  1538. var i18n = i18n || [];
  1539. i18n.French = {
  1540.     loading: "Chargement",
  1541.     error: "Erreur",
  1542.     contact_support: "Pour plus d'information contacter le support",
  1543.     yes: "oui",
  1544.     no: "non",
  1545.     pause: "Pause",
  1546.     quizz_placeholder: "Saisissez votre réponse",
  1547.     choose_avatar: "Veuillez choisir votre avatar",
  1548.     choose_meet: "Qui voudriez-vous rencontrer ?",
  1549.     connexion: {
  1550.         connexion: "Connexion",
  1551.         connexion_failed: "Echec de la connexion. Verifiez votre identifiant et votre mot de passe et réessayez",
  1552.         login: "Pseudo",
  1553.         password: "Mot de passe",
  1554.         no_information_gb: "Aucun numéro de scénario n'est spécifié"
  1555.     },
  1556.     endgame: {
  1557.         scenario_end_reached: "Vous avez atteint la fin du module !",
  1558.         end_reached: "Vous avez atteint la fin du module !",
  1559.         no_criterions: "Aucun axe d'analyse n'est défini. Vous ne pouvez donc pas avoir accès aux résultats.",
  1560.         access_result: "Vos résultats vont s'afficher d'ici quelques secondes...",
  1561.         please_save_results: "Veuillez enregistrer vos résultats"
  1562.     },
  1563.     menu: {
  1564.         settings: "Paramètres",
  1565.         sound: "son",
  1566.         subtitle: "sous-titres",
  1567.         info: "information sur le module",
  1568.         result: "accéder aux résultats",
  1569.         logout: "Déconnexion",
  1570.         tutorial: "Tutoriel",
  1571.         go_to_map: "Retour à la carte",
  1572.         go_to_map_msg: "Êtes vous sûr de vouloir retourner à la carte? Votre progression dans cette mission sera perdue.",
  1573.         observation: "une remarque ?",
  1574.         replay: "Rejouer la scène",
  1575.         conceptor_name: "Nom du/des concepteur(s)"
  1576.     },
  1577.     results: {
  1578.         title: "resultats",
  1579.         warning: "Attention, en accédant aux résultats, vous quittez la partie en cours, cette dernière ne sera pas sauvegardée."
  1580.     }
  1581. };
  1582. var i18n = i18n || [];
  1583. i18n.English = {
  1584.     loading: "Loading",
  1585.     error: "Error",
  1586.     contact_support: "For more informations, contact support",
  1587.     yes: "yes",
  1588.     no: "no",
  1589.     pause: "Pause",
  1590.     quizz_placeholder: "Enter your answer",
  1591.     choose_avatar: "Choose your avatar",
  1592.     choose_meet: "Who would you meet ?",
  1593.     connexion: {
  1594.         connexion: "Connection",
  1595.         connexion_failed: "Connection failed. Check your email and password and try again",
  1596.         login: "Login",
  1597.         password: "Password",
  1598.         no_information_gb: "None scene number specified"
  1599.     },
  1600.     endgame: {
  1601.         scenario_end_reached: "You have reached the end of the module !",
  1602.         end_reached: "You have reached the end of the module !",
  1603.         no_criterions: "No analysis axis is defined. You do not have access to the results.",
  1604.         access_result: "Your results will be displayed in a few seconds",
  1605.         please_save_results: "Please, register your results"
  1606.     },
  1607.     menu: {
  1608.         settings: "Settings",
  1609.         sound: "sound",
  1610.         subtitle: "subtitles",
  1611.         info: "information on the module",
  1612.         result: "Access to results",
  1613.         logout: "Sign Out",
  1614.         tutorial: "Tutorial",
  1615.         go_to_map: "Back to the map",
  1616.         go_to_map_msg: "Are you sure you want to return to the map? Your progress in this mission will be lost.",
  1617.         observation: "an observation ?",
  1618.         replay: "Replay scene",
  1619.         conceptor_name: "Designer name(s)"
  1620.     },
  1621.     results: {title: "results", warning: "Attention by accessing results, you leave the current game, it will not be saved."}
  1622. }, SG.Core = function () {
  1623.     var Core = function () {
  1624.         this._export_results = null, this._offline = !1, this._lang = "French", this._version = null, this._debug_mode = !1, this._base_url = "", this._medias_url = "", this._global_scenario_id = -1, this._global_scenario = {}, this._user = {}, this._i18n = {}, this._characters = [], this.init = function () {
  1625.             switch (this._i18n = i18n[this._lang] || i18n.English, this._version) {
  1626.                 case"manual":
  1627.                     break;
  1628.                 case"prod":
  1629.                     this._base_url = "http://sg.itysoft.com", this._medias_url = "http://sgdatas.itysoft.com";
  1630.                     break;
  1631.                 case"beta":
  1632.                     this._base_url = "http://sgbeta.itysoft.com", this._medias_url = "http://sgdatasbeta.itysoft.com";
  1633.                     break;
  1634.                 case"standalone":
  1635.                     this._offline = !0, this._base_url = ".", this._medias_url = "sgdatas";
  1636.                     break;
  1637.                 case"html":
  1638.                     this._offline = !0, this._base_url = ".", this._medias_url = "sgdatas";
  1639.                     break;
  1640.                 case"test":
  1641.                     this._base_url = "http://192.168.1.16/SeriousGamesBeta", this._medias_url = "http://192.168.1.16/SgDatas";
  1642.                     break;
  1643.                 case"julien_localhost":
  1644.                     this._base_url = "http://127.0.0.1/SeriousGamesBeta", this._medias_url = "http://127.0.0.1/SgDatas";
  1645.                     break;
  1646.                 case"julien":
  1647.                     this._base_url = "http://192.168.0.42/SeriousGamesBeta", this._medias_url = "http://192.168.0.42/SgDatas";
  1648.                     break;
  1649.                 case"esteban":
  1650.                     this._base_url = "http://192.168.0.80:8081/itystudiobeta", this._medias_url = "http://192.168.0.80:8081/SgDatas";
  1651.                     break;
  1652.                 case"quention_local":
  1653.                     this._base_url = "http://127.0.0.1/SeriousGamesBeta", this._medias_url = "http://127.0.0.1/sgdatas";
  1654.                     break;
  1655.                 case"quention_externe":
  1656.                     this._base_url = "http://192.168.0.31/SeriousGamesBeta", this._medias_url = "http://192.168.0.31/sgdatas";
  1657.                     break;
  1658.                 case"olivier":
  1659.                     this._base_url = "http://192.168.0.72/seriousgames", this._medias_url = "http://192.168.0.72/sgdatas";
  1660.                     break;
  1661.                 case"greg":
  1662.                     this._base_url = "http://127.0.0.1/seriousgamesbeta", this._medias_url = "http://127.0.0.1/sgdatas";
  1663.                     break;
  1664.                 case"benjamin":
  1665.                     this._base_url = "http://192.168.0.202:8081/itystudiobeta", this._medias_url = "http://192.168.0.202:8081/sgdatas";
  1666.                     break;
  1667.                 default:
  1668.                     this._base_url = "http://sg.itysoft.com", this._medias_url = "http://sgdatas.itysoft.com"
  1669.             }
  1670.             amfphp.entryPointUrl = this._base_url + "/gateway.php?contentType=application/json", !this._debug_mode
  1671.         }
  1672.     };
  1673.     Core.prototype = {
  1674.         getCharacterById: function (id) {
  1675.             var characterToReturn = null;
  1676.             return this.characters.forEach(function (character) {
  1677.                 character.id == id && (characterToReturn = character)
  1678.             }), characterToReturn
  1679.         }
  1680.     }, Object.defineProperties(Core.prototype, {
  1681.         user: {
  1682.             get: function () {
  1683.                 return this._user
  1684.             }, set: function (user) {
  1685.                 this._user = user
  1686.             }
  1687.         }, global_scenario: {
  1688.             get: function () {
  1689.                 return this._global_scenario
  1690.             }, set: function (global_scenario) {
  1691.                 this._global_scenario = global_scenario
  1692.             }
  1693.         }, global_scenario_id: {
  1694.             get: function () {
  1695.                 return this._global_scenario_id
  1696.             }, set: function (id) {
  1697.                 this._global_scenario_id = id
  1698.             }
  1699.         }, lang: {
  1700.             get: function () {
  1701.                 return this._lang
  1702.             }, set: function (lang) {
  1703.                 this._lang = lang
  1704.             }
  1705.         }, version: {
  1706.             get: function () {
  1707.                 return this._version
  1708.             }, set: function (version) {
  1709.                 this._version = version
  1710.             }
  1711.         }, export_results: {
  1712.             get: function () {
  1713.                 return this._export_results
  1714.             }, set: function (export_results) {
  1715.                 this._export_results = export_results
  1716.             }
  1717.         }, base_url: {
  1718.             get: function () {
  1719.                 return this._base_url
  1720.             }, set: function (base_url) {
  1721.                 this._base_url = base_url
  1722.             }
  1723.         }, medias_url: {
  1724.             get: function () {
  1725.                 return this._medias_url
  1726.             }, set: function (medias_url) {
  1727.                 this._medias_url = medias_url
  1728.             }
  1729.         }, offline: {
  1730.             get: function () {
  1731.                 return this._offline
  1732.             }, set: function (offline) {
  1733.                 this._offline = offline
  1734.             }
  1735.         }, debug_mode: {
  1736.             get: function () {
  1737.                 return this._debug_mode
  1738.             }, set: function (debug_mode) {
  1739.                 this._debug_mode = debug_mode
  1740.             }
  1741.         }, i18n: {
  1742.             get: function () {
  1743.                 return this._i18n
  1744.             }, set: function (i18n) {
  1745.                 this._i18n = i18n
  1746.             }
  1747.         }, characters: {
  1748.             get: function () {
  1749.                 return this._characters
  1750.             }, set: function (characters) {
  1751.                 this._characters = characters
  1752.             }
  1753.         }
  1754.     });
  1755.     var instance = null;
  1756.     return new function () {
  1757.         this.getInstance = function () {
  1758.             return null === instance && (instance = new Core), instance
  1759.         }
  1760.     }
  1761. }(), SG.core = SG.Core.getInstance(), SG.PlayerPrefs = function () {
  1762.     var PlayerPrefs = function () {
  1763.         this._boolean_list = {}, this._string_list = {}, this._float_list = {}, this._int_list = {}
  1764.     };
  1765.     PlayerPrefs.prototype = {
  1766.         getBooleanByKey: function (key) {
  1767.             return null != this._boolean_list[key] ? this._boolean_list[key] : "undefined"
  1768.         }, setBooleanByKey: function (key, value) {
  1769.             this._boolean_list[key] = value
  1770.         }, getStringByKey: function (key) {
  1771.             return null != this._string_list[key] ? this._string_list[key] : "undefined"
  1772.         }, setStringByKey: function (key, value) {
  1773.             this._string_list[key] = value
  1774.         }, getFloatByKey: function (key) {
  1775.             return null != this._float_list[key] ? this._float_list[key] : "undefined"
  1776.         }, setFloatByKey: function (key, value) {
  1777.             this._float_list[key] = value
  1778.         }, getIntByKey: function (key) {
  1779.             return null != this._int_list[key] ? this._int_list[key] : "undefined"
  1780.         }, setIntByKey: function (key, value) {
  1781.             this._int_list[key] = value
  1782.         }
  1783.     };
  1784.     var instance = null;
  1785.     return new function () {
  1786.         this.getInstance = function () {
  1787.             return null === instance && (instance = new PlayerPrefs), instance
  1788.         }
  1789.     }
  1790. }(), SG.player_prefs = SG.PlayerPrefs.getInstance(), SG.PhaseManager = function () {
  1791.     var PhaseManager = function () {
  1792.         this._phases = [], this._phase_index = 0, this._loading_phase_index = 0, this._is_in_stage_phase = !1, this._phase_are_loaded = null
  1793.     };
  1794.     PhaseManager.prototype = {
  1795.         addPhase: function (phase) {
  1796.             this.phases.push(phase)
  1797.         }, start: function () {
  1798.             var lastPhaseIndex = SG.tracker.lastPhaseIndex;
  1799.             this._loading_phase_index = lastPhaseIndex, this._phase_index = lastPhaseIndex, "Scenario" === this.phases[lastPhaseIndex].name && (this.phases[lastPhaseIndex].first_stage = SG.tracker.getLastStageId() >= 0 ? SG.tracker.getLastStageId() : this.phases[lastPhaseIndex].first_stage)
  1800.         }, preloadPhases: function (callback_phase_are_loaded) {
  1801.             var _this = this;
  1802.             return this._phase_are_loaded = callback_phase_are_loaded || this._phase_are_loaded, this._loading_phase_index == this.phases.length ? (SG.tracker.startGame(), void this._phase_are_loaded()) : void this.phases[this._loading_phase_index].loadAssets(function () {
  1803.                 _this._loading_phase_index++, _this.preloadPhases(null)
  1804.             })
  1805.         }, nextPhase: function () {
  1806.             this.phase_index++, SG.tracker.lastPhaseIndex = this.phase_index
  1807.         }, lastPhase: function () {
  1808.             this.phase_index = this._phases.length - 1, SG.tracker.lastPhaseIndex = this.phase_index
  1809.         }, getCurrentPhase: function () {
  1810.             return this.phase_index < this.phases.length && this.phases[this.phase_index]
  1811.         }, getNextScenarioPhase: function () {
  1812.             for (var i = this.phase_index; i < this.phases.length; i++) if ("Scenario" === this.phases[i].name) return this.phases[i];
  1813.             return null
  1814.         }, getPhaseByOrder: function (order) {
  1815.             var phase_to_return = null;
  1816.             return this.phases.forEach(function (phase) {
  1817.                 phase._order == order && (phase_to_return = phase)
  1818.             }), phase_to_return
  1819.         }
  1820.     }, Object.defineProperties(PhaseManager.prototype, {
  1821.         phases: {
  1822.             get: function () {
  1823.                 return this._phases
  1824.             }, set: function (phases) {
  1825.                 this._phases = phases
  1826.             }
  1827.         }, phase_index: {
  1828.             get: function () {
  1829.                 return this._phase_index
  1830.             }, set: function (phase_index) {
  1831.                 this._phase_index = phase_index
  1832.             }
  1833.         }, phase_are_loaded: {
  1834.             get: function () {
  1835.                 return this._phase_are_loaded
  1836.             }, set: function (phase_are_loaded) {
  1837.                 this._phase_are_loaded = phase_are_loaded
  1838.             }
  1839.         }, is_in_stage_phase: {
  1840.             get: function () {
  1841.                 return this._is_in_stage_phase
  1842.             }, set: function (is_in_stage_phase) {
  1843.                 this._is_in_stage_phase = is_in_stage_phase
  1844.             }
  1845.         }
  1846.     });
  1847.     var instance = null;
  1848.     return new function () {
  1849.         this.getInstance = function () {
  1850.             return null === instance && (instance = new PhaseManager), instance
  1851.         }
  1852.     }
  1853. }(), SG.phase_manager = SG.PhaseManager.getInstance(), SG.Tracker = function (criterions) {
  1854.     this.SEPARATOR = "[ ヅ ]", this._criterions = criterions, this._lastPhaseIndex = 0, this._difficulty = 0, this._stages = [], this._paths = [], this._score = {}, this._timeSinceStartUp = 0, this._current_stage_id = -1
  1855. }, SG.Tracker.prototype = {
  1856.     init: function () {
  1857.         if (SG.scorm.api_available) {
  1858.             var track = SG.scorm.getTrack();
  1859.             "" != track && this.stringToTrack(track)
  1860.         }
  1861.         return this.lastPhaseIndex
  1862.     }, startGame: function () {
  1863.         this.timeSinceStartUp = new Date
  1864.     }, endGame: function () {
  1865.         SG.scorm.api_available && (SG.scorm.storeScore(this.getGeneralScore()), "2004" == SG.scorm.scorm_version && SG.scorm.storeObjectives(), SG.scorm.storePlayTime(this.getTimeSinceStartGame(SG.scorm.scorm_version)), SG.scorm.storeGameCompleted(), SG.scorm.save(), SG.scorm.quit())
  1866.     }, addStage: function (stage) {
  1867.         var _this = this;
  1868.         this.stages.push(stage.id), stage.criterions_results.forEach(function (criterion) {
  1869.             _this.setCriterionValue(criterion)
  1870.         }), SG.game.event_controller.onCriterionsChange(stage.criterions_results), this.saveTracking()
  1871.     }, addPath: function (path) {
  1872.         var _this = this;
  1873.         this.paths.push(path.id), path.criterions_results.forEach(function (criterion) {
  1874.             _this.setCriterionValue(criterion)
  1875.         }), SG.game.event_controller.onCriterionsChange(path.criterions_results)
  1876.     }, saveTracking: function () {
  1877.         SG.scorm.api_available && (SG.scorm.storeScore(this.getGeneralScore()), SG.scorm.storeTrack(this.trackToString()), SG.scorm.storePlayTime(this.getTimeSinceStartGame(SG.scorm.scorm_version)), SG.scorm.save())
  1878.     }, setCriterionValue: function (criterion) {
  1879.         if (this.criterionExist(criterion.id)) {
  1880.             this.score[criterion.id] = this.score[criterion.id] || {};
  1881.             var current_score = this.score[criterion.id].value || 0;
  1882.             this.score[criterion.id] = {
  1883.                 id: criterion.id,
  1884.                 value: parseInt(current_score) + parseInt(criterion.value[this.difficulty])
  1885.             }, SG.core.debug_mode
  1886.         } else this.score[criterion.id] = {id: criterion.id, value: parseInt(criterion.points)}
  1887.     }, resetCriterionValue: function (criterion) {
  1888.         this.criterionExist(criterion.id) && (this.score[criterion.id] = {id: criterion.id, value: 0})
  1889.     }, criterionExist: function (criterion_id) {
  1890.         var criterion_exists = !1;
  1891.         return $.each(this.criterions, function (key, criterion) {
  1892.             criterion.id == criterion_id && (criterion_exists = !0)
  1893.         }), criterion_exists
  1894.     }, getLastStageId: function () {
  1895.         var stage_id_to_return;
  1896.         return stage_id_to_return = this.getPreviousStageId(1)
  1897.     }, getPreviousStageId: function (previous_index) {
  1898.         var stage_id_to_return;
  1899.         return stage_id_to_return = this.stages[this.stages.length - previous_index] ? this.stages[this.stages.length - previous_index - 1] : -1
  1900.     }, trackToString: function () {
  1901.         var _this = this, track_string = "";
  1902.         track_string += "i" + SG.phase_manager.phase_index + this.SEPARATOR, track_string += "u0|0" + this.SEPARATOR, track_string += "d" + this.difficulty + this.SEPARATOR, this.stages.forEach(function (stage_id) {
  1903.             track_string += "s" + stage_id + _this.SEPARATOR
  1904.         }), this.paths.forEach(function (path_id) {
  1905.             track_string += "p" + path_id + _this.SEPARATOR
  1906.         });
  1907.         var key;
  1908.         for (key in this.score) track_string += "c" + this.score[key].id + "|" + this.score[key].value + this.SEPARATOR;
  1909.         return track_string
  1910.     }, stringToTrack: function (track_string) {
  1911.         var type, value, _this = this, track_array = track_string.split(this.SEPARATOR);
  1912.         track_array.forEach(function (part) {
  1913.             switch (type = part.substr(0, 1), value = part.substr(1), type) {
  1914.                 case"i":
  1915.                     _this.lastPhaseIndex = parseInt(value);
  1916.                 case"d":
  1917.                     _this.difficulty = parseInt(value);
  1918.                     break;
  1919.                 case"s":
  1920.                     _this.stages.push(parseInt(value));
  1921.                     break;
  1922.                 case"p":
  1923.                     _this.paths.push(parseInt(value));
  1924.                     break;
  1925.                 case"c":
  1926.                     var criterion = value.split("|"), score = {id: criterion[0], value: criterion[1]};
  1927.                     _this.score[score.id] = score
  1928.             }
  1929.         })
  1930.     }, getCurrentPercentageForCriterionId: function (criterion_id) {
  1931.         var min, max, score = this.getScoreByCriterionId(criterion_id), percentage = 0;
  1932.         return "undefined" == typeof this.criterions[criterion_id] ? 0 : (this.criterions[criterion_id].min[this.difficulty] && this.criterions[criterion_id].max[this.difficulty] ? (min = this.criterions[criterion_id].min[this.difficulty], max = this.criterions[criterion_id].max[this.difficulty]) : (min = this.criterions[criterion_id][0].min[this.difficulty], max = this.criterions[criterion_id][0].max[this.difficulty]), score -= min, max -= min, max > 0 && (percentage = Math.round(parseInt(score) / parseInt(max) * 100)), percentage < 0 ? percentage = 0 : percentage > 100 && (percentage = 100), percentage)
  1933.     }, getGeneralScore: function () {
  1934.         var general_score, _this = this, score = 0, nb_criterion = 0;
  1935.         return $.each(this.criterions, function (key, criterion) {
  1936.             score += _this.getCurrentPercentageForCriterionId(criterion.id), nb_criterion++
  1937.         }), general_score = parseInt(score / nb_criterion)
  1938.     }, getScoreByCriterionId: function (criterion_id) {
  1939.         var score_value = -1;
  1940.         return void 0 !== this.score[criterion_id] && null !== this.score[criterion_id] && (score_value = this.score[criterion_id].value), score_value
  1941.     }, getNumberOfCriterion: function () {
  1942.         var nb;
  1943.         return nb = this.criterions.length
  1944.     }, getTimeSinceStartGame: function (scorm_version) {
  1945.         var currentTime = new Date, diff = currentTime - this.timeSinceStartUp, msec = diff, hh = Math.floor(msec / 1e3 / 60 / 60);
  1946.         msec -= 1e3 * hh * 60 * 60;
  1947.         var mm = Math.floor(msec / 1e3 / 60);
  1948.         msec -= 1e3 * mm * 60;
  1949.         var ss = Math.floor(msec / 1e3);
  1950.         return msec -= 1e3 * ss, "1.2" == scorm_version ? (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss : "PT" + hh + "H" + mm + "M" + ss + "S"
  1951.     }, toJsonString: function () {
  1952.         var score, _this = this, json = "{";
  1953.         json += '"lastStageId":"' + this.getLastStageId() + '",', json += '"criterions":[';
  1954.         var bFirst = !0;
  1955.         return $.each(this.criterions, function (key, criterion) {
  1956.             bFirst ? bFirst = !1 : json += ",", score = _this.score[criterion.id] ? _this.score[criterion.id].value : 0, json += '{"id":' + criterion.id + ', "name": "' + criterion.name + '", "score":' + _this.getCurrentPercentageForCriterionId(criterion.id) + "}"
  1957.         }), json += "]", json += "}"
  1958.     }
  1959. }, Object.defineProperties(SG.Tracker.prototype, {
  1960.     criterions: {
  1961.         get: function () {
  1962.             return this._criterions
  1963.         }, set: function (criterions) {
  1964.             this._criterions = criterions
  1965.         }
  1966.     }, lastPhaseIndex: {
  1967.         get: function () {
  1968.             return this._lastPhaseIndex
  1969.         }, set: function (lastPhaseIndex) {
  1970.             this.saveTracking(), this._lastPhaseIndex = lastPhaseIndex
  1971.         }
  1972.     }, difficulty: {
  1973.         get: function () {
  1974.             return this._difficulty
  1975.         }, set: function (difficulty) {
  1976.             this._difficulty = difficulty
  1977.         }
  1978.     }, stages: {
  1979.         get: function () {
  1980.             return this._stages
  1981.         }, set: function (stages) {
  1982.             this._stages = stages
  1983.         }
  1984.     }, paths: {
  1985.         get: function () {
  1986.             return this._paths
  1987.         }, set: function (paths) {
  1988.             this._paths = paths
  1989.         }
  1990.     }, score: {
  1991.         get: function () {
  1992.             return this._score
  1993.         }, set: function (score) {
  1994.             this._score = score
  1995.         }
  1996.     }, current_stage_id: {
  1997.         get: function () {
  1998.             return this._current_stage_id
  1999.         }, set: function (score) {
  2000.             this._current_stage_id = score
  2001.         }
  2002.     }, timeSinceStartUp: {
  2003.         get: function () {
  2004.             return this._timeSinceStartUp
  2005.         }, set: function (time) {
  2006.             this._timeSinceStartUp = time
  2007.         }
  2008.     }
  2009. }), SG.CheatCodeController = {
  2010.     addCheatCode: function (combination, callback) {
  2011.         var egg = new Egg;
  2012.         egg.addCode(combination, function () {
  2013.             callback()
  2014.         }).addHook(function () {
  2015.             console.log("Hook called for: " + this.activeEgg.keys), console.log(this.activeEgg.metadata)
  2016.         }).listen()
  2017.     }
  2018. }, SG.Scorm = function () {
  2019.     var Scorm = function () {
  2020.         this._is_scorm = !1, this._api_available = !1, this._scorm_version = "1.2"
  2021.     };
  2022.     Scorm.prototype = {
  2023.         init: function () {
  2024.             pipwerks.SCORM.version = this._scorm_version;
  2025.             var success = pipwerks.SCORM.init();
  2026.             success ? (console.log("Scorm init success: v" + pipwerks.SCORM.version), this._api_available = !0) : (console.log("Scorm init fail"), this._api_available = !1)
  2027.         }, storeScore: function (score) {
  2028.             "1.2" == this.scorm_version ? (pipwerks.SCORM.set("cmi.core.score.min", 0), pipwerks.SCORM.set("cmi.core.score.max", 100), pipwerks.SCORM.set("cmi.core.score.raw", score), pipwerks.SCORM.set("cmi.core.score.scaled", score / 100)) : (pipwerks.SCORM.set("cmi.score.min", 0), pipwerks.SCORM.set("cmi.score.max", 100), pipwerks.SCORM.set("cmi.score.raw", score), pipwerks.SCORM.set("cmi.score.scaled", score / 100)), console.log("Scorm store score : " + score)
  2029.         }, storeObjectives: function () {
  2030.             var criterions = SG.tracker.criterions, i = 0;
  2031.             for (var criterion_id in criterions) {
  2032.                 var score = SG.tracker.getCurrentPercentageForCriterionId(criterion_id);
  2033.                 pipwerks.SCORM.set("cmi.objectives." + i + ".id", "obj_loc_" + criterion_id), pipwerks.SCORM.set("cmi.objectives." + i + ".score.min", 0), pipwerks.SCORM.set("cmi.objectives." + i + ".score.max", 100), pipwerks.SCORM.set("cmi.objectives." + i + ".score.raw", score), "2004" == this.scorm_version && pipwerks.SCORM.set("cmi.objectives." + i + ".score.scaled", score / 100), i++
  2034.             }
  2035.         }, storeTrack: function (track) {
  2036.             pipwerks.SCORM.set("cmi.suspend_data", track), console.log("Scorm store track : " + track)
  2037.         }, storePlayTime: function (time) {
  2038.             "1.2" == this.scorm_version ? pipwerks.SCORM.set("cmi.core.session_time", time) : pipwerks.SCORM.set("cmi.session_time", time), console.log("Scorm store play time : " + time)
  2039.         }, storeGameCompleted: function () {
  2040.             "1.2" == this.scorm_version ? pipwerks.SCORM.set("cmi.core.lesson_status", "completed") : pipwerks.SCORM.set("cmi.completion_status", "completed"), console.log("Scorm storeGameCompleted : completed")
  2041.         }, getTrack: function (track) {
  2042.             var track = pipwerks.SCORM.get("cmi.suspend_data", track);
  2043.             return console.log("Scorm get track" + track), track
  2044.         }, save: function () {
  2045.             pipwerks.SCORM.save(), console.log("Scorm save in database.")
  2046.         }, quit: function () {
  2047.             pipwerks.SCORM.quit(), console.log("Scorm quit.")
  2048.         }
  2049.     }, Object.defineProperties(Scorm.prototype, {
  2050.         is_scorm: {
  2051.             get: function () {
  2052.                 return this._is_scorm
  2053.             }, set: function (is_scorm) {
  2054.                 this._is_scorm = is_scorm
  2055.             }
  2056.         }, api_available: {
  2057.             get: function () {
  2058.                 return this._api_available
  2059.             }, set: function (api_available) {
  2060.                 this._api_available = api_available
  2061.             }
  2062.         }, scorm_version: {
  2063.             get: function () {
  2064.                 return this._scorm_version
  2065.             }, set: function (scorm_version) {
  2066.                 this._scorm_version = scorm_version
  2067.             }
  2068.         }
  2069.     });
  2070.     var instance = null;
  2071.     return new function () {
  2072.         this.getInstance = function () {
  2073.             return null === instance && (instance = new Scorm), instance;
  2074.         }
  2075.     }
  2076. }(), SG.scorm = SG.Scorm.getInstance();
  2077. var amfphp;
  2078. amfphp || (amfphp = {}), amfphp.services = {}, amfphp.entryPointUrl = SG.core.base_url + "/gateway.php?contentType=application/json", amfphp.services.itysg__Echanges = {}, amfphp.services.itysg__Echanges.connexionJson = function (onSuccess, onError, login, password, key, uid, user_lang, from, client, globalscenario) {
  2079.     var callData = JSON.stringify({
  2080.         serviceName: "itysg__Echanges",
  2081.         methodName: "connexionJson",
  2082.         parameters: [login, password, key, uid, user_lang, from, client, globalscenario]
  2083.     });
  2084.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2085. }, amfphp.services.itysg__Echanges.loadGlobalScenarioJSON = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
  2086.     var callData = JSON.stringify({
  2087.         serviceName: "itysg__Echanges",
  2088.         methodName: "loadGlobalScenarioJson",
  2089.         parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
  2090.     });
  2091.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2092. }, amfphp.services.itysg__Echanges.Echanges = function (onSuccess, onError) {
  2093.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "Echanges", parameters: []});
  2094.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2095. }, amfphp.services.itysg__Echanges.getPermissionXmlDescription = function (onSuccess, onError, user_id) {
  2096.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getPermissionXmlDescription", parameters: [user_id]});
  2097.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2098. }, amfphp.services.itysg__Echanges.connexion = function (onSuccess, onError, login, password, user_lang) {
  2099.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "connexion", parameters: [login, password, user_lang]});
  2100.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2101. }, amfphp.services.itysg__Echanges.loadGlobaldatas = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
  2102.     var callData = JSON.stringify({
  2103.         serviceName: "itysg__Echanges",
  2104.         methodName: "loadGlobaldatas",
  2105.         parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
  2106.     });
  2107.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2108. }, amfphp.services.itysg__Echanges.loadScenario = function (onSuccess, onError, global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
  2109.     var callData = JSON.stringify({
  2110.         serviceName: "itysg__Echanges",
  2111.         methodName: "loadScenario",
  2112.         parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
  2113.     });
  2114.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2115. }, amfphp.services.itysg__Echanges.loadSceneryFromActScenario = function (onSuccess, onError, act_id, globalscenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
  2116.     var callData = JSON.stringify({
  2117.         serviceName: "itysg__Echanges",
  2118.         methodName: "loadSceneryFromActScenarioJson",
  2119.         parameters: [act_id, globalscenario_id, login, password, user_lang, conn_key, character_id, uid, client]
  2120.     });
  2121.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2122. }, amfphp.services.itysg__Echanges.saveGameProgression = function (onSuccess, onError, global_scenario_id, user_id, phase_index, track) {
  2123.     var callData = JSON.stringify({
  2124.         serviceName: "itysg__Echanges",
  2125.         methodName: "saveGameProgression",
  2126.         parameters: [global_scenario_id, user_id, phase_index, track]
  2127.     });
  2128.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2129. }, amfphp.services.itysg__Echanges.resetGameProgression = function (onSuccess, onError, global_scenario_id, user_id) {
  2130.     var callData = JSON.stringify({
  2131.         serviceName: "itysg__Echanges",
  2132.         methodName: "resetGameProgression",
  2133.         parameters: [global_scenario_id, user_id]
  2134.     });
  2135.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2136. }, amfphp.services.itysg__Echanges.sendTrack = function (onSuccess, onError, track, login, pwd, scenario_id, conn_key, uid) {
  2137.     var callData = JSON.stringify({
  2138.         serviceName: "itysg__Echanges",
  2139.         methodName: "sendTrack",
  2140.         parameters: [track, login, pwd, scenario_id, conn_key, uid]
  2141.     });
  2142.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2143. }, amfphp.services.itysg__Echanges.sendQuizzInfo = function (onSuccess, onError, stringInfo, login, pwd, scenario_id, conn_key, uid) {
  2144.     var callData = JSON.stringify({
  2145.         serviceName: "itysg__Echanges",
  2146.         methodName: "sendQuizzInfo",
  2147.         parameters: [stringInfo, login, pwd, scenario_id, conn_key, uid]
  2148.     });
  2149.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2150. }, amfphp.services.itysg__Echanges.sendVariousQuestionnaireEntry = function (onSuccess, onError, userlogi, userid, gsenarioid, questionnaire_id, label, value) {
  2151.     var callData = JSON.stringify({
  2152.         serviceName: "itysg__Echanges",
  2153.         methodName: "sendVariousQuestionnaireEntry",
  2154.         parameters: [userlogi, userid, gsenarioid, questionnaire_id, label, value]
  2155.     });
  2156.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2157. }, amfphp.services.itysg__Echanges.saveGenericDatas = function (onSuccess, onError, login, pwd, lang, datas) {
  2158.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "saveGenericDatas", parameters: [login, pwd, lang, datas]});
  2159.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2160. }, amfphp.services.itysg__Echanges.sendDemographicQuestionnaire = function (onSuccess, onError, userlogin, lang, age, sex, education_level, managerial_experience, country, nationality) {
  2161.     var callData = JSON.stringify({
  2162.         serviceName: "itysg__Echanges",
  2163.         methodName: "sendDemographicQuestionnaire",
  2164.         parameters: [userlogin, lang, age, sex, education_level, managerial_experience, country, nationality]
  2165.     });
  2166.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2167. }, amfphp.services.itysg__Echanges.sendSurfaceQuestionnaire = function (onSuccess, onError, userlogin, lang, enjoyable, remind_situation, go_futher_in_learning, look_realistic, too_long, change_vision_of_behaviour, enjoy_replay, discover_new_concept, choice_appropriate, seem_artificial) {
  2168.     var callData = JSON.stringify({
  2169.         serviceName: "itysg__Echanges",
  2170.         methodName: "sendSurfaceQuestionnaire",
  2171.         parameters: [userlogin, lang, enjoyable, remind_situation, go_futher_in_learning, look_realistic, too_long, change_vision_of_behaviour, enjoy_replay, discover_new_concept, choice_appropriate, seem_artificial]
  2172.     });
  2173.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2174. }, amfphp.services.itysg__Echanges.sendContactForm = function (onSuccess, onError, userlogin, type_id, text) {
  2175.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "sendContactForm", parameters: [userlogin, type_id, text]});
  2176.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2177. }, amfphp.services.itysg__Echanges.updateProposition = function (onSuccess, onError, proposition_id, lang, new_string_value) {
  2178.     var callData = JSON.stringify({
  2179.         serviceName: "itysg__Echanges",
  2180.         methodName: "updateProposition",
  2181.         parameters: [proposition_id, lang, new_string_value]
  2182.     });
  2183.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2184. }, amfphp.services.itysg__Echanges.addStage = function (onSuccess, onError, scenarioid, lang, stage_type) {
  2185.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "addStage", parameters: [scenarioid, lang, stage_type]});
  2186.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2187. }, amfphp.services.itysg__Echanges.updateStage = function (onSuccess, onError, id_stage, scenarioid, lang, label, description, color, size, x, y, act_id, stage_type, phase_id) {
  2188.     var callData = JSON.stringify({
  2189.         serviceName: "itysg__Echanges",
  2190.         methodName: "updateStage",
  2191.         parameters: [id_stage, scenarioid, lang, label, description, color, size, x, y, act_id, stage_type, phase_id]
  2192.     });
  2193.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2194. }, amfphp.services.itysg__Echanges.updatePropostionVerbose = function (onSuccess, onError, target, type, parent, active, short, lang, id, scenarioid, binMF, binFM, binFF, binMM, color, size) {
  2195.     var callData = JSON.stringify({
  2196.         serviceName: "itysg__Echanges",
  2197.         methodName: "updatePropostionVerbose",
  2198.         parameters: [target, type, parent, active, short, lang, id, scenarioid, binMF, binFM, binFF, binMM, color, size]
  2199.     });
  2200.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2201. }, amfphp.services.itysg__Echanges.removeStage = function (onSuccess, onError, stageid) {
  2202.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "removeStage", parameters: [stageid]});
  2203.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2204. }, amfphp.services.itysg__Echanges.addProposition = function (onSuccess, onError, source, target, lang, scenarioid) {
  2205.     var callData = JSON.stringify({
  2206.         serviceName: "itysg__Echanges",
  2207.         methodName: "addProposition",
  2208.         parameters: [source, target, lang, scenarioid]
  2209.     });
  2210.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2211. }, amfphp.services.itysg__Echanges.removeProposition = function (onSuccess, onError, propositionid) {
  2212.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "removeProposition", parameters: [propositionid]});
  2213.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2214. }, amfphp.services.itysg__Echanges.getScenarioTreeXML = function (onSuccess, onError, scenarioid, lang) {
  2215.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getScenarioTreeXML", parameters: [scenarioid, lang]});
  2216.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2217. }, amfphp.services.itysg__Echanges.saveTreePosition = function (onSuccess, onError, scenarioid, x, y, zoom) {
  2218.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "saveTreePosition", parameters: [scenarioid, x, y, zoom]});
  2219.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2220. }, amfphp.services.itysg__Echanges.setAndSaveFirstStageId = function (onSuccess, onError, scenarioid, stageid) {
  2221.     var callData = JSON.stringify({
  2222.         serviceName: "itysg__Echanges",
  2223.         methodName: "setAndSaveFirstStageId",
  2224.         parameters: [scenarioid, stageid]
  2225.     });
  2226.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2227. }, amfphp.services.itysg__Echanges.getDifficultiesData = function (onSuccess, onError, lang, scenario_id) {
  2228.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getDifficultiesData", parameters: [lang, scenario_id]});
  2229.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2230. }, amfphp.services.itysg__Echanges.getCriterionsForScenario = function (onSuccess, onError, lang, scenario_id) {
  2231.     var callData = JSON.stringify({
  2232.         serviceName: "itysg__Echanges",
  2233.         methodName: "getCriterionsForScenario",
  2234.         parameters: [lang, scenario_id]
  2235.     });
  2236.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2237. }, amfphp.services.itysg__Echanges.getTextsForFlashApp = function (onSuccess, onError, lang) {
  2238.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getTextsForFlashApp", parameters: [lang]});
  2239.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2240. }, amfphp.services.itysg__Echanges.saveAttributionPoint = function (onSuccess, onError, stageid, criterionid, value, level) {
  2241.     var callData = JSON.stringify({
  2242.         serviceName: "itysg__Echanges",
  2243.         methodName: "saveAttributionPoint",
  2244.         parameters: [stageid, criterionid, value, level]
  2245.     });
  2246.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2247. }, amfphp.services.itysg__Echanges.saveMultipleAttributionPointForStages = function (onSuccess, onError, stages, criterions, values, levels) {
  2248.     var callData = JSON.stringify({
  2249.         serviceName: "itysg__Echanges",
  2250.         methodName: "saveMultipleAttributionPointForStages",
  2251.         parameters: [stages, criterions, values, levels]
  2252.     });
  2253.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2254. }, amfphp.services.itysg__Echanges.saveMultipleAttributionPointForPropositions = function (onSuccess, onError, propositions, criterions, values, levels) {
  2255.     var callData = JSON.stringify({
  2256.         serviceName: "itysg__Echanges",
  2257.         methodName: "saveMultipleAttributionPointForPropositions",
  2258.         parameters: [propositions, criterions, values, levels]
  2259.     });
  2260.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2261. }, amfphp.services.itysg__Echanges.reloadPointsForStages = function (onSuccess, onError, stages) {
  2262.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "reloadPointsForStages", parameters: [stages]});
  2263.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2264. }, amfphp.services.itysg__Echanges.reloadPointsForPropositions = function (onSuccess, onError, propositions) {
  2265.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "reloadPointsForPropositions", parameters: [propositions]});
  2266.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2267. }, amfphp.services.itysg__Echanges.deleteAttributionPointForStage = function (onSuccess, onError, stageid, criterionid) {
  2268.     var callData = JSON.stringify({
  2269.         serviceName: "itysg__Echanges",
  2270.         methodName: "deleteAttributionPointForStage",
  2271.         parameters: [stageid, criterionid]
  2272.     });
  2273.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2274. }, amfphp.services.itysg__Echanges.deleteAttributionPointForProposition = function (onSuccess, onError, propositionid, criterionid) {
  2275.     var callData = JSON.stringify({
  2276.         serviceName: "itysg__Echanges",
  2277.         methodName: "deleteAttributionPointForProposition",
  2278.         parameters: [propositionid, criterionid]
  2279.     });
  2280.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2281. }, amfphp.services.itysg__Echanges.saveCriterionsChecked = function (onSuccess, onError, scenario_id, criterionsChecked) {
  2282.     var callData = JSON.stringify({
  2283.         serviceName: "itysg__Echanges",
  2284.         methodName: "saveCriterionsChecked",
  2285.         parameters: [scenario_id, criterionsChecked]
  2286.     });
  2287.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2288. }, amfphp.services.itysg__Echanges.onConnectToSGResults = function (onSuccess, onError, user_id) {
  2289.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "onConnectToSGResults", parameters: [user_id]});
  2290.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2291. }, amfphp.services.itysg__Echanges.getGlobalAccessFor = function (onSuccess, onError, user_id, role_id) {
  2292.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getGlobalAccessFor", parameters: [user_id, role_id]});
  2293.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2294. }, amfphp.services.itysg__Echanges.getScenarioAvailable = function (onSuccess, onError, user_id, lang) {
  2295.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getScenarioAvailable", parameters: [user_id, lang]});
  2296.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2297. }, amfphp.services.itysg__Echanges.getCriterionsDesc = function (onSuccess, onError, gscenario_id, lang) {
  2298.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getCriterionsDesc", parameters: [gscenario_id, lang]});
  2299.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2300. }, amfphp.services.itysg__Echanges.getAvailableDates = function (onSuccess, onError, scenario_id, user_id) {
  2301.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getAvailableDates", parameters: [scenario_id, user_id]});
  2302.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2303. }, amfphp.services.itysg__Echanges.getAvailableTracksForManager = function (onSuccess, onError, scenario_id, user_id) {
  2304.     var callData = JSON.stringify({
  2305.         serviceName: "itysg__Echanges",
  2306.         methodName: "getAvailableTracksForManager",
  2307.         parameters: [scenario_id, user_id]
  2308.     });
  2309.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2310. }, amfphp.services.itysg__Echanges.getTracks = function (onSuccess, onError, strTracksIds) {
  2311.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "getTracks", parameters: [strTracksIds]});
  2312.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2313. }, amfphp.services.itysg__Echanges.checkChangeActForStage = function (onSuccess, onError, scenarioId, stageId, newActId, lang) {
  2314.     var callData = JSON.stringify({
  2315.         serviceName: "itysg__Echanges",
  2316.         methodName: "checkChangeActForStage",
  2317.         parameters: [scenarioId, stageId, newActId, lang]
  2318.     });
  2319.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2320. }, amfphp.services.itysg__Echanges.ChangeStageDifferenceForNewAct = function (onSuccess, onError, scenarioId, stageId, newActId, lang, string_reassign) {
  2321.     var callData = JSON.stringify({
  2322.         serviceName: "itysg__Echanges",
  2323.         methodName: "ChangeStageDifferenceForNewAct",
  2324.         parameters: [scenarioId, stageId, newActId, lang, string_reassign]
  2325.     });
  2326.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2327. }, amfphp.services.itysg__Echanges.getStageMediaName = function (onSuccess, onError, phase_id, animation_type) {
  2328.     var callData = JSON.stringify({
  2329.         serviceName: "itysg__Echanges",
  2330.         methodName: "getStageMediaName",
  2331.         parameters: [phase_id, animation_type]
  2332.     });
  2333.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2334. }, amfphp.services.itysg__Echanges.log_entry = function (onSuccess, onError, message, uid, type) {
  2335.     var callData = JSON.stringify({serviceName: "itysg__Echanges", methodName: "log_entry", parameters: [message, uid, type]});
  2336.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2337. }, amfphp.services.itysg__Echanges.SaveReassignSound = function (onSuccess, onError, string_reassign, stage_id) {
  2338.     var callData = JSON.stringify({
  2339.         serviceName: "itysg__Echanges",
  2340.         methodName: "SaveReassignSound",
  2341.         parameters: [string_reassign, stage_id]
  2342.     });
  2343.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2344. }, amfphp.services.itysg__Echanges.SaveReassignSound = function (onSuccess, onError, string_reassign, stage_id) {
  2345.     var callData = JSON.stringify({
  2346.         serviceName: "itysg__Echanges",
  2347.         methodName: "SaveReassignSound",
  2348.         parameters: [string_reassign, stage_id]
  2349.     });
  2350.     $.post(amfphp.entryPointUrl, callData, onSuccess).error(onError)
  2351. }, angular.module("itysg", ["ui.router", "ui.bootstrap", "ngDialog", "ngAnimate", "ngSanitize", "ngAria", "ngMaterial", "itysg.directives", "itysg.config", "itysg.controllers", "itysg.services"]).run(["Core", "BASE_URL", "MEDIAS_URL", "GLOBAL_SCENARIO_ID", "USER_ID", "KEY", "VERSION", "LANG", "CUSTOMER_ID", "EXPORT_RESULTS", "IS_SCORM", "SCORM_VERSION", "NUMBER_VERSION", "OFFLINE", "DEBUG", function (Core, BASE_URL, MEDIAS_URL, GLOBAL_SCENARIO_ID, USER_ID, KEY, VERSION, LANG, CUSTOMER_ID, EXPORT_RESULTS, IS_SCORM, SCORM_VERSION, NUMBER_VERSION, OFFLINE, DEBUG) {
  2352.     console.log("ITycom Serious Games"), Core.offline = OFFLINE, IS_SCORM && (SG.scorm.is_scorm = IS_SCORM, SG.scorm.scorm_version = SCORM_VERSION), Core.export_results = EXPORT_RESULTS, Core.lang = LANG, Core.version = VERSION, Core.num_version = NUMBER_VERSION, Core.user = new SG.Model.User(USER_ID, KEY, CUSTOMER_ID, null), Core.global_scenario_id = GLOBAL_SCENARIO_ID, Core.base_url = BASE_URL, Core._medias_url = MEDIAS_URL, Core.debug_mode = DEBUG, SG.core.init(), SG.scorm.is_scorm && SG.scorm.init()
  2353. }]);
  2354. var params = params || {};
  2355. angular.module("itysg.config", []).constant("BASE_URL", params.base_url || "").constant("MEDIAS_URL", params.medias_url || "").constant("GLOBAL_SCENARIO_ID", params.scenario_id || -1).constant("USER_ID", params.user_id || -1).constant("KEY", params.key || -1).constant("VERSION", params.version || "").constant("LANG", params.language).constant("CUSTOMER_ID", params.customer_id || 0).constant("EXPORT_RESULTS", "boolean" != typeof params.export_results || params.export_results).constant("OFFLINE", params.offline || !1).constant("IS_SCORM", params.is_scorm || !1).constant("SCORM_VERSION", params.scorm_version || !1).constant("DEBUG", params.debug || !1).constant("NUMBER_VERSION", 1).constant("SUBTITLE_ENABLE", "boolean" != typeof params.subtitle_enable || params.subtitle_enable), angular.module("itysg.controllers", ["cgBusy"]), angular.module("itysg.services", []), angular.module("itysg.routes", []), angular.module("itysg.directives", []), angular.module("itysg").config(["$stateProvider", "$urlRouterProvider", "$locationProvider", "$mdThemingProvider", function ($stateProvider, $urlRouterProvider, $locationProvider, $mdThemingProvider) {
  2356.     var customPrimary = {
  2357.         50: "#ffffff",
  2358.         100: "#ffffff",
  2359.         200: "#ffffff",
  2360.         300: "#ffffff",
  2361.         400: "#ffffff",
  2362.         500: "#ffffff",
  2363.         600: "#f2f2f2",
  2364.         700: "#e6e6e6",
  2365.         800: "#d9d9d9",
  2366.         900: "#cccccc",
  2367.         A100: "#ffffff",
  2368.         A200: "#ffffff",
  2369.         A400: "#ffffff",
  2370.         A700: "#bfbfbf"
  2371.     };
  2372.     $mdThemingProvider.definePalette("customPrimary", customPrimary);
  2373.     var customAccent = {
  2374.         50: "#205378",
  2375.         100: "#25618c",
  2376.         200: "#2b6fa0",
  2377.         300: "#307db5",
  2378.         400: "#358bc9",
  2379.         500: "#4996cf",
  2380.         600: "#71aed9",
  2381.         700: "#85b9df",
  2382.         800: "#99c5e4",
  2383.         900: "#aed0e9",
  2384.         A100: "#71aed9",
  2385.         A200: "#5da2d4",
  2386.         A400: "#4996cf",
  2387.         A700: "#c2dcef"
  2388.     };
  2389.     $mdThemingProvider.definePalette("customAccent", customAccent);
  2390.     var customWarn = {
  2391.         50: "#fbce99",
  2392.         100: "#fac280",
  2393.         200: "#fab668",
  2394.         300: "#f9ab4f",
  2395.         400: "#f89f37",
  2396.         500: "#F7931E",
  2397.         600: "#f38709",
  2398.         700: "#da7908",
  2399.         800: "#c26c07",
  2400.         900: "#a95e06",
  2401.         A100: "#fcdab2",
  2402.         A200: "#fde6ca",
  2403.         A400: "#fef2e3",
  2404.         A700: "#905005"
  2405.     };
  2406.     $mdThemingProvider.definePalette("customWarn", customWarn);
  2407.     var customBackground = {
  2408.         50: "#737373",
  2409.         100: "#666666",
  2410.         200: "#595959",
  2411.         300: "#4d4d4d",
  2412.         400: "#404040",
  2413.         500: "#333",
  2414.         600: "#262626",
  2415.         700: "#1a1a1a",
  2416.         800: "#0d0d0d",
  2417.         900: "#000000",
  2418.         A100: "#808080",
  2419.         A200: "#8c8c8c",
  2420.         A400: "#999999",
  2421.         A700: "#000000"
  2422.     };
  2423.     $mdThemingProvider.definePalette("customBackground", customBackground), $mdThemingProvider.theme("default").primaryPalette("customPrimary").accentPalette("customAccent").warnPalette("customWarn").backgroundPalette("customBackground"), $stateProvider.state("index", {
  2424.         url: "/",
  2425.         templateUrl: "templates/views/index.html",
  2426.         controller: "IndexCtrl"
  2427.     }).state("connection", {
  2428.         templateUrl: "templates/views/connection.html",
  2429.         controller: "ConnectionCtrl"
  2430.     }).state("message", {
  2431.         templateUrl: "templates/views/message.html",
  2432.         controller: "MessageCtrl"
  2433.     }).state("chooseCharacter", {
  2434.         templateUrl: "templates/views/chooseCharacter.html",
  2435.         controller: "ChooseCharacterCtrl"
  2436.     }).state("loadingData", {controller: "LoadingDatasCtrl"}).state("phase", {
  2437.         templateUrl: "templates/views/phase/phase.html",
  2438.         controller: "PhaseCtrl"
  2439.     }).state("phase.BobSpeech", {template: '<ity-phase ity-bobspeech phase="current_phase" sceneries="sceneries" class="phase-content"></ity-phase>'}).state("phase.WebPhase", {template: '<ity-phase ity-webphase phase="current_phase" sceneries="sceneries"></ity-phase>'}).state("phase.Scenario", {template: ""}).state("phase.KinematicPhase", {template: '<ity-phase ity-kinematicphase phase="current_phase"></ity-phase>'}).state("phase.AnimationPhase", {template: '<ity-phase ity-kinematicphase phase="current_phase"></ity-phase>'}).state("phase.Quizz", {template: '<ity-phase ity-quizz-base phase="current_phase"></ity-phase>'}).state("phase.CharacterSelection", {template: '<ity-phase ity-character-selection phase="current_phase"></ity-phase>'}).state("phase.EndGame", {template: '<ity-phase ity-end-game class="phase-content"></ity-phase>'}), $urlRouterProvider.otherwise("/");
  2440.     var customPrimary = {
  2441.         50: "#ffffff",
  2442.         100: "#ffffff",
  2443.         200: "#ffffff",
  2444.         300: "#ffffff",
  2445.         400: "#ffffff",
  2446.         500: "#ffffff",
  2447.         600: "#f2f2f2",
  2448.         700: "#e6e6e6",
  2449.         800: "#d9d9d9",
  2450.         900: "#cccccc",
  2451.         A100: "#ffffff",
  2452.         A200: "#ffffff",
  2453.         A400: "#ffffff",
  2454.         A700: "#bfbfbf"
  2455.     }
  2456. }]), SG.Utils.mouse = {}, SG.Utils.mouse.origin = {x: 0, y: 0}, SG.Utils.mouse.position = {
  2457.     x: 0,
  2458.     y: 0
  2459. }, SG.Utils.mouse.down = !1, SG.Utils.mouse.mousedown = "mousedown", SG.Utils.mouse.mouseup = "mouseup", SG.Utils.mouse.mousemove = "mousemove", SG.Utils.mouse.supportsTouch = "ontouchstart" in document.documentElement, SG.Utils.mouse.supportsTouch ? (SG.Utils.mouse.mousedown = "touchstart", SG.Utils.mouse.mouseup = "touchend", SG.Utils.mouse.mousemove = "touchmove", $("body").on("touchstart", function (e) {
  2460.     SG.Utils.mouse.onMouseDown(e)
  2461. }), $("body").on("touchend", function (e) {
  2462.     SG.Utils.mouse.onMouseUp(e)
  2463. }), $("body").on("touchmove", function (e) {
  2464.     SG.Utils.mouse.onMouseMove(e)
  2465. })) : ($("body").mousedown(function (e) {
  2466.     SG.Utils.mouse.onMouseDown(e)
  2467. }), $("body").mouseup(function (e) {
  2468.     SG.Utils.mouse.onMouseUp(e)
  2469. }), $("body").mousemove(function (e) {
  2470.     SG.Utils.mouse.onMouseMove(e)
  2471. })), SG.Utils.mouse.getEvent = function (e) {
  2472.     return e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent.changedTouches ? e.originalEvent.changedTouches[0] : e
  2473. }, SG.Utils.mouse.onMouseDown = function (e) {
  2474.     var event = SG.Utils.mouse.getEvent(e);
  2475.     SG.Utils.mouse.origin.x = event.pageX, SG.Utils.mouse.origin.y = event.pageY, SG.Utils.mouse.down = !0
  2476. }, SG.Utils.mouse.onMouseUp = function () {
  2477.     SG.Utils.mouse.down = !1
  2478. }, SG.Utils.mouse.onMouseMove = function (e) {
  2479.     var event = SG.Utils.mouse.getEvent(e);
  2480.     SG.Utils.mouse.position.x = event.pageX, SG.Utils.mouse.position.y = event.pageY
  2481. }, SG.Utils.Scrollbar = function () {
  2482.     this._clicking = !1, this._oldTop = 0, this._element, this._speed = 20, this._padding = 10, this._invert = !1, this._ratio = 1, this._scrollable = {}, this._scrollable.element, this._scrollable.realHeight = 0, this._scrollable.height = 0, this._container = {}, this._container.element, this._visible = !1
  2483. }, SG.Utils.Scrollbar.prototype.setScrollSystem = function (scrollbarEl, scrollableEl) {
  2484.     var _this = this;
  2485.     this.element = scrollbarEl, this.container.element = this.element.parent(), this.scrollable.element = scrollableEl, this.element.css("top", this.padding + "px"), this.scrollable.element.scrollTop(0), this.updateHeight(), this.element.parent().on(SG.Utils.mouse.mousedown, function (e) {
  2486.         SG.Utils.mouse.supportsTouch && (SG.Utils.mouse.origin.y = e.originalEvent.changedTouches[0].pageY), _this.scroll(SG.Utils.mouse.position.y - _this.element.parent().offset().top - _this.element.height() / 2), _this.startScroll()
  2487.     }), this.element.parent().on(SG.Utils.mouse.mousemove, function (e) {
  2488.         e.preventDefault()
  2489.     }), this.setScrollControl(this.scrollable.element), $("body").on(SG.Utils.mouse.mouseup, function () {
  2490.         _this.stopScroll()
  2491.     }), $("body").on(SG.Utils.mouse.mousemove, function () {
  2492.         if (_this.clicking) {
  2493.             var newTop = 0;
  2494.             newTop = _this.invert ? _this.oldTop + (SG.Utils.mouse.origin.y - SG.Utils.mouse.position.y) * _this.ratio : _this.oldTop + (SG.Utils.mouse.position.y - SG.Utils.mouse.origin.y), _this.scroll(newTop)
  2495.         }
  2496.     }), $(window).resize(function () {
  2497.         _this.updateHeight()
  2498.     })
  2499. }, SG.Utils.Scrollbar.prototype.setScrollControl = function (element) {
  2500.     var _this = this;
  2501.     element.on(SG.Utils.mouse.mousemove, function (e) {
  2502.         _this.visible && e.preventDefault()
  2503.     }), element.bind("DOMMouseScroll", function (e) {
  2504.         return _this.visible && (_this.oldTop = parseFloat(_this.element.css("top")), e.originalEvent.detail > 0 ? _this.scroll(_this.oldTop + _this.speed * _this.ratio) : _this.scroll(_this.oldTop - _this.speed * _this.ratio)), !_this.visible
  2505.     }), element.bind("mousewheel", function (e) {
  2506.         return _this.visible && (_this.oldTop = parseFloat(_this.element.css("top")), e.originalEvent.wheelDelta < 0 ? _this.scroll(_this.oldTop + _this.speed * _this.ratio) : _this.scroll(_this.oldTop - _this.speed * _this.ratio)), !_this.visible
  2507.     }), element.on(SG.Utils.mouse.mousedown, function () {
  2508.         _this.startScroll(), _this.invert = !0
  2509.     })
  2510. }, SG.Utils.Scrollbar.prototype.stopScroll = function () {
  2511.     this._clicking = !1, this.invert = !1
  2512. }, SG.Utils.Scrollbar.prototype.startScroll = function () {
  2513.     this.oldTop = parseInt(this.element.css("top")), this._clicking = !0
  2514. }, SG.Utils.Scrollbar.prototype.updateHeight = function () {
  2515.     this.scrollable.realHeight = this.scrollable.element[0].scrollHeight, this.scrollable.height = this.scrollable.element.height(), this._ratio = this.scrollable.height / this.scrollable.realHeight, this.ratio < 1 ? (this.container.element.show(), this._visible = !0, this.element.css("height", 100 * this.ratio + "%")) : (this.container.element.hide(), this._visible = !1), this.scroll(this.scrollable.element.scrollTop())
  2516. }, SG.Utils.Scrollbar.prototype.scroll = function (newTop) {
  2517.     var barHeight = this.element.height(), newBottom = newTop + barHeight, containerHeigth = this.container.element.outerHeight();
  2518.     if (newTop > 0 + this.padding && newBottom < containerHeigth - this.padding) {
  2519.         this.element.css("top", newTop + "px");
  2520.         var percent = (newTop - this.padding) / (containerHeigth - 2 * this.padding - barHeight);
  2521.         this.scrollable.element.scrollTop(percent * (this.scrollable.realHeight - this.scrollable.element.height()))
  2522.     } else newTop <= this.padding ? (this.element.css("top", this.padding + "px"), this.scrollable.element.scrollTop(0)) : newBottom >= containerHeigth - this.padding && (this.element.css("top", containerHeigth - barHeight - this.padding + "px"), this.scrollable.element.scrollTop(this.scrollable.realHeight))
  2523. }, Object.defineProperties(SG.Utils.Scrollbar.prototype, {
  2524.     clicking: {
  2525.         get: function () {
  2526.             return this._clicking
  2527.         }
  2528.     }, oldTop: {
  2529.         get: function () {
  2530.             return this._oldTop
  2531.         }, set: function (value) {
  2532.             this._oldTop = value
  2533.         }
  2534.     }, element: {
  2535.         get: function () {
  2536.             return this._element
  2537.         }, set: function (value) {
  2538.             this._element = value
  2539.         }
  2540.     }, speed: {
  2541.         get: function () {
  2542.             return this._speed
  2543.         }, set: function (value) {
  2544.             this._speed = value
  2545.         }
  2546.     }, padding: {
  2547.         get: function () {
  2548.             return this._padding
  2549.         }, set: function (value) {
  2550.             this._padding = value
  2551.         }
  2552.     }, scrollable: {
  2553.         get: function () {
  2554.             return this._scrollable
  2555.         }
  2556.     }, invert: {
  2557.         get: function () {
  2558.             return this._invert
  2559.         }, set: function (value) {
  2560.             this._invert = value
  2561.         }
  2562.     }, ratio: {
  2563.         get: function () {
  2564.             return this._ratio
  2565.         }
  2566.     }, visible: {
  2567.         get: function () {
  2568.             return this._visible
  2569.         }
  2570.     }, container: {
  2571.         get: function () {
  2572.             return this._container
  2573.         }
  2574.     }
  2575. }), SG.Utils.AudioPlayer = function () {
  2576.     this._audio, this._player, this._playButton, this._stopButton, this._bar, this._barwrap, this._updateRate = 20, this._updateThread, this._old_pos = {}, this._clicking = !1, this._percent
  2577. }, SG.Utils.AudioPlayer.prototype.createPlayer = function (audio, player) {
  2578.     var _this = this;
  2579.     this._audio = audio, this._player = player, this._playButton = player.children(".play"), this._stopButton = player.children(".rewind"), this._muteButton = player.children(".sound"), this._barwrap = player.children(".bar-wrap"), this._bar = this._barwrap.children(".bar"), this._playButton.click(function () {
  2580.         _this.play()
  2581.     }), this._stopButton.click(function () {
  2582.         _this.rewind()
  2583.     }), this._muteButton.click(function () {
  2584.         _this.mute()
  2585.     }), this._barwrap.on(SG.Utils.mouse.mousedown, function (e) {
  2586.         e.preventDefault(), SG.Utils.mouse.onMouseDown(e), _this._clicking = !0, _this._old_pos = _this._barwrap.offset().left;
  2587.         var pos = SG.Utils.mouse.origin.x - _this._barwrap.offset().left, percent = pos / _this._barwrap.width();
  2588.         _this._percent = percent, _this._bar.css("width", 100 * percent + "%"), _this._audio.currentTime = _this._audio.duration * percent
  2589.     }), this._barwrap.on(SG.Utils.mouse.mousemove, function () {
  2590.         if (_this._clicking) {
  2591.             var pos = SG.Utils.mouse.position.x - _this._old_pos, percent = pos / _this._barwrap.width();
  2592.             _this._percent = percent, _this._bar.css("width", 100 * percent + "%")
  2593.         }
  2594.     }), $("body").on(SG.Utils.mouse.mouseup, function () {
  2595.         _this._clicking && (_this._clicking = !1, _this._audio.currentTime = _this._audio.duration * _this._percent)
  2596.     })
  2597. }, SG.Utils.AudioPlayer.prototype.play = function () {
  2598.     var _this = this;
  2599.     this._audio.paused ? (this._audio.play(), this._playButton.addClass("pause"), this._updateThread = setInterval(function () {
  2600.         _this.updatePlayer()
  2601.     }, this._updateRate)) : this.pause()
  2602. }, SG.Utils.AudioPlayer.prototype.pause = function () {
  2603.     var _this = this;
  2604.     this._audio.pause(), this._playButton.removeClass("pause"), clearInterval(_this._updateThread)
  2605. }, SG.Utils.AudioPlayer.prototype.stop = function () {
  2606.     var _this = this;
  2607.     this._audio.pause(_this), this._audio.currentTime = 0, this._bar.css("width", "0%"), this._playButton.removeClass("pause"), clearInterval(_this._updateThread)
  2608. }, SG.Utils.AudioPlayer.prototype.rewind = function () {
  2609.     this._audio.currentTime = 0, this._bar.css("width", "0%")
  2610. }, SG.Utils.AudioPlayer.prototype.updatePlayer = function () {
  2611.     if (this._audio.paused) this._audio.currentTime == this._audio.duration && (this._bar.css("width", "100%"), this.pause(), this._audio.currentTime = 0); else {
  2612.         if (this._clicking) return;
  2613.         this._bar.css("width", this._audio.currentTime / this._audio.duration * 100 + "%")
  2614.     }
  2615. }, Object.defineProperties(SG.Utils.AudioPlayer.prototype, {
  2616.     audio: {
  2617.         get: function () {
  2618.             return this._audio
  2619.         }, set: function (value) {
  2620.             this._audio = value
  2621.         }
  2622.     }, updateThread: {
  2623.         get: function () {
  2624.             return this._updateThread
  2625.         }
  2626.     }, player: {
  2627.         get: function () {
  2628.             return this._player
  2629.         }, set: function (value) {
  2630.             this._player = value
  2631.         }
  2632.     }, playButton: {
  2633.         get: function () {
  2634.             return this._playButton
  2635.         }, set: function (value) {
  2636.             this._playButton = value
  2637.         }
  2638.     }, stopButton: {
  2639.         get: function () {
  2640.             return this._stopButton
  2641.         }, set: function (value) {
  2642.             this._stopButton = value
  2643.         }
  2644.     }, bar: {
  2645.         get: function () {
  2646.             return this._bar
  2647.         }, set: function (value) {
  2648.             this._bar = value
  2649.         }
  2650.     }, barwrap: {
  2651.         get: function () {
  2652.             return this._barwrap
  2653.         }, set: function (value) {
  2654.             this._barwrap = value
  2655.         }
  2656.     }, updateRate: {
  2657.         get: function () {
  2658.             return this._updateRate
  2659.         }, set: function (value) {
  2660.             this._updateRate = value
  2661.         }
  2662.     }
  2663. }), angular.module("itysg.controllers").controller("MainCtrl", ["$scope", "$state", "$timeout", "SUBTITLE_ENABLE", function ($scope, $state, $timeout, SUBTITLE_ENABLE) {
  2664.     var DEFAULT_LOGO = "assets/images/default_logo.png";
  2665.     $scope.menu_is_display = !1, $scope.is_pause = !1, $scope.sound_is_mute = !1, $scope.subtitle_are_enable = SUBTITLE_ENABLE, $scope.displayScenario = !1, $scope.blurScenario = !1, $scope.ready_to_show = !1, $scope.first_ready_to_show = !1, $scope.msg_content = "", $scope.msg_title = "", $scope.msg_buttons = [], $scope.module_name = "", $scope.module_logo = DEFAULT_LOGO, $scope.main_overlay = !1, $scope.total_tasks = 2, $scope.task_count = 0, $scope.show_loading = !1, $scope.loading_text = "0%", $scope.$on("showOverlay", function (e, value) {
  2666.         $scope.main_overlay = value, $scope.main_overlay ? $(".main-overlay").addClass("visible") : $(".main-overlay").removeClass("visible")
  2667.     }), $scope.$on("setModuleName", function (e, value) {
  2668.         $scope.module_name = value
  2669.     }), $scope.$on("setModuleLogo", function (e, value) {
  2670.         $scope.module_logo = value
  2671.     }), $scope.$on("setDefaultLogo", function () {
  2672.         $scope.module_logo = DEFAULT_LOGO
  2673.     }), $scope.$on("setTaskCount", function (e, task_count) {
  2674.         $scope.task_count = task_count
  2675.     }), $scope.$on("setTotalTasks", function (e, total_tasks) {
  2676.         $scope.total_tasks = total_tasks
  2677.     }), $scope.$on("reportProgress", function (e, value) {
  2678.         $scope.loading_text = Math.floor(value / $scope.total_tasks + 100 / $scope.total_tasks * $scope.task_count) + "%"
  2679.     }), $scope.$on("showLoading", function (e, value) {
  2680.         $scope.show_loading = value
  2681.     }), $scope.$on("showMessage", function (e, title, message, buttons) {
  2682.         $scope.show_loading = !1, $scope.msg_content = message,
  2683.             $scope.msg_title = title, $scope.msg_buttons = buttons, $scope.goTo("message")
  2684.     }), $scope.$on("readyToShow", function (e, value) {
  2685.         $scope.ready_to_show = value, !$scope.first_ready_to_show && value && ($timeout(resizeIntroBg), $scope.first_ready_to_show = !0)
  2686.     });
  2687.     var current_state = "";
  2688.     $scope.i18n = SG.core.i18n, $scope.goTo = function (path) {
  2689.         path == current_state ? $state.reload(path) : $state.go(path), current_state = path
  2690.     };
  2691.     var getGameOffset = function () {
  2692.         var gameWidth = 980, gameHeight = 518, offset = {x: 0, y: 0, height: 0, width: 0}, width = $(document).width(),
  2693.             height = $(document).height(), ratio_game = gameWidth / gameHeight, ratio_window = width / height;
  2694.         return ratio_window < ratio_game ? (offset.height = width / ratio_game, offset.width = width, offset.y = (height - width / ratio_game) / 2) : (offset.width = height * ratio_game, offset.height = height, offset.x = (width - height * ratio_game) / 2), offset
  2695.     }, resizeIntroBg = function () {
  2696.         if ($scope.first_ready_to_show) {
  2697.             var el = $(".intro-background"), bounds = getGameOffset();
  2698.             el.width(bounds.width), el.height(bounds.height), el.offset({left: bounds.x, top: bounds.y})
  2699.         }
  2700.     };
  2701.     $(window).resize(resizeIntroBg), $scope.spinnerTpl = "templates/loadingSpinner.html", $scope.delayBusy = 200
  2702. }]), angular.module("itysg.controllers").controller("IndexCtrl", ["$scope", "$rootScope", function ($scope, $rootScope) {
  2703.     $scope.goTo("connection")
  2704. }]), angular.module("itysg.controllers").controller("ConnectionCtrl", ["$scope", "Core", "Echange", "$timeout", function ($scope, Core, Echange, $timeout) {
  2705.     console.log("CONNEXION"), $(".engine-loading").attr("style", "");
  2706.     var keep_progress_faker = !0, progress_faker_percent = 0, progress_faker = function () {
  2707.         progress_faker_percent += 2, $scope.$emit("reportProgress", progress_faker_percent);
  2708.         var rnd_delay = 10 * (Math.floor(50 * Math.random()) + 10);
  2709.         keep_progress_faker && progress_faker_percent < 98 && $timeout(progress_faker, rnd_delay)
  2710.     };
  2711.     $scope.password = SG.password, $scope.login = SG.login;
  2712.     var connect = function () {
  2713.         if ($scope.$emit("setTotalTasks", 2), $scope.$emit("setTaskCount", 0), $scope.$emit("showLoading", !0), $scope.$emit("reportProgress", 0), $timeout(progress_faker, 200), Core.user.id > 0 && Core.user.key.length > 0) $scope.connection("", "", Core.user.id, Core.user.key); else if (Core.user.login && Core.user.password) $scope.connection(Core.user.login, Core.user.password); else if (Core.offline) {
  2714.             var connectionPromise = Echange.connectionOffline();
  2715.             connectionPromise.then(function (datas) {
  2716.                 $scope.checkAuthenticationDatas(datas)
  2717.             }), $scope.busy.promise = connectionPromise
  2718.         } else $scope.displayForm = !0
  2719.     };
  2720.     $scope.connection = function (login, password, user_id, key) {
  2721.         var connectionPromise = Echange.connection(login, password, key, user_id, Core.lang, "client", "html5", Core.global_scenario_id);
  2722.         connectionPromise.then(function (datas) {
  2723.             $scope.checkAuthenticationDatas(datas)
  2724.         }, function (error) {
  2725.             console.log("error")
  2726.         }), $scope.busy.promise = connectionPromise
  2727.     }, $scope.checkAuthenticationDatas = function (datas) {
  2728.         keep_progress_faker = !1;
  2729.         try {
  2730.             var jsonData;
  2731.             jsonData = Core.offline ? datas : JSON.parse(datas), console.log(jsonData), 0 === jsonData.authentification ? (console.log("Authentication failed"), $scope.displayForm = !0) : (console.log("Authentication success"), Core.user = new SG.Model.User(jsonData.uid, jsonData.authentification.value, jsonData.authentification.cid, jsonData.access), jsonData.users.forEach(function (user) {
  2732.                 Core.characters.push(new SG.Model.Character(user, Core.global_scenario_id))
  2733.             }), $scope.displayForm = !1, $scope.goTo("loadingData"))
  2734.         } catch (e) {
  2735.             var buttons = [];
  2736.             buttons.push({
  2737.                 text: "Retour à ITyStudio", callback: function () {
  2738.                     window.location.href = SG.core.base_url
  2739.                 }
  2740.             }), $scope.$emit("showMessage", "Erreur", "Vous n'êtes pas connecté.<br/><br/>Détails : " + e.message, buttons)
  2741.         }
  2742.     }, $scope.onConnectionError = function (error) {
  2743.         $scope.displayForm = !0, console.log("Fatal error : Connection failed"), console.log(error)
  2744.     }, $scope.busy = {message: Core.i18n.loading + " - 1/2", delay: $scope.delayBusy, templateUrl: $scope.spinnerTpl}, connect()
  2745. }]), angular.module("itysg.controllers").controller("LoadingDatasCtrl", ["$scope", "$http", "Core", "Echange", "$timeout", function ($scope, $http, Core, Echange, $timeout) {
  2746.     var keep_progress_faker = !0, progress_faker_percent = 0, progress_faker = function () {
  2747.         progress_faker_percent += 2, $scope.$emit("reportProgress", progress_faker_percent);
  2748.         var rnd_delay = 10 * (Math.floor(50 * Math.random()) + 10);
  2749.         keep_progress_faker && progress_faker_percent < 98 && $timeout(progress_faker, rnd_delay)
  2750.     }, loadData = function () {
  2751.         $scope.$emit("setTaskCount", 1), $scope.$emit("reportProgress", 0), $timeout(progress_faker, 200);
  2752.         var loadGlobalScenarioPromise;
  2753.         loadGlobalScenarioPromise = Core.offline ? Echange.loadGlobalScenarioOffline(Core.global_scenario_id) : Echange.loadGlobalScenario(Core.global_scenario_id, "", "", Core.lang, Core.user.key, "", Core.user.id, "html5"), loadGlobalScenarioPromise.then(function (datas) {
  2754.             $scope.onLoadSuccess(datas)
  2755.         }), $scope.busy.promise = loadGlobalScenarioPromise
  2756.     };
  2757.     $scope.onLoadSuccess = function (datas) {
  2758.         $scope.$emit("reportProgress", 100), keep_progress_faker = !1;
  2759.         try {
  2760.             console.log("load global scenario success");
  2761.             var datas_json;
  2762.             datas_json = Core.offline ? datas : JSON.parse(datas), Core.global_scenario = new SG.Model.GlobalScenario(datas_json.datas), $scope.$emit("setMenuEnabled", !0), $scope.$emit("showLoading", !1), $scope.goTo("phase")
  2763.         } catch (e) {
  2764.             var buttons = [];
  2765.             buttons.push({
  2766.                 text: "Retour à ITyStudio", callback: function () {
  2767.                     window.location.href = SG.core.base_url
  2768.                 }
  2769.             }), $scope.$emit("showMessage", "Erreur", "Impossible de récupérer les données du jeu.<br/><br/>Détails : " + e.message, buttons)
  2770.         }
  2771.     }, $scope.onLoadError = function (error) {
  2772.         $scope.goTo("connection")
  2773.     }, $scope.busy = {message: Core.i18n.loading + " - 2/2", delay: $scope.delayBusy, templateUrl: $scope.spinnerTpl}, loadData()
  2774. }]), angular.module("itysg.controllers").controller("PhaseCtrl", ["$rootScope", "$scope", "Core", "$interval", "$timeout", function ($rootScope, $scope, Core, $interval, $timeout) {
  2775.     var ROOT_STATE = "phase.";
  2776.     $scope.ROOT_STATE = ROOT_STATE, $scope.menu_is_display = !0, $scope.phase_name = "", $scope.act_stage_id, $scope.scenario_directive_ready = !1;
  2777.     var init = function () {
  2778.         $scope.$emit("setModuleName", Core.global_scenario.names[SG.core.lang]), Core.global_scenario.corner_logo ? $scope.$emit("setModuleLogo", Core.global_scenario.corner_logo) : $scope.$emit("setDefaultLogo"), $scope.copyLogoInPhase(), $scope.$emit("showOverlay", !0), $scope.current_phase = SG.phase_manager.getCurrentPhase(), $scope.sceneries = Core.global_scenario.sceneries;
  2779.         var phase_name = SG.phase_manager.getCurrentPhase().name, phase_is_scenario = "Scenario" === phase_name,
  2780.             scenario_directive_checker = $interval(function () {
  2781.                 $scope.scenario_directive_ready && ($interval.cancel(scenario_directive_checker), $scope.$emit("scenarioIsReady", phase_is_scenario), "Scenario" == phase_name ? (displayScenario(!1, !1), $scope.goTo(ROOT_STATE + "CharacterSelection")) : (displayScenario(!1), $scope.$emit("setGamePaused", !0), $scope.goTo(ROOT_STATE + phase_name)))
  2782.             }, 250)
  2783.     };
  2784.     $scope.logoInPhase = !1, $scope.copyLogoInPhase = function () {
  2785.         $timeout(function () {
  2786.             if (0 == $scope.logoInPhase) {
  2787.                 var phase_content = angular.element(document.getElementsByClassName("phase-content")),
  2788.                     module_logo = angular.element(document.getElementsByClassName("module-logo"));
  2789.                 phase_content.append(module_logo), $scope.logoInPhase = !0
  2790.             }
  2791.         })
  2792.     }, $scope.$on("characterSelection", function (e, stage_id) {
  2793.         displayScenario(!1, !1), $scope.act_stage_id = stage_id, $scope.goTo("phase.CharacterSelection")
  2794.     });
  2795.     var endGame = function () {
  2796.         SG.phase_manager.is_in_stage_phase = !1, SG.phase_manager.lastPhase(), $scope.current_phase = SG.phase_manager.getCurrentPhase(), displayScenario(!1), $scope.goTo(ROOT_STATE + "EndGame")
  2797.     }, nextPhase = function (stage_id, state) {
  2798.         var phase_name;
  2799.         SG.phase_manager.is_in_stage_phase = !1, void 0 == stage_id ? (SG.tracker.current_stage_id = -1, SG.phase_manager.nextPhase(), $scope.current_phase = SG.phase_manager.getCurrentPhase(), phase_name = SG.phase_manager.getCurrentPhase().name) : (SG.tracker.current_stage_id = stage_id, SG.phase_manager.is_in_stage_phase = !0, SG.game.nextStep(stage_id, state)), "undefined" == typeof phase_name || SG.phase_manager.is_in_stage_phase || ($scope.phase_name = phase_name, "Scenario" == phase_name ? ($scope.$emit("showOverlay", !1), displayScenario(!1, !1), $scope.goTo(ROOT_STATE + "CharacterSelection")) : (displayScenario(!1), $scope.$emit("setGamePaused", !0), $scope.goTo(ROOT_STATE + phase_name)))
  2800.     };
  2801.     $scope.$on("nextPhase", function (e, stage_id, state) {
  2802.         nextPhase(stage_id, state)
  2803.     }), $scope.$on("endGame", function (e) {
  2804.         endGame()
  2805.     }), $scope.$on("goToStagePhase", function (event, stage) {
  2806.         1 == stage.paths.length && "" == stage.paths[0].short_descriptions[SG.core.lang] ? ($rootScope.target_stage_for_next_step = stage.paths[0].target, $rootScope.state_for_next_step = "default") : stage.paths.length > 0 ? ($rootScope.target_stage_for_next_step = -1, $rootScope.state_for_next_step = "display_proposition") : $rootScope.target_stage_for_next_step = void 0, $scope.current_phase = stage.phase_description, $scope.current_stage = stage;
  2807.         var phase_name = stage.type;
  2808.         $scope.$emit("setPauseEnabled", !("WebPhase" == phase_name)), $scope.goTo(ROOT_STATE + phase_name)
  2809.     }), $scope.$on("displayScenario", function (event, display, blur) {
  2810.         displayScenario(display, blur)
  2811.     });
  2812.     var displayScenario = function (scenario_is_display, blur) {
  2813.         $scope.displayScenario = scenario_is_display, void 0 !== blur ? $scope.blurScenario = blur : $scope.blurScenario = !scenario_is_display, scenario_is_display && $scope.$emit("startScenario")
  2814.     };
  2815.     $(document).keydown(function (e) {
  2816.         80 == e.keyCode && e.altKey && e.ctrlKey && (e.preventDefault(), SG.game.phaser_game.paused = !SG.game.phaser_game.paused)
  2817.     }), $scope.scenario = {}, SG.tracker = new SG.Tracker(Core.global_scenario.criterions), SG.tracker.init(), $scope.scenario = SG.phase_manager.getNextScenarioPhase(), SG.phase_manager.start(), SG.phase_manager.preloadPhases(init)
  2818. }]), angular.module("itysg.controllers").controller("popupCancelNextCtrl", ["$scope", "close", function ($scope, close) {
  2819.     $scope.close = function (result) {
  2820.         close(result, 500)
  2821.     }
  2822. }]), angular.module("itysg.controllers").controller("MessageCtrl", ["$scope", "$rootScope", function ($scope, $rootScope) {
  2823. }]), angular.module("itysg.services").service("Core", function () {
  2824.     return SG.core
  2825. }), angular.module("itysg.services").service("Echange", function ($http, $q, $rootScope) {
  2826.     return {
  2827.         connection: function (login, password, key, uid, user_lang, from, client, globalscenario) {
  2828.             var deferred = $q.defer(), callData = JSON.stringify({
  2829.                 serviceName: "itysg__Echanges",
  2830.                 methodName: "connexionJson",
  2831.                 parameters: [login, password, key, uid, user_lang, from, client, globalscenario]
  2832.             });
  2833.             return $.post(amfphp.entryPointUrl, callData, function (datas) {
  2834.                 $rootScope.$apply(function () {
  2835.                     deferred.resolve(datas)
  2836.                 })
  2837.             }), deferred.promise
  2838.         }, connectionOffline: function () {
  2839.             var deferred = $q.defer();
  2840.             return $http.get("assets/script/connexion.json").success(function (datas) {
  2841.                 console.log("CONNEXION OFFLINE SUCCESS"), deferred.resolve(datas)
  2842.             }).error(function (error) {
  2843.                 console.log("CONNEXION OFFLINE ERROR"), deferred.reject(error)
  2844.             }), deferred.promise
  2845.         }, loadGlobalScenario: function (global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client) {
  2846.             var deferred = $q.defer(), callData = JSON.stringify({
  2847.                 serviceName: "itysg__Echanges",
  2848.                 methodName: "loadGlobalScenarioJson",
  2849.                 parameters: [global_scenario_id, login, password, user_lang, conn_key, character_id, uid, client]
  2850.             });
  2851.             return $.post(amfphp.entryPointUrl, callData, function (datas) {
  2852.                 $rootScope.$apply(function () {
  2853.                     deferred.resolve(datas)
  2854.                 })
  2855.             }), deferred.promise
  2856.         }, loadGlobalScenarioOffline: function (global_scenario_id) {
  2857.             var deferred = $q.defer();
  2858.             return $http.get("assets/script/gb_scenario_" + global_scenario_id + ".json").success(function (datas) {
  2859.                 deferred.resolve(datas)
  2860.             }).error(function (error) {
  2861.                 deferred.reject(error)
  2862.             }), deferred.promise
  2863.         }
  2864.     }
  2865. }), angular.module("itysg.services").service("CharacterSelectionService", function () {
  2866.     this.saved_characters = [], this.multipleCharactersAreDifferents = function (available_characters, type) {
  2867.         if (!this.saved_characters[type]) return this.saved_characters[type] = [], !0;
  2868.         if (0 == this.saved_characters[type].length) return !0;
  2869.         var different = !1;
  2870.         return angular.forEach(this.saved_characters[type], function (saved_characters_object) {
  2871.             "boolean" == typeof different && (different = !1, available_characters.ids.length != saved_characters_object.ids.length ? different = !0 : angular.forEach(saved_characters_object.ids, function (saved_character_id) {
  2872.                 available_characters.ids.indexOf(saved_character_id) == -1 && (different = !0)
  2873.             }), 0 == different && (different = saved_characters_object))
  2874.         }), different
  2875.     }, this.addNewMultipleCharacterSelection = function (available_characters, selected_id, type) {
  2876.         var char_selected_object = {ids: [], selected_id: null};
  2877.         angular.forEach(available_characters.ids, function (char_id) {
  2878.             char_selected_object.ids.push(char_id)
  2879.         }), char_selected_object.selected_id = selected_id, this.saved_characters[type].push(char_selected_object)
  2880.     }
  2881. }), angular.module("itysg.directives").directive("ityCriterionsPanel", ["Core", function (Core) {
  2882.     return {
  2883.         restrict: "E", controller: function ($scope, $timeout) {
  2884.             $scope.criterionsPanel = [], $scope.$on("onCriterionsChange", function (e, criterions_results) {
  2885.                 Core.global_scenario.show_criterion_panel && criterions_results.length && ($scope.criterionsToDisplay = [], criterions_results.forEach(function (criterion_result) {
  2886.                     var scoreToDisplay, criterion = SG.core.global_scenario.criterions[criterion_result.id];
  2887.                     scoreToDisplay = criterion_result.value[0] > 0 ? "+" + criterion_result.value[0] : criterion_result.value[0];
  2888.                     var textColor = $scope.determineColorText(criterion.color),
  2889.                         critToDisplay = {name: criterion.name, score: scoreToDisplay, color: criterion.color, textColor: textColor};
  2890.                     0 != criterion_result.value[0] && $scope.criterionsToDisplay.push(critToDisplay)
  2891.                 }), $scope.criterionsPanel.push($scope.criterionsToDisplay), $timeout(function () {
  2892.                     $scope.criterionsPanel.splice(0, 1)
  2893.                 }, 4e3))
  2894.             }), $scope.determineColorText = function (hex) {
  2895.                 var black = "000000", white = "FFFFFF";
  2896.                 if ("" == hex) return black;
  2897.                 var color = {red: 0, green: 0, blue: 0}, bigint = parseInt(hex, 16);
  2898.                 color.red = bigint >> 16 & 255, color.green = bigint >> 8 & 255, color.blue = 255 & bigint;
  2899.                 for (var composantColor in color) color[composantColor] /= 255, color[composantColor] <= .03928 ? color[composantColor] /= 12.92 : color[composantColor] = Math.pow((color[composantColor] + .055) / 1.055, 2.4);
  2900.                 var luminance = .2126 * color.red + .7152 * color.green + .0722 * color.blue, colorText = black;
  2901.                 return luminance <= .179 && (colorText = white), colorText
  2902.             }
  2903.         }, link: function (scope, ele, attrs) {
  2904.         }, templateUrl: "templates/views/criterionsPanel.html"
  2905.     }
  2906. }]), angular.module("itysg.directives").directive("ityMenu", ["$rootScope", "$animate", "ngDialog", function ($rootScope, $animate, ngDialog) {
  2907.     return {
  2908.         restrict: "E", controller: function ($scope) {
  2909.             $scope.menu_is_open = !1, $scope.menu_enable = !1, $scope.pause_enabled = !0, $scope.$on("setPauseEnabled", function (e, value) {
  2910.                 $scope.pause_enabled = value
  2911.             }), $scope.$on("setMenuEnabled", function (e, value) {
  2912.                 $scope.menu_enable = value
  2913.             })
  2914.         }, link: function (scope, ele, attrs) {
  2915.             scope.toggleMenu = function () {
  2916.                 if (scope.title = SG.core.global_scenario.names.French, scope.menu_is_open = !scope.menu_is_open, $("ity-menu").toggleClass("big"), $("ity-menu").hasClass("big")) if (scope.$broadcast("setGamePaused", !0), scope.isIpad()) {
  2917.                     var items = $("#menu-content .item");
  2918.                     items.css({"margin-left": "0px"})
  2919.                 } else {
  2920.                     var items = ele.find("#menu-content .item");
  2921.                     items.each(function (index) {
  2922.                         var element = $(this);
  2923.                         setTimeout(function () {
  2924.                             element.animate({"margin-left": 0}, {
  2925.                                 duration: 200,
  2926.                                 specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
  2927.                             })
  2928.                         }, 200 / items.length * index)
  2929.                     })
  2930.                 } else {
  2931.                     var items = $("#menu-content .item");
  2932.                     items.css({"margin-left": "-250px"}), scope.$broadcast("setGamePaused", !1)
  2933.                 }
  2934.             }, scope.toggleSubtitle = function () {
  2935.                 scope.subtitle_are_enable = !scope.subtitle_are_enable
  2936.             }, scope.toggleSound = function () {
  2937.                 scope.sound_is_mute = !scope.sound_is_mute, $rootScope.$broadcast("toggleSound", scope.sound_is_mute)
  2938.             }, scope.showInfo = function () {
  2939.                 var scenarioInfo = SG.Core.getInstance()._global_scenario._global_scenario_json.lang[0];
  2940.                 ngDialog.open({
  2941.                     template: "templates/views/modals/module-information.html",
  2942.                     data: {text: scope.i18n.menu.info, scenarioInfo: scenarioInfo, conceptor_name: scope.i18n.menu.conceptor_name},
  2943.                     showClose: !1,
  2944.                     className: "popup-module-info",
  2945.                     closeByDocument: !1
  2946.                 })
  2947.             }, scope.showTuto = function () {
  2948.             }, scope.goToMap = function () {
  2949.                 var dialog = ngDialog.open({
  2950.                     template: "templates/views/modals/popup-cancel-next.html",
  2951.                     data: {text: scope.i18n.menu.go_to_map_msg},
  2952.                     showClose: !1,
  2953.                     closeByDocument: !1
  2954.                 });
  2955.                 dialog.closePromise.then(function (data) {
  2956.                     if (data.value === !0) {
  2957.                         var stage_map_id = 19426002;
  2958.                         $rootScope.$broadcast("goToStage", stage_map_id), scope.menu_is_open = !scope.menu_is_open, scope.is_pause = scope.menu_is_open
  2959.                     }
  2960.                 })
  2961.             }, scope.logout = function () {
  2962.             }, scope.showResult = function () {
  2963.                 ngDialog.open({
  2964.                     template: "templates/views/modals/popup-confirm.html",
  2965.                     data: {text: scope.i18n.results.warning},
  2966.                     showClose: !1,
  2967.                     className: "popup-confirm-resultat",
  2968.                     closeByDocument: !1
  2969.                 })
  2970.             }, scope.feedBack = function () {
  2971.                 alert("a faire : fonction feedback")
  2972.             }, scope.isIpad = function () {
  2973.                 var isiPad = null != navigator.userAgent.match(/iPad/i);
  2974.                 return isiPad
  2975.             }
  2976.         }, templateUrl: "templates/views/menu.html"
  2977.     }
  2978. }]), angular.module("itysg.directives").directive("ityScenario", function ($timeout) {
  2979.     return {
  2980.         restrict: "A", require: "ityPhase", link: function (scope, ele, attrs) {
  2981.             scope.scenario_directive_ready = !0, scope.$on("scenarioIsReady", function (event, start) {
  2982.                 var sceneries = scope.$eval(attrs.sceneries);
  2983.                 void 0 !== sceneries && null !== sceneries && void 0 !== scope.scenario && (SG.game = new SG.Game.GameController, $timeout(function () {
  2984.                     SG.game.start(scope.scenario, sceneries, scope, start)
  2985.                 }))
  2986.             }), scope.hasEndPopup = !1, scope.path = "", scope.gameIsFinished = !1, scope.hasPicture = !1, scope.hasText = !1, scope.$on("displayEndPopup", function (event, stage) {
  2987.                 scope.hasEndPopup = !0, scope.hasProposition = 1 == stage.paths.length && "" === stage.paths[0].short_descriptions[SG.core.lang] || 0 == stage.paths.length, scope.gameIsFinished = 0 == stage.paths.length, scope.hasProposition && (scope.path = stage.paths[0]), stage._stage_bob_pictures[SG.core.lang] && (scope.hasPicture = !0, scope.picture = SG.core.medias_url + stage._stage_bob_pictures[SG.core.lang]), stage._transition_content[SG.core.lang] && (scope.hasText = !0, scope.text = stage._transition_content[SG.core.lang]), scope.$apply()
  2988.             }), scope.goToNextPhase = function () {
  2989.                 1 == scope.gameIsFinished ? SG.game.event_controller.endGame() : "" != scope.path && (SG.tracker.addPath(scope.path), scope.$emit("onCriterionsChange", scope.path.criterions_results), scope.$emit("nextPhase", scope.path.target, "default"), scope.$emit("hideEndPopup"))
  2990.             }, scope.$on("hideEndPopup", function (event) {
  2991.                 scope.hasEndPopup = !1, scope.hasPicture = !1, scope.picture = "", scope.hasText = !1, scope.text = "", scope.path = "", scope.gameIsFinished = !1
  2992.             })
  2993.         }, templateUrl: "templates/views/phase/scenario.html"
  2994.     }
  2995. }), angular.module("itysg.directives").directive("ityPhase", function () {
  2996.     return {
  2997.         restrict: "E", scope: {phase: "="}, controller: function ($scope) {
  2998.             $scope.current_phase = {}
  2999.         }, link: function (scope, elem, attr) {
  3000.         }
  3001.     }
  3002. }), angular.module("itysg.directives").directive("ityBobspeech", function ($timeout) {
  3003.     var _scope, setPopupHeight = function () {
  3004.         $(".popup-context").removeClass("slide-left");
  3005.         var img = $(".bobspeech-img img"), globalHeight = $(window).height() - 140, popup = $(".popup-context"),
  3006.             imgContainer = $(".bobspeech-img"), textPadding = $(".row-wrap .content-wrap .top").height(),
  3007.             textHeight = $(".row-wrap .content-wrap .text")[0].scrollHeight + 2 * textPadding, row = $(".popup-context .row-wrap"),
  3008.             text = $(".popup-context .text"), player = $(".popup-context .audio-player");
  3009.         _scope.hasAudio && applyFlex(player, 65), img.height() + player.height() + textHeight <= globalHeight ? (applyFlex(imgContainer, img.height()), applyFlex(row, textHeight), applyFlex(text, textHeight), popup.height(img.height() + player.height() + textHeight)) : (img.height() <= globalHeight / 2 - player.height() / 2 ? (applyFlex(imgContainer, img.height()), applyFlex(row, globalHeight - img.height() - player.height()), applyFlex(text, globalHeight - img.height() - player.height())) : (applyFlex(imgContainer, globalHeight / 2 - player.height() / 2), applyFlex(row, globalHeight / 2 - player.height() / 2), applyFlex(text, globalHeight / 2 - player.height() / 2)), applyFlex($(".row-wrap .content-wrap .top"), 0), applyFlex($(".row-wrap .content-wrap .bottom"), 0), popup.height(globalHeight)), popup.height() % 2 == 1 && popup.height(popup.height() + 1)
  3010.     }, applyFlex = function (ele, value) {
  3011.         ele.css("flex", "0 0 " + value + "px")
  3012.     };
  3013.     return {
  3014.         restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $element) {
  3015.             $scope.DEFAULT_PICTURE = "assets/images/bobfacesmall.png", $scope.text = "", $scope.sound = null, $scope.hasAudio = !1, $scope.notifyAudio = !1, $scope.canNext = !0, $scope.nextPhase = function () {
  3016.                 $scope.canNext && ($(".popup-context").removeClass("slide-right"), $scope.sound && ($scope.sound.pause(), $scope.sound = null), $scope.canNext = !1, $(".popup-context").addClass("slide-left"), $timeout(function () {
  3017.                     $(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
  3018.                 }, 300))
  3019.             }
  3020.         }, link: function (scope, ele, attrs) {
  3021.             if (_scope = scope, scope.text = scope.current_phase.text[SG.core.lang].value, "undefined" != typeof scope.current_phase.picture && (scope.picture = SG.core.medias_url + scope.current_phase.picture), scope.sound = scope.current_phase.sound, scope.sound) {
  3022.                 scope.hasAudio = !0;
  3023.                 var audioPlayer = new SG.Utils.AudioPlayer;
  3024.                 audioPlayer.createPlayer(scope.sound, ele.find(".audio-player")), SG.Utils.mouse.supportsTouch ? scope.notifyAudio = !0 : audioPlayer.play(), scope.$on("toggleSound", function (e, muted) {
  3025.                     scope.sound.muted = muted
  3026.                 }), scope.$on("setGamePaused", function () {
  3027.                     SG.game.phaser_game.paused ? audioPlayer.pause() : audioPlayer.play()
  3028.                 })
  3029.             }
  3030.             var img = $(".bobspeech-img img");
  3031.             img.on("load", function () {
  3032.                 setPopupHeight()
  3033.             }), $timeout(function () {
  3034.                 scope.current_phase.picture || setPopupHeight(), scope.sound && (scope.sound.muted = SG.game.sound_muted), $(".popup-context").addClass("slide-right")
  3035.             }), $(window).resize(setPopupHeight)
  3036.         }, templateUrl: "templates/views/phase/bobspeech.html"
  3037.     }
  3038. }), angular.module("itysg.directives").directive("ityKinematicphase", function ($rootScope, $timeout) {
  3039.     return {
  3040.         restrict: "A", require: "ityPhase", controller: function ($scope) {
  3041.             $scope.urlMP4 = $scope.current_phase.urlMP4, $scope.image = $scope.current_phase.image, console.log($scope.current_phase), $scope.nextPhase = function () {
  3042.                 $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
  3043.             }
  3044.         }, link: function (scope, ele, attrs) {
  3045.             var myVideo = null;
  3046.             $(document).on("mozfullscreenchange", function () {
  3047.                 ele.find("#video-content").toggleClass("mozFullscreenFix")
  3048.             }), $timeout(function () {
  3049.                 scope.urlMP4 && (myVideo = document.getElementById("video-content"), myVideo.muted = SG.game.sound_muted)
  3050.             }), scope.$on("nextPhase", function () {
  3051.                 null != myVideo && (myVideo.remove(), myVideo = null)
  3052.             }), scope.$on("toggleSound", function (e, muted) {
  3053.                 null != myVideo && (myVideo.muted = muted)
  3054.             }), scope.$on("setGamePaused", function () {
  3055.                 null != myVideo && (SG.game.phaser_game.paused ? myVideo.pause() : myVideo.play())
  3056.             })
  3057.         }, templateUrl: "templates/views/phase/kinematicphase.html"
  3058.     }
  3059. }), angular.module("itysg.directives").directive("ityWebphase", function ($sce) {
  3060.     return {
  3061.         restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $sce, $timeout) {
  3062.             var FLASH_WIDTH = 980, FLASH_HEIGHT = 520;
  3063.             $scope.current_phase.type >= 0 && $scope.current_phase.type <= 1 ? $scope.url = $sce.trustAsResourceUrl($scope.current_phase.url) : $scope.current_phase.type >= 2 && $scope.current_phase.type <= 4 && ($scope.url = SG.core.base_url + $sce.trustAsResourceUrl($scope.current_phase.url)), $scope.style = "", $scope.current_phase.fullscreen ? ($scope.style += "left:0;", $scope.style += "top:0;", $scope.style += "width:100%;", $scope.style += "height:100%;") : ("left" == $scope.current_phase.position_enum[$scope.current_phase.position] ? $scope.style += "left:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;" : "center" == $scope.current_phase.position_enum[$scope.current_phase.position] ? $scope.style += "left:50%;transform:translate(-50%);margin-left:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;" : $scope.style += "right:" + Math.floor($scope.current_phase.horizontal_align / FLASH_WIDTH * 100) + "%;", $scope.style += "top:" + Math.floor($scope.current_phase.vertical_align / FLASH_HEIGHT * 100) + "%;", $scope.style += "width:" + Math.floor($scope.current_phase.width / FLASH_WIDTH * 100) + "%;", $scope.style += "height:" + Math.floor($scope.current_phase.height / FLASH_HEIGHT * 100) + "%;"), $scope.nextPhase = function () {
  3064.                 $scope.url = null, disableCommunicationAPI(), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
  3065.             }, $timeout(function () {
  3066.                 $(".web-wrap .close-wrap").attr("style", $scope.style)
  3067.             })
  3068.         }, link: function (scope, ele, attrs) {
  3069.             enableCommunicationAPI(scope.current_phase.url), $(".close").click(function () {
  3070.                 $(".close").fadeOut()
  3071.             })
  3072.         }, templateUrl: "templates/views/phase/webphase.html"
  3073.     }
  3074. }), angular.module("itysg.directives").directive("ityCharacterSelection", ["CharacterSelectionService", "$timeout", "$interval", function (CharacterSelectionService, $timeout, $interval) {
  3075.     return {
  3076.         restrict: "A", require: "ityPhase", controller: function ($scope, $element) {
  3077.             var scenary_checker, act_checker, checker_rate = 250;
  3078.             $scope.type = "", $scope.characters = [], $scope.character_types = {}, $scope.$emit("setGamePaused", !1), $scope.$emit("setTotalTasks", 2), $scope.$emit("setTaskCount", 0), $scope.$emit("showLoading", !0), $scope.$emit("reportProgress", 0), $scope.getCharacters = function (type) {
  3079.                 if ($scope.type = type, $scope.character_types[type].ids.length > 1) {
  3080.                     var already_selected = CharacterSelectionService.multipleCharactersAreDifferents($scope.character_types[type], type);
  3081.                     if ("object" == typeof already_selected) return void $scope.selectCharacter(already_selected.selected_id, type);
  3082.                     $scope.$emit("readyToShow", !0), $scope.resize(), SG.game.phaser_game.state.states.ScenarioEngine.drawCustomBg("character_selection"), console.log("-- Multiple characters available");
  3083.                     for (var i in $scope.character_types[type].ids) {
  3084.                         var character = SG.core.getCharacterById($scope.character_types[type].ids[i]);
  3085.                         $scope.characters[i] = {}, $scope.characters[i].id = character.id, "npc" == type ? character.not_playables[SG.core.lang] ? $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u" + character.id + "_h" + character.not_playables[SG.core.lang].char.cloth_id + ".png" : $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u6_h0.png" : character.playables[SG.core.lang] ? $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u" + character.id + "_h" + character.playables[SG.core.lang].cloth_id + ".png" : $scope.characters[i].img = SG.core.base_url + "/ressources/medias/users_preview/preview_u6_h0.png"
  3086.                     }
  3087.                 } else $scope.selectCharacter($scope.character_types[type].ids[0], type)
  3088.             }, $scope.selectCharacter = function (id, type) {
  3089.                 $scope.character_types[type].ids.length > 1 && (0 != CharacterSelectionService.saved_characters[type].length && 1 != CharacterSelectionService.multipleCharactersAreDifferents($scope.character_types[type], type) || CharacterSelectionService.addNewMultipleCharacterSelection($scope.character_types[type], id, type));
  3090.                 var type_not_set;
  3091.                 $scope.character_types[type].is_set = !0, SG.game[$scope.character_types[type].key] = SG.core.getCharacterById(id);
  3092.                 for (var char_type in $scope.character_types) if (!$scope.character_types[char_type].is_set) {
  3093.                     type_not_set = char_type;
  3094.                     break
  3095.                 }
  3096.                 type_not_set ? $scope.getCharacters(type_not_set) : ($scope.$emit("setGamePaused", !1), $scope.$emit("showLoading", !0), SG.game.phaser_game.state.start("PreloadAct"), act_checker = $interval(function () {
  3097.                     SG.game.act_loaded && (SG.game.game_ready = !0, $interval.cancel(act_checker), $scope.$emit("readyToShow", !0), $scope.$emit("showLoading", !1), $scope.act_stage_id ? $scope.$emit("nextPhase", $scope.act_stage_id) : ($scope.$emit("displayScenario", !0), $scope.goTo($scope.ROOT_STATE + "Scenario")))
  3098.                 }, checker_rate))
  3099.             }, SG.game.player.moves = [], SG.game.not_player.moves = [], scenary_checker = $interval(function () {
  3100.                 if (SG.game.scenary_loaded) {
  3101.                     $scope.$emit("setTaskCount", 1), $scope.$emit("reportProgress", 0), $scope.$emit("showLoading", !1);
  3102.                     var act = SG.game.act;
  3103.                     $scope.character_types = {
  3104.                         pc: {
  3105.                             is_set: !1,
  3106.                             ids: act.playable_character_ids,
  3107.                             key: "player",
  3108.                             title: SG.core.i18n.choose_avatar
  3109.                         }, npc: {is_set: !1, ids: act.not_playable_characters_ids, key: "not_player", title: SG.core.i18n.choose_meet}
  3110.                     };
  3111.                     for (var i in $scope.character_types) {
  3112.                         var temp = $scope.character_types[i].ids.slice();
  3113.                         $scope.character_types[i].ids = temp.filter(function (item, pos, self) {
  3114.                             return self.indexOf(item) == pos
  3115.                         })
  3116.                     }
  3117.                     $interval.cancel(scenary_checker), $scope.$emit("setGamePaused", !0), $scope.getCharacters("pc")
  3118.                 }
  3119.             }, checker_rate), $scope.resize = function () {
  3120.                 console.log("resize");
  3121.                 var offset = SG.game.getGameOffset(), el = $element.find(".character-screen");
  3122.                 el.offset({left: offset.x}), el.width(offset.width), el.height(offset.height)
  3123.             }, $(window).resize($scope.resize)
  3124.         }, link: function (scope, ele, attrs) {
  3125.         }, templateUrl: "templates/views/phase/characterSelection.html"
  3126.     }
  3127. }]), angular.module("itysg.directives").directive("ityQuizzBase", function ($timeout, $compile) {
  3128.     var detectIE = function () {
  3129.             var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
  3130.             return msie > 0 || trident > 0 || edge > 0
  3131.         }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
  3132.         isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
  3133.             var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
  3134.                 question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
  3135.                 top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
  3136.                 reponse_content_height = reponse_content[0].scrollHeight;
  3137.             detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
  3138.             var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
  3139.             if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
  3140.             question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
  3141.         }), applyFlex = function (ele, value) {
  3142.             ele.css("flex", "0 1 " + value + "px")
  3143.         };
  3144.     return {
  3145.         restrict: "A", require: "ityPhase", controller: function ($rootScope, $scope, $element) {
  3146.             $scope.name = "", $scope.index = -1, $scope.question = {}, $scope.previousAvailable = !1, $scope.nextAvailable = !0, $scope.count = Object.keys($scope.current_phase.questions).length, $scope.canSwitch = !0, $scope.canUpdate = !0, $scope.types = {
  3147.                 1: "ity-quizz-input-answer-directive",
  3148.                 2: "ity-quizz-single-choice-directive",
  3149.                 4: "ity-quizz-drop-down-directive",
  3150.                 5: "ity-quizz-multi-choice-directive",
  3151.                 6: "ity-quizz-slider-directive"
  3152.             }, $scope.$on("setPopupHeight", function () {
  3153.                 setPopupHeight()
  3154.             }), $scope.nextQuestion = function () {
  3155.                 if ($scope.nextAvailable) if ($scope.canSwitch) {
  3156.                     $scope.index++, $scope.updateQuestion();
  3157.                     var ele = $compile("<" + $scope.types[$scope.question.type.id] + "></" + $scope.types[$scope.question.type.id] + ">")($scope);
  3158.                     $element.find(".reponse-content").html("").append(ele)
  3159.                 } else $scope.$broadcast("showCorrection"), $scope.canUpdate = !1, $scope.canSwitch = !0; else $scope.nextPhase()
  3160.             }, $scope.previousQuestion = function () {
  3161.                 $scope.index--, $scope.updateQuestion()
  3162.             }, $scope.updateQuestion = function () {
  3163.                 $scope.nextAvailable = $scope.index + 1 in $scope.current_phase.questions, $scope.previousAvailable = $scope.index - 1 in $scope.current_phase.questions && $scope.current_phase.free && !$scope.current_phase.correction, $scope.question = $scope.current_phase.questions[$scope.index], $scope.canUpdate = !0, $scope.current_phase.correction && ($scope.canSwitch = !1)
  3164.             }, $scope.checkIsGoodAnswer = function (question) {
  3165.                 var isCorrect = !0;
  3166.                 for (var j in question.answers) if (question.answers[j].correct != question.answers[j].user_check) {
  3167.                     isCorrect = !1;
  3168.                     break
  3169.                 }
  3170.                 return isCorrect
  3171.             }, $scope.nextPhase = function () {
  3172.                 if ($scope.canSwitch) {
  3173.                     var correctAnswer = !1;
  3174.                     angular.forEach($scope.current_phase.questions, function (question) {
  3175.                         if (correctAnswer = $scope.checkIsGoodAnswer(question)) {
  3176.                             for (var k in question.right_criterions) SG.tracker.setCriterionValue(question.right_criterions[k]);
  3177.                             $scope.$emit("onCriterionsChange", question.right_criterions)
  3178.                         } else {
  3179.                             for (var k in question.wrong_criterions) SG.tracker.setCriterionValue(question.wrong_criterions[k]);
  3180.                             $scope.$emit("onCriterionsChange", question.wrong_criterions);
  3181.                         }
  3182.                     }), $timeout(function () {
  3183.                         $scope.canUpdate = !0, $(".quizz-wrapper").removeClass("slide-right"), $(".quizz-wrapper").addClass("slide-left"), $(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)
  3184.                     }, 300)
  3185.                 } else $scope.$broadcast("showCorrection"), $scope.canSwitch = !0, $scope.canUpdate = !1
  3186.             };
  3187.             var correctAnswer = !1;
  3188.             angular.forEach($scope.current_phase._questions, function (question) {
  3189.                 correctAnswer = $scope.checkIsGoodAnswer(question), correctAnswer && angular.forEach(question.right_criterions, function (criterion) {
  3190.                     var right_criterion = angular.copy(criterion);
  3191.                     right_criterion._value[0] = right_criterion._value[0] * -1, SG.tracker.setCriterionValue(right_criterion)
  3192.                 }), angular.forEach(question._answers, function (answer) {
  3193.                     console.log(answer), answer._user_check = !1, answer._user_value = ""
  3194.                 })
  3195.             }), 0 == $scope.count ? ($(window).unbind("resize", setPopupHeight), $scope.$emit("nextPhase", $rootScope.target_stage_for_next_step, $rootScope.state_for_next_step)) : $scope.nextQuestion()
  3196.         }, link: function (scope, ele, attrs) {
  3197.             scope.name = scope.current_phase.quizzname, $timeout(function () {
  3198.                 $(window).resize(setPopupHeight), $(".quizz-wrapper").addClass("slide-right")
  3199.             })
  3200.         }, templateUrl: "templates/views/phase/quizz/quizzBase.html"
  3201.     }
  3202. }), angular.module("itysg.directives").directive("ityQuizzInputAnswerDirective", function ($timeout) {
  3203.     var detectIE = function () {
  3204.             var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
  3205.             return msie > 0 || trident > 0 || edge > 0
  3206.         }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
  3207.         isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
  3208.             var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
  3209.                 question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
  3210.                 top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
  3211.                 reponse_content_height = reponse_content[0].scrollHeight;
  3212.             detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
  3213.             var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
  3214.             if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
  3215.             question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
  3216.         }), applyFlex = function (ele, value) {
  3217.             ele.css("flex", "0 1 " + value + "px")
  3218.         };
  3219.     return {
  3220.         restrict: "E", controller: function ($scope, $element) {
  3221.             var right_icon = '<img src="assets/images/done.svg" class="icon-check" alt="icon"/>',
  3222.                 wrong_icon = '<img src="assets/images/clear.svg" class="icon-clear" alt="icon"/>',
  3223.                 corrector = new RegExp("\\b" + $scope.question.answers[0].text + "\\b", "i");
  3224.             $scope.isCorrect = function () {
  3225.                 $scope.canUpdate && ($scope.question.answers[0].user_check = corrector.test($scope.question.answers[0].user_value))
  3226.             }, $scope.$on("showCorrection", function () {
  3227.                 $element.find("#user-input").hide(), $scope.question.answers[0].user_check != $scope.question.answers[0].correct ? "" == $scope.question.answers[0].user_value ? $scope.correction = "<p>" + wrong_icon + "aucune réponse</p><p>" + right_icon + $scope.question.answers[0].text + "</p>" : $scope.correction = "<p class='wrong'>" + wrong_icon + $scope.question.answers[0].user_value + "</p><p>" + right_icon + $scope.question.answers[0].text + "</p>" : $scope.correction = "<p class='right'>" + right_icon + $scope.question.answers[0].user_value + "</p>", $timeout(setPopupHeight)
  3228.             })
  3229.         }, link: function (scope, ele, attrs) {
  3230.             $timeout(function () {
  3231.                 scope.$emit("setPopupHeight")
  3232.             })
  3233.         }, templateUrl: "templates/views/phase/quizz/quizzInputAnswer.html"
  3234.     }
  3235. }), angular.module("itysg.directives").directive("ityQuizzMultiChoiceDirective", function ($timeout) {
  3236.     return {
  3237.         restrict: "E", controller: function ($scope, $element) {
  3238.             $scope.idList = {}, $scope.check = function () {
  3239.                 if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].id in $scope.idList && ($scope.question.answers[i].user_check = $scope.idList[$scope.question.answers[i].id])
  3240.             }, $scope.$on("showCorrection", function () {
  3241.                 for (var i in $scope.question.answers) 1 == $scope.question.answers[i].user_check ? 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("right") : $element.find("#answer" + $scope.question.answers[i].id).addClass("wrong") : 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("missRight") : $element.find("#answer" + $scope.question.answers[i].id).remove();
  3242.                 $(".reponse-wrap md-checkbox.right .icon-check").css("display", "inline-block"), $(".reponse-wrap md-checkbox.wrong .icon-clear").css("display", "inline-block"), $(".reponse-wrap md-checkbox.missRight .icon-check").css("display", "inline-block"), $scope.$emit("setPopupHeight")
  3243.             });
  3244.             var init = function () {
  3245.                 for (var i in $scope.question.answers) $scope.idList[$scope.question.answers[i].id] = $scope.question.answers[i].user_check
  3246.             };
  3247.             init()
  3248.         }, link: function (scope, ele, attrs) {
  3249.             $timeout(function () {
  3250.                 scope.$emit("setPopupHeight")
  3251.             })
  3252.         }, templateUrl: "templates/views/phase/quizz/quizzMultiChoice.html"
  3253.     }
  3254. }), angular.module("itysg.directives").directive("ityQuizzSingleChoiceDirective", function ($timeout) {
  3255.     return {
  3256.         restrict: "E", controller: function ($scope, $element) {
  3257.             $scope.selectedId = -1, $scope.check = function () {
  3258.                 if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].user_check = $scope.selectedId == $scope.question.answers[i].id
  3259.             }, $scope.$on("showCorrection", function () {
  3260.                 for (var i in $scope.question.answers) 1 == $scope.question.answers[i].user_check ? 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("right") : $element.find("#answer" + $scope.question.answers[i].id).addClass("wrong") : 1 == $scope.question.answers[i].correct ? $element.find("#answer" + $scope.question.answers[i].id).addClass("missRight") : $element.find("#answer" + $scope.question.answers[i].id).remove();
  3261.                 $(".reponse-wrap md-radio-button.right .icon-check").css("display", "inline-block"), $(".reponse-wrap md-radio-button.wrong .icon-clear").css("display", "inline-block"), $(".reponse-wrap md-radio-button.missRight .icon-check").css("display", "inline-block"), $scope.$emit("setPopupHeight")
  3262.             });
  3263.             var init = function () {
  3264.                 for (var i in $scope.question.answers) $scope.question.answers[i].user_check && ($scope.selectedId = $scope.question.answers[i].id)
  3265.             };
  3266.             init()
  3267.         }, link: function (scope, ele, attrs) {
  3268.             $timeout(function () {
  3269.                 scope.$emit("setPopupHeight")
  3270.             })
  3271.         }, templateUrl: "templates/views/phase/quizz/quizzSingleChoice.html"
  3272.     }
  3273. }), angular.module("itysg.directives").directive("ityQuizzDropDownDirective", function ($timeout) {
  3274.     var detectIE = function () {
  3275.             var ua = window.navigator.userAgent, msie = ua.indexOf("MSIE "), trident = ua.indexOf("Trident/"), edge = ua.indexOf("Edge/");
  3276.             return msie > 0 || trident > 0 || edge > 0
  3277.         }, isChromium = window.chrome, winNav = window.navigator, vendorName = winNav.vendor, isOpera = winNav.userAgent.indexOf("OPR") > -1,
  3278.         isIEedge = winNav.userAgent.indexOf("Edge") > -1, setPopupHeight = (winNav.userAgent.match("CriOS"), function () {
  3279.             var globalHeight = $(window).height() - 140, extra = 2, min = 150, popup = $(".quizz-wrapper"), reponse_wrap = $(".reponse-wrap"),
  3280.                 question_wrap = $(".question"), question_wrap_height = question_wrap[0].scrollHeight, top_wrap = $(".top"),
  3281.                 top_wrap_height = top_wrap[0].scrollHeight, reponse_content = $(".reponse-content"),
  3282.                 reponse_content_height = reponse_content[0].scrollHeight;
  3283.             detectIE() && (question_wrap_height = question_wrap.height(), top_wrap_height = top_wrap.height());
  3284.             var question_wrap_outer_height = question_wrap.outerHeight(), top_wrap_outer_height = top_wrap.outerHeight();
  3285.             if (null !== isChromium && void 0 !== isChromium && "Google Inc." === vendorName && 0 == isOpera && 0 == isIEedge) var reponse_content_outer_height = reponse_content.outerHeight(!0); else var reponse_content_outer_height = reponse_content_height + 50;
  3286.             question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < min ? (applyFlex(reponse_wrap, min - question_wrap_outer_height - top_wrap_outer_height), popup.height(min)) : question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height < globalHeight ? (applyFlex(reponse_wrap, reponse_content_outer_height + extra), popup.height(question_wrap_outer_height + top_wrap_outer_height + reponse_content_outer_height + extra)) : (applyFlex(reponse_wrap, globalHeight - question_wrap_outer_height - top_wrap_outer_height), popup.height(globalHeight)), applyFlex(question_wrap, question_wrap_height), applyFlex(top_wrap, top_wrap_height)
  3287.         }), applyFlex = function (ele, value) {
  3288.             ele.css("flex", "0 1 " + value + "px")
  3289.         };
  3290.     return {
  3291.         restrict: "E", controller: function ($scope, $element) {
  3292.             $scope.selectedId = -1, $scope.correct = !0;
  3293.             var right_icon = '<img src="assets/images/done.svg" class="icon-check" alt="icon"/>',
  3294.                 wrong_icon = '<img src="assets/images/clear.svg" class="icon-clear" alt="icon"/>';
  3295.             $scope.check = function () {
  3296.                 if ($scope.canUpdate) for (var i in $scope.question.answers) $scope.question.answers[i].user_check = $scope.selectedId == $scope.question.answers[i].id
  3297.             }, $scope.$on("showCorrection", function () {
  3298.                 var correction = "";
  3299.                 for (var i in $scope.question.answers) $scope.question.answers[i].user_check != $scope.question.answers[i].correct && ($scope.correct = !1), $scope.question.answers[i].correct && (correction = $scope.question.answers[i].text);
  3300.                 if ($element.find("#drop-down").hide(), $scope.correct) $scope.correction = "<p class='right'>" + right_icon + correction + "</p>"; else if ($scope.selectedId < 0) $scope.correction = "<p>" + wrong_icon + "aucune réponse</p><p>" + right_icon + correction + "</p>"; else for (var i in $scope.question.answers) if ($scope.question.answers[i].id == $scope.selectedId) {
  3301.                     $scope.correction = "<p class='wrong'>" + wrong_icon + $scope.question.answers[i].text + "</p><p>" + right_icon + correction + "</p>";
  3302.                     break
  3303.                 }
  3304.                 $timeout(setPopupHeight)
  3305.             });
  3306.             var init = function () {
  3307.                 for (var i in $scope.question.answers) $scope.question.answers[i].user_check && ($scope.selectedId = $scope.question.answers[i].id)
  3308.             };
  3309.             init()
  3310.         }, link: function (scope, ele, attrs) {
  3311.             $timeout(function () {
  3312.                 scope.$emit("setPopupHeight")
  3313.             })
  3314.         }, templateUrl: "templates/views/phase/quizz/quizzDropDown.html"
  3315.     }
  3316. }), angular.module("itysg.directives").directive("ityQuizzSliderDirective", function ($timeout) {
  3317.     return {
  3318.         restrict: "E", controller: function ($scope, $element) {
  3319.             $scope.max = 0, $scope.min = 0, $scope.ok = 0;
  3320.             var props = $scope.question.answers[0].text.split(",");
  3321.             for (var i in props) {
  3322.                 var prop = props[i].split(":");
  3323.                 $scope[prop[0].toLowerCase()] = parseInt(prop[1])
  3324.             }
  3325.             $scope.isCorrect = function () {
  3326.                 $scope.canUpdate && ($scope.question.answers[0].user_check = $scope.ok == $scope.question.answers[0].user_value)
  3327.             }, $scope.$on("showCorrection", function () {
  3328.                 $element.find("._md-slider-wrapper").unbind("mousedown").unbind("keydown").unbind("focus").unbind("blur").unbind("$md"), $element.find("md-slider").addClass("_md-active"), $scope.question.answers[0].user_check != $scope.question.answers[0].correct && ($scope.question.answers[0].user_value = $scope.ok, $element.find("._md-slider-content").append($element.find("._md-thumb-container").clone().attr("id", "wrongBubble")))
  3329.             })
  3330.         }, link: function (scope, ele, attrs) {
  3331.             $timeout(function () {
  3332.                 scope.$emit("setPopupHeight")
  3333.             })
  3334.         }, templateUrl: "templates/views/phase/quizz/quizzSlider.html"
  3335.     }
  3336. }), angular.module("itysg.directives").directive("ityEndGame", function ($timeout) {
  3337.     return {
  3338.         restrict: "A", require: "ityPhase", controller: function ($scope, $modal) {
  3339.             $scope.criterionLength = SG.core.global_scenario._criterions_json.length
  3340.         }, link: function (scope, ele, attrs) {
  3341.             scope.messages = {
  3342.                 end_game_message: SG.core.i18n.endgame.scenario_end_reached,
  3343.                 access_result: SG.core.i18n.endgame.access_result,
  3344.                 display_access_result: !0
  3345.             }, 0 == SG.tracker.getNumberOfCriterion() && (scope.messages.display_access_result = !1, scope.current_phase.param && scope.current_phase.param.hideMessageIfNoCriterions && (scope.messages.end_game_message += "<br/>" + SG.core.i18n.endgame.no_criterions));
  3346.             var general_score = isNaN(SG.tracker.getGeneralScore()) || void 0 === SG.tracker.getGeneralScore() ? 0 : SG.tracker.getGeneralScore();
  3347.             "undefined" != typeof scope.current_phase.custom_message && null !== scope.current_phase.custom_message && "" !== scope.current_phase.custom_message && (scope.current_phase.custom_message.replace("{score}", general_score), scope.messages.end_game_message = scope.current_phase.custom_message), SG.tracker.endGame(), scope.showResults = function () {
  3348.                 var global_scenario = SG.core.global_scenario, tracker = SG.tracker, criterions = SG.tracker.criterions, datas = {},
  3349.                     index = 0, scores = SG.tracker.score;
  3350.                 for (var i in criterions) datas[i] = {}, datas[i].id = criterions[i].id, datas[i].name = criterions[i].name, datas[i].criterionDescription = global_scenario._criterions_json[index].descriptions[0].description, datas[i].criterionComments = global_scenario._criterions_json[index].comments_by_score, void 0 != scores[i] ? datas[i].score = tracker.getCurrentPercentageForCriterionId(datas[i].id) : datas[i].score = 0, index++;
  3351.                 sessionStorage.setItem("datas", JSON.stringify(datas)), sessionStorage.setItem("tracker", JSON.stringify(SG.tracker)), sessionStorage.setItem("global_scenario", JSON.stringify(SG.core.global_scenario)), sessionStorage.setItem("engine", "html5"), sessionStorage.setItem("lang", SG.core.lang), sessionStorage.setItem("scenarioName", JSON.stringify(SG.core.global_scenario.names[SG.core.lang])), sessionStorage.setItem("criterionLength", JSON.stringify(scope.criterionLength)), window.location.href = "results/resultat.html"
  3352.             }, $timeout(function () {
  3353.                 scope.criterionLength >= 1 && 1 == SG.core.export_results ? $timeout(scope.showResults, 1e3) : $(".endgame p").text("")
  3354.             })
  3355.         }, templateUrl: "templates/views/phase/endgame.html"
  3356.     }
  3357. }), angular.module("itysg.directives").directive("ityProposition", function () {
  3358.     return {
  3359.         restrict: "E", controller: function ($scope, $timeout, $element) {
  3360.             $scope.displayProposition = !0, $scope.paths = [], $scope.stage_type_base = "", $scope.isCallByNextStep = !1, $scope.replay = function () {
  3361.                 "" != $scope.stage_type_base && (SG.game.current_stage.type = $scope.stage_type_base), $scope.$emit("nextPhase", $scope.current_stage.id, "replay"), $scope.$emit("hideEndPopup"), $scope.paths = [], $scope.hideList()
  3362.             }, $scope.expand = function (e) {
  3363.                 console.log($scope.current_stage);
  3364.                 var more = $(e.currentTarget), item = more.parent().parent(), less = item.find(".less"), text = item.find(".text");
  3365.                 more.addClass("closed"), less.addClass("opened"), more.data("expanded", "true"), item.animate({height: text[0].scrollHeight + 50}, 200)
  3366.             }, $scope.collapse = function (e) {
  3367.                 var less = $(e.currentTarget), item = less.parent(), more = item.find(".more");
  3368.                 item.find(".text");
  3369.                 more.removeClass("closed"), less.removeClass("opened"), more.data("expanded", "false"), item.animate({height: 100}, 200)
  3370.             }, $scope.showList = function () {
  3371.                 $element.stop(!0, !1).animate({left: "0"}, {
  3372.                     duration: 300,
  3373.                     specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
  3374.                 })
  3375.             }, $scope.hideList = function () {
  3376.                 $element.animate({left: "50%"}, {duration: 300, specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}})
  3377.             }, $scope.$on("displayProposition", function (event, stage, hide, isNextStep, stage_type) {
  3378.                 isNextStep && ($scope.isCallByNextStep = !0, $scope.stage_type_base = stage_type);
  3379.                 var propositions_list;
  3380.                 return stage.paths ? ($scope.current_stage = stage, propositions_list = stage.paths) : propositions_list = [], hide === !0 ? ($scope.paths = [], $scope.hideList(), null) : ($scope.showList(), void $scope.$apply(function () {
  3381.                     var memory_effect = new SG.Game.MemoryEffect, propositions_to_display = propositions_list.slice(0),
  3382.                         proposition_to_remove = [];
  3383.                     propositions_to_display.forEach(function (proposition, index, object) {
  3384.                         checkStageIsAlreadyPlayed(proposition), memory_effect.executePropositionMemoryEffect(proposition), proposition.is_display && "interactive_link_to" != proposition.type || proposition_to_remove.push(proposition)
  3385.                     }), propositions_to_display = $(propositions_to_display).not(proposition_to_remove).get(), propositions_to_display.length > 0 ? (propositions_to_display[0].order > 0 ? propositions_to_display.sort(function (p1, p2) {
  3386.                         return p1.order - p2.order
  3387.                     }) : propositions_to_display.sort(function (p1, p2) {
  3388.                         return .5 - Math.random()
  3389.                     }), $scope.paths = propositions_to_display, $scope.lang = SG.core.lang, console.log(propositions_to_display), SG.core.debug_mode && propositions_to_display.forEach(function (path) {
  3390.                         var message_to_concat = "[ ";
  3391.                         path.criterions_results.forEach(function (criterion_result) {
  3392.                             message_to_concat += " c : " + criterion_result.id + " value : " + criterion_result.value[0]
  3393.                         }), message_to_concat += " ]", console.log(path), path.short_descriptions[SG.core.lang] += message_to_concat
  3394.                     }), $scope.animation = !0, $timeout(function () {
  3395.                         var items = $element.find(".list .item");
  3396.                         items.each(function (index) {
  3397.                             var element = $(this);
  3398.                             setTimeout(function () {
  3399.                                 element.animate({"margin-left": 0, opacity: 1}, {
  3400.                                     duration: 200,
  3401.                                     specialEasing: {width: "easeInOutCubic", height: "easeInOutCubic"}
  3402.                                 })
  3403.                             }, 40 * index)
  3404.                         })
  3405.                     })) : $scope.$emit("goToStage", -1)
  3406.                 }))
  3407.             }), $scope.goToStage = function (path) {
  3408.                 $scope.isCallByNextStep && (SG.game.current_stage.type = $scope.stage_type_base, $scope.stage_type_base = "", $scope.isCallByNextStep = !1), SG.tracker.addPath(path), $scope.$emit("nextPhase", path.target, "default"), $scope.$emit("hideEndPopup"), $scope.paths = [], $scope.hideList()
  3409.             };
  3410.             var checkStageIsAlreadyPlayed = function (stage_path) {
  3411.                 var stage_id = stage_path.target, display_path = !0;
  3412.                 if (SG.tracker.stages.indexOf(stage_id) >= 0) {
  3413.                     var stage = SG.game.scenario.getStageById(stage_id);
  3414.                     display_path = stage.back_later_enabled
  3415.                 }
  3416.                 stage_path.is_display = display_path
  3417.             }
  3418.         }, link: function (scope, ele, attrs) {
  3419.         }, templateUrl: "templates/views/phase/proposition.html"
  3420.     }
  3421. }), angular.module("itysg.directives").directive("itySubtitle", function () {
  3422.     return {
  3423.         restrict: "E", controller: function ($scope) {
  3424.             $scope.subtitle_text = "", $scope.subtitle_displayed = !1, $scope.margin = 100, $scope.realWidth = 0, $scope.fontRatio = 1, $scope.fontSize = 1.5, $scope.minRatio = .8, $scope.$on("displaySubtitle", function (event, subtitle, name) {
  3425.                 $scope.$apply(function () {
  3426.                     subtitle ? (0 == SG.core.global_scenario.display_name_in_subtitle ? name = "" : name += " : ", $scope.subtitle_text = name + '" ' + subtitle + ' "') : $scope.subtitle_text = "", $scope.subtitle_displayed = "" !== $scope.subtitle_text
  3427.                 });
  3428.                 var resize = function () {
  3429.                     var offset = SG.game.getGameOffset(), subtitle = $(".subtitle");
  3430.                     subtitle.css("bottom", offset.y + "px"), subtitle.css("white-space", "nowrap"), subtitle.css("width", "auto"), subtitle.css("font-size", $scope.fontSize + "em"), $scope.realWidth = subtitle.outerWidth(), $scope.realWidth > offset.width - 2 * $scope.margin && ($scope.fontRatio = (offset.width - 2 * $scope.margin) / $scope.realWidth, $scope.fontRatio >= $scope.minRatio ? subtitle.css("font-size", $scope.fontSize * $scope.fontRatio + "em") : subtitle.css("font-size", $scope.fontSize * $scope.minRatio + "em"), subtitle.css("white-space", "normal"), subtitle.css("width", offset.width - 2 * $scope.margin + "px"))
  3431.                 };
  3432.                 resize(), $(window).resize(resize)
  3433.             })
  3434.         }, link: function (scope, ele, attrs) {
  3435.         }, templateUrl: "templates/views/phase/scenario/subtitle.html"
  3436.     }
  3437. }), angular.module("itysg.directives").directive("ityNotification", function () {
  3438.     return {
  3439.         restrict: "E", controller: function ($scope) {
  3440.             $scope.notification_title = "", $scope.notification_text = "", $scope.notification_displayed = !1, $scope.$on("displayNotification", function (event, title, text) {
  3441.                 $scope.notification_displayed = !0, title && text ? ($scope.notification_title = title, $scope.notification_text = text) : ($scope.notification_title = "", $scope.notification_text = ""), $scope.subtitle_displayed = "" !== $scope.subtitle_text, setTimeout(function () {
  3442.                     $scope.notification_displayed = !1
  3443.                 }, 5e3)
  3444.             })
  3445.         }, link: function (scope, ele, attrs) {
  3446.         }, templateUrl: "templates/views/notification.html"
  3447.     }
  3448. }), SG.Game.GameController = function () {
  3449.     this._player = {}, this._not_player = {}, this._scenario = {}, this._current_stage = {}, this._scenery = {}, this._sceneries = {}, this._act = null, this.event_controller = {}, this.scenario_is_ready = !1, this.phaser_game = {}, this.scenary_loaded = !1, this.act_loaded = !1, this.game_ready = !1, this.sound_muted = !1, this.custom_backgrounds = {}
  3450. }, SG.Game.GameController.prototype = {
  3451.     start: function (scenario, sceneries, scope, start) {
  3452.         var _this = this;
  3453.         this.width = 980, this.height = 518;
  3454.         var game = new Phaser.Game(this.width, this.height, Phaser.CANVAS, "gameCanvas");
  3455.         return game.resolution = 2, game.transparent = !0, game.antialias = !0, game.state.add("Boot", SG.Game.Boot), game.state.add("PreloadScenery", SG.Game.PreloadScenery), game.state.add("ChooseCharacter", SG.Game.ChooseCharacter), game.state.add("PreloadAct", SG.Game.PreloadAct), game.state.add("ScenarioEngine", SG.Game.ScenarioEngine), game.state.start("Boot"), this.scenario = scenario, this.scenario.first_stage > 0 ? this.current_stage = this.scenario.getStageById(this.scenario.first_stage) : this.current_stage = this.scenario.stages[0], this.act = this.scenario.getActById(SG.game.current_stage.act_id), this.sceneries = sceneries, this.scenery = this.sceneries[this.act.scenery_id], this.event_controller = new SG.Game.EventController(scope), game.state.states.ScenarioEngine.ready_for_next_dialog_part = start, scope.$on("startScenario", function () {
  3456.             game.state.states.ScenarioEngine.ready_for_next_dialog_part = !0
  3457.         }), scope.$on("goToStage", function (event, stage_id) {
  3458.             var target_stage = _this.scenario.getStageById(stage_id);
  3459.             stage_id > 0 && null !== target_stage ? _this.event_controller.nextPhase(stage_id) : _this.event_controller.nextPhase()
  3460.         }), scope.$on("toggleSound", function (e, muted) {
  3461.             game.sound.mute = muted, SG.game.sound_muted = muted
  3462.         }), scope.$on("togglePause", function () {
  3463.             SG.phase_manager.is_in_stage_phase || (game.paused = scope.is_pause)
  3464.         }), scope.$on("setGamePaused", function (e, value) {
  3465.             game.paused = value, game.sound.mute = SG.game.sound_muted, game.paused ? game.sound.pauseAll() : game.sound.resumeAll()
  3466.         }), scope.$on("$destroy", function () {
  3467.             _this.phaser_game.destroy()
  3468.         }), this.phaser_game = game, SG.tracker.addStage(this.current_stage), game
  3469.     }, nextStep: function (stage_id, state) {
  3470.         this.phaser_game.paused = !0, stage_id != -1 ? SG.game.event_controller.displayProposition([], !0, !1) : SG.game.event_controller.displayProposition([], !0, !0, SG.game.current_stage.type);
  3471.         var target_stage = this.scenario.getStageById(stage_id);
  3472.         "display_proposition" == state ? (SG.game.current_stage.type = "default", this.phaser_game.state.start("ScenarioEngine"), this.phaser_game.paused = !1, this.event_controller.displayScenario(!0)) : ("replay" != state && SG.tracker.addStage(target_stage), this.current_stage.act_id !== target_stage.act_id && target_stage != -1 ? (this.scenary_loaded = !1, this.act_loaded = !1, this.game_ready = !1, SG.game.event_controller.readyToShow(!1), this.current_stage = target_stage, this.act = this.scenario.getActById(target_stage.act_id), this.scenery = this.sceneries[this.act.scenery_id], this.phaser_game.stage.removeChildren(), this.phaser_game.state.states.ScenarioEngine.reset(), this.phaser_game.state.start("PreloadScenery"), this.phaser_game.state.states.ScenarioEngine.ready_for_next_dialog_part = !0, this.event_controller.displayScenario(!1, !1), this.event_controller.characterSelection(stage_id)) : (this.current_stage = target_stage, "default" === target_stage.type ? this.phaser_game.state.start("ScenarioEngine") : this.event_controller.goToStagePhase(target_stage), this.phaser_game.paused = "default" != SG.game.current_stage.type, this.event_controller.displayScenario("default" == SG.game.current_stage.type)))
  3473.     }, selectCharacter: function (mode, id) {
  3474.         SG.game.act;
  3475.         "pc" == mode ? SG.game.player = SG.core.getCharacterById(id) : SG.game.not_player = SG.core.getCharacterById(id), this.phaser_game.paused = !1, this.phaser_game.state.start("PreloadAct")
  3476.     }, getOppositeCharacter: function (id) {
  3477.         var character_to_return = null;
  3478.         return this.player.id == id ? character_to_return = this.not_player : this.not_player.id == id && (character_to_return = this.player), character_to_return
  3479.     }, getGameOffset: function () {
  3480.         var offset = {x: 0, y: 0, height: 0, width: 0}, width = $(document).width(), height = $(document).height(),
  3481.             ratio_game = this.width / this.height, ratio_window = width / height;
  3482.         return ratio_window < ratio_game ? (offset.height = width / ratio_game, offset.width = width, offset.y = (height - width / ratio_game) / 2) : (offset.width = height * ratio_game, offset.height = height, offset.x = (width - height * ratio_game) / 2), offset
  3483.     }
  3484. }, Object.defineProperties(SG.Game.GameController.prototype, {
  3485.     player: {
  3486.         get: function () {
  3487.             return this._player
  3488.         }, set: function (player) {
  3489.             this._player = player
  3490.         }
  3491.     }, not_player: {
  3492.         get: function () {
  3493.             return this._not_player
  3494.         }, set: function (not_player) {
  3495.             this._not_player = not_player
  3496.         }
  3497.     }, scenario: {
  3498.         get: function () {
  3499.             return this._scenario
  3500.         }, set: function (scenario) {
  3501.             this._scenario = scenario
  3502.         }
  3503.     }, current_stage: {
  3504.         get: function () {
  3505.             return this._current_stage
  3506.         }, set: function (current_stage) {
  3507.             this._current_stage = current_stage
  3508.         }
  3509.     }, scenery: {
  3510.         get: function () {
  3511.             return this._scenery
  3512.         }, set: function (scenery) {
  3513.             this._scenery = scenery
  3514.         }
  3515.     }, sceneries: {
  3516.         get: function () {
  3517.             return this._sceneries
  3518.         }, set: function (seneries) {
  3519.             this._sceneries = seneries
  3520.         }
  3521.     }, act: {
  3522.         get: function () {
  3523.             return this._act
  3524.         }, set: function (act) {
  3525.             this._act = act
  3526.         }
  3527.     }, scenario_is_ready: {
  3528.         get: function () {
  3529.             return this._scenario_is_ready
  3530.         }, set: function (scenario_is_ready) {
  3531.             this._scenario_is_ready = scenario_is_ready
  3532.         }
  3533.     }
  3534. }), SG.Game.Boot = function (game) {
  3535.     this.game = game, this.isReady = !1
  3536. }, SG.Game.Boot.prototype = {
  3537.     init: function () {
  3538.         this.setScaleMode()
  3539.     }, create: function () {
  3540.         this.game.stage.backgroundColor = "#000000", SG.CheatCodeController.addCheatCode(["up", "right", "down", "left", "up", "right", "down", "left", "enter"], function () {
  3541.             SG.game.event_controller.goToStage(-1)
  3542.         }), SG.CheatCodeController.addCheatCode(["g", "t", "s", "b", "i", "enter"], function () {
  3543.             var id = prompt("Saisissez l'id de la scène cible");
  3544.             SG.game.scenario.getStageById(parseInt(id)) && SG.game.event_controller.goToStage(id)
  3545.         }), SG.CheatCodeController.addCheatCode(["up", "up", "down", "down", "left", "right", "left", "right", "b", "a"], function () {
  3546.             alert("KONAMI CODE TODO IMPLEMENT")
  3547.         }), this.game.state.start("PreloadScenery")
  3548.     }, setScaleMode: function () {
  3549.         this.scale.parentIsWindow = !0, this.game.time.advancedTiming = !0, this.game.device.desktop ? (this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL, this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0) : (this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL, this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0), console.log("%cSCALE MODE SETTED", "color : purple; font-size : 20px")
  3550.     }
  3551. }, SG.Game.PreloadScenery = function (game) {
  3552.     this.game = game
  3553. }, SG.Game.PreloadScenery.prototype = {
  3554.     init: function () {
  3555.         this.scenario = SG.game.scenario
  3556.     }, preload: function () {
  3557.         this.game.load.onFileComplete.add(function (progress, cacheKey, success, totalLoaded, totalFiles) {
  3558.             SG.game.event_controller.reportProgress(progress)
  3559.         }, this);
  3560.         var loadManager = new SG.Game.LoadManager(this.game.load);
  3561.         loadManager.loadScenery(SG.game.act, SG.game.scenery), loadManager.preloadCustomBackground("character_selection", "assets/images/character_select.png"), loadManager.preloadCustomBackground("bg_neutre", "assets/images/bg_neutre.jpg")
  3562.     }, create: function () {
  3563.         var loadManager = new SG.Game.LoadManager(this.game.load);
  3564.         loadManager.loadCustomBackgrounds(), SG.game.scenary_loaded = !0, SG.game.phaser_game.state.states.ScenarioEngine.drawCustomBg("bg_neutre")
  3565.     }
  3566. }, SG.Game.PreloadAct = function (game) {
  3567.     this.game = game
  3568. }, SG.Game.PreloadAct.prototype = {
  3569.     init: function () {
  3570.         this.scenario = SG.game.scenario
  3571.     }, preload: function () {
  3572.         this.game.load.onFileComplete.add(function (progress, cacheKey, success, totalLoaded, totalFiles) {
  3573.             SG.game.event_controller.reportProgress(progress)
  3574.         }, this);
  3575.         var loadManager = new SG.Game.LoadManager(this.game.load);
  3576.         loadManager.preloadScenario()
  3577.     }, create: function () {
  3578.         SG.game.act_loaded = !0, this.game.state.start("ScenarioEngine")
  3579.     }
  3580. }, SG.Game.ScenarioEngine = function (game) {
  3581.     this.game = game, this.dialog_list = [], this.camera_controller = null, this.subtitle_controller = new SG.Game.SubtitleController, this.loadManager = null, this.current_stage = {}, this.group_characters = null, this.player = null, this.not_player = null, this.current_character = null, this.force_camera = "undefined", this.index_dial_part = 0, this.ready_for_next_dialog_part = !1, this.wait_proposition = !1
  3582. }, SG.Game.ScenarioEngine.prototype = {
  3583.     init: function () {
  3584.         this.game.sound.stopAll(), this.current_stage = SG.game.current_stage, this.wait_proposition = !1, this.force_camera = "undefined", this.index_dial_part = 0, this.subtitle_controller.setSubtitle("", "");
  3585.         var dialog_parser = new SG.Game.DialogParserController;
  3586.         this.dialog_list = dialog_parser.parseStageContent(this.current_stage), null === this.loadManager && (this.loadManager = new SG.Game.LoadManager(this.game.load)), null === this.camera_controller && (this.camera_controller = new SG.Game.CameraController(this.game, 2)), null === this.group_characters && (this.group_characters = this.add.group(null, "characters", !0), this.player = new SG.Game.CharacterPrefab(this.game, SG.game.player), this.player.onSpecificAnimation.add(this.camera_controller.displayItemById, this), this.not_player = new SG.Game.CharacterPrefab(this.game, SG.game.not_player), this.player.onSpecificAnimation.add(this.camera_controller.displayItemById, this), this.group_characters.add(this.player), this.group_characters.add(this.not_player), this.current_character = this.player)
  3587.     }, preload: function () {
  3588.         this.loadManager.removeUnusedAssets(), this.loadManager.loadStage(this.current_stage, this.dialog_list), this.resizeGame()
  3589.     }, create: function () {
  3590.         this.nb = 0
  3591.     }, drawCustomBg: function (name) {
  3592.         var children_count = SG.game.phaser_game.stage.children.length, index_to_top = children_count - 1;
  3593.         SG.game.phaser_game.stage.setChildIndex(SG.game.custom_backgrounds[name], index_to_top)
  3594.     }, update: function () {
  3595.         if (SG.game.game_ready) if (this.current_stage = SG.game.current_stage, this.ready_for_next_dialog_part && !this.wait_proposition && (this.subtitle_controller.setSubtitle("", ""), this.current_character.character.id != this.player.character.id || this.player.is_animated ? this.current_character.character.id != this.not_player.character.id || this.not_player.is_animated || (this.player.animations.stop(), this.player.is_animated = !1) : (this.not_player.animations.stop(), this.not_player.is_animated = !1)), this.ready_for_next_dialog_part && this.index_dial_part < this.dialog_list.length && !this.player.is_animated && !this.not_player.is_animated) this.player.wait = !1, this.not_player.wait = !1, this._nextDialogPart(this.index_dial_part); else if (this.ready_for_next_dialog_part && this.index_dial_part >= this.dialog_list.length && (0 === this.index_dial_part && (this.switchCurrentCharacter(1, 2), this.player.is_speaking = !1, this.not_player.is_speaking = !1, this.index_dial_part = 1), !this.wait_proposition)) if (this.current_character.is_speaking = !1, this.player.wait = !1, this.not_player.wait = !1, "default" != this.current_stage.type) SG.phase_manager.is_in_stage_phase || SG.game.event_controller.nextPhase(this.current_stage.id); else if (1 == this.current_stage.paths.length && "" === this.current_stage.paths[0].short_descriptions[SG.core.lang]) {
  3596.             var stage_id = this.current_stage.paths[0].target;
  3597.             this.stageHasEndPopup(this.current_stage) ? (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left"), this.wait_proposition = !0) : SG.game.event_controller.nextPhase(stage_id)
  3598.         } else this.current_stage.paths.length > 0 ? (this.wait_proposition = !0, this.stageHasEndPopup(this.current_stage) && (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left")), SG.game.event_controller.displayProposition(this.current_stage, !1, !1)) : (this.ready_for_next_dialog_part = !1, this.stageHasEndPopup(this.current_stage) ? (SG.game.event_controller.displayEndPopup(this.current_stage), $(".popup-context").removeClass("slide-left")) : SG.game.event_controller.endGame())
  3599.     }, reset: function () {
  3600.         this.cache.destroy(), this.dialog_list = [], this.camera_controller = null, this.subtitle_controller = new SG.Game.SubtitleController, this.loadManager = null, this.current_stage = {}, this.group_characters = null, this.player = null, this.not_player = null, this.current_character = null, this.force_camera = "undefined", this.index_dial_part = 0, this.ready_for_next_dialog_part = !1, this.load_status = null, this.wait_proposition = !1, this.current_sound = {}
  3601.     }, _nextDialogPart: function (index) {
  3602.         this.ready_for_next_dialog_part = !1;
  3603.         var data, datatype, role, character, data_types_list = ["role", "move_ref", "text", "sound", "force_camera"];
  3604.         for (var key in data_types_list) if (datatype = data_types_list[key], this.dialog_list[index].datas.hasOwnProperty(datatype)) switch (data = this.dialog_list[index].datas[datatype],
  3605.             datatype) {
  3606.             case"force_camera":
  3607.                 this.force_camera = 0 == this.current_stage.cam_auto ? data : "undefined", this.player.wait = !0, this.not_player.wait = !0, this.ready_for_next_dialog_part = !0;
  3608.                 break;
  3609.             case"sound":
  3610.                 var sound = data;
  3611.                 this.playSound(sound);
  3612.                 break;
  3613.             case"text":
  3614.                 var subtitle_text = data,
  3615.                     name = this.current_character.character.names_to_display[SG.core.lang] ? this.current_character.character.names_to_display[SG.core.lang] : this.current_character.character.names[SG.core.lang];
  3616.                 this.subtitle_controller.setSubtitle(subtitle_text, name);
  3617.                 break;
  3618.             case"move_ref":
  3619.                 this.current_character.wait = !0;
  3620.                 var move_string = data;
  3621.                 this.current_character.movement_controller.setMove(move_string), this.ready_for_next_dialog_part = !0;
  3622.                 break;
  3623.             case"role":
  3624.                 role = data, character = this.dialog_list[index].datas.character, this.switchCurrentCharacter(role, character.id, this.force_camera)
  3625.         }
  3626.         this.index_dial_part = index + 1
  3627.     }, switchCurrentCharacter: function (role, character_id, force_cam) {
  3628.         var pos;
  3629.         return 1 == role ? (this.current_character = this.not_player, pos = 2) : 2 == role && (this.current_character = this.player, pos = 1), 1 == this.current_stage.cam_auto && (6 == this.player.character.id ? force_cam = 2 : 6 == this.not_player.character.id && (force_cam = 1)), 1 == force_cam ? (this.player.is_filmed = !0, this.not_player.is_filmed = !1, this.player.attitude_id = this.player.attitude_id || 1, this.player.is_speaking = 2 == role, pos = 1) : 2 == force_cam ? (this.player.is_filmed = !1, this.not_player.is_filmed = !0, this.not_player.attitude_id = this.not_player.attitude_id || 3, this.not_player.is_speaking = 1 == role, pos = 2) : 1 == role ? (this.player.is_filmed = !1, this.not_player.is_filmed = !0, this.not_player.is_speaking = !0, this.not_player._attitude_id = this.not_player._attitude_id < 1 || 3 == this.not_player.attitude_id ? 1 : this.not_player._attitude_id) : 2 == role ? (this.not_player.is_filmed = !1, this.player.is_filmed = !0, this.player.is_speaking = !0, this.player._attitude_id = this.player._attitude_id < 1 || 3 == this.player.attitude_id ? 1 : this.player._attitude_id) : console.log("Le role id n'éxiste pas"), this.camera_controller.switchCamera(pos), null
  3630.     }, playSound: function (sound_string) {
  3631.         var _this = this;
  3632.         if (this.cache.checkSoundKey(sound_string)) {
  3633.             var soundToPlay = this.current_sound = this.game.add.audio(sound_string);
  3634.             null !== soundToPlay ? (this.game.sound.setDecodedCallback([soundToPlay], function () {
  3635.                 soundToPlay.play()
  3636.             }, this), soundToPlay.onStop.add(function (sound) {
  3637.                 _this.ready_for_next_dialog_part = !0, null != _this.player && null != _this.not_player ? (_this.player.wait = !0, _this.not_player.wait = !0) : this.waitIfNotSound(this.subtitle_controller.temporisation)
  3638.             }, this)) : this.waitIfNotSound(this.subtitle_controller.temporisation)
  3639.         } else this.waitIfNotSound(this.subtitle_controller.temporisation)
  3640.     }, waitIfNotSound: function (temporisation) {
  3641.         var _this = this;
  3642.         setTimeout(function () {
  3643.             _this.ready_for_next_dialog_part = !0, _this.player.wait = !0, _this.not_player.wait = !0
  3644.         }, temporisation)
  3645.     }, resizeGame: function () {
  3646.         var width = SG.game.width, height = SG.game.height, offset_x = -((1650 - width) / 2);
  3647.         this.group_characters.x = offset_x, this.camera_controller.cams[1].x = offset_x, this.camera_controller.cams[2].x = offset_x, this.camera_controller.cams[1].items.x = offset_x, this.camera_controller.cams[2].items.x = offset_x;
  3648.         var offset_y = -((1050 - height) / 2);
  3649.         this.group_characters.y = offset_y, this.camera_controller.cams[1].y = offset_y, this.camera_controller.cams[2].y = offset_y, this.camera_controller.cams[1].items.y = offset_y, this.camera_controller.cams[2].items.y = offset_y, this.scale.refresh()
  3650.     }, render: function () {
  3651.         SG.core.debug_mode && this.game.debug.text("FPS : " + this.game.time.fps || "--", 30, 100)
  3652.     }, stageHasEndPopup: function (stage) {
  3653.         return "" != stage._transition_content[SG.core.lang] && null != stage._transition_content[SG.core.lang] || "" != stage._stage_bob_pictures[SG.core.lang] && null != stage._stage_bob_pictures[SG.core.lang]
  3654.     }
  3655. }, SG.Game.CharacterPrefab = function (game, character) {
  3656.     Phaser.Sprite.call(this, game), this.movement_controller = new SG.Game.MovementController(this), this._character = character, this._current_move = {}, this._is_speaking = !0, this._is_filmed = !1, this._is_animated = !1, this._wait = !0, this._attitude_id = 0, this._pause_attitude_id = 0, this.onSpecificAnimation = new Phaser.Signal;
  3657.     var _this = this;
  3658.     this.events.onAnimationComplete.add(function () {
  3659.         this._is_animated = !1, 130 == _this.current_move.id && _this.onSpecificAnimation.dispatch(this, 7, !0)
  3660.     }, this), this.events.onAnimationStart.add(function () {
  3661.         this._is_animated = !0, 133 == _this.current_move.id && _this.onSpecificAnimation.dispatch(this, 7, !1)
  3662.     }, this)
  3663. }, SG.Game.CharacterPrefab.prototype = Object.create(Phaser.Sprite.prototype), SG.Game.CharacterPrefab.prototype.constructor = SG.Game.CharacterPrefab, SG.Game.CharacterPrefab.prototype.update = function () {
  3664.     6 != this.character.id && (this.is_animated || this.wait || this.movement_controller.playMovement())
  3665. }, Object.defineProperties(SG.Game.CharacterPrefab.prototype, {
  3666.     character: {
  3667.         get: function () {
  3668.             return this._character
  3669.         }, set: function (character) {
  3670.             this._character = character
  3671.         }
  3672.     }, current_move: {
  3673.         get: function () {
  3674.             return this._current_move
  3675.         }, set: function (current_move) {
  3676.             this._current_move = current_move
  3677.         }
  3678.     }, is_filmed: {
  3679.         get: function () {
  3680.             return this._is_filmed
  3681.         }, set: function (is_filmed) {
  3682.             this._is_filmed = is_filmed
  3683.         }
  3684.     }, attitude_id: {
  3685.         get: function () {
  3686.             return this._attitude_id
  3687.         }, set: function (attitude_id) {
  3688.             this._attitude_id = attitude_id
  3689.         }
  3690.     }, pause_attitude_id: {
  3691.         get: function () {
  3692.             return this._pause_attitude_id
  3693.         }, set: function (pause_attitude_id) {
  3694.             this._pause_attitude_id = pause_attitude_id
  3695.         }
  3696.     }, is_animated: {
  3697.         get: function () {
  3698.             return this._is_animated
  3699.         }, set: function (is_animated) {
  3700.             this._is_animated = is_animated
  3701.         }
  3702.     }, is_speaking: {
  3703.         get: function () {
  3704.             return this._is_speaking
  3705.         }, set: function (is_speaking) {
  3706.             this._is_speaking = is_speaking
  3707.         }
  3708.     }, wait: {
  3709.         get: function () {
  3710.             return this._wait
  3711.         }, set: function (wait) {
  3712.             this._wait = wait
  3713.         }
  3714.     }
  3715. }), SG.Game.CameraPrefab = function (game, parent, name, addToStage, background, items, cam_id) {
  3716.     Phaser.Group.call(this, game, parent, name, addToStage);
  3717.     var _this = this;
  3718.     this.items = new Phaser.Group(_this.game, null, "", !0), this.create(0, 0, background);
  3719.     var item_name;
  3720.     for (var item_id in items) if (void 0 !== items[item_id].position[cam_id]) {
  3721.         var position = items[item_id].position[cam_id], item_id = items[item_id].id;
  3722.         _this.items.name = "items_cam" + position.cam, item_name = "itm" + item_id + "_bgn" + position.bgn + "_cam" + cam_id;
  3723.         var item_inserted = _this.items.create(parseInt(position.x), parseInt(position.y), item_name);
  3724.         item_inserted.id = item_id
  3725.     }
  3726. }, SG.Game.CameraPrefab.prototype = Object.create(Phaser.Group.prototype), SG.Game.CameraPrefab.prototype.constructor = SG.Game.CameraPrefab, SG.Game.CameraController = function (game, position) {
  3727.     var _this = this;
  3728.     this.game = game, this.cam_position = position, this.cams = [];
  3729.     var i = 1;
  3730.     SG.game.scenery.cameras.forEach(function (camera) {
  3731.         var backgroundToSet = "cam_" + camera.id;
  3732.         _this.cams[i] = new SG.Game.CameraPrefab(game, null, backgroundToSet, !0, backgroundToSet, SG.game.scenery.items, camera.id), i++
  3733.     }), this.switchCamera(position, !0)
  3734. }, SG.Game.CameraController.prototype.switchCamera = function (position, force) {
  3735.     force = force || !1;
  3736.     var _this = this, turned = !1;
  3737.     if (position != this.cam_position || force) {
  3738.         this.cam_position = position;
  3739.         var children_count = this.game.stage.children.length, index_to_top = children_count - 1;
  3740.         this.game.stage.setChildIndex(this.cams[position], index_to_top), this.game.stage.children.forEach(function (child) {
  3741.             "characters" == child.name && _this.game.stage.setChildIndex(child, index_to_top)
  3742.         }), this.game.stage.setChildIndex(this.cams[position].items, index_to_top), this.game.stage.children.forEach(function (child) {
  3743.             "__world" == child.name && _this.game.stage.setChildIndex(child, index_to_top)
  3744.         }), turned = !0
  3745.     }
  3746.     return turned
  3747. }, SG.Game.CameraController.prototype._getItemsByCamId = function (cam_id) {
  3748.     var items_to_return = [];
  3749.     return this._items_list.forEach(function (item) {
  3750.         item.pos.cam == cam_id && items_to_return.push(item)
  3751.     }), items_to_return
  3752. }, SG.Game.CameraController.prototype.displayItemById = function (event, id, is_display) {
  3753.     var item_to_set, _this = SG.game.phaser_game.state.callbackContext.camera_controller;
  3754.     _this.cams[_this.cam_position].items.children.forEach(function (item) {
  3755.         item.id == id && (item_to_set = item)
  3756.     }), void 0 !== item_to_set && (item_to_set.visible = is_display, console.log("the item : " + item_to_set.id + " is display ? " + is_display + " - " + item_to_set.visible))
  3757. }, SG.Game.LoadManager = function (loader) {
  3758.     this.loader = loader, this.sounds_list = [], this.nb_sounds_loaded = 0, this.nb_sounds_loading = 0, this.loading_lvl = 1, this.limit_of_sounds_to_preload = 20
  3759. }, SG.Game.LoadManager.prototype = {
  3760.     loadScenery: function (act, scenery) {
  3761.         var cam_name, _this = this;
  3762.         scenery.cameras.forEach(function (camera) {
  3763.             cam_name = "cam_" + camera.id, _this.loader.image(cam_name, SG.core.base_url + "" + camera.path)
  3764.         });
  3765.         var item_name;
  3766.         for (var item in scenery.items) {
  3767.             var item_id = scenery.items[item].id;
  3768.             scenery.items[item].position.forEach(function (position) {
  3769.                 item_name = "itm" + item_id + "_bgn" + position.bgn + "_cam" + position.cam, _this.loader.image(item_name, SG.core.base_url + "/ressources/medias/items/" + item_name + ".png")
  3770.             })
  3771.         }
  3772.     }, preloadCustomBackground: function (name, url) {
  3773.         this.loader.image(name, url), SG.game.custom_backgrounds[name] = new Phaser.Group(SG.game.phaser_game, null, name, !0)
  3774.     }, loadCustomBackgrounds: function () {
  3775.         for (var name in SG.game.custom_backgrounds) SG.game.custom_backgrounds[name].create(0, 0, name)
  3776.     }, preloadScenario: function () {
  3777.         var url, animation_name, sprite_url, sprite_json_url, _this = this,
  3778.             player_moves = SG.game.scenery.getBasicMovesForUser(SG.game.player.id, 1),
  3779.             not_player_moves = SG.game.scenery.getBasicMovesForUser(SG.game.not_player.id, 2);
  3780.         player_moves.forEach(function (move) {
  3781.             SG.game.player.moves.push(move), url = SG.game.scenery.getUrlForUser(SG.game.player.id, move.position, move.cam), animation_name = "s" + SG.game.scenery.id + "_u" + SG.game.player.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(animation_name, sprite_url, sprite_json_url)
  3782.         }), not_player_moves.forEach(function (move) {
  3783.             SG.game.not_player.moves.push(move), url = SG.game.scenery.getUrlForUser(SG.game.not_player.id, move.position, move.cam), animation_name = "s" + SG.game.scenery.id + "_u" + SG.game.not_player.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(animation_name, sprite_url, sprite_json_url)
  3784.         })
  3785.     }, loadStage: function (stage, dialog_list) {
  3786.         var sound_name, sound_url, move_name, url, moves, sprite_url, sprite_json_url, _this = this;
  3787.         dialog_list.forEach(function (dialog) {
  3788.             dialog.type == SG.Model.DialogPart.TYPE_MOVE && (moves = SG.game.scenery.getSpecificMovesForUser(dialog.datas.character.id, dialog.datas.role, dialog.datas.move_ref), moves.forEach(function (move) {
  3789.                 dialog.datas.character.moves.push(move), url = SG.game.scenery.getUrlForUser(dialog.datas.character.id, move.position, move.cam), move_name = "s" + SG.game.scenery.id + "_u" + dialog.datas.character.id + "_" + move.reference, sprite_url = SG.core.base_url + url + "/" + move.reference + ".png", sprite_json_url = SG.core.base_url + url + "/" + move.reference + ".json", _this.loader.atlasJSONArray(move_name, sprite_url, sprite_json_url)
  3790.             }))
  3791.         }), stage.sounds[SG.core.lang].forEach(function (sound) {
  3792.             sound.character_id != SG.game.player.id && sound.character_id != SG.game.not_player.id || (sound_name = "stage" + stage.id + "_u" + sound.character_id + "_p" + sound.part, sound_url = SG.core.medias_url + "" + sound.file_path, _this.loader.audio(sound_name, sound_url), _this.sounds_list.push(sound_name))
  3793.         })
  3794.     }, loadNextStage: function () {
  3795.     }, removeUnusedAssets: function () {
  3796.         this.loader.game.sound.destroy()
  3797.     }
  3798. }, SG.Game.DialogParserController = function () {
  3799.     this.START_DIALOG_DELIMITER1 = "(--", this.START_DIALOG_DELIMITER2 = ")", this.START_MOVE_DELIMITER1 = "(MV-", this.START_MOVE_DELIMITER2 = "[", this.PARAM_MOVE_DELIMITER = ",", this.END_MOVE_DELIMITER = "])", this.START_CINEMATIC_DELIMITER1 = "[C", this.START_CINEMATIC_DELIMITER2 = "]", this.START_BGS_DELIMITER1 = "[BGS:", this.START_BGS_DELIMITER2 = "]", this.START_DOC_DELIMITER1 = "[DOC-", this.START_DOC_DELIMITER2 = "]", this.START_BLUR_DELIMITER1 = "[BLUR:", this.START_BLUR_DELIMITER2 = "]", this.SHOW_ITEM_DELIMITER1 = "[SHOWITEM:", this.SHOW_ITEM_DELIMITER2 = "]", this.START_PICTURE_DELIMITER1 = "[IMG:", this.START_PICTURE_DELIMITER2 = "]", this.START_SWF_DELIMITER1 = "[SWF:", this.START_SWF_DELIMITER2 = "]", this.SWITCHCAM_DELIMITER1 = "[SwitchCam:", this.SWITCHCAM_DELIMITER2 = "]"
  3800. }, SG.Game.DialogParserController.prototype = {
  3801.     parseStageContent: function (stage) {
  3802.         for (var skip_this_part, DialogPart = SG.Model.DialogPart, stage_id = (SG.core.lang, stage.scenario_id, stage.id), description = stage.short_descriptions[SG.core.lang], list_of_part = [], delimiter_positions = {}, delimiters_length = this._getDelimitersLength(), part_number = 1, security_cpt = 0; description.length > 0;) {
  3803.             skip_this_part = !1, delimiter_positions = {}, delimiter_positions = this._getDelimitersPositionsFromDescription(description);
  3804.             var current_type = DialogPart.NONE;
  3805.             for (var key in delimiter_positions) (delimiter_positions[current_type] == -1 || delimiter_positions[key] < delimiter_positions[current_type] && delimiter_positions[key] > -1) && (current_type = key);
  3806.             var tmp_length, string_role_id, role_id, current_character, cam_id, sound_name, text_speech, datas = {};
  3807.             switch (current_type) {
  3808.                 case DialogPart.TYPE_CAMERA:
  3809.                     description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf(this.SWITCHCAM_DELIMITER2), cam_id = description.substring(0, tmp_length), description = description.substring(tmp_length + 1), datas.force_camera = cam_id;
  3810.                     break;
  3811.                 case DialogPart.TYPE_SPEECH:
  3812.                     description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf(this.START_DIALOG_DELIMITER2), string_role_id = description.substring(0, tmp_length), description = description.substring(string_role_id.length), role_id = parseInt(string_role_id), delimiter_positions = {}, delimiter_positions = this._getDelimitersPositionsFromDescription(description);
  3813.                     var next_type = DialogPart.NONE;
  3814.                     tmp_length = -1;
  3815.                     for (key in delimiter_positions) (delimiter_positions[next_type] == -1 || delimiter_positions[key] < delimiter_positions[next_type] && delimiter_positions[key] > -1) && (next_type = key);
  3816.                     tmp_length = delimiter_positions[next_type] - 1, tmp_length >= 0 ? text_speech = description.substring(this.START_DIALOG_DELIMITER2.length, tmp_length) : (text_speech = description.substring(this.START_DIALOG_DELIMITER2.length), description = ""), current_character = this._findUserIdFromRoleId(role_id), datas.role = role_id, datas.character = current_character, datas.text = text_speech, sound_name = "stage" + stage_id + "_u" + current_character.id + "_p" + part_number, datas.sound = sound_name, part_number++;
  3817.                     break;
  3818.                 case DialogPart.TYPE_MOVE:
  3819.                     description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), tmp_length = description.indexOf("["), string_role_id = description.substring(0, tmp_length), description = description.substring(string_role_id.length + 1), role_id = parseInt(string_role_id), tmp_length = description.indexOf(this.END_MOVE_DELIMITER);
  3820.                     var move_info = description.substring(0, tmp_length);
  3821.                     description = description.substring(tmp_length + 1);
  3822.                     var move_info_array = move_info.split(this.PARAM_MOVE_DELIMITER), move_ref = move_info_array[0],
  3823.                         force_speeking_move = "undefined";
  3824.                     move_info_array.length > 1 && (force_speeking_move = move_info_array[1]), current_character = this._findUserIdFromRoleId(role_id), datas.role = role_id, datas.character = current_character, datas.move_ref = move_ref, datas.override_speeking = force_speeking_move;
  3825.                     break;
  3826.                 case DialogPart.NONE:
  3827.                     console.log("No More Tag"), description = "", skip_this_part = !0;
  3828.                     break;
  3829.                 default:
  3830.                     description = description.substring(delimiter_positions[current_type] + delimiters_length[current_type]), skip_this_part = !0, console.log("tag not yet supported : " + current_type)
  3831.             }
  3832.             if (!skip_this_part) {
  3833.                 var part = new DialogPart(current_type, datas);
  3834.                 list_of_part.push(part)
  3835.             }
  3836.             if (security_cpt++, security_cpt > 100) return console.log("Boucle supérieur à " + security_cpt + " itérations"), list_of_part
  3837.         }
  3838.         return list_of_part
  3839.     }, _findUserIdFromRoleId: function (role_id) {
  3840.         return 2 == role_id ? SG.game.player : SG.game.not_player
  3841.     }, _getDelimitersPositionsFromDescription: function (currentDescription) {
  3842.         var delimiters = {}, DialogPart = SG.Model.DialogPart;
  3843.         return delimiters[DialogPart.TYPE_SPEECH] = currentDescription.indexOf(this.START_DIALOG_DELIMITER1), delimiters[DialogPart.TYPE_CINEMATIC] = currentDescription.indexOf(this.START_CINEMATIC_DELIMITER1), delimiters[DialogPart.TYPE_PICTURE] = currentDescription.indexOf(this.START_PICTURE_DELIMITER1), delimiters[DialogPart.TYPE_SWF] = currentDescription.indexOf(this.START_SWF_DELIMITER1), delimiters[DialogPart.TYPE_BGS] = currentDescription.indexOf(this.START_BGS_DELIMITER1), delimiters[DialogPart.TYPE_MOVE] = currentDescription.indexOf(this.START_MOVE_DELIMITER1), delimiters[DialogPart.TYPE_DOC] = currentDescription.indexOf(this.START_DOC_DELIMITER1), delimiters[DialogPart.TYPE_BLUR] = currentDescription.indexOf(this.START_BLUR_DELIMITER1), delimiters[DialogPart.TYPE_ITEM] = currentDescription.indexOf(this.SHOW_ITEM_DELIMITER1), delimiters[DialogPart.TYPE_CAMERA] = currentDescription.indexOf(this.SWITCHCAM_DELIMITER1), delimiters[DialogPart.NONE] = -1, delimiters
  3844.     }, _getDelimitersLength: function () {
  3845.         var delimiters = {}, DialogPart = SG.Model.DialogPart;
  3846.         return delimiters[DialogPart.TYPE_SPEECH] = this.START_DIALOG_DELIMITER1.length, delimiters[DialogPart.TYPE_CINEMATIC] = this.START_CINEMATIC_DELIMITER1.length, delimiters[DialogPart.TYPE_PICTURE] = this.START_PICTURE_DELIMITER1.length, delimiters[DialogPart.TYPE_SWF] = this.START_SWF_DELIMITER1.length, delimiters[DialogPart.TYPE_BGS] = this.START_BGS_DELIMITER1.length, delimiters[DialogPart.TYPE_MOVE] = this.START_MOVE_DELIMITER1.length, delimiters[DialogPart.TYPE_DOC] = this.START_DOC_DELIMITER1.length, delimiters[DialogPart.TYPE_BLUR] = this.START_BLUR_DELIMITER1.length, delimiters[DialogPart.TYPE_ITEM] = this.SHOW_ITEM_DELIMITER1.length, delimiters[DialogPart.TYPE_CAMERA] = this.SWITCHCAM_DELIMITER1.length, delimiters[DialogPart.NONE] = 2, delimiters
  3847.     }
  3848. }, SG.Game.SubtitleController = function () {
  3849.     this._temporisation = 0
  3850. }, SG.Game.SubtitleController.prototype = {
  3851.     setSubtitle: function (text, name) {
  3852.         SG.game.event_controller.setSubtitle(text, name);
  3853.         var longueur = text.length;
  3854.         this.temporisation = longueur / 25, this.temporisation < 1.5 && (this.temporisation = 1.5), this.temporisation = 1e3 * this.temporisation
  3855.     }
  3856. }, Object.defineProperties(SG.Game.SubtitleController.prototype, {
  3857.     temporisation: {
  3858.         get: function () {
  3859.             return this._temporisation
  3860.         }, set: function (time) {
  3861.             this._temporisation = time
  3862.         }
  3863.     }
  3864. }), SG.Game.EventController = function (scope) {
  3865.     this.scope = scope, this.displayProposition = function (stage, hide, isByNextStep, stage_type) {
  3866.         this.scope.$emit("displayProposition", stage, hide, isByNextStep, stage_type)
  3867.     }, this.displayEndPopup = function (stage) {
  3868.         this.scope.$emit("displayEndPopup", stage)
  3869.     }, this.displayNotification = function (title, text) {
  3870.         this.scope.$emit("displayNotification", title, text)
  3871.     }, this.displayScenario = function (display) {
  3872.         this.scope.$emit("displayScenario", display)
  3873.     }, this.setSubtitle = function (subtitle, name, is_displayed) {
  3874.         this.scope.$emit("displaySubtitle", subtitle, name)
  3875.     }, this.goToStagePhase = function (stage) {
  3876.         this.scope.$emit("goToStagePhase", stage)
  3877.     }, this.goToStage = function (stage_id) {
  3878.         this.scope.$emit("goToStage", stage_id)
  3879.     }, this.nextPhase = function (stage_id) {
  3880.         this.scope.$emit("nextPhase", stage_id, "default")
  3881.     }, this.endGame = function (stage_id) {
  3882.         this.scope.$emit("endGame")
  3883.     }, this.characterSelection = function (stage_id) {
  3884.         this.scope.$emit("characterSelection", stage_id)
  3885.     }, this.reportProgress = function (value) {
  3886.         this.scope.$emit("reportProgress", value)
  3887.     }, this.readyToShow = function (value) {
  3888.         this.scope.$emit("readyToShow", value)
  3889.     }, this.onCriterionsChange = function (value) {
  3890.         this.scope.$emit("onCriterionsChange", value)
  3891.     }
  3892. }, SG.Game.MovementController = function (character) {
  3893.     this.character = character, this.FRAME_PER_SECOND = 24, this.DEFAULT_SPEAK_ATTITUDE_ID = 1, this.DEFAULT_PAUSE_ATTITUDE_ID = 3
  3894. }, SG.Game.MovementController.prototype = {
  3895.     playMovement: function () {
  3896.         var moves, attitude_id;
  3897.         this.character.is_filmed ? ("backview_breath_front" == this.character.current_move.reference && (this.character.attitude_id = this.saved_attitude_id, this.character.pause_attitude_id = this.saved_pause_attitude_id, this.saved_attitude_id = this.DEFAULT_SPEAK_ATTITUDE_ID, this.saved_pause_attitude_id = this.DEFAULT_PAUSE_ATTITUDE_ID), attitude_id = this.character.is_speaking ? this.character.attitude_id : this.character.pause_attitude_id, moves = this.character.character.getMovesByAttitudeId(attitude_id, this.character.is_filmed), 0 === moves.length && (attitude_id = this.character.is_speaking ? this.DEFAULT_SPEAK_ATTITUDE_ID : this.DEFAULT_PAUSE_ATTITUDE_ID, moves = this.character.character.getMovesByAttitudeId(attitude_id, this.character.is_filmed))) : moves = this.character.character.getMovesByAttitudeId(this.DEFAULT_PAUSE_ATTITUDE_ID, this.character.is_filmed);
  3898.         var movesToSelect = [];
  3899.         moves.forEach(function (move) {
  3900.             for (var i = 0; i < move.proba; i++) movesToSelect.push(move)
  3901.         });
  3902.         var index;
  3903.         index = movesToSelect.length > 0 ? (Math.random() * (movesToSelect.length - 1)).toFixed() : 0;
  3904.         var move = movesToSelect[index];
  3905.         0 != movesToSelect.length && (this.character.current_move.reference ? ("backview_breath_front" == move.reference && this.character.current_move.reference != move.reference && (this.saved_attitude_id = this.character.attitude_id, this.saved_pause_attitude_id = this.character.pause_attitude_id), this._playAnimation(move)) : move && this._playAnimation(move))
  3906.     }, setMove: function (move_reference) {
  3907.         var move = this.character.character.getMoveByReference(move_reference);
  3908.         null !== move && this.character.is_filmed && (console.log("set specific movement for character : " + this.character.character.id + " animation : " + move.reference), this._playAnimation(move))
  3909.     }, _playAnimation: function (move) {
  3910.         this.character.current_move = move, this.character.attitude_id = move.speak_id ? move.speak_id : this.DEFAULT_SPEAK_ATTITUDE_ID, this.character.pause_attitude_id = move.pause_id ? move.pause_id : this.DEFAULT_PAUSE_ATTITUDE_ID, this.character.loadTexture("s" + SG.game.scenery.id + "_u" + this.character.character.id + "_" + move.reference, 0), this.character.animations.add(move.reference), this.character.animations.play(move.reference, this.FRAME_PER_SECOND, !1), this.character.x = move.x, this.character.y = move.y, this.character.is_animated = !0
  3911.     }
  3912. }, SG.Game.MemoryEffect = function (stage) {
  3913.     this.stage = stage || {}
  3914. }, SG.Game.MemoryEffect.prototype = {
  3915.     executeStageMemoryEffect: function (stage) {
  3916.     }, executePropositionMemoryEffect: function (stage_path) {
  3917.         var condition = stage_path.condition;
  3918.         "" !== condition && (condition = condition.replace("displayPathIf(", "this.displayPathIf( stage_path,"), condition = condition.replace("criterionEqualTo", "this.criterionEqualTo"), condition = condition.replace("criterionInfOrEqTo", "this.criterionInfOrEqTo"), condition = condition.replace("criterionSuperiorTo", "this.criterionSuperiorTo"), condition = condition.replace("goneThrew", "this.goneThrew"), condition = condition.replace("goneThrewIn", "this.goneThrewIn"), console.log("Memory effect - condition ---> "), console.log(condition), eval(condition))
  3919.     }, _executeMemoryEffect: function (conditions, path_id, parent, target) {
  3920.     }, runCmd: function (cmd) {
  3921.     }, criterionEqualTo: function (criterion_id, value) {
  3922.         var is_equal, score;
  3923.         return score = SG.tracker.getScoreByCriterionId(criterion_id), is_equal = score == value
  3924.     }, criterionInfOrEqTo: function (criterion_id, value) {
  3925.         var is_inferior_or_equal, score;
  3926.         return score = SG.tracker.getScoreByCriterionId(criterion_id), is_inferior_or_equal = score <= value
  3927.     }, criterionSuperiorTo: function (criterion_id, value) {
  3928.         var is_superior, score;
  3929.         return score = SG.tracker.getScoreByCriterionId(criterion_id), is_superior = score > value
  3930.     }, goneThrew: function (stage_id) {
  3931.         var is_gone_threw;
  3932.         return is_gone_threw = void 0 !== SG.tracker.stages[stage_id] && null !== SG.tracker.stages[stage_id]
  3933.     }, goneThrewIn: function (stage_ids_list, number_done) {
  3934.         var is_gone_threw, cpt = 0;
  3935.         return stage_ids_list.forEach(function (stage_id) {
  3936.             this.goneThrew(stage_id) && cpt++
  3937.         }), is_gone_threw = cpt >= number_done
  3938.     }, displayPathIf: function (stage_path, is_display) {
  3939.         stage_path.is_display = is_display
  3940.     }, addPointIf: function () {
  3941.     }, gotoPreviousStage: function () {
  3942.     }, goToStage: function () {
  3943.     }, isInArray: function () {
  3944.     }, goToIf: function () {
  3945.     }, enablePathIf: function () {
  3946.     }, getCriterionPercentage: function () {
  3947.     }, getPreviousStage: function () {
  3948.     }
  3949. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement