popup.js
/**
 * Actives the Timer for refreshing the Page to the defined time
 */
Actives the Timer for refreshing the Page to the defined time
Actives the Timer for refreshing the Page to the defined time
function activeTimerForRefreshing() {
    isRefreshed = false;
    let txtStartTime = document.getElementById("start_time");
    if (!txtStartTime.value) {
        showMessage("Please define an URL Opening Time");
        return;
    }
    let startDate = new Date();
    try {
        let startTime = txtStartTime.value.split(':');
        startDate.setHours(+startTime[0]); 
        startDate.setMinutes(startTime[1]);
        startDate.setSeconds(startTime[2]);
        startDate.setMilliseconds(0);
    } catch (err) {
        showMessage(err);
        return;
    }
    let txtOffset = document.getElementById("offset");
    if (!txtOffset.value) {
        showMessage("Please define an Offset in Milliseconds");
        return;
    } else if (txtOffset.value < 0) {
        showMessage("Please define a positive Offset in Milliseconds");
        return;
    }
    let startDateWithOffset = new Date(startDate.getTime() - txtOffset.value);
    let refreshHour = startDateWithOffset.getHours();
    let refreshMinute = startDateWithOffset.getMinutes();
    let refreshSeconds = startDateWithOffset.getSeconds();
    let refreshMilliseconds = startDateWithOffset.getMilliseconds();
    let txtTimeRefresh = document.getElementById("time_refresh");
    txtTimeRefresh.textContent = checkTime(refreshHour) + ":" + checkTime(refreshMinute) + ":" + checkTime(refreshSeconds) + ":" + checkTime(refreshMilliseconds)
    startRefreshWatcher(startDateWithOffset);
}
function activeTimerForRefreshing ( ) { isRefreshed = false ; let txtStartTime = document . getElementById ( "start_time" ) ; if ( ! txtStartTime . value ) { showMessage ( "Please define an URL Opening Time" ) ; return ; } let startDate = new Date ( ) ; try { let startTime = txtStartTime . value . split ( ':' ) ; startDate . setHours ( + startTime [ 0 ] ) ; startDate . setMinutes ( startTime [ 1 ] ) ; startDate . setSeconds ( startTime [ 2 ] ) ; startDate . setMilliseconds ( 0 ) ; } catch ( err ) { showMessage ( err ) ; return ; } let txtOffset = document . getElementById ( "offset" ) ; if ( ! txtOffset . value ) { showMessage ( "Please define an Offset in Milliseconds" ) ; return ; } else if ( txtOffset . value < 0 ) { showMessage ( "Please define a positive Offset in Milliseconds" ) ; return ; } let startDateWithOffset = new Date ( startDate . getTime ( ) - txtOffset . value ) ; let refreshHour = startDateWithOffset . getHours ( ) ; let refreshMinute = startDateWithOffset . getMinutes ( ) ; let refreshSeconds = startDateWithOffset . getSeconds ( ) ; let refreshMilliseconds = startDateWithOffset . getMilliseconds ( ) ; let txtTimeRefresh = document . getElementById ( "time_refresh" ) ; txtTimeRefresh . textContent = checkTime ( refreshHour ) + ":" + checkTime ( refreshMinute ) + ":" + checkTime ( refreshSeconds ) + ":" + checkTime ( refreshMilliseconds ) startRefreshWatcher ( startDateWithOffset ) ; }
Actives the Timer for refreshing the Page to the defined time
Actives the Timer for refreshing the Page to the defined time
// Get the defined refresh time // set Time accordingly, using implicit type coercion // Subtract Offset from current Date