Skip to content

Commit

Permalink
Merge branch 'pr/1374' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Jul 10, 2023
2 parents bb7a674 + 56dff92 commit da2d827
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Chart Activity
- CSV support in the Journal
- Export CSV instead of TXT in Measure.activity
- Export CSV in Stopwatch activity

### Fixed
- Chess multiplayer bug when a third player join #1047
Expand Down
4 changes: 4 additions & 0 deletions activities/Stopwatch.activity/css/activity.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
background-image: url(../icons/help.svg);
}

#main-toolbar #export-csv-button {
background-image: url(../icons/save-as-csv.svg);
}

/*Add image to fullscreen/unfullscreen button*/
#fullscreen-button {
background-image: url(../icons/view-fullscreen.svg);
Expand Down
92 changes: 92 additions & 0 deletions activities/Stopwatch.activity/css/libnotify.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
html,
body {
min-height: 100%;
}
.humane,
.humane-libnotify {
position: fixed;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
z-index: 100000;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
}
.humane,
.humane-libnotify {
font-family: Ubuntu, Arial, sans-serif;
text-align: center;
font-size: 15px;
bottom: 10px;
right: 10px;
opacity: 0;
width: 150px;
color: #fff;
padding: 10px;
background: #000;

}
.humane p,
.humane-libnotify p,
.humane ul,
.humane-libnotify ul {
margin: 0;
padding: 0;
}
.humane ul,
.humane-libnotify ul {
list-style: none;
}
.humane.humane-libnotify-info,
.humane-libnotify.humane-libnotify-info {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAABQCAYAAADYxx/bAAAABmJLR0QA/wD/AP+gvaeTAAAAMUlEQVQYlWNgYDB6ysTAwMDAxMDACCcYUFkMDEwMDEwMBNVhkxg65jGhmke6M6hgHgBSdgHnpZwADwAAAABJRU5ErkJggg==');
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0,0,50,0.9)), color-stop(1, rgba(0,0,100,0.9))) no-repeat;
background: -moz-linear-gradient(top, rgba(0,0,50,0.9) 0%, rgba(0,0,100,0.9) 100%) no-repeat;
background: -webkit-linear-gradient(top, rgba(0,0,50,0.9) 0%, rgba(0,0,100,0.9) 100%) no-repeat;
background: -ms-linear-gradient(top, rgba(0,0,50,0.9) 0%, rgba(0,0,100,0.9) 100%) no-repeat;
background: -o-linear-gradient(top, rgba(0,0,50,0.9) 0%, rgba(0,0,100,0.9) 100%) no-repeat;
background: linear-gradient(top, rgba(0,0,50,0.9) 0%, rgba(0,0,100,0.9) 100%) no-repeat;
*background-color: #030;
}
.humane.humane-libnotify-success,
.humane-libnotify.humane-libnotify-success {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAABQCAYAAADYxx/bAAAABmJLR0QA/wD/AP+gvaeTAAAAMUlEQVQYlWNgMGJ4ysTAwMDAxMAIJxhQWQwMDEwMTKgS2NRhkxg65jGhmke6M6hhHgBS2QHn2LzhygAAAABJRU5ErkJggg==');
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0,50,0,0.9)), color-stop(1, rgba(0,100,0,0.9))) no-repeat;
background: -moz-linear-gradient(top, rgba(0,50,0,0.9) 0%, rgba(0,100,0,0.9) 100%) no-repeat;
background: -webkit-linear-gradient(top, rgba(0,50,0,0.9) 0%, rgba(0,100,0,0.9) 100%) no-repeat;
background: -ms-linear-gradient(top, rgba(0,50,0,0.9) 0%, rgba(0,100,0,0.9) 100%) no-repeat;
background: -o-linear-gradient(top, rgba(0,50,0,0.9) 0%, rgba(0,100,0,0.9) 100%) no-repeat;
background: linear-gradient(top, rgba(0,50,0,0.9) 0%, rgba(0,100,0,0.9) 100%) no-repeat;
*background-color: #030;
}
.humane.humane-libnotify-error,
.humane-libnotify.humane-libnotify-error {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADICAYAAAAp8ov1AAAABmJLR0QA/wD/AP+gvaeTAAAAPklEQVQokWMwYmB4ysTAwMCATjASFsOmBBvBRJ7x+O0g0wCS7CDTH/RwH7X9MVDuwyaG032D2M2UeIYO7gMAqt8C19Bn7+YAAAAASUVORK5CYII=');
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(50,0,0,0.9)), color-stop(1, rgba(100,0,0,0.9))) no-repeat;
background: -moz-linear-gradient(top, rgba(50,0,0,0.9) 0%, rgba(100,0,0,0.9) 100%) no-repeat;
background: -webkit-linear-gradient(top, rgba(50,0,0,0.9) 0%, rgba(100,0,0,0.9) 100%) no-repeat;
background: -ms-linear-gradient(top, rgba(50,0,0,0.9) 0%, rgba(100,0,0,0.9) 100%) no-repeat;
background: -o-linear-gradient(top, rgba(50,0,0,0.9) 0%, rgba(100,0,0,0.9) 100%) no-repeat;
background: linear-gradient(top, rgba(50,0,0,0.9) 0%, rgba(100,0,0,0.9) 100%) no-repeat;
*background-color: #300;
}
.humane.humane-animate,
.humane-libnotify.humane-libnotify-animate {
opacity: 1;

}
.humane.humane-animate:hover,
.humane-libnotify.humane-libnotify-animate:hover {
opacity: 0.2;
}
.humane.humane-animate,
.humane-libnotify.humane-libnotify-js-animate {
opacity: 1;

}
.humane.humane-animate:hover,
.humane-libnotify.humane-libnotify-js-animate:hover {
opacity: 0.2;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=20);
}
141 changes: 141 additions & 0 deletions activities/Stopwatch.activity/icons/save-as-csv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions activities/Stopwatch.activity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
href="lib/sugar-web/graphics/css/sugar-200dpi.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/introjs.css">
<link rel="stylesheet" href="css/libnotify.css" />
<link rel="stylesheet" href="css/activity.css">
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="lib/jquery.min.js"></script>
Expand All @@ -25,6 +26,8 @@
<body>
<div id="main-toolbar" class="toolbar">
<button class="toolbutton" id="activity-button" title="My Activity"></button>
<hr style="margin-inline: 10px;" />
<button class="toolbutton" id="export-csv-button" title="Export as csv"></button>
<button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
<button class = "toolbutton pull-right" id = "fullscreen-button" title = "Fullscreen"></button>
<button class="toolbutton pull-right" id="help-button" title="Tutorial"></button>
Expand Down
37 changes: 37 additions & 0 deletions activities/Stopwatch.activity/js/activity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define(["sugar-web/activity/activity","mustache", "sugar-web/env", "tutorial", "webL10n"], function (activity,mustache,env, tutorial, webL10n) {


// Manipulate the DOM only when it is ready.
requirejs(['domReady!'], function (doc) {
Expand Down Expand Up @@ -275,4 +276,40 @@ define(["sugar-web/activity/activity","mustache", "sugar-web/env", "tutorial", "
tutorial.start();
});

document.getElementById("export-csv-button").addEventListener('click', function() {
var stopwatchData = document.getElementById("stopwatch-list").getElementsByTagName("li");
var csvContent = "Marks No.,Time (s),Marks,Counter\n";
var marksSet = [];

for (i = 0; i < stopwatchData.length; i++) {
var marks = stopwatchData[i].getElementsByClassName("marks")[0].innerHTML.split(" - ");
for (var j = 0; j < marks.length; j++) {
if (marks.length === 1 && !marks[0]) break;
var mark = marks[j];

var minutes = parseInt(mark.split(":")[0]);
var sec = parseInt(mark.split(":")[1]);
var tenthsOfSec = parseInt(mark.split(":")[2]);
var time = (minutes * 60) + sec + (tenthsOfSec / 10);

if (!marksSet.includes(mark)) marksSet.push(mark);
var markNo = marksSet.indexOf(mark) + 1;
csvContent += `${markNo},${time || ""},${mark},${i+1}\n`;
};
}
var metadata = {
mimetype: "text/csv",
title: "Stopwatch export.csv",
activity: "org.sugarlabs.ChartActivity",
timestamp: new Date().getTime(),
creation_time: new Date().getTime(),
file_size: 0
};
requirejs(["sugar-web/datastore", "humane"], function (datastore, humane) {
datastore.create(metadata, function () {
humane.log(webL10n.get("exportAsCSV"));
}, csvContent);
});
});

});
Loading

0 comments on commit da2d827

Please sign in to comment.