Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 09-26-2013, 12:05 PM   #1
jordan_rap13
Registered User
 
Join Date: Sep 2013
Location: Kalamata, Greece
Posts: 53
look at this example:

var dayarray=new Array("Sunday","Monday","Thusday","Wednesday","Thu rsday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")

function getthedate(){
var currentTime = new Date();

var day=currentTime.getDay();
var day_month = currentTime.getDate();
if (day_month<10){
day_month="0"+day_month;
}
var month = currentTime.getMonth();
var year = currentTime.getFullYear();

var hours=currentTime.getHours();
var minutes=currentTime.getMinutes();
var seconds=currentTime.getSeconds();

var last="am";
if (hours>=12){last="pm";}
if (hours>12){hours=hours-12;}
if (hours==0){hours=12;}

if (minutes<=9){minutes="0"+minutes;}
if (seconds<=9){seconds="0"+seconds;}

var ddate=dayarray[day]+"&nbsp;"+day_month+"&nbsp;"+montharray[month]+"&nbsp;"+year+",&nbsp;"+hours+":"+minutes+":"+sec onds+"&nbsp;"+last;

$(".date_time").html(ddate);

setTimeout("getthedate()",1000);
}

So the final line, will run the getthedate function every 1000ms (1 sec)
jordan_rap13 is offline   Reply With Quote

Old 03-11-2014, 12:33 AM   #2
alligatortek001
Registered User
 
Join Date: Nov 2013
Posts: 92
For example:

var heartbeat = function (data) {
if (!heartbeatInterval) {
// no heartbeat
return;
}

var obj = Package.encode(Package.TYPE_HEARTBEAT);
if (heartbeatTimeoutId) {
clearTimeout(heartbeatTimeoutId);
heartbeatTimeoutId = null;
}

if (heartbeatId) {
// already in a heartbeat interval
return;
}

heartbeatId = setTimeout(function () {
heartbeatId = null;
send(obj);

nextHeartbeatTimeout = Date.now() + heartbeatTimeout;
heartbeatTimeoutId = setTimeout(heartbeatTimeoutCb, heartbeatTimeout);
}, heartbeatInterval);
};

var heartbeatTimeoutCb = function () {
var gap = nextHeartbeatTimeout - Date.now();
if (gap > gapThreshold) {
heartbeatTimeoutId = setTimeout(heartbeatTimeoutCb, gap);
} else {
console.error('server heartbeat timeout');
pomelo.emit('heartbeat timeout');
pomelo.disconnect();
}
};
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
alligatortek001 is offline   Reply With Quote
Old 04-09-2014, 11:00 PM   #3
simar
Registered User
 
Join Date: Mar 2014
Posts: 71
set Timeout

Thanks for coding of javascript set timeout
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
simar is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Implement Interfaces in JavaScript JavaScriptBank Javascript 1 03-30-2014 11:48 PM
Javascript Countdown Timer redirecting Affiliate Links JavaScriptBank Javascript 0 05-20-2013 10:29 PM
40 Super Nice JavaScript Extensions and Plugins JavaScriptBank Javascript 0 04-28-2013 11:14 PM
9 Funniest JavaScript effects JavaScriptBank Javascript 0 04-18-2013 02:13 AM
65 Free JavaScript Photo Gallery Solutions JavaScriptBank Javascript 0 04-15-2013 06:38 PM


All times are GMT -7. The time now is 07:38 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.