Skip to content

Commit

Permalink
Revert usage of Object.fromEntries and fix it trough patching Object
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowee committed Sep 23, 2019
1 parent c466c82 commit dab3b27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions web/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ const CONCURRENT_WORKER = 3;
// Retry to upload chunks if failed for at most `CHUNK_RETRY` times;
const CHUNK_RETRY = 3;

if (Object.fromEntries == undefined) {
Object.fromEntries = function(entries) {
const object = new Object();
for (const [key, value] of entries) {
object[key] = value;
}
return object;
}
}

const logBase = (base, number) => Math.log(number) / Math.log(base);
function size_to_readable(size) {
if (size === 0) {
Expand Down Expand Up @@ -69,9 +79,9 @@ const fileNameList = document.getElementById("file-name-list");
const uploadButton = document.getElementById("upload-button");
const taskItemTemplate = document.getElementById("task-item-template");
// TODO: in EDGE: SCRIPT438: Object doesn't support property or method 'fromEntries'
const statusTemplate = new Object();
["pending", "progress", "failed", "done"].forEach(
status => statusTemplate[status] = document.getElementById(`status-${status}-template`));
const statusTemplate = Object.fromEntries(
["pending", "progress", "failed", "done"].map(
status => [status, document.getElementById(`status-${status}-template`)]));
let filesSelected = null;
let taskId = 0;
let workerToken = 0;
Expand Down Expand Up @@ -122,8 +132,9 @@ async function onUpload() {
taskItem.querySelector("[name=id]").textContent = taskId;
taskItem.querySelector("[name=id]").title = `Submitted: ${new Date()}`;
taskItem.querySelector("[name=name]").textContent = file.name;
taskItem.querySelector("[name=name]").title = `Last Modified: ${file.lastModifiedDate}`;
taskItem.querySelector("[name=size]").textContent = size_to_readable(file.size);
taskItem.querySelector("[name=size]").title = file.size;
taskItem.querySelector("[name=size]").title = `${file.size} Bytes`;
taskItem.querySelector("[name=status]").appendChild(statusPending);
taskList.insertBefore(taskItem, taskList.firstElementChild);
TASKS.pending.push(new Task(taskId, file));
Expand Down
3 changes: 2 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<style>
html {
height: 100%;
/* scroll set by bulma */
overflow-y: auto !important;
}

Expand Down Expand Up @@ -113,14 +114,14 @@ <h1 class="title">
</template>
<template id="status-progress-template">
<progress class="progress is-primary" name="progress" max="100"></progress>
<!-- <button class="button is-primary"></button> -->
</template>
<template id="status-failed-template">
<span class="tag is-danger">Failed</span>
</template>
<template id="status-done-template">
<!-- TODO: template & slot (no support in IE(?) and ...(?)) -->
<span class="tags has-addons status-tags">
<!-- TODO: line broken unintendedly -->
<span class="tag is-success">Done</span>
<span class="tag is-light">
<!-- // TODO: Must be a &nbsp; escape? -->
Expand Down

0 comments on commit dab3b27

Please sign in to comment.