Change all monitors mode buttons

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
minnow
Posts: 1
Joined: Wed May 28, 2008 10:13 pm
Contact:

Change all monitors mode buttons

Post by minnow »

I thought it would be usefull to have buttons on the index page that can change the mode of all the monitors.
Use full in an office so you can turn on recording when you leave the office, or change to Monitor when you are in the office.
Quick easy buttons.
I have modified files to do this for me, I think it would be a great feature for the future.
http://www.vitl.co.nz/zm/zm-buttons.rar

Just add the get_monitors.php to the root dir of ZM and rename your zm_html_view_console.php and copy this one over.

Note. I am using ZM v1.23.3
Darafeyen
Posts: 4
Joined: Thu Dec 04, 2008 9:18 am

Post by Darafeyen »

Im very interested in a single button for arming (changing monitor cameras to morecord)

I've tried the link, and its not found.

Can you repost it?
Does anyone know another way of 'arming' the ZM system as you walk out the door?

Cheers,

Darafeyen
Darafeyen
Posts: 4
Joined: Thu Dec 04, 2008 9:18 am

Post by Darafeyen »

Thankyou minnow, the link works :)

I added some buttons to make a delayed set of buttons.
This code goes in replace of minnow's section in zm_html_view_console.php

Code: Select all

// Functions added by minnow
// Delayed functions added by Darafeyen, based on monnow's code

function DelayedSetAll(mode){
        
        var xmlHttp = get_ajax_object();
	var params = "";
	xmlHttp.open("POST","get_monitors.php",false);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	if(xmlHttp.status==200){
		validation_status = xmlHttp.responseXML.getElementsByTagName('status')[0].firstChild.data;
		if (validation_status == 1){
			monitorCount = xmlHttp.responseXML.getElementsByTagName('monitor_count')[0].firstChild.data;
			monitors = xmlHttp.responseXML.getElementsByTagName('monitors')[0].firstChild.data;
			monitorArray = new Array();
			monitorArray = monitors.split(',');
			i = 0;
			monitorCount = monitorCount * 1;
			while (i < monitorCount){
				currentMonitor = monitorArray[i];
				setMode(currentMonitor,mode);
				i++;
			}
			location.reload(true);
		}
	}
   //alert("Delayed 10 seconds");    
}
//Added by Darafeyen
function setAllDelayed(mode){
	 
        //alert("Alert "+mode);
        //Fetch the delay time from the text input box
        var Delaytime= document.getElementById('Delay-time').value;

        //alert("The delay t&nbsp;ime is "+Delaytime);
        setTimeout("DelayedSetAll('"+mode+"')", Delaytime*1000); //pause appears to happen at : 4 seconds plus the entry here      
}
//Added by Darafeyen
function setAll(mode){
        //alert("Alert "+mode);
        setTimeout("DelayedSetAll('"+mode+"')", 1000); //pause appears to happen at : 4 seconds plus the entry here      
}

function setMode(monitorId,monitorMode){
        var xmlHttp = get_ajax_object();
	var params = "view=none&action=function&new_enabled=1&mid=" + monitorId + "&new_function=" + monitorMode;
	xmlHttp.open("POST","index.php",false);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params); 
}
function get_ajax_object(){
	var ajax_object;
		try{
			// Firefox, Opera 8.0+, Safari
			ajax_object=new XMLHttpRequest();
		}
		catch (e){
			// Internet Explorer
			try{
			  ajax_object=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				try{
					ajax_object=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
	return ajax_object;
}
//end of functions added by minnow and Darafeyen


And some code at the end of zm_html_view_console.php

Code: Select all

<!-- html code added by minnow, extra buttons by Darafeyen, this is the actual buttons-->
<!-- This is a text box (use &nbsp; in a span if you want extra spaces)-->
<div style="padding-left: 40px;"><div class="smallhead">
Delay Time:
<input class="form" style="width: 25px;" type="text" name="Delay-time" id="Delay-time" value="60"/>
</div>
<input class="form" onClick="javascript:setAll('Mocord') "type="submit" value="Set All to Motion Record"/>
<input class="form" onClick="javascript:setAll('Monitor') "type="submit" value="Set All to Monitor"/>
<input class="form" onClick="javascript:setAll('Modect') "type="submit" value="Set All to Modect"/>
<input class="form" onClick="javascript:setAll('Record') "type="submit" value="Set All to Record"/>
<br />
<br />
<input class="form" onClick="javascript:setAllDelayed('Mocord') "type="submit" value="Set All to Motion Record (Delayed)"/>
<input class="form" onClick="javascript:setAllDelayed('Monitor') "type="submit" value="Set All to Monitor (Delayed)"/>
<input class="form" onClick="javascript:setAllDelayed('Record') "type="submit" value="Set All to Record (Delayed)"/>
</div>
menesi
Posts: 2
Joined: Thu Feb 19, 2009 8:58 pm
Location: Debrecen, Hungary EU

Post by menesi »

I tried this solution in VB Script to integrate ZM with my home automation software HouseBot. Here is my code:

Code: Select all

Dim objXMLHTTP
Dim strParams, strURL
Dim strMonitorId, strMonitorMode

	strURL = "http://192.168.2.13/zm/index.php"
	strMonitorId = "8"
	strMonitorMode = "Modect"
	strParams = "view=none&action=function&new_enabled=1&mid=" & strMonitorId & "&new_function=" & strMonitorMode
	
	Set objXMLHTTP = CreateObject ("Microsoft.XMLHTTP")
	
	objXMLHTTP.Open "POST", strURL, False
	objXMLHTTP.SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
	objXMLHTTP.SetRequestHeader "Content-length", Len (strParams)
	objXMLHTTP.SetRequestHeader "Connection", "close"
	objXMLHTTP.Send strParams

	Set objXMLHTTP = Nothing
Script ran without error, but the "Function" changed to empty and the "Enabled" to 0. My ZM version is 1.24.0

Where is the error in this solution? Any idea?
Laszlo Menesi
menesi
Posts: 2
Joined: Thu Feb 19, 2009 8:58 pm
Location: Debrecen, Hungary EU

Post by menesi »

I found it, in action.php (v1.24.0) "new_enabled" request is renamed to "newEnabled" and "new_function" to ""newFunction"... :roll:
Laszlo Menesi
Post Reply