Skip to content

index.js

Ryan Fu edited this page Sep 10, 2024 · 1 revision

UI Interaction Script

This script manages user interactions within the web application. It allows users to upload files, navigate between pages, adjust settings like colormap and tolerance, and trigger custom events.

  • Global Shared Data (window.sharedData):
    • This object is initialized to store shared properties across the code, such as:
    • colorMapType: Tracks the current type of colormap (initially set to 'none').
    • tolerance: Stores tolerance levels (default 0).
    • logarithmic: A boolean to control whether the scale is logarithmic or not.
    • mask: A boolean to track masking status (whether undefined values are handled as -1 or interpolated).
  • File Upload Button (uploadButton):
    • Clicking the "Upload" button triggers the file input click event (fileInput), opening the file dialog.
  • File Input (fileInput):
    • After selecting a file, it stores the file in sharedData.uploadedFile and dispatches a fileUploaded event to notify other parts of the app that a file has been uploaded.
    • It also resets the pageInput and toleranceInput values to their initial states.
  • Discrete Button (discreteButton):
    • Dispatches a discrete event when clicked. This likely signals that the discrete colormap type is being applied.
  • Pagination Controls (next, prev, and pageButton):
    • Next/Prev: These buttons increase or decrease the current page number in the pageInput element and trigger a pageChanged event with the updated page number.
  • Page Button: When clicked, it dispatches a pageChanged event based on the current page input value.
  • Key Endpoints Button (keyEndpointsButton):
    • Dispatches a continuous event, likely indicating a shift to continuous data processing.
  • Crop Button (cropButton):
    • Sets sharedData.crop to true and triggers a crop event to initiate a cropping action.
  • Get Data Button (getData):
    • This checks if a colormap type has been selected and sends appropriate events based on whether the colormap is discrete or continuous. It prevents further action if no colormap is selected.
  • Tolerance Input (toleranceInput):
    • Updates the sharedData.tolerance property based on the user’s input.
  • Scale Type Toggle (scaleType):
    • Toggles between logarithmic and linear scale types and updates the button text to reflect the current scale type.
  • Zoom Controls (zoomIn, zoomOut):
    • Dispatches either a zoomIn or zoomOut event to adjust the zoom level of the view.
  • Mask Toggle (maskOrNot):
    • Toggles between different methods of handling undefined values (either setting them to -1 or interpolating) and updates the button text accordingly.
Clone this wiki locally