Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation in protoblocks.js #3830

Merged
merged 46 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8af62fb
Added JSDoc style documentation
hackorlyf Feb 7, 2024
adedcc5
Added JSDoc style documentation
hackorlyf Feb 10, 2024
057de04
Removed the definition which belonged only to EnvelopBlock
hackorlyf Feb 10, 2024
ee25470
Merge branch 'master' into jsDocumentation
walterbender Feb 10, 2024
4e7b8c6
Added appropriate JSDoc
hackorlyf Feb 11, 2024
2435f7f
Merge branch 'jsDocumentation' of https://github.com/hackorlyf/musicb…
hackorlyf Feb 11, 2024
2e0946b
Added further JS Documentation
hackorlyf Feb 12, 2024
3d95832
Completed JS style documentation for WidgetBlocks.js
hackorlyf Feb 13, 2024
2d87ed1
Started adding comments for activity.js and temperament.js
hackorlyf Feb 14, 2024
646c234
Added further activity.js
hackorlyf Feb 15, 2024
f5c20ba
JS Docs added for activity.js
hackorlyf Feb 16, 2024
222f9aa
added JS documentation for activity.js
hackorlyf Feb 17, 2024
1efcc67
Rectified and added some documentations
hackorlyf Feb 18, 2024
4537916
Merge branch 'master' of https://github.com/hackorlyf/musicblocks int…
hackorlyf Feb 21, 2024
effc5b8
Completed Documentation for artwork.js
hackorlyf Feb 21, 2024
bbd27d8
Completed JS style Documentation for 2 files.
hackorlyf Feb 22, 2024
e13bc1a
Started Documentation for block.js
hackorlyf Feb 23, 2024
6a32081
Added and updated Documentation in block.js
hackorlyf Feb 24, 2024
ee80f36
JS Documentation
hackorlyf Feb 25, 2024
23d3b20
JS style documentation
hackorlyf Feb 26, 2024
f8c7425
Further js documentation in block.js
hackorlyf Feb 27, 2024
4b63720
Added lint error triggered comment
hackorlyf Feb 29, 2024
ff9759b
Documentation for block.js
hackorlyf Feb 29, 2024
46223eb
Merge branch 'master' into jsDocumentation
walterbender Feb 29, 2024
f11e860
Rectified and Added documentation
hackorlyf Mar 1, 2024
42afc7d
Merge branch 'jsDocumentation' of https://github.com/hackorlyf/musicb…
hackorlyf Mar 1, 2024
a45fef3
Completed and rectified documentation in block.js
hackorlyf Mar 2, 2024
48fc00d
Completed documentation for activity.js and added comments
hackorlyf Mar 3, 2024
dc76492
Completed Documentation in sugarizer.js
hackorlyf Mar 4, 2024
58bd7b5
Completed JS style documentation for env.js
hackorlyf Mar 5, 2024
42f4f29
Added documentation for jquery-3.7.1.js
hackorlyf Mar 6, 2024
8affa9a
Completed Documentation in planetInterface.js
hackorlyf Mar 8, 2024
062bdc5
Merge branch 'sugarlabs:master' into jsDocumentation
hackorlyf Mar 8, 2024
bcd5bf5
Reverted the changes back to original of a lib file
hackorlyf Mar 8, 2024
753c026
Merge branch 'jsDocumentation' of https://github.com/hackorlyf/musicb…
hackorlyf Mar 8, 2024
84b5573
Documentation in protoblocks.js
hackorlyf Mar 10, 2024
343d239
Further documentation in protoblocks.js
hackorlyf Mar 11, 2024
ad87f5e
Further Documentation in protoblocks.js
hackorlyf Mar 13, 2024
da31e44
Added the blank spaced lines as it was originally present in jquery t…
hackorlyf Mar 16, 2024
519f9f2
Removed blank space
hackorlyf Mar 16, 2024
64616b3
completing documentation in protoblocks.js
hackorlyf Mar 18, 2024
5b9880a
added documentation in protoblocks upto 2018 LOC
hackorlyf Mar 19, 2024
1b702a1
Completed Documentation in protoblocks.js
hackorlyf Mar 20, 2024
826f140
Eg shifted below L636
hackorlyf Apr 1, 2024
aaf3c66
Shifted all the comments in it's respective documentation
hackorlyf Apr 4, 2024
4bb58e9
Merge branch 'master' into jsDocumentation
walterbender Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions js/planetInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
exported PlanetInterface
*/

