Skip to content

Commit

Permalink
various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
acenturyandabit committed Dec 11, 2020
1 parent 01996b4 commit 79a11af
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 32 deletions.
45 changes: 38 additions & 7 deletions cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3241,6 +3241,10 @@ if (isPhone()) {
polymorph_core.currentOperator = id;
polymorph_core.items._meta.focusedContainer = id;
polymorph_core.fire("updateItem", { id: "_meta", sender: this });

document.querySelector(".operatorName").parentElement.style.display = "inline";
document.querySelector(".operatorName").innerText = polymorph_core.items[id]._od.tabbarName;

polymorph_core.containers[id].refresh();
}

Expand Down Expand Up @@ -4352,7 +4356,7 @@ if (isPhone()) {
</style>`));
document.body.appendChild(htmlwrap(`<div id="topbar" style="flex: 0 0 2em">
<button id="menu" style="font-size: 1.5em;width: 1.5em;height: 1.5em;text-align:center; overflow:hidden;">=</button>
<span class="docName" contentEditable>Polymorph</span>
<span class="docName" contentEditable>Polymorph</span><span style="display:none">&gt;<span class="operatorName"></span></span>
<button id="opop" style="position: absolute; right:0; top: 0; z-index:5;font-size: 1.5em;width: 1.5em;height: 1.5em;text-align:center; overflow:hidden;">*</button>
</div>`));

Expand Down Expand Up @@ -4725,7 +4729,9 @@ if (!isPhone()) {

function updateDBM() {
if (localStorage.getItem("__polymorph_debug_flag") == "true") {
dbm.innerText = "Debug Mode (now ON)";
dbm.children[0].children[0].innerText = "Debug Mode (now ON)";
} else {
dbm.children[0].children[0].innerText = "Debug Mode";
}
}
updateDBM();
Expand Down Expand Up @@ -9602,16 +9608,36 @@ if (isPhone()) {
section: "Layout",
mustColdLoad: true
}, function(container) {
polymorph_core.operatorTemplate.call(this, container, {});
let defaultSettings = {
expanded: false
};
polymorph_core.operatorTemplate.call(this, container, defaultSettings);
this.rootdiv.remove(); //nerf the standard rootdiv because of differring naming conventions between rects and operators.
this.outerDiv = document.createElement("div");
//Add div HTML here
this.outerDiv.innerHTML = ``;
this.outerDiv.style.cssText = `width:100%; position:relative`;

//////////////////Handle polymorph_core item updates//////////////////

let checkExpanded = () => {
if (this.settings.expanded) {
this.outerDiv.style.display = "none";
} else {
this.outerDiv.style.display = "block";
}
}
checkExpanded();
this.refresh = function() {
container.rect.listContainer.querySelector(`[data-containerid='${container.id}']`).appendChild(this.outerDiv);
//Replace the parent container label
let myRectContainerParent = container.rect.listContainer.querySelector(`[data-containerid='${container.id}']`);
myRectContainerParent.innerHTML = `
<p>${container.settings.tabbarName} V </p>`;
myRectContainerParent.children[0].style.margin = 0;
myRectContainerParent.children[0].addEventListener("click", (e) => {
this.settings.expanded = !this.settings.expanded;
checkExpanded();
e.stopPropagation();
})
myRectContainerParent.appendChild(this.outerDiv);
polymorph_core.rects[this.rectID].refresh();
}

Expand Down Expand Up @@ -10325,7 +10351,12 @@ function _itemcluster_extend_svg(me) { // very polymorph_core functions!
}
let fob = me.itemPointerCache[id].children()[1];
if (fob.width() == 0) { // when container starts invisible, fob does not show.
fob.size(dvd.scrollWidth, tta.scrollHeight);
if (tta.scrollHeight < 1) {
//wait
setTimeout(() => {
fob.size(dvd.scrollWidth, tta.scrollHeight);
})
}
}

//add icons if necessary
Expand Down
4 changes: 4 additions & 0 deletions core_modules/core/core.phone.rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ if (isPhone()) {
polymorph_core.currentOperator = id;
polymorph_core.items._meta.focusedContainer = id;
polymorph_core.fire("updateItem", { id: "_meta", sender: this });

document.querySelector(".operatorName").parentElement.style.display = "inline";
document.querySelector(".operatorName").innerText = polymorph_core.items[id]._od.tabbarName;

polymorph_core.containers[id].refresh();
}

Expand Down
2 changes: 2 additions & 0 deletions core_modules/ui/core.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ if (!isPhone()) {
function updateDBM() {
if (localStorage.getItem("__polymorph_debug_flag") == "true") {
dbm.children[0].children[0].innerText = "Debug Mode (now ON)";
} else {
dbm.children[0].children[0].innerText = "Debug Mode";
}
}
updateDBM();
Expand Down
2 changes: 1 addition & 1 deletion core_modules/ui/core.phone.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (isPhone()) {
</style>`));
document.body.appendChild(htmlwrap(`<div id="topbar" style="flex: 0 0 2em">
<button id="menu" style="font-size: 1.5em;width: 1.5em;height: 1.5em;text-align:center; overflow:hidden;">=</button>
<span class="docName" contentEditable>Polymorph</span>
<span class="docName" contentEditable>Polymorph</span><span style="display:none">&gt;<span class="operatorName"></span></span>
<button id="opop" style="position: absolute; right:0; top: 0; z-index:5;font-size: 1.5em;width: 1.5em;height: 1.5em;text-align:center; overflow:hidden;">*</button>
</div>`));

