Linux-DVB-DVBT-Apps-QuartzPVR

 view release on metacpan or  search on metacpan

js/tvguide/GridApp.js  view on Meta::CPAN


	GridApp.get('update', {}) ;
}

//--------------------------------------------------------------------------------------------
GridApp.set_rec = function(prog, old_record)
{
try {
	prog.rid = 0 ;
	if (old_record > 0)
	{
		// get existing record id
		var recording = GridApp.grid.lookup_recording(prog.pid) ;
		prog.rid = recording.rid ;
	}
	var recspec = GridApp.recspec(prog) ;
	
	GridApp.get('rec', {
		nocache		: 1,
		parameters 	: {
			rec : recspec
		}
	}) ;
	
}
catch (e) {
	log.error("Bugger! Failed to set record "+e) ;
	
	GridApp.error_handler("Failed to set recording: "+e) ;
}

}

//== common ==

//--------------------------------------------------------------------------------------------
GridApp.get = function(cmd, options)
{
//	GridApp.loading.show() ;
	var showLoading = 1 ;
	if (options && options.hasOwnProperty('showLoading'))
		showLoading = options.showLoading ;
	
	if (GridApp.getting(showLoading))
	{
		// don't run if alrwady running
		return ;
	}
	
	Profile.start('GridApp.get') ;

	GridApp.checkUrl() ;

	var params = {} ;
	if (options && options.parameters)
		params = options.parameters ;
	
	// Track each command (unless told not to) so we can reload on redraw
	if (!(options && options.nocache))
	{
		// check to see if popups should be closed
		if (!GridApp.cmdCache || (GridApp.cmdCache.cmd !== cmd))
		{
			// new command so close any open popups
			ClickHandler.closeAll() ;
			InPlace.closeAll() ;
		}
		
		// Update the cache
		GridApp.cmdCache = {
			cmd		: cmd,
			options	: options
		} ;
	}

	params['json'] = cmd ;
//	params['ts'] = ++GridApp.timestamp ; // Change timestamp each time to avoid caching

	if (!params['hr'])
		params['hr'] = GridApp.settings.DISPLAY_HOUR ;
	if (!params['dt'])
		params['dt'] = GridApp.settings.DISPLAY_DATE ;
	if (!params['t'])
		params['t'] = GridApp.settings.LISTINGS_TYPE ;
	if (!params['shw'])
		params['shw'] = GridApp.settings.DISPLAY_PERIOD ;

	HTTP.get(GridApp.url, function(reply) {GridApp.http_reply_handler(reply); }, 
		{
			timeout		: 30000,
			parameters	: params,
			errorHandler	: function(xhr, status, e) { GridApp.error_handler("HTTP error :"+status+" : "+e); },
			timeoutHandler	: function() { GridApp.error_handler("HTTP timeout"); },
			progressHandler	: function() { /* log.debug("HTTP progress"); */ }
		}) ;
}

//--------------------------------------------------------------------------------------------
GridApp.http_reply_handler = function(reply)
{
//log.debug("GridApp.http_reply_handler() getFlag="+GridApp.getFlag+", redrawFlag="+GridApp.redrawFlag) ;

	
try {
	if (GridApp.debug >= 5)
	{
		// log.debug("HTTP reply", reply) ;
	}
	Profile.stop('GridApp.get') ;
	Profile.start('GridApp.http_reply_handler') ;

	
	var msgType ;
	var msgContent ;
	
	if (reply && reply.cmd)
	{
		var displayPage = null ;
		var redisplay_schedule = [] ;
		
		// tv/radio
		var listingsType = GridApp.settings.LISTINGS_TYPE ;
		
		// log.debug(reply.cmd+" cmd") ;



( run in 1.116 second using v1.01-cache-2.11-cpan-364913b4093 )