I am looking to organize my content by creating categories such as How, When, and Why for different videos. How can I achieve this for a large amount of text

I am in the process of organizing categories for the text I have. My goal is to display text from specific categories based on the color that a random video lands on. For example, if the video lands on the color red, I want text from the category labeled "when?" to appear. If it lands on the color blue, then I want text from the category labeled "how?" to be displayed, and so on...

Here is the revised code:

<html>

<head>
  <link rel="stylesheet" type="text/css" href="style.css" title="Default Styles"/>
    <script>

var r_text = new Array();
r_text[0] = "How can we enhance self-organization in the upcoming sprint?";
r_text[1] = "How can we boost productivity and increase velocity?";
r_text[2] = "How can we achieve greater transparency and visibility regarding issues and challenges?";
r_text[3] = "How can our Product Owner assist us in focusing on the sprint goal?";
r_text[4] = "How can our Scrum Master help us enhance our delivery?";
r_text[5] = "How can we adopt a more T-shaped approach in the next sprint?";
r_text[6] = "How should we better celebrate our achievements?";
r_text[7] = "How can we minimize our cycle times?";
r_text[8] = "How can we make our daily scrum meetings more effective?";
r_text[9] = "How can we enhance delivery flow by implementing WIP Limits?";
r_text[10] = "How can we improve collaboration?";
r_text[11] = "How can I support someone else in the next sprint?";
r_text[12] = "How can we enhance our Sprint planning sessions?";
r_text[13] = "How can we demonstrate the Scrum Value of Courage more effectively?";
r_text[14] = "How can we embody the Scrum Value of Respect more?";
r_text[15] = "How can we display the Scrum Value of Focus more prominently?";
r_text[16] = "How can we exemplify the Scrum Value of Commitment more?";
// Repeat the above lines as needed for additional questions

var i = Math.floor(20*Math.random())

var videos = [{
    id: 1,
    url: "https://www.youtube.com/embed/ngUMyF9D9SQ?autoplay=1",
    text: r_text[i]
  },
  {
    id: 2,
    url: "https://www.youtube.com/embed/r-l_gVPVylM?autoplay=1",
    text: r_text[i]
  },
  {
    id: 3,
    url: "https://www.youtube.com/embed/6ukTzRjXcR0?autoplay=1",
    text: r_text[i]
  },
  {
    id: 4,
    url: "https://www.youtube.com/embed/n5BXMNCTu8I?autoplay=1",
    text: r_text[i]
  },
  {
    id: 5,
    url: "https://www.youtube.com/embed/JtwVmnMNaEY?autoplay=1",
    text: r_text[i]
  },
  {
    id: 6,
    url: "https://www.youtube.com/embed/lAMgRaHP8Q4?autoplay=1",
    text: r_text[i]
  }

];

window.onload = function() {
  function rollVideo(numberRand) {
    let playerDiv = document.getElementById("random_player");
    if (document.querySelector("iframe") !== null) {
      document.querySelector("iframe").remove();
    }
    let player = document.createElement("IFRAME");
    let randomVideoUrl = videos[numberRand].url;
    player.setAttribute("width", "640");
    player.setAttribute("height", "390");
    player.setAttribute("src", randomVideoUrl);
    playerDiv.appendChild(player);
    document.getElementById("r_text").innerHTML = "";
    document.getElementById("r_text").innerHTML = r_text[Math.floor(6*Math.random())];
  }


  document.getElementById("btn-roll").addEventListener("click", startRoll);

  function startRoll() {
    let currentNumber = Math.floor(Math.random() * videos.length);
    rollVideo(currentNumber);
  }
};





    </script>
</head>


<div id="random_player">
  <div id="r_text">
  </div>
</div>
<button id="btn-roll">Roll</button>
</html>

Answer №1

I have created three arrays to categorize videos based on specific criteria. Moving forward, I plan to incorporate more arrays to further organize the videos. My main goal is to randomly select and display relevant text when a video corresponds to a specific category, such as the color red.

<html>

<head>
  <link rel="stylesheet" type="text/css" href="style.css" title="Default Styles"/>
    <script>

var r_text = new Array();
r_text[0] = "How can we become more self-organised in the next sprint?";
r_text[1] = "How can we improve our productivity, increase our velocity?";
r_text[2] = "How can we get better in Transparency and Visibility of issues and challenges?";
r_text[3] = "How can our PO help us, to focus more on the sprint goal?";
r_text[4] = "How can our SM help us improve our delivery?";
...
...
...
var videos = [{
    id: 1,
    url: "https://www.youtube.com/embed/ngUMyF9D9SQ?autoplay=1",
    text: r_text[i]
  },
  {
    id: 2,
    url: "https://www.youtube.com/embed/r-l_gVPVylM?autoplay=1",
    text: r_text[i]
  },
  ...
];