/**
* Represents an interface for interacting with a planet.
* @param {object} activity - The activity object associated with the interface.
*/
class PlanetInterface {
constructor(activity) {
this.planet = null;
this.iframe = null;
this.mainCanvas = null;
this.activity = activity;

/**
* Hides music blocks and related elements.
*/
this.hideMusicBlocks = () => {
this.activity.hideSearchWidget();
window.widgetWindows.hideAllWindows();
Expand All @@ -45,6 +52,9 @@ class PlanetInterface {
window.scroll(0, 0);
};

/**
* Shows music blocks and related elements.
*/
this.showMusicBlocks = () => {
document.title = this.activity.planet.getCurrentProjectName();
document.getElementById("toolbars").style.display = "block";
Expand All @@ -62,6 +72,9 @@ class PlanetInterface {
docById("buttoncontainerTOP").style.display = "block";
};

/**
* Shows the planet interface.
*/
this.showPlanet = () => {
const png = docById("overlayCanvas").toDataURL("image/png");
this.planet.open(png); // this.mainCanvas.toDataURL("image/png"));
Expand All @@ -75,21 +88,35 @@ class PlanetInterface {
}
};

/**
* Hides the planet interface.
*/
this.hidePlanet = () => {
this.iframe.style.display = "none";
};

/**
* Opens the planet interface.
*/
this.openPlanet = () => {
this.saveLocally();
this.hideMusicBlocks();
this.showPlanet();
};

/**
* Closes the planet interface.
*/
this.closePlanet = () => {
this.hidePlanet();
this.showMusicBlocks();
};

/**
* Loads a project from data.
* @param {string} data - The project data to load.
* @param {boolean} [merge=false] - Whether to merge with existing project data.
*/
this.loadProjectFromData = (data, merge) => {
if (merge === undefined) {
merge = false;
Expand Down Expand Up @@ -134,26 +161,44 @@ class PlanetInterface {
document.body.style.cursor = "default";
};

/**
* Function to trigger loading a project from a file.
* Focuses on the file input element and clicks it to trigger file selection.
* Scrolls the window to the top.
*/
this.loadProjectFromFile = () => {
document.querySelector("#myOpenFile").focus();
document.querySelector("#myOpenFile").click();
window.scroll(0, 0);
};

/**
* Function to create a new project.
* Closes the current project if open, initializes a new project, loads the start page, and saves the project locally.
*/
this.newProject = () => {
this.closePlanet();
this.initialiseNewProject();
this.activity._loadStart();
this.saveLocally();
};

/**
* Initializes a new project with the provided name or a default name.
* Clears the canvas, resets project data, and refreshes the canvas.
* @param {string} [name] - The name of the new project.
*/
this.initialiseNewProject = (name) => {
this.planet.ProjectStorage.initialiseNewProject(name);
this.activity.sendAllToTrash();
this.activity.refreshCanvas();
this.activity.blocks.trashStacks = [];
};

/**
* Function to save the current project locally.
* Prepares project data for export, generates SVG data, and saves the project data locally.
*/
this.saveLocally = () => {
this.activity.stage.update(event);
const data = this.activity.prepareExport();
Expand Down Expand Up @@ -199,34 +244,67 @@ class PlanetInterface {
}
};

/**
* Function to asynchronously open the current project.
* @returns {Promise} - A promise that resolves with the current project data.
*/
this.openCurrentProject = async () => {
return await this.planet.ProjectStorage.getCurrentProjectData();
};

/**
* Opens a project from the Planet by its ID.
* @param {string} id - The ID of the project to open.
* @param {string} [error] - Error message if project opening fails.
*/
this.openProjectFromPlanet = (id, error) => {
this.planet.openProjectFromPlanet(id, error);
};

/**
* Function to execute when the converter is loaded.
* Sets the Converter object in the window context.
*/
this.onConverterLoad = () => {
window.Converter = this.planet.Converter;
};

/**
* Retrieves the name of the current project.
* @returns {string} - The name of the current project.
*/
this.getCurrentProjectName = () => {
return this.planet.ProjectStorage.getCurrentProjectName();
};

/**
* Retrieves the description of the current project.
* @returns {string} - The description of the current project.
*/
this.getCurrentProjectDescription = () => {
return this.planet.ProjectStorage.getCurrentProjectDescription();
};

/**
* Retrieves the image associated with the current project.
* @returns {string} - The URL of the image associated with the current project.
*/
this.getCurrentProjectImage = () => {
return this.planet.ProjectStorage.getCurrentProjectImage();
};

/**
* Retrieves the timestamp of the last time the project was saved.
* @returns {Date} - The timestamp of the last save operation.
*/
this.getTimeLastSaved = () => {
return this.planet.ProjectStorage.TimeLastSaved;
};

/**
* Initializes the Planet iframe and sets up communication between the main window and the iframe.
* Sets up event handlers and initializes Converter.
*/
this.init = async () => {
this.iframe = document.getElementById("planet-iframe");
try {
Expand Down
Loading
Loading