Expand Down
5 changes: 3 additions & 2 deletions filemanager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let fileList = [
"3pt/localforage.min.js",
"manager.js",
"utils.js",
"core.js",
"core_modules/ui/core.tutorial.js",
"core_modules/core/core.docLoading.js",
Expand Down Expand Up @@ -86,12 +86,13 @@ try {
setTimeout(start);
}
} catch (e) {
console.log(e);
console.log(e); // in case it's actually a browser error.
let fs = require("fs");
//this is a compilation script
fs.writeFileSync("cat.js", fs.readFileSync(fileList[0]));
for (let i = 1; i < fileList.length; i++) {
fs.appendFileSync("cat.js", ";\n\n"); // #safe
fs.appendFileSync("cat.js", fs.readFileSync(fileList[i]));
console.log("adding file " + fileList[i] + "...");
}
}
19 changes: 17 additions & 2 deletions operators/itemList.phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ if (isPhone()) {
position:sticky;
top:0;
}
.propertyLabel{
border-top: 1px solid white;
}
</style>
<div class="taskList">
<div class="plusButton"> + </div>
Expand Down Expand Up @@ -129,12 +133,13 @@ if (isPhone()) {
props[i].keep = true;
} else {
props[i] = {
div: htmlwrap(`<p>${i}</p><p contenteditable></p>`),
div: htmlwrap(`<p class="propertyLabel">${i}</p><p contenteditable></p>`),
keep: true
}
props[i].div.dataset.prop = i;
backDiv.appendChild(props[i].div);
}
//if () // special treatment of dates
props[i].div.children[1].innerText = polymorph_core.items[id][i] || "";
}
for (let i in props) {
Expand All @@ -146,7 +151,17 @@ if (isPhone()) {
}

backDiv.addEventListener("input", (e) => {
polymorph_core.items[editingID][e.target.parentElement.dataset.prop] = e.target.innerText;
let currentItem = polymorph_core.items[editingID];
if (this.settings.phoneProperties[i] == 'date') {
if (!currentItem[e.target.dataset.role]) currentItem[e.target.dataset.role] = {};
if (!currentItem[e.target.dataset.role].datestring) currentItem[e.target.dataset.role] = {
"datestring": ""
};
currentItem[e.target.dataset.role].datestring = e.target.value;
currentItem[e.target.dataset.role].date = dateParser.richExtractTime(currentItem[e.target.dataset.role].datestring);
} else {
currentItem[e.target.parentElement.dataset.prop] = e.target.innerText;
}
container.fire("updateItem", { id: editingID });
})

Expand Down
7 changes: 6 additions & 1 deletion operators/itemcluster.svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ function _itemcluster_extend_svg(me) { // very polymorph_core functions!
}
let fob = me.itemPointerCache[id].children()[1];
if (fob.width() == 0) { // when container starts invisible, fob does not show.
fob.size(dvd.scrollWidth, tta.scrollHeight);
if (tta.scrollHeight < 1) {
//wait
setTimeout(() => {
fob.size(dvd.scrollWidth, tta.scrollHeight);
})
}
}

//add icons if necessary
Expand Down
28 changes: 24 additions & 4 deletions operators/subframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,36 @@ if (isPhone()) {
section: "Layout",
mustColdLoad: true
}, function(container) {
polymorph_core.operatorTemplate.call(this, container, {});
let defaultSettings = {
expanded: false
};
polymorph_core.operatorTemplate.call(this, container, defaultSettings);
this.rootdiv.remove(); //nerf the standard rootdiv because of differring naming conventions between rects and operators.
this.outerDiv = document.createElement("div");
//Add div HTML here
this.outerDiv.innerHTML = ``;
this.outerDiv.style.cssText = `width:100%; position:relative`;

//////////////////Handle polymorph_core item updates//////////////////

let checkExpanded = () => {
if (this.settings.expanded) {
this.outerDiv.style.display = "none";
} else {
this.outerDiv.style.display = "block";
}
}
checkExpanded();
this.refresh = function() {
container.rect.listContainer.querySelector(`[data-containerid='${container.id}']`).appendChild(this.outerDiv);
//Replace the parent container label
let myRectContainerParent = container.rect.listContainer.querySelector(`[data-containerid='${container.id}']`);
myRectContainerParent.innerHTML = `
<p>${container.settings.tabbarName} V </p>`;
myRectContainerParent.children[0].style.marginTop = 0;
myRectContainerParent.children[0].addEventListener("click", (e) => {
this.settings.expanded = !this.settings.expanded;
checkExpanded();
e.stopPropagation();
})
myRectContainerParent.appendChild(this.outerDiv);
polymorph_core.rects[this.rectID].refresh();
}

Expand Down
3 changes: 2 additions & 1 deletion pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Place those scripts in the 'urlsToCache' property and you'll be ready to go.
var _pwaManager = (() => {
let serviceWorkerSettings = {
urlsToCache: [
"manager.js",
"utils.js",
"filemanager.js",
"core.js",
"core_modules/ui/core.tutorial.js",
"core_modules/core/core.docLoading.js",
Expand Down
26 changes: 12 additions & 14 deletions saveSources/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,23 @@ polymorph_core.registerSaveSource("lobby", function(save_source_data) { // a sam
} catch (e) {
//ws already closed
}
console.log("ws error, reconnecting in 5...");
setTimeout(this.updateRTstate, 5000);
console.log("ws error, reconnecting...");
setTimeout(this.updateRTstate);
clearInterval(this.wsQueueDigester);
})
} else {
this.wsQueueDigester = setInterval(() => {
toSends = this.RTSyncQueue.slice(0, 5);
if (toSends.length) {
if (this.ws.readyState != WebSocket.OPEN) {
console.log("ws error, reconnecting in 5...");
setTimeout(this.updateRTstate, 5000);
clearInterval(this.wsQueueDigester);
} else {
this.ws.send(JSON.stringify({
type: "postUpdate",
data: toSends
}));
this.RTSyncQueue.splice(0, 5);
}
if (this.ws.readyState != WebSocket.OPEN) {
console.log("ws error, reconnecting...");
setTimeout(this.updateRTstate);
clearInterval(this.wsQueueDigester);
} else if (toSends.length) {
this.ws.send(JSON.stringify({
type: "postUpdate",
data: toSends
}));
this.RTSyncQueue.splice(0, 5);
}
}, 1000);
}
Expand Down
0 manager.js → utils.js
100755 → 100644
File renamed without changes.

0 comments on commit 79a11af

Please sign in to comment.