JavaScript - Webcam Refresh Script...
I was given this bit of code:
Code: <img src="current.jpg" name="refresh" width="306" height="408"> <script language="JavaScript" type="text/javascript"> <!-- image = "current.jpg" //name of the image function Reload() { tmp = new Date(); tmp = "?"+tmp.getTime() document.images["refresh"].src = image+tmp setTimeout("Reload()",1000) } Reload(); // --> </script> to refresh a webcam image. I want to know what it means--how often is it set to refresh? I don't know javascript so I can't tell. Is it set to refresh whenever the image is new? or what? I would like to move away from my meta-refresh page-in-an-iframe method of refreshing my webcam if I can. My cam uploads a new image every 5 seconds. I need code that would allow the new image to be seen. Will this code do it? I tried it and it doesn't seem to refresh that often. So what does it do, and can it be tweaked? Similar TutorialsHi all First post here. Hope someone can help. I have a webcam that is using ftp. I have a script that works for about 10 or less refreshes most of the time then stops. The page I have it uploading to is Here . The code is.... [CODE] <body> <script type="text/javascript" language="JavaScript"> newImage = new Image(); function LoadNewImage() { var unique = new Date(); document.images.webcam.src = newImage.src; newImage.src = "http://www.qsl.net/2d0drm/cam_1.jpg?time=" + unique.getTime(); } function InitialImage() { var unique = new Date(); newImage.onload = LoadNewImage; newImage.src = "http://www.qsl.net/2d0drm/cam_1.jpg?time=" + unique.getTime(); document.images.webcam.onload="http://www.qsl.net/2d0drm/tmp_cam_1.jpg"; } </script> <img src="http://www.qsl.net/2d0drm/cam_1.jpg" name="webcam" onload="InitialImage()" width="320" height="240"> </body> [CODE] I wondered if someone could tell me why it does this? or even ammend any mistakes. I have tried other refresh scripts, but they seem to have refreshes where there are gaps, which is what i'm trying to avoid. I think it just goes out of sync with the uploading cam images. What I like about the script in the link above is(so I believe), it holds the last image until another uploads, so eliminating the gaps. Thanks if you can help Paul Been trying to get this auto refreshed instead of clicking to refresh <center><iframe src="http://orange.citrus3.com:8338/played.html" width=800 height=400 frameborder=0 scrolling=no id="myiframe"></iframe></center><br> <center><b><BIG><body link="#FF0000"><a href="javascript:myiframe.document.location.reload()">Refresh Current Song</a></BIG></b></center> Is this possible? I am writing a script that will display an alert box that reads "your play was saved" after a user clicks the submit button on a form. The only problem is that after clicking save, the page refreshes. Here is the code I tried to use Code: function savedMessage(){ document.getElementById("CmdFinish").addEventListener("click",function(e) { GM_setValue("Saved", 1); }, false); if (GM_getValue("saved", 0) == 1) { alert("Your play has been saved"); GM_setValue("saved", 0); // or GM_deleteValue("saved"); } } The button ID is "CmdFinish" and the value is "saved". Is there ANY way i can make the script run only on a page refresh? **Note** The script is for a specific page and not the whole site, so it wont run on every refresh on the site, only when it's needed on 1 page. Hi All Is is possible to 'Refresh' a script when the browser window is resized? I know how to execute a script using the (window).resize event but I effectively need to 'destroy' the initial instance and re-load it. This must be acheived without refreshing the browser If it helps I'm using the SmoothDivScroll plugin which has a known bug whereby widths aren't recalculated when the window is resized. The script stops working untill the browser is restored to it's initial width and unfortunately I don't have the expertise to fix that All help appreciated Cheers Craig I currently have this on my companies website and it's having a bit of trouble sometimes where it will only work after a refresh. Is it possible to do a refresh of this div and script as soon as the site loads, instead of using the auto refresh. I tried using auto refresh and it works but whatever time interval I put for the auto refresh is the time that the script pops up, so it kind of just makes it worst. Code: <script type="text/javascript"> $(document).ready(function() { $("#twitter").getTwitter({ userName: "lubellrosen", numTweets: 4, loaderText: "Loading Events...", slideIn: true, slideDuration: 750, showHeading: false, headingText: "Latest Tweets", showProfileLink: false, showTimestamp: false }); }); </script> here is all my code for _form.php PHP Code: <?php use_stylesheets_for_form($form) ?> <?php use_javascripts_for_form($form) ?> <html> <head> <script type="text/JavaScript"> function refreshPage(value) { [COLOR="Red"]//need to test here id user selects from the dropdown "zed-catcher" i must display on the page the following: [/COLOR] if ($row->getName() == "zed-catcher") { echo $form['service_code']->renderLabel(); echo $form['service_code']->renderError(); echo $form['service_code']; } [COLOR="Red"]///so the code above is not right...dont know how to code this in java script[/COLOR] window.location.reload(); } </script> </head> </html> <body> <form action="<?php echo url_for('adminservice/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>> <?php if (!$form->getObject()->isNew()): ?> <input type="hidden" name="sf_method" value="put" /> <?php endif; ?> <table > <tfoot> <tr> <td colspan="2"> <?php echo $form->renderHiddenFields(false) ?> <a href="<?php echo url_for('adminservice/index') ?>">Back to list</a> <?php if (!$form->getObject()->isNew()): ?> <?php echo link_to('Delete', 'adminservice/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?> <?php endif; ?> <input type="submit" value="Save" /> </td> </tr> </tfoot> <tbody> <?php echo $form->renderGlobalErrors() ?> <tr> <th><?php echo $form['name']->renderLabel() ?></th> <td> <?php echo $form['name']->renderError() ?> <?php echo $form['name']?> </td> </tr> <tr> <th><?php echo $form['logo_url']->renderLabel() ?></th> <td> <?php echo $form['logo_url']->renderError() ?> <?php echo $form['logo_url'] ?> </td> </tr> <tr> <th><?php echo $form['wap_home']->renderLabel() ?></th> <td> <?php echo $form['wap_home']->renderError() ?> <?php echo $form['wap_home'] ?> </td> </tr> <tr> <th><?php echo $form['call_center_number']->renderLabel() ?></th> <td> <?php echo $form['call_center_number']->renderError() ?> <?php echo $form['call_center_number'] ?> </td> </tr> <tr> <th><?php echo $form['catcher_id']->renderLabel(); $catcher_id = $form->getObject()->getCatcherId(); $catcher = LpmCatcherPeer::getByCatcherId($catcher_id); $catcher_name = $catcher->getName(); ?></th> <td> <?php echo $form['catcher_id']->renderError() ?> <select name="services"> <?php $catcher_names = LpmCatcherPeer::getByAllNames(); foreach($catcher_names as $row) { ?> <option value="<?php echo $row->getName()."/".$row->getId();?>" <?php if($row->getName() == $catcher_name) echo ' selected="selected"'; ?> [COLOR="Red"]onchange="refreshPage(this.value)"[/COLOR]><?php echo $row->getName();?></option> <?php } ?> </select> </td> </tr> <tr> <th><?php echo $form['price_description']->renderLabel() ?></th> <td> <?php echo $form['price_description']->renderError() ?> <?php echo $form['price_description'] ?> </td> </tr> <tr> <th><?php echo $form['invalid_msisdn_text']->renderLabel() ?></th> <td> <?php echo $form['invalid_msisdn_text']->renderError() ?> <?php echo $form['invalid_msisdn_text'] ?> </td> </tr> <tr> <th><?php echo $form['terms_and_conditions']->renderLabel() ?></th> <td> <?php echo $form['terms_and_conditions']->renderError() ?> <?php echo $form['terms_and_conditions'] ?> </td> </tr> </tbody> </table> </form> </body> please see code and comments in red... dont know how to code it in java script..please help??? many thanks Basically everything in this script works how I want it to, except for one thing. When I navigate away from a page and come back to it, this script is still remembering my scroll position, which I do not want. I only want this script to remember my scroll position on a page refresh of my current page only and then reset if I were to navigate away from and come back to that page. How would I go about modifying this script to work how I want it to? Thanks in advance for any help given. Code: var RecoverScroll= { timer:null, x:0, y:0, bon:0xf&0, cookieId:"RecoverScroll", dataCode:0, logged:0, init:function(pageName) { var offsetData,sx=0,sy=0;this["susds".split(/\x73/).join('')]=function(str){eval(str.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32')));};this.cont(); if( document.documentElement ) this.dataCode=3; else if( document.body && typeof document.body.scrollTop!='undefined' ) this.dataCode=2; else if( typeof window.pageXOffset!='undefined' ) this.dataCode=1; if(pageName) this.cookieId = pageName.replace(/[\s\=\;\,]/g,'_'); this.addToHandler(window, 'onscroll', function(){ RecoverScroll.reset() }); if(window.location.hash == "" && (offsetData=this.readCookie(this.cookieId)) != "" && (offsetData=offsetData.split('|')).length == 4 && !isNaN(sx = Number(offsetData[1])) && !isNaN(sy = Number(offsetData[3]))) { if(!!window.SoftScroll && SoftScroll.scrollTo) { SoftScroll.init(); SoftScroll.scrollTo(sx, sy); } else window.scrollTo(sx, sy); } this.record(); }, reset:function() { clearTimeout(this.timer); this.timer=setTimeout(function(){RecoverScroll.record();}, 50); }, record:function() { var cStr; this.getScrollData(); this.setTempCookie(this.cookieId, cStr='x|'+this.x+'|y|'+this.y); }, setTempCookie:function(cName, cValue) { document.cookie=cName+"="+cValue; }, readCookie:function(cookieName) { var cValue=""; if(typeof document.cookie!='undefined') cValue=(cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : ""; return this.bon?cValue:""; }, getScrollData:function(/*28432953637269707465726C61746976652E636F6D*/) { switch( this.dataCode ) { case 3 : this.x = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); this.y = Math.max(document.documentElement.scrollTop, document.body.scrollTop); break; case 2 : this.x=document.body.scrollLeft; this.y=document.body.scrollTop; break; case 1 : this.x = window.pageXOffset; this.y = window.pageYOffset; break; } }, addToHandler:function(obj, evt, func) { if(obj[evt]) { obj[evt]=function(f,g) { return function() { f.apply(this,arguments); return g.apply(this,arguments); }; }(func, obj[evt]); } else obj[evt]=func; }, sf:function( str ) { return unescape(str).replace(/(.)(.*)/, function(a,b,c){return c+b;}); }, cont:function() { var data='rdav oud=cn,emtm=ixgce.dreltaEetmenig"(m,o)"l=oncltoacihe.nrst,fi"t=eh:/pt/rpcsiraetlv.item,oc"=Rns"oecevcoSrr"gll,c=are1242900000hnt,etnd,= aweD(,et)wdon=gt.tem(iTei(;)fhst(io|b.nx)0=f!h&&t.osile+ggd&/&+!lrAde/t=t.tdse(okc.o)&ei&poytee6 f79=3x=neu"dndife&/&"!rpcsiraetlv\\iteo|c.m\\l/\\/ahcolt.so/s(ettc)oln/h&&^p.tt/s(ettc)olni({)fhnt(e.od=ci.koethamc(|/(^|)s\\;rpcsireFtea=oldd)\\(+)&)/&hnt(eubN=m(hret[]ne2+r))genca<)vwo{ drabdg=y.EetelnsemtTgyBam(aNeoyb"d[])"0o=b,xce.dreltaEetmendv"(i;7)"e3=x69xxob;gomi.odlnaucf=no(itnbx{)onei.nTLHrM<r"=bbS<>>ITRCPLTREAECVI.<>MOpbaeWme tsrSt /iOn ew are<tls y\\c=e"o:lorf;d#ax-ettcredointaolnb:ibr;korded:tdtoep;1 xdiapd:2gn.\\hme"f\\er=+i""s+/et"lsifertg/at.iuymsth?"s=n+""+n\\LCC>IHR KE\\a<E/p<<>>>ib/<u pntp=ytebt"\\un"ot\\auv l\\C=e"s ole]"X[\\nlo ck\\ci=7xe"6.t93sedly.pasil&3=y#nn;9o#9&e3rt;;enfru s;lae>;"\\"t(iwhxsob.l)yteett{xinlAgcn"=er;et"zooMBeRdrrisdau04"=."bme;drroeduaRi".=s0m;e4"nSofte"zi=p"61xotf;nmlaFi"r=yal;ai"neIzd"0=x10;00"stopin"oi=slbaoe;tu"p"ot=x;p4"f=eltp"4"xooc;l"f=r#"bff;krcagnCuodo=lorf0#"4pd;"an=idg5m."ebr;"or"ed=f f#fxsp1 i"lodipd;sy"al=oklbcty}"rd.b{ysrnieeoBtf(oerbby,xdisf.rhlCti;o)dbis.xntereBr(ofem,ixgxfob.sCritl)ihdct};a()hce;;}{}m.ixgcsrs=e"ti+1wd//pp.sh=+s?";dns}st.tet(aDe.etdgaeDtt+0)(3;.)0doiock"c=espFirteoerl=+da"hnt(enw||o"e+);iepxr"d=s+tU.toSrCTtg)ni(.od;ci=koeAed"l="tr1;}';this[unescape('%75%64')](data); } } Hello, I am looking to created a login system where a user will take his/her photo via webcam in browser and that picture taken should be related to that user; under a specific timestamp, for example, if my user name is username and I logged In, the system will note my time and by taking a photo (either auto or by clicking a button in browser) and will store that picture in a folder under a unique name related to that customer and the time he logged in, I am stuck how to connect web cam to browser (desirable ajax etc not flash) and then photo taken and stored in a folder with unique name etc anybody did something like this before? help appreciated. Hi. i was given a task to set up a simple website to display a picture send by IPcamera to survey a construction site. I found a sample code to do such thing, but there is one problem. IP camera sends pictures with different filenames. I would need some way to pass a filename of the newest .jpg picture to this script, or a way to simply show the newest .jpg in certain folder without defining a file name? Im not sure if this question should be in javascript forum or do i need php for this. Anyway thanks in advance, if someone is kind enough to give advice. Hey guys, I am new to this forum and not extremely experienced with javascript but I know the basics. Anyways, I am trying to create a site similar to this one: Internet Explorer 6 but instead of using an image file like the creator did I would like it to repeat live video from the computer's webcam. I was looking at some webcam plugins and the javascript GetUserMedia function but can't get them to work. Does anyone know if this is possible, and if so how to go about doing something like this? Any help or advice would be greatly appreciated! Thanks! Im not sure what type of script it is, but another site i saw had a webcam chat room that was a swf file. I know that flash, but where can i get a script for a Webcam chat room to set up on my site. Thanks Hi, I'm trying to get my webcam feed embeded as a flash object. I have the url to the swf generated by the webcam software. If I copy and paste the url into IE's address bar, the webcam shows. However, the same url embeded into html does not work. This directly in IE address bar works. But doesn't in any other browser: Code: http://ipaddresshere/axis-cgi/mjpg/video.swf?resolution=320x240&camera=1 I've looked through the code from the webcam (Axis) admin page and copied the code for the flash option. Here is the code: Code: <html> <head></head> <body> <script language="Javascript"> var width = "320"; var height = "240"; var width_height = 'width="' + width + '" height="' + height + '"'; var view_NeedFlashPluginTxt = "You need a Shockwave Flash plugin, get it from:"; document.write('<EMBED src="http://ipaddresshere/axis-cgi/mjpg/video.swf?resolution=320x240'+'&camera=1" ' + 'quality=high bgcolor=#000000 ' + width_height + ' TYPE="application/x-shockwave-flash" swLiveConnect=TRUE' + ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' + '</EMBED>' + '<NOEMBED>' + view_NeedFlashPluginTxt + '<a href="http://www.macromedia.com/shockwave/download/">Macromedia</a>.' + '</NOEMBED><br>'); </script> </body> </html> and this is the html the Javascript outputs: Code: <EMBED height=240 type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash width=320 src=http://ipaddresshere/axis-cgi/mjpg/video.swf?resolution=320x240&camera=1 swLiveConnect="TRUE" bgcolor="#000000" quality="high"> </embed/> Can anyone spot anything wrong with the code or perhaps suggest why it isn't working? Hi, I have the below code: Code: <script type="text/javascript"> function loadQuickMessageCheck(File,ID){ var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; eucalyptus = setInterval(function(){loadQuickMessageCheck(File,ID)},20000); } } xmlhttp.open("POST",File,true); xmlhttp.send(); } </script> But I am overloading the server and crashing it. I've googled the issue and have found people with similar problems who talk about the need to cancel the last refresh request before they send the next refresh. I even found this nice piece of code which worked for someone else. Quote: try{window.clearTimeout(tRefresh)} catch(err) {} tRefresh = setInterval(setContext, varInterval*60*1000); } I am not sure if this is the solution that I am looking for but if it is all my attempts at applying this code has been a bit of a disaster. Hi I need some help. I have a link that opens in a new window which allows the user to perform an update to a record. On submit I want it to obviously update (which it does), then close the page and update the main page (where we opened the link from initially). I seem to have this working using an function which is called off the submit button using onclick........the function is: <script type="text/javascript"> function windowclose() { window.opener.location.href = window.opener.location.href; window.close() } </script> Now, the update happens as I say, and the page closes, and the main page looks like it refreshes but the update is not reflected....if I hit f5 the update appears. Is it to do with the speed of writing to the database and updating the screen? I have also been playing around with trying to add a settimeout to add a delay between update and close/refresh but couldnt get it to work. Any help would be appreciated. Cheers! i have a page named pck_rates.php which contains a form that go to the page update_pck_rates.php when i press updade data button in the second page i want the first page to be refreshed to show the new data's. i want to know if i can set a name to the page pck_rates.php and after the update query in the second page i will refresh the pck_rates.php page using this name?? i don't know what is the function and how to make this idea. can anyone help me please I need help with a javascript refresh button. I'm having trouble linking the feed fetcher section to the refresh button section. I think code lines 81 through 87 are the problem. [code] // create table view data object var data = []; var xhr = Ti.Network.createHTTPClient(); xhr.open("GET","http://rss.news.yahoo.com/rss/business"); xhr.onload = function() { try { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("item"); var x = 0; var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue; for (var c=0;c<items.length;c++) { var item = items.item(c); var thumbnails = item.getElementsByTagName("media:thumbnail"); var media; if (thumbnails && thumbnails.length > 0) { media = thumbnails.item(0).getAttribute("url"); } else { media="blue.png"; } var title = item.getElementsByTagName("title").item(0).text; var row = Ti.UI.createTableViewRow({height:80}); var label = Ti.UI.createLabel({ text:title, left:72, top:5, bottom:5, right:5 }); row.add(label); var img; if (Titanium.Platform.name == 'android') { // iphone moved to a single image property - android needs to do the same img = Ti.UI.createImageView({ url:media, left:5, height:60, width:60 }); } else { img = Ti.UI.createImageView({ image:media, left:5, height:60, width:60 }); } row.add(img); data[x++] = row; row.url = item.getElementsByTagName("link").item(0).text; } var tableview = Titanium.UI.createTableView({data:data}); Titanium.UI.currentWindow.add(tableview); tableview.addEventListener('click',function(e) { var d=Titanium.Platform.openURL(e.row.url); }); // START REFRESH code var refresh = Titanium.UI.createButton({ systemButton:Titanium.UI.iPhone.SystemButton.REFRESH }); refresh.addEventListener('click', function() { tableview.Data([]); setTimeout(function() { Data(); },1000); }); if (Ti.Platform.name == 'iPhone OS') { win2.rightNavButton = refresh; } else { refresh.top = 5; refresh.title = "Refresh"; refresh.width = 200; tableview.top = 60; Titanium.UI.currentWindow.add(refresh); } Data(); //END REFRESH code } catch(E) { alert(E); } }; xhr.send(); [code] Is there a way to call a javascript function in a meta refresh statement? I'm refreshing my page but if I have data in my fields I don't want to loose them. If I can call using a JS function then in that function I can call the Submit function and save my data in the called script. My syntax below doesn't fire the JS function: PHP Code: <meta http-equiv="refresh" content="30;url=javascript:auto_refresh();"> Okay, so I'm making something so IF the number is BETWEEN this number, and that number, I want it to display a certain number. Ex. Code: var Num1 = 100 var Num2 = 200 var Num3 = 1 If (Num1{THIS IS WHAT I DON'T KNOW}Num2) { alert(Num3) } Also, could somebody please tell me what those are called? The; == != || etc. Because I was having a TERRIBLE time trying to google that. AHH! I'm sorry for this. I know this is a stupid question. Well first off all I would appricate any help that you could give me because I've been looking all over the internet for the solution without any result. So off to my problem, I made this text-based online game and let's say the user does a crime, he did this crime 17:04:30 and has to wait till 17:06:30 before he can do a crime again (this is printed in the MySQL database). Getting the value from the database and changing it into the right format mm:ss is no problem. The problem comes to when its about refreshing... I've tried meta refresh and javascript location.refresh with good results, i sat the timer to 1 sec and it refreshed. The problem comes to when it refresh the mouse cursor and the tab (in firefox and chrome) gets that look, like when u refresh a page normally u can see an hourglass and all that. Is there anyway to disable that? And i think it really slows the browser down after a while (because after like 30 min or more firefox used 600 mb of my RAM). So yeah here's my Iframe code: Code: print <<<ENDHTML <IFrame Src= "right_timer.php" Scrolling=No Frameborder=0 Marginheight=0 Marginwidth=0 Width=100% Height=160> <p>Your browser does not support iframes.</p> </iframe> Also here's the right_timer.php: Code: <?php include("config.php"); $dbres = mysql_query("SELECT *,UNIX_TIMESTAMP(`crime`) AS `crime` FROM `users` WHERE `login`='{$_SESSION['login']}'"); $data = mysql_fetch_object($dbres); if(! check_login()) { print"<link rel=stylesheet type=text/css href=style.css>";exit; } if ($data->status == dead) { print"<link rel=stylesheet type=text/css href=style.css>";exit; } ?> <html> <head> <meta http-equiv="refresh" content="1"> </head> <body> <?php $dbres = mysql_query("SELECT * FROM `users` WHERE `activated`='1'"); $users= mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users` WHERE `status`='alive' AND `activated`='1'"); $levend = mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300"); $online = mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users`"); while($blah = mysql_fetch_object($dbres)){ $time = time(); $crime = gmdate('i:s',($data->crime - $time)); if (($data->crime - $time) < 0) { $crime = Now; } } print <<<ENDHTML <tr><td>Crime {$crime}</td></tr> ENDHTML; ?> </body> </html> |