Skip to content

Commit

Permalink
Merge branch 'pr/1381' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Oct 17, 2023
2 parents e2426b2 + 6b9307b commit 536d13c
Show file tree
Hide file tree
Showing 37 changed files with 992 additions and 3,987 deletions.
2 changes: 1 addition & 1 deletion activities/MindMath.activity/css/activity.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body {
transition: opacity .4s;
}

.fade-enter, .fade-leave-to {
.fade-enter-from, .fade-leave-to {
opacity: 0;
}

Expand Down
77 changes: 38 additions & 39 deletions activities/MindMath.activity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta charset="utf-8" />
<title>Mind Math Activity</title>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, viewport-fit=cover" />
<link rel="prefetch" type="application/l10n" href="locale.ini" />
<link rel="stylesheet" media="not screen and (device-width: 1200px) and (device-height: 900px)"
href="lib/sugar-web/graphics/css/sugar-96dpi.css">
href="lib/sugar-web/graphics/css/sugar-96dpi.css"/>
<link rel="stylesheet" media="screen and (device-width: 1200px) and (device-height: 900px)"
href="lib/sugar-web/graphics/css/sugar-200dpi.css">
<link rel="stylesheet" href="css/activity.css">
Expand All @@ -18,7 +17,7 @@
<link rel="stylesheet" href="css/introjs.css">
<link rel="stylesheet" href="css/libnotify.css">
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<script src="lib/vue.min.js"></script>
<script src="lib/vue.global.prod.js"></script>
<script src="lib/intro.js"></script>
<script src="lib/require.js"></script>
<script type="text/javascript" src="../../cordova.js"></script>
Expand Down Expand Up @@ -86,47 +85,47 @@
<sugar-toolitem v-else v-on:click="unfullscreen" id="unfullscreen-button" v-bind:title="l10n.stringUnfullscreen" class="pull-right"></sugar-toolitem>
<sugar-toolitem id="help-button" v-bind:title="l10n.stringTutorial" class="pull-right" v-on:click="onHelp"></sugar-toolitem>
</sugar-toolbar>

<transition name="fade" id="app-content" mode="out-in">
<component
v-bind:is="currentScreen"
v-bind:time="clock.time"
v-bind:stroke-color="strokeColor"
v-bind:fill-color="fillColor"
v-bind:questions="questions"
v-bind:q-no="qNo"
v-bind:score="score"
v-bind:mode="mode"
v-bind:compulsory-ops="compulsoryOps"
v-bind:compulsory-ops-for-each-question="compulsoryOpsForEachQuestion"
v-bind:compulsory-ops-rem="compulsoryOpsRem"
v-bind:slots="slots"
v-bind:scores="scores"
v-bind:time-taken="timeTaken"
v-bind:input-numbers="inputNumbers"
v-bind:input-numbers-types="inputNumbersTypes"
v-bind:players-all="playersAll"
v-bind:players-playing="playersPlaying"
v-bind:disabled="disabled"
v-bind:multiplayer="multiplayer"
v-bind:sugar-presence="SugarPresence"
v-bind:is-target-acheived="isTargetAcheived"
v-bind:l10n="l10n"
v-on:validate="onValidate"
v-on:slots-update="onSlotsUpdated"
v-on:restart-game="handleRestartButton"
v-on:pass-question="handlePassButton"
v-on:see-leaderboard="currentScreen = 'leaderboard'"
v-on:go-to-result="currentScreen = 'result'"
></component>
</transition>

<div id="app-content">
<transition name="fade" mode="out-in">
<component
v-bind:is="currentScreen"
v-bind:time="clock.time"
v-bind:stroke-color="strokeColor"
v-bind:fill-color="fillColor"
v-bind:questions="questions"
v-bind:q-no="qNo"
v-bind:score="score"
v-bind:mode="mode"
v-bind:compulsory-ops="compulsoryOps"
v-bind:compulsory-ops-for-each-question="compulsoryOpsForEachQuestion"
v-bind:compulsory-ops-rem="compulsoryOpsRem"
v-bind:slots="slots"
v-bind:scores="scores"
v-bind:time-taken="timeTaken"
v-bind:input-numbers="inputNumbers"
v-bind:input-numbers-types="inputNumbersTypes"
v-bind:players-all="playersAll"
v-bind:players-playing="playersPlaying"
v-bind:disabled="disabled"
v-bind:multiplayer="multiplayer"
v-bind:sugar-presence="currentScreen === 'result' ? SugarPresence : ''"
v-bind:is-target-acheived="isTargetAcheived"
v-bind:l10n="l10n"
v-on:validate="onValidate"
v-on:slots-update="onSlotsUpdated"
v-on:restart-game="handleRestartButton"
v-on:pass-question="handlePassButton"
v-on:see-leaderboard="currentScreen = 'leaderboard'"
v-on:go-to-result="currentScreen = 'result'"
></component>
</transition>
</div>

<sugar-activity ref="SugarActivity" v-on:initialized="initialized"></sugar-activity>
<sugar-popup ref="SugarPopup"></sugar-popup>
<sugar-journal ref="SugarJournal" v-on:journal-data-loaded="onJournalDataLoaded" v-on:journal-load-error="onJournalLoadError" v-on:journal-new-instance="onJournalNewInstance"></sugar-journal>
<sugar-presence ref="SugarPresence" v-on:data-received="onNetworkDataReceived" v-on:user-changed="onNetworkUserChanged"></sugar-presence>
<sugar-localization ref="SugarL10n" v-on:localized="localized"></sugar-localization>
<sugar-localization></sugar-localization>
<sugar-tutorial ref="SugarTutorial"></sugar-tutorial>
<sugar-icon ref="SugarIcon"></sugar-icon>
</div>
Expand Down
45 changes: 20 additions & 25 deletions activities/MindMath.activity/js/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var Game = {
<div class="list-numbers">
<inputNumber
v-for="(number,index) in inputNumbers"
v-on:click.native="onSelectNumber(index)"
v-on:click="onSelectNumber(index)"
class="btn-number"
v-bind:class="{
'selected-num': index === currentSelectedNums.numIndex1 || index === currentSelectedNums.numIndex2,
Expand Down Expand Up @@ -129,16 +129,13 @@ var Game = {
},
currentSelectedOp: null,
compulsoryOpUsed: false,
l10n: {
stringScore: ''
}
};
},
created: function() {
var vm = this;
window.addEventListener('resize', vm.resize);
},
destroyed: function() {
unmounted: function() {
var vm = this;
window.removeEventListener("resize", vm.resize);
},
Expand All @@ -147,10 +144,13 @@ var Game = {
vm.resize();
},
watch: {
slots: function(newVal) {
var vm = this;
//deselecting
vm.deselect();
slots: {
handler(){
var vm = this;
//deselecting
vm.deselect();
},
deep: true
},
qNo: function() {
var vm = this;
Expand All @@ -160,11 +160,6 @@ var Game = {
}
},
methods: {
localized: function() {
console.log("game");
this.SugarL10n.localize(this.l10n);
},

resize: function() {
var vm = this;
var toolbarElem = document.getElementById("main-toolbar");
Expand Down Expand Up @@ -197,8 +192,8 @@ var Game = {
var vm = this;
if (vm.currentSelectedNums.nums.length != 0) {
vm.currentSelectedOp = null;
vm.$set(vm.currentSelectedNums, 'numIndex1', null);
vm.$set(vm.currentSelectedNums, 'numIndex2', null);
vm.currentSelectedNums['numIndex1'] = null;
vm.currentSelectedNums['numIndex2'] = null;
vm.currentSelectedNums.nums = removeEntryFromArray(vm.currentSelectedNums.nums, 0);
if (vm.currentSelectedNums.nums.length != 0) {
vm.currentSelectedNums.nums = removeEntryFromArray(vm.currentSelectedNums.nums, 0);
Expand All @@ -211,10 +206,10 @@ var Game = {
if (vm.currentSelectedNums.numIndex1 === index) {
//deselecting
if (vm.currentSelectedNums.numIndex2 != null) {
vm.$set(vm.currentSelectedNums, 'numIndex1', vm.currentSelectedNums.numIndex2);
vm.$set(vm.currentSelectedNums, 'numIndex2', null);
vm.currentSelectedNums['numIndex1'] = vm.currentSelectedNums.numIndex2;
vm.currentSelectedNums['numIndex2'] = null;
} else {
vm.$set(vm.currentSelectedNums, 'numIndex1', null);
vm.currentSelectedNums['numIndex1'] = null;
}
vm.currentSelectedOp = null;
vm.currentSelectedNums.nums = removeEntryFromArray(vm.currentSelectedNums.nums, 0);
Expand All @@ -225,20 +220,20 @@ var Game = {
return;
} else if (vm.currentSelectedNums.nums.length === 0) {
var at = 0;
vm.$set(vm.currentSelectedNums.nums, at, vm.inputNumbers[index]);
vm.$set(vm.currentSelectedNums, 'numIndex' + (at + 1), index);
vm.currentSelectedNums.nums[at] = vm.inputNumbers[index];
vm.currentSelectedNums['numIndex' + (at + 1)] = index;
} else {
var at = 1;
if (vm.currentSelectedOp !== null) {
if (vm.checkOperation(vm.currentSelectedNums.nums[0], vm.inputNumbers[index], vm.operators[vm.currentSelectedOp]).valid) {
vm.$set(vm.currentSelectedNums.nums, at, vm.inputNumbers[index]);
vm.$set(vm.currentSelectedNums, 'numIndex' + (at + 1), index);
vm.currentSelectedNums.nums[at] = vm.inputNumbers[index];
vm.currentSelectedNums['numIndex' + (at + 1)] = index;
vm.computeOperation();
}
} else {
vm.deselect();
vm.$set(vm.currentSelectedNums.nums, 0, vm.inputNumbers[index]);
vm.$set(vm.currentSelectedNums, 'numIndex1', index);
vm.currentSelectedNums.nums[0] = vm.inputNumbers[index];
vm.currentSelectedNums['numIndex1'] = index;
}
}
},
Expand Down
36 changes: 25 additions & 11 deletions activities/MindMath.activity/js/Leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var Leaderboard = {
window.addEventListener('resize', vm.resize)
vm.sortLeaderboard();
},
destroyed: function() {
unmounted: function() {
var vm = this;
window.removeEventListener("resize", vm.resize);
},
Expand All @@ -92,18 +92,24 @@ var Leaderboard = {
vm.resize();
},
watch: {
playersAll: function() {
var vm = this;
vm.pageCount = Math.ceil(vm.playersAll.length / vm.visibleItemsPerPageCount);
vm.sortLeaderboard();
setTimeout(() => {
vm.resize();
}, 0);
playersAll: {
handler(){
var vm = this;
vm.pageCount = Math.ceil(vm.playersAll.length / vm.visibleItemsPerPageCount);
vm.sortLeaderboard();
setTimeout(() => {
vm.resize();
}, 0);
},
deep: true
},

playersPlaying: function() {
var vm = this;
vm.sortLeaderboard();
playersPlaying: {
handler() {
var vm = this;
vm.sortLeaderboard();
},
deep: true
},

currentPage: function () {
Expand Down Expand Up @@ -175,6 +181,14 @@ var Leaderboard = {
this.currentPage = value
}
this.sortLeaderboard();
},

generateXOLogoWithColor: function (strokeColor, fillColor) {
var xoLogo = '<?xml version="1.0" ?><!DOCTYPE svg PUBLIC \'-//W3C//DTD SVG 1.1//EN\' \'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\' [<!ENTITY stroke_color "#010101"><!ENTITY fill_color "#FFFFFF">]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="stock-xo_1_"><path d="M33.233,35.1l10.102,10.1c0.752,0.75,1.217,1.783,1.217,2.932 c0,2.287-1.855,4.143-4.146,4.143c-1.145,0-2.178-0.463-2.932-1.211L27.372,40.961l-10.1,10.1c-0.75,0.75-1.787,1.211-2.934,1.211 c-2.284,0-4.143-1.854-4.143-4.141c0-1.146,0.465-2.184,1.212-2.934l10.104-10.102L11.409,24.995 c-0.747-0.748-1.212-1.785-1.212-2.93c0-2.289,1.854-4.146,4.146-4.146c1.143,0,2.18,0.465,2.93,1.214l10.099,10.102l10.102-10.103 c0.754-0.749,1.787-1.214,2.934-1.214c2.289,0,4.146,1.856,4.146,4.145c0,1.146-0.467,2.18-1.217,2.932L33.233,35.1z" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/><circle cx="27.371" cy="10.849" fill="&fill_color;" r="8.122" stroke="&stroke_color;" stroke-width="3.5"/></g></svg>';
var coloredLogo = xoLogo;
coloredLogo = coloredLogo.replace("#010101", strokeColor)
coloredLogo = coloredLogo.replace("#FFFFFF", fillColor)
return "data:image/svg+xml;base64," + btoa(coloredLogo);
}

}
Expand Down
10 changes: 9 additions & 1 deletion activities/MindMath.activity/js/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ var Result = {
window.addEventListener('resize', vm.resize)
vm.initializeSlots();
},
destroyed: function() {
unmounted: function() {
var vm = this;
window.removeEventListener("resize", vm.resize);
},
Expand Down Expand Up @@ -300,6 +300,14 @@ var Result = {
this.currentPage = value
}
this.initializeSlots();
},

generateXOLogoWithColor: function (strokeColor, fillColor) {
var xoLogo = '<?xml version="1.0" ?><!DOCTYPE svg PUBLIC \'-//W3C//DTD SVG 1.1//EN\' \'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\' [<!ENTITY stroke_color "#010101"><!ENTITY fill_color "#FFFFFF">]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="stock-xo_1_"><path d="M33.233,35.1l10.102,10.1c0.752,0.75,1.217,1.783,1.217,2.932 c0,2.287-1.855,4.143-4.146,4.143c-1.145,0-2.178-0.463-2.932-1.211L27.372,40.961l-10.1,10.1c-0.75,0.75-1.787,1.211-2.934,1.211 c-2.284,0-4.143-1.854-4.143-4.141c0-1.146,0.465-2.184,1.212-2.934l10.104-10.102L11.409,24.995 c-0.747-0.748-1.212-1.785-1.212-2.93c0-2.289,1.854-4.146,4.146-4.146c1.143,0,2.18,0.465,2.93,1.214l10.099,10.102l10.102-10.103 c0.754-0.749,1.787-1.214,2.934-1.214c2.289,0,4.146,1.856,4.146,4.145c0,1.146-0.467,2.18-1.217,2.932L33.233,35.1z" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/><circle cx="27.371" cy="10.849" fill="&fill_color;" r="8.122" stroke="&stroke_color;" stroke-width="3.5"/></g></svg>';
var coloredLogo = xoLogo;
coloredLogo = coloredLogo.replace("#010101", strokeColor)
coloredLogo = coloredLogo.replace("#FFFFFF", fillColor)
return "data:image/svg+xml;base64," + btoa(coloredLogo);
}

}
Expand Down
4 changes: 2 additions & 2 deletions activities/MindMath.activity/js/Slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Slots = {
>{{slot.res}}</div>
</div>
<template>
<div>
<div
v-bind:style="{
visibility: emptyLinesAllowed != null ? 'visible' : 'hidden'
Expand All @@ -59,7 +59,7 @@ var Slots = {
<div class="slotChild symbol"> = </div>
<div class="slotChild empty-slot"></div>
</div>
</template>
</div>
</div>
`,
Expand Down
Loading

0 comments on commit 536d13c

Please sign in to comment.