window.onload = function() {
  function rollVideo(numberRand) {
    let playerDiv = document.getElementById("random_player");
    if (document.querySelector("iframe") !== null) {
      document.querySelector("iframe").remove();
    }
    ...
    ...
  }
...
...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble with submitting the second stage of a multi-step form through Ajax technology

I'm currently tackling a multi-step form project using JavaScript, specifically focusing on submitting the second step of the form via Ajax. I've taken the initiative to create a distinct JavaScript file titled ajaxRequest.js to manage the Ajax r ...

The JavaScript array on its second usage had a length of '0', yet it still contained objects within it

About the Task: This task involves working with two arrays: arrNumber, which is a number array, and arrString, which is a string array. The goal is to create a list of objects using the values from arrNumber, where the object keys are numbers or characte ...

Looking for a Plugin that Can Responsively Display Images in a Vertical Layout - Does One Exist using Jquery

Looking for a gallery slider plugin that is responsive both horizontally and vertically. Have tried Flexslider1/2, Galleria, and others but they do not adjust to vertical resizing. Changing the CSS did not help. If you resize the browser horizontally with ...

Tips for locating the index of a substring within a string with varying line endings using Typescript

I am faced with the task of comparing two strings together. abc\r\ndef c\nde My goal is to determine the index of string 2 within string 1. Using the indexOf() method is not an option due to different line endings, so I require an altern ...

The system encountered an error stating that the class 'Database' could not be found

Whenever I try to establish a connection to my SQL database using my pdo_object.php file, I encounter the following error in my model.php: Fatal error: Class 'Db' not found in /path/model.php on line 8 I have double-checked that all permissions ...

Compiling with Gulp Browserify may have longer processing times after each save or change

I have been working on improving the speed of my Gulp workflow by using Browserify. The approach I am taking is heavily influenced by this informative blog post: Initially, everything seems to be functioning well with changes reflecting quickly (around 50 ...

The functionality of React useState seems to be operational for one state, but not for the other

I am currently working on developing a wordle-style game using react. Within my main component, I have implemented a useEffect that executes once to handle initialization tasks and set up a "keydown" event listener. useEffect(() => { //The getWor ...

Iterating through a 2D array using KnockoutJS foreach loop

I am working on binding a JSON string returned from the server to a foreach loop using KnockoutJS. The JSON structure is as follows: [{"FileID":19, "ParentID":6, "SubType":"Page", "FileName":"nav_secondary_bg.png", "FileExtension":null,"Filetype":"20 ...

The Layout of Bootstrap4 Form is Displaying Incorrectly

I'm attempting to create a basic email form similar to the one shown in the Bootstrap 4 documentation. However, I am facing an issue where the formatting is not displaying correctly. Here is what the example should look like: https://i.sstatic.net/qx ...

Positioning Backgrounds with Padding in DIV Elements

I am trying to figure out how to add a check mark next to text in a button with specific styling. I have managed to get the check mark aligned properly using Background:left center, but I also want to add padding and adjust spacing. Is there a way to achie ...

What is the best way to retrieve child elements from JSON within an Angular JS controller?

I'm having trouble understanding how to ensure the resource call completes before assigning the data.properties to $scope in my controller. My confusion lies here: The resource call returns the following response: [ { "PreAlertInventory": "5.00 ...

Broadcast and listen to events in AngularJS using `$rootScope.$emit`

I am currently working on a large Angular app and I have encountered the need to trigger an event using $rootscope.$emit, and then listen to this event inside a factory. Doing this inside a controller is not feasible because the controller hasn't load ...

What is the best way to align the text in the center without centering the numbers in an HTML ordered list?

I am currently working on a small widget for a webpage that displays steps in reverse order. My plan is to use an ol element and adjust the value attribute on each li tag to make the numbering of the ordered list reversed. Everything seems to be going smoo ...

Unraveling encoded characters in URLs using Node.js

When I try to send a cookie back using res.cookie(JSON.stringify({bar: "baz"}), the value that I get in return is %7B%22bar%22%3A%22baz%22%7D. How can I decode this in a Javascript setting like node.js? ...

Issue with displaying Bootstrap 3 modal on Mozilla browser

Hello everyone, I've encountered an issue with my Bootstrap modal on Mozilla browser. Everything works perfectly on Chrome and Safari, but when I click the modal button in Mozilla, nothing happens. Here's a snippet of my code: <button type="b ...

Ways to display or conceal dual views within a single Marionette js region

In my LayoutView, I have set up two regions: the filter region and the main region (Content Region). The main region displays a view based on the selection made in the filter region. Currently, I have a view for the main region called Current Year view. H ...

Tips for positioning bootstrap dropdowns side by side in a row

I'm having trouble aligning my li items in a Bootstrap dropdown next to each other. I've tried everything but nothing seems to work. Here's my code: <nav class="navbar navbar-expand-lg navbar-light bg-light"> < ...

Arranging expandable divs horizontally

Looking for a way to align these blocks so they can expand while remaining in line, I'm struggling with maintaining their individual spaces. The layout I have in mind is as follows: In this setup, box 2 and 3 should automatically adjust to fill the a ...

Having difficulty importing the WebRTCAdaptor from the antmedia package stored in the node modules directory into an Angular Typescript file

An error is appearing indicating that: There seems to be a problem finding a declaration file for the module '@antmedia/webrtc_adaptor/js/webrtc_adaptor.js'. The file 'D:/web/node_modules/@antmedia/webrtc_adaptor/js/webrtc_adaptor.js' ...

The Google Maps application is experiencing an issue with rendering maps

Here is my code without the google map key. I am not receiving any errors, but the map is not showing up. What could I be missing? To test it out yourself, you will need to add your own map key which you can obtain from here. <!DOCTYPE html> <h ...