[Solved] Hide an element and show another if page is taking too long to load [closed]

It’s not something I’d usually recommend but here’s a pretty hacky solution. const video = document.querySelector(“#video-element-id”); let tooSlow = false; let timeout = setTimeout(() => { tooSlow = true; …logic to change header clearTimeout(timeout); }, 1000); video.addEventListener(‘loadeddata’, () => { console.log(tooSlow ? ‘too slow’ : ‘loaded’); clearTimeout(timeout); }); * EDIT – or you could do … Read more

[Solved] Java Timer : I want to fade in and out for my picture but there are some error [closed]

Screen size you cat get without using JFrame’s instance: screen = Toolkit.getDefaultToolkit().getScreenSize(); Also after creating JFrame, add a component listener to update width, height on any resize: JFrame frame = new JFrame(“fade frame”); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { width = image.getWidth(frame); height = image.getHeight(frame); } }); solved Java Timer : I … Read more

[Solved] linking timers to variables [closed]

Well as you have not shown us any code, let me assume that you at least have a class to encapsulate order. public class Order { public int OrderNumber{get;set;} ///other properties } Now if you add following two properties and a method, your problem is resolved. public class Order { public int OrderNumber{get;set;} //other properties … Read more

[Solved] document.write is killing page

as everybody suggested. document.write will clear everything from the DOM. the best way to write this would be to have a DIV in your HTML and set that div in your javascript code. here’s what your HTML should look like <div id=”page_message” style=”display: none;”></div> <div class=”countdown_out”> <div id=”countdown_title”>NFL Season Opener Countdown</div> <div class=”countdown_position”> <div class=”countdownBox”> … Read more

[Solved] Increment variable by X every second [closed]

Do you want to make it single-threaded? int i = 0; while (i < max) { i++; Thread.Sleep(x); // in milliseconds } or multi-threaded: static int i = 0; // class scope var timer = new Timer { Interval = x }; // in milliseconds timer.Elapsed += (s,e) => { if (++i > max) timer.Stop(); … Read more

[Solved] How to add a timer in a C++ program [closed]

If your platform has conio.h available and your compiler supports C++11 (including <chrono>) you can do it like this: #include <iostream> #include <chrono> #include <conio.h> int main(int argc, char* argv[]){ std::chrono::time_point<std::chrono::system_clock> start; start = std::chrono::system_clock::now(); /* start timer */ while(true){ __int64 secondsElapsed = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now()-start).count(); if(secondsElapsed >= 20){ /* 20 seconds elapsed -> leave main lopp … Read more

[Solved] Lua timer script producing all-numeric value instead of proper time

It looks like you are saving the Unix Timestamp to your file, you can try and make it human readable using an online time converter (https://time.is/Unix_time_converter) Besides this, take some time to read the os.time() implementation details on this lua page: https://www.lua.org/pil/22.1.html The time function, when called without arguments, returns the current date and time, … Read more

[Solved] How to control multiple CoundownTimer in android

I would do something like this: private void startNewTimer(List<CountDownTimer> listOfTimers) { CountDownTimer countDownTimer = new CountDownTimer(1000,1000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { } }.start(); listOfTimers.add(countDownTimer); } private boolean cancelTimers(List<CountDownTimer> listOfTimers) { if(listOfTimers != null && !listOfTimers.isEmpty()) { for(CountDownTimer cdt : listOfTimers) { cdt.cancel(); } listOfTimers = null; return … Read more

[Solved] How to connect a seconds timer to a minutes timer in Swift? [closed]

I would not use separate timers. Have a seconds timer that fires once a second. It sounds like you want a count-down timer. So… Record the time when the timer starts using code like this: let secondsToEnd = 60*5 let startInterval = NSDate.timeIntervalSinceReferenceDate() let endInterval = startInterval + Double(secondsToEnd) Then in your timer code: let … Read more