better text fitting
This commit is contained in:
+6
-4
@@ -23,9 +23,7 @@
|
|||||||
<li>
|
<li>
|
||||||
Remaining meeting time: <b>{{ timeText(totalRemainingTime) }}</b>
|
Remaining meeting time: <b>{{ timeText(totalRemainingTime) }}</b>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>End estimated at: <b>{{ timeText(estimatedEnd) }}</b></li>
|
||||||
End estimated at: <b>{{ timeText(estimatedEnd) }}</b>
|
|
||||||
</li>
|
|
||||||
<li>Total meeting time: <b>{{ timeText(totalTime) }}</b></li>
|
<li>Total meeting time: <b>{{ timeText(totalTime) }}</b></li>
|
||||||
<li>
|
<li>
|
||||||
<label for="wheighted">Wheighted topics</label> <input
|
<label for="wheighted">Wheighted topics</label> <input
|
||||||
@@ -78,7 +76,11 @@
|
|||||||
<text
|
<text
|
||||||
:x="d.textPosition"
|
:x="d.textPosition"
|
||||||
y="0"
|
y="0"
|
||||||
style="font: bold 1px sans-serif; text-align: center"
|
style="
|
||||||
|
font: bold 1px sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
"
|
||||||
dominant-baseline="middle"
|
dominant-baseline="middle"
|
||||||
text-anchor="end"
|
text-anchor="end"
|
||||||
fill="white"
|
fill="white"
|
||||||
|
|||||||
@@ -45,11 +45,14 @@ let app = {
|
|||||||
},
|
},
|
||||||
estimatedEnd() {
|
estimatedEnd() {
|
||||||
const delta = this.timerStarted
|
const delta = this.timerStarted
|
||||||
? ((this.timerEnd - new Date()) / (1000 * 60))
|
? (this.timerEnd - new Date()) / (1000 * 60)
|
||||||
: this.showSelected
|
: this.showSelected
|
||||||
? this.selectedData.time
|
? this.selectedData.time
|
||||||
: 0;
|
: 0;
|
||||||
const toAdd = (this.totalRemainingTime - (this.showSelected ? this.selectedData.time : 0) + delta);
|
const toAdd =
|
||||||
|
this.totalRemainingTime -
|
||||||
|
(this.showSelected ? this.selectedData.time : 0) +
|
||||||
|
delta;
|
||||||
const end = new Date();
|
const end = new Date();
|
||||||
end.setMinutes(end.getMinutes() + toAdd);
|
end.setMinutes(end.getMinutes() + toAdd);
|
||||||
return end.getHours() * 60 + end.getMinutes();
|
return end.getHours() * 60 + end.getMinutes();
|
||||||
@@ -60,9 +63,9 @@ let app = {
|
|||||||
const ratio = this.wheighted
|
const ratio = this.wheighted
|
||||||
? item.time / this.totalRemainingTime
|
? item.time / this.totalRemainingTime
|
||||||
: 1 / this.filteredData.length;
|
: 1 / this.filteredData.length;
|
||||||
const textScale = item.text.length * 1.1;
|
|
||||||
const angleRad = 2 * Math.PI * ratio;
|
const angleRad = 2 * Math.PI * ratio;
|
||||||
const angleDeg = 360 * ratio;
|
const angleDeg = 360 * ratio;
|
||||||
|
const textScale = this.textScale(item.text, angleRad);
|
||||||
totalAngle += angleDeg;
|
totalAngle += angleDeg;
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -83,6 +86,12 @@ let app = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
textScale(text, angleRad) {
|
||||||
|
const r = 1.2;
|
||||||
|
const n = text.length;
|
||||||
|
const k = n + r / (2 * Math.tan(angleRad / 2));
|
||||||
|
return k / r;
|
||||||
|
},
|
||||||
overtime() {
|
overtime() {
|
||||||
return this.timerStarted && this.timerEnd - new Date() <= 0;
|
return this.timerStarted && this.timerEnd - new Date() <= 0;
|
||||||
},
|
},
|
||||||
@@ -92,9 +101,9 @@ let app = {
|
|||||||
: this.showSelected
|
: this.showSelected
|
||||||
? this.selectedData.time * 60
|
? this.selectedData.time * 60
|
||||||
: 0;
|
: 0;
|
||||||
return `${delta < 0 ? '-' : ''}${String(Math.floor(Math.abs(delta) / 60)).padStart(2, "0")}:${String(
|
return `${delta < 0 ? "-" : ""}${String(
|
||||||
Math.abs(delta) % 60
|
Math.floor(Math.abs(delta) / 60)
|
||||||
).padStart(2, "0")}`;
|
).padStart(2, "0")}:${String(Math.abs(delta) % 60).padStart(2, "0")}`;
|
||||||
},
|
},
|
||||||
beep(remaining = 3) {
|
beep(remaining = 3) {
|
||||||
if (remaining < 0) {
|
if (remaining < 0) {
|
||||||
@@ -111,10 +120,10 @@ let app = {
|
|||||||
oscillator.start();
|
oscillator.start();
|
||||||
const self = this;
|
const self = this;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
oscillator.stop();
|
oscillator.stop();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
self.beep(remaining - 1);
|
self.beep(remaining - 1);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 150);
|
}, 150);
|
||||||
},
|
},
|
||||||
timeText(minutes) {
|
timeText(minutes) {
|
||||||
@@ -150,7 +159,7 @@ let app = {
|
|||||||
},
|
},
|
||||||
getData() {
|
getData() {
|
||||||
const re = /:\s?(?:(?:(\d+)\s?h)?(\d+)?(?:\s?m(?:in)?)?)\s?$/i;
|
const re = /:\s?(?:(?:(\d+)\s?h)?(\d+)?(?:\s?m(?:in)?)?)\s?$/i;
|
||||||
this.setCookie('rawData', btoa(this.rawData));
|
this.setCookie("rawData", btoa(this.rawData));
|
||||||
return this.rawData
|
return this.rawData
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((line) => line.trim())
|
.map((line) => line.trim())
|
||||||
@@ -201,29 +210,27 @@ let app = {
|
|||||||
this.timerEnd = new Date(
|
this.timerEnd = new Date(
|
||||||
new Date().getTime() + this.selectedData.time * 60 * 1000
|
new Date().getTime() + this.selectedData.time * 60 * 1000
|
||||||
);
|
);
|
||||||
this.beepTimer = setTimeout(
|
this.beepTimer = setTimeout(() => {
|
||||||
() => {
|
this.beep();
|
||||||
this.beep();
|
}, this.selectedData.time * 60 * 1000);
|
||||||
}, this.selectedData.time * 60 * 1000
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
document.title = "Meeting Roulette";
|
document.title = "Meeting Roulette";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCookie(cname, cvalue, exdays) {
|
setCookie(cname, cvalue, exdays) {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
|
||||||
let expires = "expires="+ d.toUTCString();
|
let expires = "expires=" + d.toUTCString();
|
||||||
console.log(cname + "=" + cvalue + "; path=/; " + expires);
|
console.log(cname + "=" + cvalue + "; path=/; " + expires);
|
||||||
document.cookie = cname + "=" + cvalue + "; path=/; " + expires;
|
document.cookie = cname + "=" + cvalue + "; path=/; " + expires;
|
||||||
},
|
},
|
||||||
getCookie(cname, defaultValue) {
|
getCookie(cname, defaultValue) {
|
||||||
let name = cname + "=";
|
let name = cname + "=";
|
||||||
let decodedCookie = decodeURIComponent(document.cookie);
|
let decodedCookie = decodeURIComponent(document.cookie);
|
||||||
let ca = decodedCookie.split(';');
|
let ca = decodedCookie.split(";");
|
||||||
for(let i = 0; i <ca.length; i++) {
|
for (let i = 0; i < ca.length; i++) {
|
||||||
let c = ca[i];
|
let c = ca[i];
|
||||||
while (c.charAt(0) == ' ') {
|
while (c.charAt(0) == " ") {
|
||||||
c = c.substring(1);
|
c = c.substring(1);
|
||||||
}
|
}
|
||||||
if (c.indexOf(name) == 0) {
|
if (c.indexOf(name) == 0) {
|
||||||
@@ -231,11 +238,11 @@ let app = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
console.log("app mounted");
|
console.log("app mounted");
|
||||||
this.rawData = atob(this.getCookie('rawData', btoa(this.rawData)));
|
this.rawData = atob(this.getCookie("rawData", btoa(this.rawData)));
|
||||||
this.data = this.getData();
|
this.data = this.getData();
|
||||||
setTimeout(this.showApp);
|
setTimeout(this.showApp);
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user