Skip to content

Commit

Permalink
minor renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Oct 31, 2023
1 parent bdab8fc commit ff4fd05
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 46 deletions.
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"type": "git",
"url": "https://github.com/hetalang/heta-online.git"
},
"homepage": "https://hetalang.github.io/#/heta-compiler/",
"homepage": "https://hetalang.github.io/#/heta-online/",
"bugs": {
"url": "https://github.com/hetalang/heta-online/issues",
"email": "[email protected]"
Expand Down Expand Up @@ -51,7 +51,6 @@
},
"dependencies": {
"ajv": "^8.12.0",
"ajv-errors": "^3.0.0",
"font-awesome": "^4.7.0",
"heta-compiler": "^0.6.20",
"jquery": "^3.7.0",
Expand Down
29 changes: 13 additions & 16 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ $(window).on('resize', updateWindowHeight);
import hetaPackage from 'heta-compiler/package';

// heta modules collection
let leftCollection = window.leftCollection = new PagesCollection('#leftPanel', '#newButton');
let leftCollection = new PagesCollection('#leftPanel', '#newButton');

// heta exports collection
let rightCollection = window.rightCollection = new PagesCollection('#rightPanel');
let rightCollection = new PagesCollection('#rightPanel');

$(window).on('beforeunload', async function(evt) {
evt.preventDefault();
Expand All @@ -29,7 +29,7 @@ $(window).on('beforeunload', async function(evt) {

async function saveSession() {
let leftCollectionArray = [];
for (let page of leftCollection.hetaPagesStorage.values()) {
for (let page of leftCollection.pagesStorage.values()) {
let uint8 = await page.toUint8String();
let options = page.monacoEditor?.getRawOptions();
leftCollectionArray.push({
Expand All @@ -43,7 +43,7 @@ async function saveSession() {
window.localStorage.setItem('leftCollectionArray', JSON.stringify(leftCollectionArray));

let rightCollectionArray = [];
for (let page of rightCollection.hetaPagesStorage.values()) {
for (let page of rightCollection.pagesStorage.values()) {
let uint8 = await page.toUint8String();
let options = page.monacoEditor?.getRawOptions();
rightCollectionArray.push({
Expand All @@ -56,7 +56,6 @@ async function saveSession() {
}
window.localStorage.setItem('rightCollectionArray', JSON.stringify(rightCollectionArray));
}
window.saveSession = saveSession;

function loadSession() {
let leftCollectionString = localStorage.getItem('leftCollectionArray');
Expand All @@ -65,7 +64,7 @@ function loadSession() {
let uint8 = new Uint8Array(x.uint8.split(','));
leftCollection.addPageFromArrayBuffer(uint8.buffer, x.filepath, x.readOnly, x.deleteBtn, x.rightSide);
});
leftCollection.defaultPageName = 'index.heta';
leftCollection.defaultPageName = 'platform.json';
/*
let rightCollectionString = localStorage.getItem('rightCollectionArray');
let rightCollectionObject = JSON.parse(rightCollectionString);
Expand Down Expand Up @@ -110,10 +109,10 @@ $(async () => {
let isOk = window.confirm('You are about to reset the platform to the initial state and delete all progress. Are you sure?');
if (isOk) {
// delete pages
for (let page of leftCollection.hetaPagesStorage.values()) {
for (let page of leftCollection.pagesStorage.values()) {
page.delete();
}
for (let page of rightCollection.hetaPagesStorage.values()) {
for (let page of rightCollection.pagesStorage.values()) {
page.delete();
}
localStorage.clear();
Expand All @@ -132,7 +131,7 @@ $(async () => {
builderWorker.onmessage = async function({data}) {
// update editor {action: 'editor', value: 'Some message', append: true} NOT USED
if (data.action === 'editor') {
let he = rightCollection.hetaPagesStorage.get(data.editor);
let he = rightCollection.pagesStorage.get(data.editor);
if (data.append) {
let currentValue = he.monacoEditor.getValue();
he.monacoEditor.setValue(currentValue + data.value);
Expand All @@ -145,7 +144,7 @@ $(async () => {

// update console {action: 'console', value: 'Some message'}
if (data.action === 'console') {
rightCollection.hetaPagesStorage.get('CONSOLE').appendText(data.value);
rightCollection.pagesStorage.get('CONSOLE').appendText(data.value);

return; // BRAKE
}
Expand All @@ -166,13 +165,13 @@ $(async () => {
$('#buildBtn').removeClass('w3-disabled'); // to turn it on
$('#buildBtn').on('click', async () => {
// clean old exports
for (let [filepath, page] of rightCollection.hetaPagesStorage) {
for (let [filepath, page] of rightCollection.pagesStorage) {
filepath!==rightCollection.defaultPageName && page.delete();
}

// save all as object {filepath1: buffer1, filepath2: buffer2, ...}
let fileDict = {};
for (let [filepath, page] of leftCollection.hetaPagesStorage) {
for (let [filepath, page] of leftCollection.pagesStorage) {
fileDict['/' + filepath] = await page.getArrayBuffer(); // ArrayBuffer
}

Expand All @@ -194,10 +193,8 @@ function updateWindowHeight(){
$('#rightPanel .codeContainer').height(h3 + 'px');

// update editors
window.leftCollection
.hetaPagesStorage
leftCollection.pagesStorage
.forEach((x) => $(x.editorContainer).css('display') === 'block' && x.monacoEditor?.layout());
window.rightCollection
.hetaPagesStorage
rightCollection.pagesStorage
.forEach((x) => $(x.editorContainer).css('display') === 'block' && x.monacoEditor?.layout());
}
1 change: 0 additions & 1 deletion src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Container, ModuleSystem, Transpot } from 'heta-compiler/src/webpack';
import path from 'path';
import declarationSchema from 'heta-compiler/src/builder/declaration-schema.json';
import Ajv from 'ajv';
//const ajvErrors = require('ajv-errors');
import hetaCompilerPackage from 'heta-compiler/package.json';
import semver from 'semver';

Expand Down
26 changes: 13 additions & 13 deletions src/drug-and-drop.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
export default function DnDFileController(selector, onDropCallback) {
var el_ = document.querySelector(selector);

this.dragenter = function(e) {
e.stopPropagation();
e.preventDefault();
this.dragenter = function(evt) {
evt.stopPropagation();
evt.preventDefault();

// Give a visual indication this element is a drop target.
el_.classList.add('dropping');
};

this.dragover = function(e) {
e.stopPropagation();
e.preventDefault();
this.dragover = function(evt) {
evt.stopPropagation();
evt.preventDefault();
};

this.dragleave = function(e) {
e.stopPropagation();
e.preventDefault();
this.dragleave = function(evt) {
evt.stopPropagation();
evt.preventDefault();
el_.classList.remove('dropping');
};

this.drop = function(e) {
e.stopPropagation();
e.preventDefault();
this.drop = function(evt) {
evt.stopPropagation();
evt.preventDefault();

el_.classList.remove('dropping');

onDropCallback(e.dataTransfer.files[0]);
onDropCallback(evt.dataTransfer.files[0]);
};

el_.addEventListener('dragenter', this.dragenter, false);
Expand Down
10 changes: 5 additions & 5 deletions src/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const FORMATS = { // + Exports/Modules
export class PagesCollection {
constructor(panel, newButton) {
this.panel = panel;
this.hetaPagesStorage = new Map();
this.pagesStorage = new Map();
this.defaultPageName = undefined;
// set events
this.count = 0;
Expand Down Expand Up @@ -112,7 +112,7 @@ export class PagesCollection {
return page;
}
get defaultPage() {
return this.hetaPagesStorage.get(this.defaultPageName);
return this.pagesStorage.get(this.defaultPageName);
}
checkPageName(format) {
// prompt for module name
Expand All @@ -121,7 +121,7 @@ export class PagesCollection {
do {
fileName = window.prompt(title, fileName);
title = `"${fileName}" already exist. Choose another name.`
} while (this.hetaPagesStorage.has(fileName))
} while (this.pagesStorage.has(fileName))

return fileName;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ export class Page {
window.localStorage.removeItem(this.id);
$(this.navigationButton).remove();
$(this.editorContainer).remove();
this._parent.hetaPagesStorage.delete(this.id);
this._parent.pagesStorage.delete(this.id);
this._parent.defaultPage?.show();
}
addTo(pageCollection, setAsDefault=false) {
Expand All @@ -186,7 +186,7 @@ export class Page {
$(pageCollection.panel).find('.codeNavigation').append($(this.navigationButton));

// add to storage
pageCollection.hetaPagesStorage.set(this.id, this);
pageCollection.pagesStorage.set(this.id, this);
this.show();

return this;
Expand Down

0 comments on commit ff4fd05

Please sign in to comment.