Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
75 views
in Technique[技术] by (71.8m points)

javascript - Program made to join you into ZOOM classes automatically doesn't work for first class?

I have a program made to automatically join you into your ZOOM classes that works by checking the time, and if the time is equal to one of the join times inputted by the user (stored in localStorage) than it will use window.open to open the launch meeting page, and therefore join you into the ZOOM meeting using the inputted link (also in localStorage) Our school has A days and B days, half of your classes are on an A day, half on a B day except for advisory, The problem is, whether it is an A day or a B day, the program doesn't join you into your first class. My code is here.

var tst = localStorage.getItem("a1");
if (tst == null) {
  alert(
    "Hello, it appears that there was a problem retreiving your stored data, meaning either that you have cleared your browsing data or started using a new device or browser to access our service, or this is your first time. Either way, please enter your ZOOM links into their respective boxes below."
  );
}

function timeNow() {
  var d = new Date(),
    h = (d.getHours() < 10 ? "0" : "") + d.getHours(),
    m = (d.getMinutes() < 10 ? "0" : "") + d.getMinutes();

  return h + ":" + m;
}
function Aday() {
  tst = localStorage.getItem("a1");
  if (tst == null) {
    alert(
      "Hello, it appears that there was a problem retreiving your stored data, meaning either that you have cleared your browsing data or started using a new device or browser to access our service, or this is your first time. Either way, please enter your ZOOM links into their respective boxes below."
    );
  } else {
    if (counter === true) {
      alert("You will be joined into your A day classes");
      counter = false;
    }
  }

  if (timeNow() === localStorage.getItem("a1t")) {
    window.open(localStorage.getItem("a1"));
    setTimeout(Aday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("a2t")) {
    window.open(localStorage.getItem("a2"));
    setTimeout(Aday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("adt")) {
    window.open(localStorage.getItem("ad"));
    setTimeout(Aday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("a3t")) {
    window.open(localStorage.getItem("a3"));
    setTimeout(Aday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("a4t")) {
    window.open(localStorage.getItem("a4"));
    setTimeout(Aday, 60000);
    return;
  }
  setTimeout(Aday, 500);
}
var counter = true;

function Bday() {
  tst = localStorage.getItem("a1");
  if (tst == null) {
    alert(
      "Hello, it appears that there was a problem retreiving your stored data, meaning either that you have cleared your browsing data or started using a new device or browser to access our service, or this is your first time. Either way, please enter your ZOOM links into their respective boxes below."
    );
  } else {
    if (counter === true) {
      alert("You will be joined into your B day classes");
      counter = false;
    }
  }
  if (timeNow() === localStorage.getItem('b1t')) {
    window.open(localStorage.getItem("b1"));
    setTimeout(Bday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("b2t")) {
    window.open(localStorage.getItem("b2"));
    setTimeout(Bday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("adt")) {
    window.open(localStorage.getItem("ad"));
    setTimeout(Bday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("b3t")) {
    window.open(localStorage.getItem("b3"));
    setTimeout(Bday, 60000);
    return;
  }
  if (timeNow() === localStorage.getItem("b4t")) {
    window.open(localStorage.getItem("b4"));
    setTimeout(Bday, 60000);
    return;
  }
  setTimeout(Bday, 500);
}
function submitLinks() {
  var a1 = document.getElementById("a1").value;
  var a2 = document.getElementById("a2").value;
  var ad = document.getElementById("ad").value;
  var a3 = document.getElementById("a3").value;
  var a4 = document.getElementById("a4").value;
  var b1 = document.getElementById("b1").value;
  var b2 = document.getElementById("b2").value;
  var b3 = document.getElementById("b3").value;
  var b4 = document.getElementById("b4").value;
  localStorage.setItem("a1", a1);
  localStorage.setItem("a2", a2);
  localStorage.setItem("ad", ad);
  localStorage.setItem("a3", a3);
  localStorage.setItem("a4", a4);
  localStorage.setItem("b1", b1);
  localStorage.setItem("b2", b2);
  localStorage.setItem("b3", b3);
  localStorage.setItem("b4", b4);
  var a1t = document.getElementById("a1t").value;
  var a2t = document.getElementById("a2t").value;
  var adt = document.getElementById("adt").value;
  var a3t = document.getElementById("a3t").value;
  var a4t = document.getElementById("a4t").value;
  var b1t = document.getElementById("b1t").value;
  var b2t = document.getElementById("b2t").value;
  var b3t = document.getElementById("b3t").value;
  var b4t = document.getElementById("b4t").value;
  localStorage.setItem("a1t", a1t);
  localStorage.setItem("a2t", a2t);
  localStorage.setItem("adt", adt);
  localStorage.setItem("a3t", a3t);
  localStorage.setItem("a4t", a4t);
  localStorage.setItem("b1t", b1t);
  localStorage.setItem("b2t", b2t);
  localStorage.setItem("b3t", b3t);
  localStorage.setItem("b4t", b4t);
  alert("successfully stored ZOOM links in browsing data");
}
function saveCheck() {
  if (
    localStorage.getItem("a1") == null ||
    localStorage.getItem("a1t") == null
  ) {
    alert(
      "could not retreive stored data. Please fill out the fields again and submit your data."
    );
  } else {
    if (window.confirm("You have stored data, would you like to view it?")) {
      var pFill =
        "A day class 1 link: " +
        localStorage.getItem("a1") +
        " A day class 1 join time: " +
        localStorage.getItem("a1t") +
        " A day second class link: " +
        localStorage.getItem("a2") +
        " a day second class join time: " +
        localStorage.getItem("a2t") +
        " Advisory link: " +
        localStorage.getItem("ad") +
        " advisory join time: " +
        localStorage.getItem("adt") +
        " a day first after-lunch class link: " +
        localStorage.getItem("a3") +
        "  a day first after-lunch class join time: " +
        localStorage.getItem("a3t") +
        "A day last class link: " +
        localStorage.getItem("a4") +
        " a day last class join time: " +
        localStorage.getItem("a4t") +
        " b day first class link: " +
        localStorage.getItem("b1") +
        " b day first class join time: " +
        localStorage.getItem("b1t") +
        " b day second class link " +
        localStorage.getItem("b2") +
        " b day second class join time:  " +
        localStorage.getItem("b2t") +
        " b day first after-lunch class link: " +
        localStorage.getItem("b3") +
        " b day first after lunch class join time: " +
        localStorage.getItem("b3t") +
        " B day last class link: " +
        localStorage.getItem("b4") +
        " b day last class join time: " +
        localStorage.getItem("b4t");
      alert(pFill);
    }
  }
}
<!DOCTYPE html>
<style>
  @keyframes e {
    0% {
      background-color: aqua;
      border-radius: 10px;
      border-width: 5px;
      color: black;
    }
    50% {
      border-radius: 60px;
      background-color: crimson;
      border-width: 15px;
      color: white;
    }
    100% {
      background-color: aqua;
      border-radius: 10px;
      border-width: 5px;
      color: black;
    }
  }
  @keyframes btn {
    0% {
      color: black;
      background-color: aqua;
    }
    50% {
      color: white;
      background-color: crimson;
    }
    100% {
      background-color: aqua;
      color: black;
    }
  }
  h1 {
    font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
      sans-serif;
    background-color: aqua;
    border-width: 5px;
    border-color: black;
    border-style: solid;
    border-radius: 13px;
    padding: 10px;
    text-align: center;
    font-size: 65px;
    animation-name: e;
    animation-duration: 10s;
    animation-iteration-count: infinite;
  }
  a {
    background-color: crimson;
    color: white;
    border-style: solid;
    padding: 10px;
    border-width: 5px;
    border-color: black;
    border-radius: 17px;
    animation-name: btn;
    animation-duration: 5s;
    animation-iteration-count: infinite;
  }
  button {
    border-radius: 10px;
    border-width: 5px;
    border-color: black;
    border-style: solid;
    font-family: Arial, Helvetica, sans-serif;
    animation-name: btn;
    animation-duration: 5s;
    animation-iteration-count: infinite;
  }
  p {
    font-family: sans-serif;
    background-color: yellow;
    border-style: solid;
    border-width: 5px;
    border-color: black;
    border-radius: 20px;
    padding: 10px;
  }
  .IE {
    text-align: left;
    width: 17%;
  }
</style>
<h1>AutoZOOM</h1>
<button onclick="saveCheck()">CHECK LOCALSTORAGE FOR ZOOM LINKS</button>
<a
  href="https://docs.google.com/forms/d/e/1FAIpQLSeLzUxenxt_qEAVQflWTeub4IAKOnd1DL9pLQ3OFDr3TcBgFQ/viewform?usp=sf_link"
  >SUGGESTIONS, REVIEWS, AND BUG REPORTS</a
>
<h5>HOW TO USE</h5>
<p>
  This program works by constantly checking if you have a class, then if so,
  opening the launch meeting page for the correct class. You do not need to
  enter your ZOOM links every time, but you do need to keep this tab open.
  <br />
  <br />
  Please select whether today is an A day or a B day.
</p>
<script src="script.js"></script>
<button onclick="Aday()">A day</button>
<button onclick="Bday()">B day</button>
<p>
  If this is your first time using this service or you have recently cleared
  your browsing data, copy and paste the ZOOM links for your classes into their
  respective input boxes.
</p>
<div>
  <div>
    <p class="IE">A day, first class</p>
    <input type="text" id="a1" />
  </div>
  <div>
    <p class="IE">A day, second class</p>
    <input type="text" id="a2" />
  </div>
  <div>
    <p class="IE">Advisory</p>
    <input type="text" id="ad" />
  </div>
  <div>
    <p class="IE">A day, first after-lunch class</p>
    <input type="text" id="a3" />
  </div>
  <div>
    <p class="IE">A day, last class</p>
    <input type="text" id="a4" />
  </div>
  <div>
    <p class="IE">B day, first class</p>
    <input type="text" id="b1" />
  </div>
  <div>
    <p class="IE">B day, second class</p>
    <input type="text" id="b2" />
  </div>
  <div>
    <p class="IE">B day, first after-lunch class</p>
    <input type="text" id="b3" />
  </div>
  <div>
    <p class="IE">B day, last class</p>
    <input type="text" id="b4" />
  </div>
  <h2>
    WHEN INPUTTING THE TIME, MAKE SURE TO: <br />-USE 24 HOUR TIME, 13:00, not
    1:00 <br />
    INPUT THE TIME IN THIS EXACT FORMAT:
    <strong>MAKE SURE THERE ARE NO SPACES:</strong> HH/MM
  </h2>
  <div>
    <p class="IE">A day, first class join time</p>
    <input type="

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...