Skip to content

Commit adeb62c

Browse files
authoredJan 1, 2023
* remove unused artwork * eslint
1 parent 70200b4 commit adeb62c

24 files changed

+1017
-716
lines changed
 

‎gulpfile.js

+54-54
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1+
/*
2+
global
3+
4+
require, exports
5+
*/
6+
17
// Initialize modules
28
// Importing specific gulp API functions lets us write them below as series() instead of gulp.series()
3-
const { src, dest, watch, series, parallel } = require('gulp');
9+
const { src, dest, watch, series, parallel } = require("gulp");
410
// Importing all the Gulp-related packages we want to use
5-
const sourcemaps = require('gulp-sourcemaps');
6-
const sass = require('gulp-sass');
7-
const concat = require('gulp-concat');
8-
const uglify = require('gulp-uglify');
9-
const babel = require('gulp-babel');
10-
const postcss = require('gulp-postcss');
11-
const autoprefixer = require('autoprefixer');
12-
const cssnano = require('cssnano');
13-
const replace = require('gulp-replace');
11+
const sourcemaps = require("gulp-sourcemaps");
12+
const sass = require("gulp-sass");
13+
const concat = require("gulp-concat");
14+
const uglify = require("gulp-uglify");
15+
const babel = require("gulp-babel");
16+
const postcss = require("gulp-postcss");
17+
const autoprefixer = require("autoprefixer");
18+
const cssnano = require("cssnano");
19+
const replace = require("gulp-replace");
1420
const minifyCSS = require("gulp-minify-css");
15-
const gulp = require('gulp');
16-
const prettier = require('gulp-prettier');
17-
21+
const gulp = require("gulp");
22+
const prettier = require("gulp-prettier");
1823

1924
// File paths
20-
const files = {
21-
22-
jsPath: 'js/**/*.js',
23-
cssPath: 'css/*.css',
24-
sassPath: 'css/*.sass'
25+
const files = {
26+
jsPath: "js/**/*.js",
27+
cssPath: "css/*.css",
28+
sassPath: "css/*.sass"
2529

26-
}
30+
};
2731

28-
const sassTask = () => {
32+
const sassTask = () => {
2933
return src(files.sassPath)
3034
.pipe(sourcemaps.init()) // initialize sourcemaps first
3135
.pipe(sass()) // compile SASS to CSS
3236
.pipe(postcss([ autoprefixer(), cssnano() ])) // PostCSS plugins
33-
.pipe(sourcemaps.write('.')) // write sourcemaps file in current directory
34-
.pipe(dest('dist/css')
35-
); // put final CSS in dist folder
36-
}
37+
.pipe(sourcemaps.write(".")) // write sourcemaps file in current directory
38+
.pipe(dest("dist/css")); // put final CSS in dist folder
39+
};
3740

38-
const cssTask = () => {
41+
const cssTask = () => {
3942
return src(files.cssPath)
40-
.pipe(minifyCSS({compatibility: 'ie8'}))
41-
.pipe(gulp.dest('dist/css'));
43+
.pipe(minifyCSS({compatibility: "ie8"}))
44+
.pipe(gulp.dest("dist/css"));
4245
};
4346

44-
45-
46-
4747
// JS task: concatenates and uglifies JS files to app.min.js
4848
const jsTask = () => {
49-
return src([
50-
files.jsPath
51-
])
52-
.pipe(concat('app.min.js'))
53-
.pipe(babel({
54-
presets: ['@babel/env']
55-
}))
49+
return src([files.jsPath])
50+
.pipe(concat("app.min.js"))
51+
.pipe(babel(
52+
{
53+
presets: ["@babel/env"]
54+
}
55+
))
5656
.pipe(uglify())
57-
.pipe(dest('dist')
58-
);
59-
}
60-
57+
.pipe(dest("dist")
58+
);
59+
};
6160

6261
// Cachebust
6362
const cbString = new Date().getTime();
6463
const cacheBustTask = () => {
65-
return src(['index.html'])
66-
.pipe(replace(/cb=\d+/g, 'cb=' + cbString))
67-
.pipe(dest('.'));
68-
}
64+
return src(["index.html"])
65+
.pipe(replace(/cb=\d+/g, "cb=" + cbString))
66+
.pipe(dest("."));
67+
};
6968

7069
//This gulp task formats the js files
7170

7271
const prettify = () => {
7372
return gulp.src(files.jsPath)
74-
.pipe(prettier({ singleQuote: true,
75-
trailingComma: "all"
76-
}))
77-
.pipe(gulp.dest('./dist/js'));
78-
};
73+
.pipe(prettier({
74+
singleQuote: true,
75+
trailingComma: "all"
76+
}))
77+
.pipe(gulp.dest("./dist/js"));
78+
};
7979

8080
//to check whether or not files adhere to Prettier's formatting
8181

@@ -87,9 +87,9 @@ const validate = () => {
8787
// Watch task: watch SASS , CSS and JS files for changes
8888
// If any change, run sass, css and js tasks simultaneously
8989
const watchTask = () => {
90-
watch([ files.jsPath, files.cssPath, files.sassPath ],
91-
parallel( jsTask, cssTask, sassTask));
92-
}
90+
watch([ files.jsPath, files.cssPath, files.sassPath ],
91+
parallel( jsTask, cssTask, sassTask));
92+
};
9393

9494
// Export the default Gulp task so it can be run
9595
// Runs the sass ,css and js tasks simultaneously
@@ -98,4 +98,4 @@ exports.default = series(
9898
parallel( jsTask, cssTask , sassTask ), prettify,
9999
cacheBustTask,
100100
watchTask, validate
101-
);
101+
);

‎js/blocks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
DEFAULTVOICE, INLINECOLLAPSIBLES, NATURAL, NUMBERBLOCKDEFAULT,
2020
SPECIALINPUTS, STANDARDBLOCKHEIGHT, STRINGLEN, TEXTWIDTH,
2121
WESTERN2EISOLFEGENAMES, WIDENAMES, _, addTemperamentToDictionary,
22-
Block, closeBlkWidgets, createjs, delayExecution,
22+
Block, closeBlkWidgets, createjs, delayExecution, DEFAULTCHORD,
2323
deleteTemperamentFromList, getDrumSynthName, getNoiseName,
2424
getNoiseSynthName, getTemperamentsList, getTextWidth,
2525
getVoiceSynthName, i18nSolfege, last, MathUtility, mixedNumber,

‎js/turtledefs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
DEFAULTPALETTE, BUILTINPALETTES, MULTIPALETTES, SKIPPALETTES,
3030
MULTIPALETTEICONS, MULTIPALETTENAMES, HELPCONTENT, DATAOBJS,
3131
BUILTINPALETTESFORL23N, getMainToolbarButtonNames,
32-
getAuxToolbarButtonNames
32+
getAuxToolbarButtonNames, TITLESTRING
3333
*/
3434

3535
const VERSION = "3.5.2.7";

‎js/widgets/phrasemaker.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
DEFAULTVOICE, getDrumName, MATRIXSOLFEWIDTH, getDrumIcon,
1919
noteIsSolfege, isCustomTemperament, i18nSolfege, getNote, DEFAULTDRUM, last,
2020
DRUMS, SHARP, FLAT, PREVIEWVOLUME, DEFAULTVOLUME, noteToFrequency,
21-
getDrumIndex, LCD, calcNoteValueToDisplay, NOTESYMBOLS,
21+
LCD, calcNoteValueToDisplay, NOTESYMBOLS,
2222
EIGHTHNOTEWIDTH, docBySelector, getTemperament
2323
*/
2424

