galleryThumbs.js 3.46 KB
// Daten zu einem einzelnen Teaser
function c_GalleryThumb (thu, cat, tit, tex, u)
{
	var thumb = thu;
	var cat   = cat;
	var title = tit;
	var text  = tex;
	var url   = u;

	this.getThumb = function ()	{ return thumb; }
	this.getCat   = function ()	{ return cat; }
	this.getTitle = function ()	{ return title; }
	this.getText  = function ()	{ return text; }
	this.getUrl   = function ()	{ return url; }
}

// Container fuer alle Teaser wird via ajax ueber den picToolService
// gefuellt.
function c_GalleryThumbs (_id, pos, _count)
{
	var thumbs = new Array ();
	var startIdx = pos;
	var id = _id;
	var count = _count;

	// Dies kann warscheinlich auch raus aus c_GalleryThumbs
	this.popup = function (i)
	{
		url = document.getElementById (id+'_BG_URL1_'+i).href;

		if (url.match (/javascript:ftvlaunch\(/))
		{
			expr = /\(([0-9]+),\s*([0-9]+),\s*'(.+)'\)/;
			expr.exec (url);

			ftvlaunch (RegExp.$1, RegExp.$2, RegExp.$3);
			return false;
		}

		return popup (document.getElementById (id+'_BG_URL1_'+i).href);
	}
	// -----

	function changeDisplay (client)
	{
		for (i = 0; i < count; i++)
		{
			idx = i + startIdx;

			if (idx > (thumbs.length - 1))
				idx -= thumbs.length;

			thumb = thumbs[idx].getThumb ();
			cat   = thumbs[idx].getCat ();
			title = thumbs[idx].getTitle ();
			text  = thumbs[idx].getText ();
			url   = thumbs[idx].getUrl ();

			document.getElementById (id+'_BG_THUMB'+i).src = thumb;

			node = document.getElementById (id+'_BG_CAT'+i);
			node.firstChild.data = cat;
			node = document.getElementById (id+'_BG_TITLE'+i);
			node.firstChild.data = title;
			node = document.getElementById (id+'_BG_TEXT'+i);
			node.firstChild.data = text;

			document.getElementById (id+'_BG_URL1_'+i).href = 
				url + '?em_client=' + client;
			document.getElementById (id+'_BG_URL2_'+i).href =
				url + '?em_client=' + client;
		}
	}

	this.incGallery = function (client)
	{
		startIdx = (startIdx == (thumbs.length - count)) ? 
			thumbs.length - count : startIdx + 1;

		changeDisplay (client);

		if (thumbs.length - (startIdx + count) === 4)
		{
			nBildertool.callback = this.callback;
			var url = 'http://georgs_test/_module/bildertool/' + 
				'fakeFotoService.php?' +
				'action=latest&cnt=3&limit=10&lfrom=' + thumbs.length +
				'&omit=3,7';
			nBildertool.service (url);
		}

		return false;
	}

	this.decGallery = function (client)
	{
		startIdx = (startIdx == 0) ?  0 : startIdx - 1;

		changeDisplay (client);

		return false;
	}

	this.callback = function ()
	{
		switch (nBildertool.req.readyState)
		{
			case 4:
				if (nBildertool.req.status != 200)
					alert ("Fehler:" + nBildertool.req.status);
				else
				{
					var data = nBildertool.deXmlify (nBildertool.req.responseXML);
					for (d in data['data'])
					{
						var expr = /(.*) [^ ]*$/;
						thumbs.push (
							new c_GalleryThumb (
								data['data'][d].getThumbUrl (),
								data['data'][d].getOrdnerName (0).toUpperCase (),
								data['data'][d].titel,
								data['data'][d].ffBildzeile+
									' '.substr (0, 100).replace (expr, '$1...'),
								data['data'][d].getShowUrl ()));
					}
				}
				return true;

			default:
				return false;
		}
	}

	nBildertool.callback = this.callback;
	var url = 'http://georgs_test/_module/bildertool/fakeFotoService.php?' +
		'action=latest&cnt=3&limit=' + (startIdx+count+5) + '&lfrom=0' +
		'&omit=3,7';
	nBildertool.service (url);
}