A section of JavaScript alert playback code

Source: Internet
Author: User
Tags setinterval
/** * Description: * Here is the realization of playback, fast-forward and other functions of the JS file * * * * * * * * * * * * 5;//replayspeed = 1000 * 50-second playback speed of var alarmreplaytimer = null; Defines the playback timer var alarmbackuptimer = null; Defines a fallback player var flag = false;

Play switch//Play forward action address var alarmforwardurl = Getrootpath () + "/web/alarm/alarmreplaycontroller/alarmforward.do";

Play back the action address var alarmbackupurl = Getrootpath () + "/web/alarm/alarmreplaycontroller/alarmbackup.do"; var startorpause = function () {//(start/pause) play//modify start/Pause Play button value var Startorpausebutton = document.getElementById ("star
	Torpause ");
	var startorpausebuttonvalue = startorpausebutton.innerhtml;
		if (Startorpausebuttonvalue = = "Start") {UpdateTime ();
	startorpausebutton.innerhtml = "Pause";
	else {startorpausebutton.innerhtml = "start";
		//Start Play or pause play if (!flag) {//not started flag = true; Alarmreplaytimer = SetInterval ("Forward ()", replayspeed);
		Timer Refresh} else {//started flag = false; Cleartimer ()//Stop Playback}} var forward = function () {//forward var currenttime = document.getElementById ("CurrentTime "). Value;
	var currentendtime = document.getElementById ("Currentendtime"). Value;
	var comparedate = Isbigger (currenttime,currentendtime); if (comparedate==0) {$.ajax ({url:alarmforwardurl, data:{currenttime:currenttime, Currentendtime:currente
			 Ndtime}, type: ' Post ', Cache:false, DataType: ' JSON ', success:function (data) {var time = data[0]; var alarmlist = data[1];
			 Alarm Object Set inittablehtml (alarmlist);
			 Console.info (alarmlist);	 
			 if (time!=null) {document.getElementById ("CurrentTime"). Value = time;
			 }else{document.getElementById ("CurrentTime"). Value = document.getElementById ("Currentendtime"). Value; 
			}//$ ("#alarmRelay"). HTML (tablecontent);
		 }, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {alert ("Play exception");
		},})}else if (comparedate==1) {alert ("Play completed");
	Cleartimer ();
	}else if (comparedate = = null) {alert ("Play exception"); The var stop = function () {//Stop CleartimeR ();
	var backward = function () {//backward var currenttime = document.getElementById ("CurrentTime"). Value;
	var currentstarttime = document.getElementById ("Currentstarttime"). Value;
	var comparedate = Isbigger (currentstarttime,currenttime); if (comparedate==0) {$.ajax ({url:alarmbackupurl, data:{currenttime:currenttime, currentstarttime:current
			 StartTime}, type: ' Post ', Cache:false, DataType: ' JSON ', success:function (data) {var time = data[0]; var alarmlist = data[1];
			 Alarm Object Set inittablehtml (alarmlist);	 
			 if (time!=null) {document.getElementById ("CurrentTime"). Value = time;
			 }else{document.getElementById ("CurrentTime"). Value = document.getElementById ("Currentstarttime"). Value;
}//document.getElementById ("CurrentTime"). Value = time; 
			$ ("#alarmRelay"). HTML (tablecontent);
		 }, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {alert ("Play exception"); })}else if (comparedate==1) {alert ("PlayCompleted ");
	Cleartimer ();
	}else if (comparedate = = null) {alert ("Play exception");
	} var lasttime = function () {//Last Cleartimer ();
Backward ();
	var nexttime = function () {//Next cleartimer ();
Forward (); var clearalarmreplaytimer = function () {//Clear forward Timer if (alarmreplaytimer!=null) {cleartimeout (Alarmreplaytimer);//Clear down
	One player timer alarmreplaytimer = null; } var Clearalarmbackuptimer = function () {//Clear backward Timer if (alarmbackuptimer!=null) {cleartimeout (Alarmbackuptimer);//Clear
	Except for the last playback timer alarmbackuptimer = null;
	} var backSpace = function () {//fallback//speedup ();
	Cleartimer (); Alarmbackuptimer = SetInterval ("Backward ()", replayspeed);
	Timer timed Refresh} var fastforward = function () {//Fast-forward/speedup ();
	Cleartimer (); Alarmreplaytimer = SetInterval ("Forward ()", replayspeed);
	Timer timed Refresh} var cleartimer = function () {//Clear timer clearalarmreplaytimer ();
	Clearalarmbackuptimer ();
	
document.getElementById ("Startorpause"). InnerHTML = "Start";
	var speedup = function () {//accelerationif (Replayspeed = = 1000 * 5) {replayspeed = 1000 * 3;
	}else if (replayspeed = = 1000 * 3) {replayspeed = 1000 * 1;
	}else if (replayspeed = = 1000 * 1) {replayspeed = 100 * 5;
	}else if (replayspeed = = 5) {replayspeed = 100 * 3;
	}else if (replayspeed = = 3) {replayspeed = 100 * 1; The var assignspeed = function () {//Specifies a speed multiplier//specified multiple var assignspeedselect = document.getElementById ("Assignspeedselect"). V
	Alue;
	if (Assignspeedselect = = "1") {replayspeed = 1000 * 5;
	}else if (Assignspeedselect = = "2") {replayspeed = 1000 * 3;
	}else if (Assignspeedselect = = "5") {replayspeed = 1000 * 1;
	}else if (Assignspeedselect = = "Ten") {replayspeed = 100 * 5;
	}else if (Assignspeedselect = = "") {replayspeed = 100 * 3;
	}else if (Assignspeedselect = = "X") {replayspeed = 100 * 1;
		}//Restart timer if (alarmreplaytimer!=null) {Clearalarmreplaytimer (); Alarmreplaytimer = SetInterval ("Forward ()", replayspeed); Timer timed Refresh} if (Alarmbackuptimer!=null) {ClearalarmbackupTimer (); Alarmbackuptimer = SetInterval ("Backward ()", replayspeed);  
    Timer timed Refresh}} function Getrootpath () {//Get project path var strfullpath = Window.document.location.href;  
    var strpath = Window.document.location.pathname;  
    var pos = strfullpath.indexof (strpath);  
    var prepath = strfullpath.substring (0, POS);  
    var postpath = strpath.substring (0, Strpath.substr (1). IndexOf ('/') + 1);  
    var RootPath = Prepath + Postpath;  
return (RootPath); } $ (window). Load (function () {(function ($) {$) {$ (document). Ready (function () {jedate ({datecell: ' #current
		      StartTime ', format: ' Yyyy-mm-dd hh:mm:ss ', Istime:true, mindate: ' 2014-09-19 00:00:00 ' 
		        }), Jedate ({datecell: ' #currentEndTime ', format: ' Yyyy-mm-dd hh:mm:ss ', Istime:true,
		
		
	MinDate: ' 2014-09-19 00:00:00 '});
	
	
}) (JQuery); var updatetime = function () {var currentstarttime = document.getElementById("Currentstarttime");
	var currenttime = document.getElementById ("CurrentTime");
Currenttime.value = Currentstarttime.value;
		} * * Table content/function inittablehtml (arr) {if (arr==null) return;
		Console.info (arr);
		var str = ', Strnull = ' <td><div></div></td> ';
			var getrowhtml = function (alarmlist) {var subs = '; Subs + = ' <td player= ' a ' ><div><input type= ' checkbox ' class= ' select ' value= ' ' + Alarmlist.deviceid + ' '
			</div></td> '; if (alarmlist.alarmlevel) Subs + = ' <td><div> ' + alarmlist.alarmlevel + ' </div></td> '; else subs +
			= Strnull; if (alarmlist.alarmtype) Subs + = ' <td><div> ' + alarmlist.alarmtype + ' </div></td> '; else subs =
			Strnull; if (alarmlist.devicename) Subs + = ' <td><div> ' + alarmlist.devicename + ' </div></td> '; else subs +
			= Strnull; if (ALARMLIST.IP) Subs + = ' <td><div> ' + alarmlist.ip + ' </div></td> '; else subs + = StRnull;
			if (alarmlist.area) Subs + = ' <td><div> ' + alarmlist.area + ' </div></td> '; else subs + = Strnull; if (alarmlist.ceatetime) Subs + = ' <td><div> ' + getlocaltime (alarmlist.ceatetime) + ' </div></td
			> Else Subs + = Strnull; if (alarmlist.lastupdatetime) Subs + = ' <td><div> ' + getlocaltime (alarmlist.lastupdatetime) + ' </div>
			</td> Else Subs + = Strnull; if (alarmlist.alarmnumber) Subs + = ' <td><div> ' + alarmlist.alarmnumber + ' </div></td> '; else
			Subs + = Strnull; if (alarmlist.status) Subs + = ' <td><div> ' + alarmlist.status + ' </div></td> '; else subs + = Strnull
			;
		return subs;
		};
		var len = arr.length;
			for (var i=0;i<len;i++) {str = ' <tr class= ' id ' + arr[i].deviceid + ' ' > ';
			str = getrowhtml (arr[i]);
		str = ' </tr> ';
		var stationcontent = Document.queryselector (". Stationcontent");
		stationcontent.innerhtml = str; Document.queryselector(". SelectAll"). Checked = false; Cancels the multiple} function Getlocaltime (ns) {return new Date (NS) of the header.
Format ("Yyyy-mm-dd HH:mm:ss");

 };

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.