@@ -628,9 +628,9 @@ class PhraseMaker {
628628
const label = this.rowLabels[i];
629629
const notes = getTemperament(this.activity.logo.synth.inTemperament);
630630
let note = [];
631-
for (let n in notes) {
631+
for (const n in notes) {
632632
if (notes[n][1] === label) {
633-
let note = notes[n];
633+
note = notes[n];
634634
break;
635635
}
636636
}
@@ -1502,12 +1502,14 @@ class PhraseMaker {
15021502
cell.style.fontSize = Math.floor(this._cellScale * 12) + "px";
15031503
}
15041504

1505+
/*
15051506
let noteStored = null;
15061507
if (condition === "graphicsblocks") {
15071508
noteStored = this.rowLabels[blockIndex] + ": " + this.rowArgs[blockIndex];
15081509
} else if (condition === "synthsblocks") {
15091510
noteStored = this.rowArgs[blockIndex];
15101511
}
1512+
*/
15111513
this._noteStored[blockIndex] =
15121514
this.rowLabels[blockIndex] + ": " + this.rowArgs[blockIndex];
15131515
};
@@ -2093,7 +2095,7 @@ class PhraseMaker {
20932095
}
20942096

20952097
const sortableList = [];
2096-
let drumName, drumIndex;
2098+
let drumName;
20972099
// Make a list to sort, skipping drums and graphics.
20982100
// frequency;label;arg;row index
20992101
for (let i = 0; i < this.rowLabels.length; i++) {
@@ -2138,9 +2140,7 @@ class PhraseMaker {
21382140
for (let i = 0; i < this.rowLabels.length; i++) {
21392141
drumName = getDrumName(this.rowLabels[i]);
21402142
if (drumName != null) {
2141-
drumIndex = getDrumIndex(this.rowLabels[i]);
21422143
sortableList.push([
2143-
// -drumIndex,
21442144
-1 * i,
21452145
this.rowLabels[i],
21462146
this.rowArgs[i],
@@ -3960,10 +3960,12 @@ class PhraseMaker {
39603960
} else {
39613961
if (
39623962
isCustomTemperament(this.activity.logo.synth.inTemperament)) {
3963-
const notes = getTemperament(this.activity.logo.synth.inTemperament);
3963+
const notes = getTemperament(
3964+
this.activity.logo.synth.inTemperament
3965+
);
39643966
const label = this.rowLabels[j];
39653967
let customNote = [];
3966-
for (let n in notes) {
3968+
for (const n in notes) {
39673969
if (notes[n][1] === label) {
39683970
customNote = notes[n];
39693971
break;

‎js/widgets/rhythmruler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ class RhythmRuler {
875875
const elapseTime = d.getTime() - this._longPressStartTime;
876876
if (elapseTime > 1500) {
877877
this._inLongPress = true;
878-
this.__toggleRestState(cell, true);
878+
this.__toggleRestState(cell, true);
879879
}
880880
}
881881

‎js/widgets/status.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class StatusMatrix {
2121
static BUTTONSIZE = 53;
2222
static ICONSIZE = 32;
2323
static OUTERWINDOWWIDTH = 620;
24-
static INNERWINDOWWIDTH = StatusMatrix.OUTERWINDOWWIDTH - StatusMatrix.BUTTONSIZE * 1.5;
24+
static INNERWINDOWWIDTH = this.OUTERWINDOWWIDTH - this.BUTTONSIZE * 1.5;
2525
static FONTSCALEFACTOR = 75;
2626

2727
/**

‎js/widgets/timbre.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
DEFAULTOSCILLATORTYPE, platformColor, rationalToFraction, last,
1818
Singer, instrumentsEffects:writeable, instrumentsFilters:writeable,
1919
_, docById, DEFAULTFILTERTYPE, docByName, OSCTYPES, FILTERTYPES,
20-
oneHundredToFraction
20+
oneHundredToFraction, delayExecution
2121
*/
2222

2323
/*

‎planet/js/Converter.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,27 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
13+
/*
14+
exported
15+
16+
Converter
17+
*/
18+
1219
function Converter(Planet) {
1320
this.ServerInterface = Planet.ServerInterface;
1421

1522
this.isConnected = function() {
1623
return Planet.ConnectedToServer;
17-
}
24+
};
1825

1926
// callbacks: (success, data/error message)
2027
// Conversion Functions
2128

2229
this.ly2pdf = function(data, callback) {
23-
this.ServerInterface.convertFile('ly', 'pdf', window.btoa(encodeURIComponent(data)), function(result) {
24-
this.afterly2pdf(result,callback);
25-
}.bind(this));
30+
this.ServerInterface.convertFile("ly", "pdf", window.btoa(encodeURIComponent(data)), function(result) {
31+
this.afterly2pdf(result,callback);
32+
}.bind(this));
2633
};
2734

2835
this.afterly2pdf = function(data, callback) {
@@ -35,19 +42,19 @@ function Converter(Planet) {
3542

3643
// Ancillary Functions
3744
this.getDataURL = function(mime, data){
38-
return 'data:' + mime + ';base64,' + data;
45+
return "data:" + mime + ";base64," + data;
3946
};
4047

4148
// Unused, but might be useful.
4249
this.getBlob = function(mime, data) {
43-
let rawData = window.atob(data);
44-
let len = rawData.length;
45-
let arr = new Uint8Array(len);
50+
const rawData = window.atob(data);
51+
const len = rawData.length;
52+
const arr = new Uint8Array(len);
4653
for (let i = 0; i < len; i++){
4754
arr[i] = rawData.charCodeAt(i);
4855
}
4956

50-
let blob = new Blob([arr], {type: mime});
57+
const blob = new Blob([arr], {type: mime});
5158
return blob;
5259
};
5360

‎planet/js/GlobalCard.js

+105-83
Large diffs are not rendered by default.

‎planet/js/GlobalPlanet.js

+136-72
Large diffs are not rendered by default.

‎planet/js/GlobalTag.js

+53-41
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,46 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
_
16+
*/
17+
/*
18+
exported
19+
20+
GlobalTag
21+
*/
22+
1223
function GlobalTag(Planet) {
13-
let tagNames = [
14-
//.TRANS: On the Planet, we use labels to tag projects.
15-
_('All Projects'),
16-
//.TRANS: On the Planet, we use labels to tag projects.
17-
_('My Projects'),
18-
//.TRANS: On the Planet, we use labels to tag projects.
19-
_('Examples'),
20-
//.TRANS: On the Planet, we use labels to tag projects.
21-
_('Music'),
22-
//.TRANS: On the Planet, we use labels to tag projects.
23-
_('Art'),
24-
//.TRANS: On the Planet, we use labels to tag projects.
25-
_('Math'),
26-
//.TRANS: On the Planet, we use labels to tag projects.
27-
_('Interactive'),
28-
//.TRANS: On the Planet, we use labels to tag projects.
29-
_('Design'),
30-
//.TRANS: On the Planet, we use labels to tag projects.
31-
_('Game'),
32-
//.TRANS: On the Planet, we use labels to tag projects.
33-
_('Media'),
34-
//.TRANS: On the Planet, we use labels to tag projects.
35-
_('Sensors'),
36-
//.TRANS: On the Planet, we use labels to tag projects.
37-
_('Effects'),
38-
//.TRANS: On the Planet, we use labels to tag projects.
39-
_('Code Snippet'),
24+
// eslint-disable-next-line no-unused-vars
25+
const tagNames = [
26+
//.TRANS: On the Planet, we use labels to tag projects.
27+
_("All Projects"),
28+
//.TRANS: On the Planet, we use labels to tag projects.
29+
_("My Projects"),
30+
//.TRANS: On the Planet, we use labels to tag projects.
31+
_("Examples"),
32+
//.TRANS: On the Planet, we use labels to tag projects.
33+
_("Music"),
34+
//.TRANS: On the Planet, we use labels to tag projects.
35+
_("Art"),
36+
//.TRANS: On the Planet, we use labels to tag projects.
37+
_("Math"),
38+
//.TRANS: On the Planet, we use labels to tag projects.
39+
_("Interactive"),
40+
//.TRANS: On the Planet, we use labels to tag projects.
41+
_("Design"),
42+
//.TRANS: On the Planet, we use labels to tag projects.
43+
_("Game"),
44+
//.TRANS: On the Planet, we use labels to tag projects.
45+
_("Media"),
46+
//.TRANS: On the Planet, we use labels to tag projects.
47+
_("Sensors"),
48+
//.TRANS: On the Planet, we use labels to tag projects.
49+
_("Effects"),
50+
//.TRANS: On the Planet, we use labels to tag projects.
51+
_("Code Snippet"),
4052
];
4153

4254
this.id = null;
@@ -50,31 +62,31 @@ function GlobalTag(Planet) {
5062
this.selectedClass = null;
5163

5264
this.render = function() {
53-
let tag = document.createElement('div');
54-
tag.classList.add('chipselect');
55-
tag.classList.add('cursor');
56-
if (this.selected){
65+
const tag = document.createElement("div");
66+
tag.classList.add("chipselect");
67+
tag.classList.add("cursor");
68+
if (this.selected) {
5769
tag.classList.add(this.selectedClass);
5870
}
5971

6072
tag.textContent = _(this.name);
6173

62-
63-
tag.addEventListener('click', (evt) => {
74+
// eslint-disable-next-line no-unused-vars
75+
tag.addEventListener("click", (evt) => {
6476
this.onTagClick();
6577
});
6678

67-
let el = document.getElementById('morechips');
68-
if (this.IsDisplayTag){
69-
el = document.getElementById('primarychips');
79+
let el = document.getElementById("morechips");
80+
if (this.IsDisplayTag) {
81+
el = document.getElementById("primarychips");
7082
}
7183

7284
el.appendChild(tag);
7385
this.tagElement = tag;
7486
};
7587

7688
this.onTagClick = function() {
77-
if (this.specialTag){
89+
if (this.specialTag) {
7890
if (!this.selected) {
7991
this.globalPlanet.selectSpecialTag(this);
8092
}
@@ -99,26 +111,26 @@ function GlobalTag(Planet) {
99111
this.selected = false;
100112
};
101113

102-
this.init = function(obj){
114+
this.init = function(obj) {
103115
if (obj.id !== undefined) {
104116
this.specialTag = false;
105117
this.id = obj.id;
106118
this.name = Planet.TagsManifest[this.id].TagName;
107119
this.func = null;
108-
if (Planet.TagsManifest[this.id].IsDisplayTag === '1') {
120+
if (Planet.TagsManifest[this.id].IsDisplayTag === "1") {
109121
this.IsDisplayTag = true;
110122
} else {
111123
this.IsDisplayTag = false;
112124
}
113125

114-
this.selectedClass = 'selected'
126+
this.selectedClass = "selected";
115127
} else {
116128
this.specialTag = true;
117129
this.IsDisplayTag = true;
118130
this.id = null;
119131
this.name = obj.name;
120132
this.func = obj.func;
121-
this.selectedClass = 'selected-special'
133+
this.selectedClass = "selected-special";
122134
}
123135

124136
this.render();

‎planet/js/LocalCard.js

+72-47
Original file line numberDiff line numberDiff line change
@@ -9,126 +9,151 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12-
function LocalCard(Planet){
13-
this.PlaceholderMBImage = 'images/mbgraphic.png';
14-
this.PlaceholderTBImage = 'images/tbgraphic.png';
12+
/*
13+
global
14+
15+
_
16+
*/
17+
/*
18+
exported
19+
20+
LocalCard
21+
*/
22+
23+
function LocalCard(Planet) {
24+
this.PlaceholderMBImage = "images/mbgraphic.png";
25+
this.PlaceholderTBImage = "images/tbgraphic.png";
1526
this.id = null;
1627
this.ProjectData = null;
17-
this.CopySuffix = '(' + _('Copy') + ')';
18-
this.renderData = '\
19-
<div class="col no-margin-left s12 m6 l4"> \
20-
<div class="card"> \
21-
<a class="published-cloud tooltipped" data-position="top" data-delay="50" data-tooltip="'+_('View published project')+'" style="display:none;" id="local-project-cloud-{ID}"><i class="material-icons small">cloud_done</i></a>\
22-
<div class="card-image"> \
23-
<img class="project-image project-card-image" id="local-project-image-{ID}"> \
24-
<a class="btn-floating halfway-fab waves-effect waves-light orange tooltipped" data-position="top" data-delay="50" data-tooltip="'+_('Publish project')+'" id="local-project-publish-{ID}"><i class="material-icons">cloud_upload</i></a> \
28+
this.CopySuffix = "(" + _("Copy") + ")";
29+
this.renderData = "\
30+
<div class=\"col no-margin-left s12 m6 l4\"> \
31+
<div class=\"card\"> \
32+
<a class=\"published-cloud tooltipped\" data-position=\"top\" data-delay=\"50\" data-tooltip=\"'+_('View published project')+'\" style=\"display:none;\" id=\"local-project-cloud-{ID}\"><i class=\"material-icons small\">cloud_done</i></a>\
33+
<div class=\"card-image\"> \
34+
<img class=\"project-image project-card-image\" id=\"local-project-image-{ID}\"> \
35+
<a class=\"btn-floating halfway-fab waves-effect waves-light orange tooltipped\" data-position=\"top\" data-delay=\"50\" data-tooltip=\"'+_('Publish project')+'\" id=\"local-project-publish-{ID}\"><i class=\"material-icons\">cloud_upload</i></a> \
2536
</div> \
26-
<div class="card-content"> \
27-
<input class="card-title grey-text text-darken-4" id="local-project-input-{ID}" /> \
37+
<div class=\"card-content\"> \
38+
<input class=\"card-title grey-text text-darken-4\" id=\"local-project-input-{ID}\" /> \
2839
</div> \
29-
<div class="card-action"> \
30-
<div class="flexcontainer"> \
31-
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="'+_('Edit project')+'" id="local-project-edit-{ID}"><i class="material-icons">edit</i></a> \
32-
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="'+_('Delete project')+'" id="local-project-delete-{ID}"><i class="material-icons">delete</i></a> \
33-
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="'+_('Download project')+'" id="local-project-download-{ID}"><i class="material-icons">file_download</i></a> \
34-
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="'+_('Merge with current project')+'" id="local-project-merge-{ID}"><i class="material-icons">merge_type</i></a> \
35-
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="'+_('Duplicate project')+'" id="local-project-duplicate-{ID}"><i class="material-icons">content_copy</i></a> \
40+
<div class=\"card-action\"> \
41+
<div class=\"flexcontainer\"> \
42+
<a class=\"project-icon tooltipped\" data-position=\"bottom\" data-delay=\"50\" data-tooltip=\"'+_('Edit project')+'\" id=\"local-project-edit-{ID}\"><i class=\"material-icons\">edit</i></a> \
43+
<a class=\"project-icon tooltipped\" data-position=\"bottom\" data-delay=\"50\" data-tooltip=\"'+_('Delete project')+'\" id=\"local-project-delete-{ID}\"><i class=\"material-icons\">delete</i></a> \
44+
<a class=\"project-icon tooltipped\" data-position=\"bottom\" data-delay=\"50\" data-tooltip=\"'+_('Download project')+'\" id=\"local-project-download-{ID}\"><i class=\"material-icons\">file_download</i></a> \
45+
<a class=\"project-icon tooltipped\" data-position=\"bottom\" data-delay=\"50\" data-tooltip=\"'+_('Merge with current project')+'\" id=\"local-project-merge-{ID}\"><i class=\"material-icons\">merge_type</i></a> \
46+
<a class=\"project-icon tooltipped\" data-position=\"bottom\" data-delay=\"50\" data-tooltip=\"'+_('Duplicate project')+'\" id=\"local-project-duplicate-{ID}\"><i class=\"material-icons\">content_copy</i></a> \
3647
</div> \
3748
</div> \
3849
</div> \
39-
</div>';
50+
</div>";
4051

4152
this.download = function() {
4253
let image = Planet.ProjectStorage.ImageDataURL;
43-
if (this.ProjectData.ProjectImage !== null){
54+
if (this.ProjectData.ProjectImage !== null) {
4455
image = this.ProjectData.ProjectImage;
4556
}
4657

4758
let description = null;
48-
if (this.ProjectData.PublishedData !== null){
59+
if (this.ProjectData.PublishedData !== null) {
4960
description = this.ProjectData.PublishedData.ProjectDescription;
5061
}
5162

52-
Planet.SaveInterface.saveHTML(this.ProjectData.ProjectName, this.ProjectData.ProjectData, image, description);
63+
Planet.SaveInterface.saveHTML(
64+
this.ProjectData.ProjectName,
65+
this.ProjectData.ProjectData,
66+
image,
67+
description
68+
);
5369
};
5470

5571
this.duplicate = function() {
56-
Planet.ProjectStorage.initialiseNewProject(this.ProjectData.ProjectName + ' ' + this.CopySuffix, this.ProjectData.ProjectData, this.ProjectData.ProjectImage);
72+
Planet.ProjectStorage.initialiseNewProject(this.ProjectData.ProjectName + " " + this.CopySuffix, this.ProjectData.ProjectData, this.ProjectData.ProjectImage);
5773
Planet.LocalPlanet.updateProjects();
5874
};
5975

6076
this.render = function() {
6177
// TODO: Have a TB placeholder image specific to TB projects
62-
let html = this.renderData.replace(new RegExp('\{ID\}', 'g'), this.id);
63-
let frag = document.createRange().createContextualFragment(html);
78+
const html = this.renderData.replace(new RegExp("{ID}", "g"), this.id);
79+
const frag = document.createRange().createContextualFragment(html);
6480

6581
// set image
66-
if (this.ProjectData.ProjectImage !== null){
67-
frag.getElementById('local-project-image-' + this.id).src = this.ProjectData.ProjectImage;
68-
} else if (Planet.IsMusicBlocks==1){
69-
frag.getElementById('local-project-image-' + this.id).src = this.PlaceholderMBImage;
82+
if (this.ProjectData.ProjectImage !== null) {
83+
frag.getElementById("local-project-image-" + this.id).src = this.ProjectData.ProjectImage;
84+
} else if (Planet.IsMusicBlocks==1) {
85+
frag.getElementById("local-project-image-" + this.id).src = this.PlaceholderMBImage;
7086
} else {
71-
frag.getElementById('local-project-image-' + this.id).src = this.PlaceholderTBImage;
87+
frag.getElementById("local-project-image-" + this.id).src = this.PlaceholderTBImage;
7288
}
7389

7490
// set input text
75-
frag.getElementById('local-project-input-' + this.id).value = this.ProjectData.ProjectName;
91+
frag.getElementById("local-project-input-" + this.id).value = this.ProjectData.ProjectName;
7692

77-
let that = this;
93+
const that = this;
7894

7995
// set edit modify listener
80-
frag.getElementById('local-project-edit-' + this.id).addEventListener('click', function (evt) {
96+
// eslint-disable-next-line no-unused-vars
97+
frag.getElementById("local-project-edit-" + this.id).addEventListener("click", function (evt) {
8198
Planet.LocalPlanet.openProject(that.id);
8299
});
83100

84101
// set image listener
85-
frag.getElementById('local-project-image-' + this.id).addEventListener('click', function (evt) {
102+
// eslint-disable-next-line no-unused-vars
103+
frag.getElementById("local-project-image-" + this.id).addEventListener("click", function (evt) {
86104
Planet.LocalPlanet.openProject(that.id);
87105
});
88106

89107
// set merge modify listener
90-
frag.getElementById('local-project-merge-' + this.id).addEventListener('click', function (evt) {
108+
// eslint-disable-next-line no-unused-vars
109+
frag.getElementById("local-project-merge-" + this.id).addEventListener("click", function (evt) {
91110
Planet.LocalPlanet.openProject(that.id);
92111
});
93112

94113
// set input modify listener
95-
frag.getElementById('local-project-input-' + this.id).addEventListener('input', function (evt) {
114+
// eslint-disable-next-line no-unused-vars
115+
frag.getElementById("local-project-input-" + this.id).addEventListener("input", function (evt) {
96116
Planet.ProjectStorage.renameProject(that.id, this.value);
97117
});
98118

99119
// set delete button listener
100-
frag.getElementById('local-project-delete-' + this.id).addEventListener('click', function (evt) {
120+
// eslint-disable-next-line no-unused-vars
121+
frag.getElementById("local-project-delete-" + this.id).addEventListener("click", function (evt) {
101122
Planet.LocalPlanet.openDeleteModal(that.id);
102123
});
103124

104125
// set publish button listener
105-
frag.getElementById('local-project-publish-' + this.id).addEventListener('click', function (evt) {
126+
// eslint-disable-next-line no-unused-vars
127+
frag.getElementById("local-project-publish-" + this.id).addEventListener("click", function (evt) {
106128
Planet.LocalPlanet.Publisher.open(that.id);
107129
});
108130

109131
// set download button listener
110-
frag.getElementById('local-project-download-' + this.id).addEventListener('click', function (evt) {
132+
// eslint-disable-next-line no-unused-vars
133+
frag.getElementById("local-project-download-" + this.id).addEventListener("click", function (evt) {
111134
that.download();
112135
});
113136

114137
// set duplicate button listener
115-
frag.getElementById('local-project-duplicate-' + this.id).addEventListener('click', function (evt) {
138+
// eslint-disable-next-line no-unused-vars
139+
frag.getElementById("local-project-duplicate-" + this.id).addEventListener("click", function (evt) {
116140
that.duplicate();
117141
});
118142

119143
// set published cloud listener
120-
if (this.ProjectData.PublishedData !== null){
121-
frag.getElementById('local-project-cloud-' + this.id).style.display = 'initial';
122-
frag.getElementById('local-project-cloud-' + this.id).addEventListener('click', function (evt) {
144+
if (this.ProjectData.PublishedData !== null) {
145+
frag.getElementById("local-project-cloud-" + this.id).style.display = "initial";
146+
// eslint-disable-next-line no-unused-vars
147+
frag.getElementById("local-project-cloud-" + this.id).addEventListener("click", function (evt) {
123148
// TODO: Implement view-published-project thing
124-
document.getElementById('global-tab').click();
149+
document.getElementById("global-tab").click();
125150
Planet.GlobalPlanet.forceAddToCache(that.id, function() {
126151
Planet.GlobalPlanet.ProjectViewer.open(that.id);
127152
});
128153
});
129154
}
130155

131-
document.getElementById('local-projects').appendChild(frag);
156+
document.getElementById("local-projects").appendChild(frag);
132157
};
133158

134159
this.init = function(id) {

‎planet/js/LocalPlanet.js

+36-18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
jQuery, LocalCard, Publisher
16+
*/
17+
/*
18+
exported
19+
20+
LocalPlanet
21+
*/
22+
1223
function LocalPlanet(Planet) {
1324
this.CookieDuration = 3650;
1425
this.ProjectTable = null;
@@ -19,7 +30,7 @@ function LocalPlanet(Planet) {
1930
this.currentProjectID = null;
2031

2132
this.updateProjects = function() {
22-
jQuery('.tooltipped').tooltip('remove');
33+
jQuery(".tooltipped").tooltip("remove");
2334
this.refreshProjectArray();
2435
this.initCards();
2536
this.renderAllProjects();
@@ -32,17 +43,19 @@ function LocalPlanet(Planet) {
3243

3344
this.refreshProjectArray = function() {
3445
this.projects = [];
35-
for (let project in this.ProjectTable) {
46+
for (const project in this.ProjectTable) {
47+
// eslint-disable-next-line no-prototype-builtins
3648
if (this.ProjectTable.hasOwnProperty(project)) {
3749
this.projects.push([project,null]);
3850
}
3951
}
4052

41-
let that = this;
53+
const that = this;
4254

4355
this.projects.sort(function(a, b) {
56+
// eslint-disable-next-line max-len
4457
return that.ProjectTable[b[0]].DateLastModified - that.ProjectTable[a[0]].DateLastModified;
45-
});
58+
});
4659
};
4760

4861
this.initCards = function() {
@@ -53,7 +66,7 @@ function LocalPlanet(Planet) {
5366
};
5467

5568
this.renderAllProjects = function() {
56-
document.getElementById('local-projects').innerHTML = '';
69+
document.getElementById("local-projects").innerHTML = "";
5770
let index = -1;
5871
for (let i = 0; i < this.projects.length; i++) {
5972
this.projects[i][1].render();
@@ -62,29 +75,34 @@ function LocalPlanet(Planet) {
6275
}
6376
}
6477
if (index!=-1) {
65-
let id = 'local-project-image-' + this.projects[index][0];
78+
const id = "local-project-image-" + this.projects[index][0];
79+
// eslint-disable-next-line no-console
6680
console.log(id);
67-
let cardimg = document.getElementById(id);
81+
const cardimg = document.getElementById(id);
6882
cardimg.src=this.currentProjectImage;
6983
}
70-
jQuery('.tooltipped').tooltip({delay: 50});
84+
jQuery(".tooltipped").tooltip({delay: 50});
7185
};
7286

7387
this.initDeleteModal = function() {
74-
let t = this;
75-
document.getElementById('deleter-button').addEventListener('click', function (evt) {
76-
if (t.DeleteModalID !== null) {
77-
Planet.ProjectStorage.deleteProject(t.DeleteModalID);
88+
const t = this;
89+
document.getElementById("deleter-button").addEventListener(
90+
"click",
91+
// eslint-disable-next-line no-unused-vars
92+
function (evt) {
93+
if (t.DeleteModalID !== null) {
94+
Planet.ProjectStorage.deleteProject(t.DeleteModalID);
95+
}
7896
}
79-
});
97+
);
8098
};
8199

82100
this.openDeleteModal = function(id) {
83101
this.DeleteModalID = id;
84-
let name = this.ProjectTable[id].ProjectName;
85-
document.getElementById('deleter-title').textContent = name;
86-
document.getElementById('deleter-name').textContent = name;
87-
jQuery('#deleter').modal('open');
102+
const name = this.ProjectTable[id].ProjectName;
103+
document.getElementById("deleter-title").textContent = name;
104+
document.getElementById("deleter-name").textContent = name;
105+
jQuery("#deleter").modal("open");
88106
};
89107

90108
this.openProject = function(id) {
@@ -93,7 +111,7 @@ function LocalPlanet(Planet) {
93111
};
94112

95113
this.mergeProject = function(id) {
96-
let d = this.ProjectStorage.getCurrentProjectData();
114+
const d = this.ProjectStorage.getCurrentProjectData();
97115
if (d === null) {
98116
this.ProjectStorage.initialiseNewProject();
99117
Planet.loadProjectFromData(this.ProjectTable[id].ProjectData);

‎planet/js/Planet.js

+29-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
setCookie, getCookie, StringHelper, ProjectStorage, ServerInterface,
16+
Converter, SaveInterface, LocalPlanet, GlobalPlanet
17+
*/
18+
/*
19+
exported
20+
21+
Planet
22+
*/
1223

1324
function Planet(isMusicBlocks, storage) {
1425
this.LocalPlanet = null;
@@ -21,7 +32,7 @@ function Planet(isMusicBlocks, storage) {
2132
this.ConnectedToServer = null;
2233
this.TagsManifest = null;
2334
this.IsMusicBlocks = isMusicBlocks;
24-
this.UserIDCookie = 'UserID';
35+
this.UserIDCookie = "UserID";
2536
this.UserID = null;
2637
this.loadProjectFromData = null;
2738
this.loadNewProject = null;
@@ -31,7 +42,7 @@ function Planet(isMusicBlocks, storage) {
3142

3243
this.prepareUserID = function() {
3344
let id = getCookie(this.UserIDCookie);
34-
if (id === ''){
45+
if (id === ""){
3546
id = this.ProjectStorage.generateID();
3647
setCookie(this.UserIDCookie, id, 3650);
3748
}
@@ -85,30 +96,37 @@ function Planet(isMusicBlocks, storage) {
8596
this.ServerInterface = new ServerInterface(this);
8697
this.ServerInterface.init();
8798

88-
let that = this;
99+
const that = this;
89100

90-
document.getElementById('close-planet').addEventListener('click', function (evt) {
101+
// eslint-disable-next-line no-unused-vars
102+
document.getElementById("close-planet").addEventListener("click", function (evt) {
91103
that.closeButton();
92104
});
93105

94-
document.getElementById('planet-open-file').addEventListener('click', function (evt) {
106+
// eslint-disable-next-line no-unused-vars
107+
document.getElementById("planet-open-file").addEventListener("click", function (evt) {
95108
that.loadProjectFromFile();
96109
});
97110

98-
document.getElementById('planet-new-project').addEventListener('click', function (evt) {
111+
// eslint-disable-next-line no-unused-vars
112+
document.getElementById("planet-new-project").addEventListener("click", function (evt) {
99113
that.loadNewProject();
100-
})
114+
});
101115

102-
this.ServerInterface.getTagManifest(function(data){this.initPlanets(data)}.bind(this));
116+
this.ServerInterface.getTagManifest(
117+
function(data) {
118+
this.initPlanets(data);
119+
}.bind(this)
120+
);
103121
};
104122

105123
this.closeButton = function() {
106124
if (this.ProjectStorage.getCurrentProjectID() !== this.oldCurrentProjectID) {
107-
let d = this.ProjectStorage.getCurrentProjectData();
125+
const d = this.ProjectStorage.getCurrentProjectData();
108126
if (d === null){
109-
this.loadNewProject();
127+
this.loadNewProject();
110128
} else {
111-
this.loadProjectFromData(d);
129+
this.loadProjectFromData(d);
112130
}
113131
} else {
114132
this.planetClose();

‎planet/js/ProjectStorage.js

+38-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎planet/js/ProjectViewer.js

+89-60
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,86 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
_, jQuery, hideOnClickOutside
16+
*/
17+
/*
18+
exported
19+
20+
ProjectViewer
21+
*/
22+
1223
function ProjectViewer(Planet) {
1324
this.ProjectCache = Planet.GlobalPlanet.cache;
14-
this.PlaceholderMBImage = 'images/mbgraphic.png';
15-
this.PlaceholderTBImage = 'images/tbgraphic.png';
16-
this.ReportError = _('Error: Report could not be submitted. Try again later.');
17-
this.ReportSuccess = _('Thank you for reporting this project. A moderator will review the project shortly, to verify violation of the Sugar Labs Code of Conduct.');
18-
this.ReportEnabledButton = _('Report Project');
19-
this.ReportDisabledButton = _('Project Reported');
20-
this.ReportDescriptionError = _('Report description required');
21-
this.ReportDescriptionTooLongError = _('Report description too long');
25+
this.PlaceholderMBImage = "images/mbgraphic.png";
26+
this.PlaceholderTBImage = "images/tbgraphic.png";
27+
this.ReportError = _("Error: Report could not be submitted. Try again later.");
28+
this.ReportSuccess = _("Thank you for reporting this project. A moderator will review the project shortly, to verify violation of the Sugar Labs Code of Conduct.");
29+
this.ReportEnabledButton = _("Report Project");
30+
this.ReportDisabledButton = _("Project Reported");
31+
this.ReportDescriptionError = _("Report description required");
32+
this.ReportDescriptionTooLongError = _("Report description too long");
2233
this.id = null;
2334

2435
this.open = function(id) {
2536
this.id = id;
26-
let proj = this.ProjectCache[id];
27-
document.getElementById('projectviewer-title').textContent = proj.ProjectName;
28-
document.getElementById('projectviewer-last-updated').textContent = proj.ProjectLastUpdated;
29-
document.getElementById('projectviewer-date').textContent = proj.ProjectCreatedDate;
30-
document.getElementById('projectviewer-downloads').textContent = proj.ProjectDownloads;
31-
document.getElementById('projectviewer-likes').textContent = proj.ProjectLikes;
37+
const proj = this.ProjectCache[id];
38+
document.getElementById("projectviewer-title").textContent = proj.ProjectName;
39+
document.getElementById("projectviewer-last-updated").textContent = proj.ProjectLastUpdated;
40+
document.getElementById("projectviewer-date").textContent = proj.ProjectCreatedDate;
41+
document.getElementById("projectviewer-downloads").textContent = proj.ProjectDownloads;
42+
document.getElementById("projectviewer-likes").textContent = proj.ProjectLikes;
3243
let img = proj.ProjectImage;
33-
if (img === '' || img === null) {
44+
if (img === "" || img === null) {
3445
if (proj.ProjectIsMusicBlocks==1) {
3546
img = this.PlaceholderMBImage;
3647
} else {
3748
img = this.PlaceholderTBImage;
3849
}
3950
}
4051

41-
document.getElementById('projectviewer-image').src = img;
42-
document.getElementById('projectviewer-description').textContent = proj.ProjectDescription;
43-
let tagcontainer = document.getElementById('projectviewer-tags');
44-
tagcontainer.innerHTML = '';
52+
document.getElementById("projectviewer-image").src = img;
53+
document.getElementById("projectviewer-description").textContent = proj.ProjectDescription;
54+
const tagcontainer = document.getElementById("projectviewer-tags");
55+
tagcontainer.innerHTML = "";
4556
for (let i = 0; i < proj.ProjectTags.length; i++) {
46-
let chip = document.createElement('div');
47-
chip.classList.add('chipselect');
57+
const chip = document.createElement("div");
58+
chip.classList.add("chipselect");
4859
chip.textContent = _(Planet.TagsManifest[proj.ProjectTags[i]].TagName);
4960
tagcontainer.appendChild(chip);
5061
}
5162

5263
if (Planet.ProjectStorage.isReported(this.id)){
53-
document.getElementById('projectviewer-report-project').style.display = 'none';
54-
document.getElementById('projectviewer-report-project-disabled').style.display = 'block';
64+
document.getElementById("projectviewer-report-project").style.display = "none";
65+
document.getElementById("projectviewer-report-project-disabled").style.display = "block";
5566
} else {
56-
document.getElementById('projectviewer-report-project').style.display = 'block';
57-
document.getElementById('projectviewer-report-project-disabled').style.display = 'none';
67+
document.getElementById("projectviewer-report-project").style.display = "block";
68+
document.getElementById("projectviewer-report-project-disabled").style.display = "none";
5869
}
5970

60-
jQuery('#projectviewer').modal('open');
71+
jQuery("#projectviewer").modal("open");
6172
};
6273

6374
this.download = function() {
6475
Planet.GlobalPlanet.getData(this.id,this.afterDownload.bind(this));
6576
};
6677

6778
this.afterDownload = function(data) {
68-
let proj = this.ProjectCache[this.id];
79+
const proj = this.ProjectCache[this.id];
6980
let image = Planet.ProjectStorage.ImageDataURL;
70-
if (proj.ProjectImage !== '') {
81+
if (proj.ProjectImage !== "") {
7182
image = proj.ProjectImage;
7283
}
7384

74-
Planet.SaveInterface.saveHTML(proj.ProjectName, data, image, proj.ProjectDescription, this.id);
85+
Planet.SaveInterface.saveHTML(
86+
proj.ProjectName,
87+
data,
88+
image,
89+
proj.ProjectDescription,
90+
this.id
91+
);
7592
};
7693

7794
this.openProject = function() {
@@ -87,76 +104,88 @@ function ProjectViewer(Planet) {
87104
};
88105

89106
this.openReporter = function() {
90-
console.log('load');
91-
document.getElementById('reportdescription').value = '';
92-
document.getElementById('projectviewer-report-content').style.display = 'block';
93-
document.getElementById('projectviewer-reportsubmit-content').style.display = 'none';
94-
document.getElementById('projectviewer-report-progress').style.visibility = 'hidden';
95-
document.getElementById('report-error').style.display = 'none';
96-
document.getElementById('projectviewer-report-card').style.display = 'block';
97-
hideOnClickOutside([document.getElementById('projectviewer-report-card'),document.getElementById('projectviewer-report-project')], 'projectviewer-report-card');
107+
// eslint-disable-next-line no-console
108+
console.log("load");
109+
document.getElementById("reportdescription").value = "";
110+
document.getElementById("projectviewer-report-content").style.display = "block";
111+
document.getElementById("projectviewer-reportsubmit-content").style.display = "none";
112+
document.getElementById("projectviewer-report-progress").style.visibility = "hidden";
113+
document.getElementById("report-error").style.display = "none";
114+
document.getElementById("projectviewer-report-card").style.display = "block";
115+
hideOnClickOutside(
116+
[
117+
document.getElementById("projectviewer-report-card"),
118+
document.getElementById("projectviewer-report-project")
119+
],
120+
"projectviewer-report-card"
121+
);
98122
};
99123

100124
this.submitReporter = function() {
101-
let text;
102-
text = document.getElementById('reportdescription').value;
103-
if (text === ''){
104-
document.getElementById('report-error').textContent = this.ReportDescriptionError;
105-
document.getElementById('report-error').style.display = 'block';
125+
const text = document.getElementById("reportdescription").value;
126+
if (text === ""){
127+
document.getElementById("report-error").textContent = this.ReportDescriptionError;
128+
document.getElementById("report-error").style.display = "block";
106129
return;
107130
} else if (text.length > 1000){
108-
document.getElementById('report-error').textContent = this.ReportDescriptionTooLongError;
109-
document.getElementById('report-error').style.display = 'block';
131+
document.getElementById("report-error").textContent = this.ReportDescriptionTooLongError;
132+
document.getElementById("report-error").style.display = "block";
110133
return;
111134
} else {
112-
document.getElementById('projectviewer-report-progress').style.visibility = 'hidden';
135+
document.getElementById("projectviewer-report-progress").style.visibility = "hidden";
113136
Planet.ServerInterface.reportProject(this.id, text, this.afterReport.bind(this));
114137
}
115138
};
116139

117140
this.afterReport = function(data) {
118141
if (data.success) {
119-
document.getElementById('submittext').textContent = this.ReportSuccess;
142+
document.getElementById("submittext").textContent = this.ReportSuccess;
120143
Planet.ProjectStorage.report(this.id,true);
121-
document.getElementById('projectviewer-report-project').style.display = 'none';
122-
document.getElementById('projectviewer-report-project-disabled').style.display = 'block';
144+
document.getElementById("projectviewer-report-project").style.display = "none";
145+
document.getElementById("projectviewer-report-project-disabled").style.display = "block";
123146
} else {
124-
document.getElementById('submittext').textContent = this.ReportError;
147+
document.getElementById("submittext").textContent = this.ReportError;
125148
}
126149

127-
document.getElementById('projectviewer-report-content').style.display = 'none';
128-
document.getElementById('projectviewer-report-progress').style.visibility = 'hidden';
129-
document.getElementById('projectviewer-reportsubmit-content').style.display = 'block';
150+
document.getElementById("projectviewer-report-content").style.display = "none";
151+
document.getElementById("projectviewer-report-progress").style.visibility = "hidden";
152+
document.getElementById("projectviewer-reportsubmit-content").style.display = "block";
130153
};
131154

132155
this.closeReporter = function() {
133-
document.getElementById('projectviewer-report-card').style.display = 'none';
156+
document.getElementById("projectviewer-report-card").style.display = "none";
134157
};
135158

136159
this.init = function(){
137-
let that = this;
160+
const that = this;
138161

139-
document.getElementById('projectviewer-download-file').addEventListener('click', function (evt) {
162+
// eslint-disable-next-line no-unused-vars
163+
document.getElementById("projectviewer-download-file").addEventListener("click", function (evt) {
140164
that.download();
141165
});
142166

143-
document.getElementById('projectviewer-open-mb').addEventListener('click', function (evt) {
167+
// eslint-disable-next-line no-unused-vars
168+
document.getElementById("projectviewer-open-mb").addEventListener("click", function (evt) {
144169
that.openProject();
145170
});
146171

147-
document.getElementById('projectviewer-merge-mb').addEventListener('click', function (evt) {
172+
// eslint-disable-next-line no-unused-vars
173+
document.getElementById("projectviewer-merge-mb").addEventListener("click", function (evt) {
148174
that.mergeProject();
149175
});
150176

151-
document.getElementById('projectviewer-report-project').addEventListener('click', function (evt) {
177+
// eslint-disable-next-line no-unused-vars
178+
document.getElementById("projectviewer-report-project").addEventListener("click", function (evt) {
152179
that.openReporter();
153180
});
154181

155-
document.getElementById('projectviewer-report-submit').addEventListener('click', function (evt) {
182+
// eslint-disable-next-line no-unused-vars
183+
document.getElementById("projectviewer-report-submit").addEventListener("click", function (evt) {
156184
that.submitReporter();
157185
});
158186

159-
document.getElementById('projectviewer-report-close').addEventListener('click', function (evt) {
187+
// eslint-disable-next-line no-unused-vars
188+
document.getElementById("projectviewer-report-close").addEventListener("click", function (evt) {
160189
that.closeReporter();
161190
});
162191
};

‎planet/js/Publisher.js

+120-107
Large diffs are not rendered by default.

‎planet/js/SaveInterface.js

+28-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎planet/js/ServerInterface.js

+29-16
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,30 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
jQuery
16+
*/
17+
/*
18+
exported
19+
20+
ServerInterface
21+
*/
22+
23+
// eslint-disable-next-line no-unused-vars
1224
function ServerInterface(Planet) {
13-
this.ServerURL = 'https://musicblocks.sugarlabs.org/planet-server/index.php';
14-
this.ConnectionFailureData = {'success': false, 'error': 'ERROR_CONNECTION_FAILURE'};
15-
this.APIKey = '3f2d3a4c-c7a4-4c3c-892e-ac43784f7381';
25+
this.ServerURL = "https://musicblocks.sugarlabs.org/planet-server/index.php";
26+
this.ConnectionFailureData = {"success": false, "error": "ERROR_CONNECTION_FAILURE"};
27+
this.APIKey = "3f2d3a4c-c7a4-4c3c-892e-ac43784f7381";
1628

1729
this.request = function(data, callback) {
18-
let that = this;
19-
data['api-key'] = this.APIKey;
30+
const that = this;
31+
data["api-key"] = this.APIKey;
2032

21-
let req = jQuery.ajax({
22-
type: 'POST',
33+
// eslint-disable-next-line no-unused-vars
34+
const req = jQuery.ajax({
35+
type: "POST",
2336
url: this.ServerURL,
2437
data: data
2538
})
@@ -32,47 +45,47 @@ function ServerInterface(Planet) {
3245
};
3346

3447
this.getTagManifest = function(callback) {
35-
let obj = {'action': 'getTagManifest'};
48+
const obj = {"action": "getTagManifest"};
3649
this.request(obj, callback);
3750
};
3851

3952
this.addProject = function(data, callback) {
40-
let obj = {'action': 'addProject', 'ProjectJSON': data};
53+
const obj = {"action": "addProject", "ProjectJSON": data};
4154
this.request(obj, callback);
4255
};
4356

4457
this.downloadProjectList = function(ProjectTags, ProjectSort, Start, End, callback) {
45-
let obj = {'action': 'downloadProjectList', 'ProjectTags': ProjectTags, 'ProjectSort': ProjectSort, 'Start': Start, 'End': End};
58+
const obj = {"action": "downloadProjectList", "ProjectTags": ProjectTags, "ProjectSort": ProjectSort, "Start": Start, "End": End};
4659
this.request(obj, callback);
4760
};
4861

4962
this.getProjectDetails = function(ProjectID, callback) {
50-
let obj = {'action': 'getProjectDetails', 'ProjectID': ProjectID};
63+
const obj = {"action": "getProjectDetails", "ProjectID": ProjectID};
5164
this.request(obj, callback);
5265
};
5366

5467
this.searchProjects = function(Search, ProjectSort, Start, End, callback) {
55-
let obj = {'action': 'searchProjects', 'Search': Search, 'ProjectSort': ProjectSort, 'Start': Start, 'End': End};
68+
const obj = {"action": "searchProjects", "Search": Search, "ProjectSort": ProjectSort, "Start": Start, "End": End};
5669
this.request(obj, callback);
5770
};
5871

5972
this.downloadProject = function(ProjectID, callback) {
60-
let obj = {'action': 'downloadProject', 'ProjectID': ProjectID};
73+
const obj = {"action": "downloadProject", "ProjectID": ProjectID};
6174
this.request(obj, callback);
6275
};
6376

6477
this.likeProject = function(ProjectID, Like, callback) {
65-
let obj = {'action': 'likeProject', 'ProjectID': ProjectID, 'Like': ((Like) ? 'true' : 'false')};
78+
const obj = {"action": "likeProject", "ProjectID": ProjectID, "Like": ((Like) ? "true" : "false")};
6679
this.request(obj, callback);
6780
};
6881

6982
this.reportProject = function(ProjectID, Description, callback) {
70-
let obj = {'action': 'reportProject', 'ProjectID': ProjectID, 'Description': Description};
83+
const obj = {"action": "reportProject", "ProjectID": ProjectID, "Description": Description};
7184
this.request(obj, callback);
7285
};
7386

7487
this.convertFile = function(From, To, Data, callback) {
75-
let obj = {'action': 'convertData', 'From': From, 'To': To, 'Data': Data};
88+
const obj = {"action": "convertData", "From": From, "To": To, "Data": Data};
7689
this.request(obj, callback);
7790
};
7891

‎planet/js/StringHelper.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
// License along with this library; if not, write to the Free Software
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

12+
/*
13+
global
14+
15+
_
16+
*/
17+
/*
18+
exported
19+
20+
StringHelper
21+
*/
22+
1223
function StringHelper(Planet) {
1324
//[id, string, property (if present)]
1425
// append to innerhtml
@@ -55,7 +66,7 @@ function StringHelper(Planet) {
5566
["projectviewer-report-close",_("Close")],
5667
["projectviewer-download-file",_("Download as File"),"data-tooltip"],
5768
["projectviewer-merge-mb",_("Merge with current project"),"data-tooltip"]
58-
]
69+
];
5970
if (Planet.IsMusicBlocks) {
6071
this.strings.push(["projectviewer-open-mb",_("Open in Music Blocks"),"data-tooltip"]);
6172
} else {
@@ -65,8 +76,8 @@ function StringHelper(Planet) {
6576

6677
this.init = function(){
6778
for (let i = 0; i<this.strings.length; i++){
68-
let obj = this.strings[i];
69-
let elem = document.getElementById(obj[0]);
79+
const obj = this.strings[i];
80+
const elem = document.getElementById(obj[0]);
7081
if (this.strings[i].length==3){
7182
elem.setAttribute(obj[2],obj[1]);
7283
} else {

‎planet/js/helper.js

+57-39
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,30 @@
1515
// N milliseconds. If `immediate` is passed, trigger the function on the
1616
// leading edge, instead of the trailing.
1717

18+
/*
19+
global
20+
21+
_, $
22+
*/
23+
/*
24+
exported
25+
26+
debounce, getCookie, setCookie, hideOnClickOutside,
27+
updateCheckboxes
28+
*/
29+
1830
function debounce(func, wait, immediate) {
1931
let timeout;
2032
return function () {
21-
let context = this,
33+
const context = this,
2234
args = arguments;
2335

24-
let later = function () {
36+
const later = function () {
2537
timeout = null;
2638
if (!immediate) func.apply(context, args);
2739
};
2840

29-
let callNow = immediate && !timeout;
41+
const callNow = immediate && !timeout;
3042
clearTimeout(timeout);
3143
timeout = setTimeout(later, wait);
3244
if (callNow) func.apply(context, args);
@@ -35,40 +47,40 @@ function debounce(func, wait, immediate) {
3547

3648
function getCookie(cname) {
3749
// from W3Schools
38-
let name = cname + '=';
39-
let decodedCookie = decodeURIComponent(document.cookie);
40-
let ca = decodedCookie.split(';');
50+
const name = cname + "=";
51+
const decodedCookie = decodeURIComponent(document.cookie);
52+
const ca = decodedCookie.split(";");
4153
for (let i = 0; i < ca.length; i++) {
4254
let c = ca[i];
43-
while (c.charAt(0) === ' ') {
55+
while (c.charAt(0) === " ") {
4456
c = c.substring(1);
4557
}
4658

4759
if (c.indexOf(name) === 0) {
4860
return c.substring(name.length, c.length);
4961
}
5062
}
51-
return '';
63+
return "";
5264
};
5365

5466
function setCookie(cname, cvalue, exdays) {
5567
// from W3Schools
56-
let d = new Date();
68+
const d = new Date();
5769
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
58-
let expires = 'expires=' + d.toUTCString();
59-
document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/';
70+
const expires = "expires=" + d.toUTCString();
71+
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
6072
};
6173

6274
function toggleSearch(on) {
6375
if (on) {
64-
document.getElementById('searchcontainer').style.display = 'block';
76+
document.getElementById("searchcontainer").style.display = "block";
6577
} else {
66-
document.getElementById('searchcontainer').style.display = 'none';
78+
document.getElementById("searchcontainer").style.display = "none";
6779
}
6880
};
6981

7082
function toggleText(id, a, b) {
71-
let t = document.getElementById(id).innerHTML;
83+
const t = document.getElementById(id).innerHTML;
7284
if (t.indexOf(a) !== -1) {
7385
document.getElementById(id).innerHTML = t.replace(a, b);
7486
} else {
@@ -77,18 +89,19 @@ function toggleText(id, a, b) {
7789
};
7890

7991
function toggleExpandable(id, c) {
80-
let d = document.getElementById(id).className;
81-
if (d === c + ' open') {
92+
const d = document.getElementById(id).className;
93+
if (d === c + " open") {
8294
document.getElementById(id).className = c;
8395
} else {
84-
document.getElementById(id).className = c + ' open';
96+
document.getElementById(id).className = c + " open";
8597
}
8698
};
8799

88100
function hideOnClickOutside(eles, other) {
89101
// if click not in id, hide
90102
const outsideClickListener = function (event) {
91-
let path = event.path || (event.composedPath && event.composedPath()) || composedPath(event.target);
103+
// eslint-disable-next-line max-len
104+
const path = event.path || (event.composedPath && event.composedPath()) || event.composedPath(event.target);
92105
let ok = false;
93106
for (let i = 0; i < eles.length; i++) {
94107
if (path.indexOf(eles[i]) !== -1) {
@@ -97,50 +110,55 @@ function hideOnClickOutside(eles, other) {
97110
}
98111

99112
if (ok === false) {
100-
document.getElementById(other).style.display = 'none';
113+
document.getElementById(other).style.display = "none";
114+
// eslint-disable-next-line no-use-before-define
101115
removeClickListener();
102116
}
103117
};
104118

105119
const removeClickListener = function () {
106-
document.removeEventListener('click', outsideClickListener);
120+
document.removeEventListener("click", outsideClickListener);
107121
};
108122

109-
document.addEventListener('click', outsideClickListener);
123+
document.addEventListener("click", outsideClickListener);
110124
};
111125

112126
function updateCheckboxes(id) {
113-
let elements = document.getElementById(id).querySelectorAll('input:checked');
114-
let urlel = document.getElementById(id).querySelectorAll('input[type=text]')[0];
115-
let url = urlel.getAttribute('data-originalurl');
127+
const elements = document.getElementById(id).querySelectorAll("input:checked");
128+
const urlel = document.getElementById(id).querySelectorAll("input[type=text]")[0];
129+
let url = urlel.getAttribute("data-originalurl");
116130
for (let i = 0; i < elements.length; i++) {
117-
url += '&' + elements[i].name + '=True';
131+
url += "&" + elements[i].name + "=True";
118132
}
119133

120134
urlel.value = url;
121135
};
122136

123137
$(document).ready(function () {
124-
$('#publisher').modal();
125-
$('#deleter').modal();
126-
$('#projectviewer').modal();
127-
document.getElementById('global-search').addEventListener('input', function (evt) {
128-
if (this.value !== '') {
129-
document.getElementById('search-close').style.display = 'initial';
138+
$("#publisher").modal();
139+
$("#deleter").modal();
140+
$("#projectviewer").modal();
141+
// eslint-disable-next-line no-unused-vars
142+
document.getElementById("global-search").addEventListener("input", function (evt) {
143+
if (this.value !== "") {
144+
document.getElementById("search-close").style.display = "initial";
130145
} else {
131-
document.getElementById('search-close').style.display = 'none';
146+
document.getElementById("search-close").style.display = "none";
132147
}
133148
});
134-
document.getElementById('local-tab').addEventListener('click', function (evt) {
149+
// eslint-disable-next-line no-unused-vars
150+
document.getElementById("local-tab").addEventListener("click", function (evt) {
135151
toggleSearch(false);
136152
});
137-
document.getElementById('global-tab').addEventListener('click', function (evt) {
153+
// eslint-disable-next-line no-unused-vars
154+
document.getElementById("global-tab").addEventListener("click", function (evt) {
138155
toggleSearch(true);
139156
});
140-
document.getElementById('view-more-chips').addEventListener('click', function (evt) {
141-
showMore = _('Show more tags');
142-
showLess = _('Show fewer tags');
143-
toggleExpandable('morechips', 'flexchips');
144-
toggleText('view-more-chips', showMore, showLess);
157+
// eslint-disable-next-line no-unused-vars
158+
document.getElementById("view-more-chips").addEventListener("click", function (evt) {
159+
const showMore = _("Show more tags");
160+
const showLess = _("Show fewer tags");
161+
toggleExpandable("morechips", "flexchips");
162+
toggleText("view-more-chips", showMore, showLess);
145163
});
146164
});

‎planet/js/main.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
global
3+
4+
Planet
5+
*/
6+
17
window.p;
28
window.makePlanet = async function(isMusicBlocks,storage,translationFunction) {
39
window._=translationFunction;

‎script.js

+23-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
$(document).ready(function () {
2-
var mode = localStorage.beginnerMode;
1+
/*
2+
global
3+
4+
$
5+
*/
36

4-
var modeIcon = document.getElementById('mode');
5-
var modeText = document.getElementById('modeText');
7+
$(document).ready(function () {
8+
var mode = localStorage.beginnerMode;
69

10+
var modeIcon = document.getElementById("mode");
11+
var modeText = document.getElementById("modeText");
712

8-
if (mode === null || mode === 'true') {
9-
modeIcon.innerHTML = 'star_border';
10-
modeText.setAttribute('data-tooltip', 'Switch to advanced mode');
11-
} else {
12-
modeIcon.innerHTML = 'star';
13-
modeText.setAttribute('data-tooltip', 'Switch to beginner mode');
14-
}
1513

16-
$('.tooltipped').tooltip();
14+
if (mode === null || mode === "true") {
15+
modeIcon.innerHTML = "star_border";
16+
modeText.setAttribute("data-tooltip", "Switch to advanced mode");
17+
} else {
18+
modeIcon.innerHTML = "star";
19+
modeText.setAttribute("data-tooltip", "Switch to beginner mode");
20+
}
1721

18-
$('.materialize-iso, .dropdown-trigger').dropdown({
19-
constrainWidth: false,
20-
hover: false, // Activate on hover
21-
belowOrigin: true, // Displays dropdown below the button
22-
});
22+
$(".tooltipped").tooltip();
2323

24-
});
24+
$(".materialize-iso, .dropdown-trigger").dropdown({
25+
constrainWidth: false,
26+
hover: false, // Activate on hover
27+
belowOrigin: true, // Displays dropdown below the button
28+
});
29+
});

‎sw.js

+97-86
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,123 @@
1+
/*
2+
global
3+
4+
offlineFallbackPage, divInstall
5+
*/
6+
17
// This is the "Offline page" service worker
28

39
const CACHE = "pwabuilder-precache";
410
const precacheFiles = [
5-
/* Add an array of files to precache for your app */
6-
'./index.html'
7-
];
11+
/* Add an array of files to precache for your app */
12+
"./index.html"
13+
];
814

915
self.addEventListener("install", function (event) {
10-
console.log("[PWA Builder] Install Event processing");
11-
12-
console.log("[PWA Builder] Skip waiting on install");
13-
self.skipWaiting();
14-
15-
event.waitUntil(
16-
caches.open(CACHE).then(function (cache) {
17-
console.log("[PWA Builder] Caching pages during install");
18-
return cache.addAll(precacheFiles);
19-
})
20-
);
16+
// eslint-disable-next-line no-console
17+
console.log("[PWA Builder] Install Event processing");
18+
19+
// eslint-disable-next-line no-console
20+
console.log("[PWA Builder] Skip waiting on install");
21+
self.skipWaiting();
22+
23+
event.waitUntil(
24+
caches.open(CACHE).then(function (cache) {
25+
// eslint-disable-next-line no-console
26+
console.log("[PWA Builder] Caching pages during install");
27+
return cache.addAll(precacheFiles);
28+
})
29+
);
2130
});
2231

2332
// Allow sw to control of current page
2433
self.addEventListener("activate", function (event) {
25-
console.log("[PWA Builder] Claiming clients for current page");
26-
event.waitUntil(self.clients.claim());
27-
});
28-
29-
// If any fetch fails, it will look for the request in the cache and serve it from there first
30-
self.addEventListener("fetch", function (event) {
31-
if (event.request.method !== "GET") return;
32-
33-
event.respondWith(
34-
fromCache(event.request).then(
35-
function (response) {
36-
// The response was found in the cache so we responde with it and update the entry
37-
38-
// This is where we call the server to get the newest version of the
39-
// file to use the next time we show view
40-
event.waitUntil(
41-
fetch(event.request).then(function (response) {
42-
return updateCache(event.request, response);
43-
})
44-
);
45-
46-
return response;
47-
},
48-
function () {
49-
// The response was not found in the cache so we look for it on the server
50-
return fetch(event.request)
51-
.then(function (response) {
52-
// If request was success, add or update it in the cache
53-
event.waitUntil(updateCache(event.request, response.clone()));
54-
55-
return response;
56-
})
57-
.catch(function (error) {
58-
console.log("[PWA Builder] Network request failed and no cache." + error);
59-
});
60-
}
61-
)
62-
);
34+
// eslint-disable-next-line no-console
35+
console.log("[PWA Builder] Claiming clients for current page");
36+
event.waitUntil(self.clients.claim());
6337
});
6438

39+
function updateCache(request, response) {
40+
return caches.open(CACHE).then(function (cache) {
41+
return cache.put(request, response);
42+
});
43+
}
6544

6645
function fromCache(request) {
67-
// Check to see if you have it in the cache
68-
// Return response
69-
// If not in the cache, then return
70-
return caches.open(CACHE).then(function (cache) {
71-
return cache.match(request).then(function (matching) {
72-
if (!matching || matching.status === 404) {
73-
return Promise.reject("no-match");
74-
}
75-
76-
return matching;
46+
// Check to see if you have it in the cache
47+
// Return response
48+
// If not in the cache, then return
49+
return caches.open(CACHE).then(function (cache) {
50+
return cache.match(request).then(function (matching) {
51+
if (!matching || matching.status === 404) {
52+
return Promise.reject("no-match");
53+
}
54+
55+
return matching;
56+
});
7757
});
78-
});
7958
}
8059

81-
self.addEventListener('beforeinstallprompt', (event) => {
82-
console.log('done', 'beforeinstallprompt', event);
83-
// Stash the event so it can be triggered later.
84-
window.deferredPrompt = event;
85-
// Remove the 'hidden' class from the install button container
86-
divInstall.classList.toggle('hidden', false);
60+
// If any fetch fails, it will look for the request in the cache and
61+
// serve it from there first
62+
self.addEventListener("fetch", function (event) {
63+
if (event.request.method !== "GET") return;
64+
65+
event.respondWith(
66+
fromCache(event.request).then(
67+
function (response) {
68+
// The response was found in the cache so we responde
69+
// with it and update the entry
70+
71+
// This is where we call the server to get the newest
72+
// version of the file to use the next time we show view
73+
event.waitUntil(
74+
fetch(event.request).then(function (response) {
75+
return updateCache(event.request, response);
76+
})
77+
);
78+
79+
return response;
80+
},
81+
function () {
82+
// The response was not found in the cache so we look
83+
// for it on the server
84+
return fetch(event.request)
85+
.then(function (response) {
86+
// If request was success, add or update it in the cache
87+
event.waitUntil(updateCache(event.request, response.clone()));
88+
return response;
89+
})
90+
.catch(function (error) {
91+
// eslint-disable-next-line no-console
92+
console.log("[PWA Builder] Network request failed and no cache." + error);
93+
});
94+
}
95+
)
96+
);
8797
});
8898

89-
function updateCache(request, response) {
90-
return caches.open(CACHE).then(function (cache) {
91-
return cache.put(request, response);
92-
});
93-
}
94-
99+
self.addEventListener("beforeinstallprompt", (event) => {
100+
// eslint-disable-next-line no-console
101+
console.log("done", "beforeinstallprompt", event);
102+
// Stash the event so it can be triggered later.
103+
window.deferredPrompt = event;
104+
// Remove the "hidden" class from the install button container
105+
divInstall.classList.toggle("hidden", false);
106+
});
95107

96-
// This is an event that can be fired from your page to tell the SW to update the offline page
108+
// This is an event that can be fired from your page to tell the SW to
109+
// update the offline page
97110
self.addEventListener("refreshOffline", function () {
98-
const offlinePageRequest = new Request(offlineFallbackPage);
99-
100-
return fetch(offlineFallbackPage).then(function (response) {
101-
return caches.open(CACHE).then(function (cache) {
102-
console.log("[PWA Builder] Offline page updated from refreshOffline event: " + response.url);
103-
return cache.put(offlinePageRequest, response);
111+
const offlinePageRequest = new Request(offlineFallbackPage);
112+
113+
return fetch(offlineFallbackPage).then(function (response) {
114+
return caches.open(CACHE).then(function (cache) {
115+
// eslint-disable-next-line no-console
116+
console.log("[PWA Builder] Offline page updated from refreshOffline event: " + response.url);
117+
return cache.put(offlinePageRequest, response);
118+
});
104119
});
105-
});
106120
});
107121

108122

109123

110-
111-
112-

0 commit comments

Comments
 (0)
Please sign in to comment.