-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create small menu at bottom left to load new file
- Loading branch information
1 parent
9a6a61d
commit 5053077
Showing
8 changed files
with
126 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#current-file { | ||
position: fixed; | ||
bottom: 10px; | ||
left: 10px; | ||
display: none; | ||
flex-direction: row; | ||
align-items: center; | ||
background-color: #e1e1e1; | ||
padding: 8px 10px; | ||
font-size: 14px; | ||
border: 1px solid #000; | ||
border-radius: 5px; | ||
} | ||
|
||
#change-file { | ||
margin-left: 5px; | ||
width: 20px; | ||
height: 20px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { eventCollection, renderEvent } from "./event-number.js"; | ||
import { selectViewInformation } from "./information.js"; | ||
import { jsonData } from "./main.js"; | ||
import { scrollLocations } from "./views/views.js"; | ||
|
||
const fileInput = document.getElementById("change-file-input"); | ||
|
||
fileInput.addEventListener("change", (event) => { | ||
for (const file of event.target.files) { | ||
if (!file.name.endsWith("edm4hep.json")) { | ||
errorMsg("Provided file is not EDM4hep JSON!"); | ||
} | ||
|
||
if (!file.type.endsWith("/json")) { | ||
errorMsg("ERROR: Provided file is not EDM4hep JSON!"); | ||
} | ||
|
||
setFileName(file.name); | ||
|
||
const reader = new FileReader(); | ||
reader.addEventListener("load", (event) => { | ||
const fileText = event.target.result; | ||
jsonData.data = JSON.parse(fileText); | ||
|
||
const eventOptions = Object.keys(jsonData.data).map((event) => | ||
parseInt(event.replace("Event ", "")) | ||
); | ||
|
||
if (eventOptions.length === 0) { | ||
errorMsg("ERROR: No events found in file!"); | ||
return; | ||
} | ||
|
||
const eventNumber = eventOptions[0]; | ||
clearAllData(); | ||
selectViewInformation(); | ||
renderEvent(eventNumber); | ||
|
||
const eventSelectorMenu = document.getElementById("event-selector-menu"); | ||
eventSelectorMenu.replaceChildren(); | ||
|
||
eventOptions.forEach((option) => { | ||
const optionElementMenu = document.createElement("div"); | ||
optionElementMenu.className = "event-option"; | ||
optionElementMenu.appendChild(document.createTextNode(option)); | ||
eventSelectorMenu.appendChild(optionElementMenu); | ||
optionElementMenu.addEventListener("click", () => { | ||
renderEvent(option); | ||
eventSelectorMenu.style.display = "none"; | ||
}); | ||
}); | ||
}); | ||
|
||
reader.readAsText(file); | ||
break; | ||
} | ||
}); | ||
|
||
function clearAllData() { | ||
Object.keys(eventCollection).forEach((key) => { | ||
delete eventCollection[key]; | ||
}); | ||
|
||
Object.keys(scrollLocations).forEach((key) => { | ||
delete scrollLocations[key]; | ||
}); | ||
} | ||
|
||
function handleFileInput() { | ||
fileInput.click(); | ||
} | ||
|
||
const button = document.getElementById("change-file"); | ||
button.addEventListener("click", handleFileInput); | ||
|
||
export function setFileName(name) { | ||
const fileName = document.getElementById("current-file-name"); | ||
fileName.textContent = name; | ||
} | ||
|
||
export function showFileNameMenu() { | ||
const fileNameMenu = document.getElementById("current-file"); | ||
fileNameMenu.style.display = "flex"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters