Georg Hopp 18 years ago
parent
commit
debc7ec4c2
  1. 19
      js/bildertool/callbacks.js
  2. 103
      js/bildertool/galleryThumbs.js
  3. 14
      js/bildertool/helper.js
  4. 48
      js/bildertool/service.js
  5. 111
      js/bildertool/strecke.js
  6. 184
      js/bildertool/xmlify.js

19
js/bildertool/callbacks.js

@ -0,0 +1,19 @@
if (typeof (nBildertool) === 'undefined')
nBildertool = {};
nBildertool.cbCommon = function ()
{
switch (nBildertool.req.readyState)
{
case 4:
if (nBildertool.req.status != 200)
alert ("Fehler:" + nBildertool.req.status);
else
data = nBildertool.deXmlify (nBildertool.req.responseXML);
return true;
default:
return false;
}
}

103
js/bildertool/galleryThumbs.js

@ -0,0 +1,103 @@
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; }
}
function c_GalleryThumbs (_id, data, pos, _count)
{
var thumbs = new Array ();
var startIdx = pos;
var id = _id;
var count = _count;
for (var d in data)
{
var expr = /(.*) [^ ]*$/;
thumbs.push (
new c_GalleryThumb (
d.getThumbUrl (),
d.getOrdnerName (0).toUpperCase (),
d.titel,
d.ffBildzeile+' '.substr (0, 100).replace (expr, '$1...'),
d.getShowUrl ()));
}
// Dies kann warscheinlich auch raus aus c_GalleryThumbs
this.popup = function (i)
{
url = document.getElementById (id+'_BG_URL1_'+i).href;
thumbs = eval ();
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);
return false;
}
this.decGallery = function (client)
{
startIdx = (startIdx == 0) ? 0 : startIdx - 1;
changeDisplay (client);
return false;
}
}

14
js/bildertool/helper.js

@ -0,0 +1,14 @@
if (typeof (nBildertool) === 'undefined')
nBildertool = {};
nBildertool.extend = function (subClass, baseClass)
{
function inheritance() {}
inheritance.prototype = baseClass.prototype;
subClass.prototype = new inheritance();
subClass.prototype.constructor = subClass;
subClass.baseConstructor = baseClass;
subClass.superClass = baseClass.prototype;
}

48
js/bildertool/service.js

@ -0,0 +1,48 @@
if (typeof (nBildertool) === 'undefined')
nBildertool = {};
nBildertool.req = null;
nBildertool.service = function (url, callback)
{
// erstellen des requests
try
{
nBildertool.req = new XMLHttpRequest();
}
catch (e)
{
try
{
nBildertool.req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
nBildertool.req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed)
{
nBildertool.req = null;
}
}
}
if (nBildertool.req == null)
alert("Error creating request object!");
nBildertool.req.open("GET", url, true);
// Beim abschliessen des request wird diese Funktion ausgeführt
if (typeof (callback) === 'undefined')
nBildertool.req.onreadystatechange = nBildertool.cbCommon;
else
nBildertool.req.onreadystatechange = callback;
nBildertool.req.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
nBildertool.req.send(null);
}

111
js/bildertool/strecke.js

@ -0,0 +1,111 @@
if (typeof (nBildertool) === 'undefined')
nBildertool = {};
if (typeof (FRONT_URL) === 'undefined')
FRONT_URL = 'http://foto.westfaelische-nachrichten.de/';
// strecke wird ausschliesslich ueber einen entsprechenden xml Datensatz
// gefuellt.
nBildertool.strecke = function (data)
{
this.streckeId = null;
this.date = null;
this.showDate = null;
this.titel = null;
this.prio = null;
this.sektionen = null;
this.template = null;
this.ordnerId = null;
this.connectionId = null;
this.flags = null;
this.l0Id = null;
this.l1Id = null;
this.l2Id = null;
this.l3Id = null;
this.ordnerName = null;
this.viewFoto = null;
this.viewIndex = null;
this.downloads = null;
this.ffId = null;
this.ffBildzeile = null;
this.ffCopy = null;
this.ffSId = null;
this.ffSBildzeile = null;
this.ffSCopy = null;
this.fotoCount = null;
this.path = null;
function getOrdnerInfo (value, idx)
{
var val = value.split ('|%|');
if (typeof (idx) === 'undefined') return val;
return val[idx];
}
function getOrdnerId (idx)
{
return getOrdnerInfo (this.ordnerId, idx);
}
function getConnectionId (idx)
{
return getOrdnerInfo (this.connectionId, idx);
}
function getFlags (idx)
{
return getOrdnerInfo (this.flags, idx);
}
function getL0Id (idx)
{
return getOrdnerInfo (this.l0Id, idx);
}
function getL1Id (idx)
{
return getOrdnerInfo (this.l1Id, idx);
}
function getL2Id (idx)
{
return getOrdnerInfo (this.l2Id, idx);
}
function getL3Id (idx)
{
return getOrdnerInfo (this.l3Id, idx);
}
function getOrdnerName (idx)
{
return getOrdnerInfo (this.ordnerName, idx);
}
this.getTeaserUrl = function ()
{
var teaserPath =
escape (this.titel) + '/' +
this.streckeId.substr (this.streckeId.length-2) + '/' +
this.streckeId;
return FRONT_URL + teaserPath + '.jpeg';
}
this.getThumbUrl = function ()
{
return FRONT_URL + this.path + 'T.jpeg';
}
this.getScreenUrl = function ()
{
return FRONT_URL + this.path + 'S.jpeg';
}
this.getDownlUrl = function ()
{
return FRONT_URL + this.path + '.jpeg';
}
this.getShowUrl = function ()
{
return FRONT_URL + this.path + '.html';
}
nBildertool.strecke.baseConstructor.call (this, data);
}
nBildertool.extend (nBildertool.strecke, nBildertool.c_xmlify);

184
js/bildertool/xmlify.js

@ -0,0 +1,184 @@
if (typeof (nBildertool) === 'undefined')
nBildertool = {};
nBildertool.xmlToVar = function (data)
{
if (!data.hasChildNodes ())
return null;
var ret = null;
for (var node in data.childNodes)
{
var child = data.childNodes[node];
if (child.nodeType === 3 && child.nodeValue !== null)
{
ret = data.childNodes[node].nodeValue;
break;
}
}
switch (data.getAttribute ('type'))
{
case 'integer': ret = parseInt (ret, 10); break;
case 'double': ret = parseFloat (ret);
}
return ret;
}
nBildertool.xmlToObjectArray = function (data)
{
var ret = new Array ();
if (! data.hasChildNodes ())
return ret;
for (var node in data.childNodes)
{
var child = data.childNodes[node];
if (child.nodeType === 1)
{
name = child.getAttribute ('name');
switch (child.nodeName)
{
case 'variable':
ret[name] = nBildertool.xmlToVar (child); break;
case 'array':
ret[name] = nBildertool.xmlToArray (child); break;
case 'class':
var cName = child.getAttribute ('class');
switch (cName)
{
case 'c_picToolStrecke_new3':
ret[name] = new nBildertool.strecke (child);
break;
default:
ret[name] = nBildertool.xmlToObjectArray (child);
}
}
}
}
return ret;
}
nBildertool.xmlToArray = function (data)
{
var ret = new Array ();
if (! data.hasChildNodes ())
return ret;
for (var node in data.childNodes)
{
var child = data.childNodes[node];
if (child.nodeType === 1 && child.nodeName === 'item')
{
var key = child.getAttribute ('key');
for (var _node in child.childNodes)
{
var _child = child.childNodes[_node];
if (_child.nodeType === 1)
{
switch (_child.nodeName)
{
case 'variable':
ret[key] = nBildertool.xmlToVar (_child); break;
case 'array':
ret[key] = nBildertool.xmlToArray (_child); break;
case 'class':
var cName = child.getAttribute ('class');
switch (cName)
{
case 'c_picToolStrecke_new3':
ret[key] = new nBildertool.strecke (_child);
break;
default:
ret[key] = nBildertool.xmlToObjectArray (_child);
}
}
}
}
}
}
return ret;
}
nBildertool.c_xmlify = function (data)
{
if (! data.hasChildNodes ())
return;
for (var node in data.childNodes)
{
var child = data.childNodes[node];
if (child.nodeType === 1)
{
var name = child.getAttribute ('name');
if (typeof (this[name]) !== 'undefined')
{
switch (child.nodeName)
{
case 'variable':
this[name] = nBildertool.xmlToVar (child); break;
case 'array':
this[name] = nBildertool.xmlToArray (child); break;
case 'class':
var cName = child.getAttribute ('class');
switch (cName)
{
case 'c_picToolStrecke_new3':
this[name] = new nBildertool.strecke (child);
break;
default:
this[name] = nBildertool.xmlToObjectArray (child);
}
}
}
}
}
}
nBildertool.deXmlify = function (data)
{
var ret = null;
var child = data.firstChild;
switch (child.nodeName)
{
case 'variable':
ret = nBildertool.xmlToVar (child); break;
case 'array':
ret = nBildertool.xmlToArray (child); break;
case 'class':
var cName = child.getAttribute ('class');
switch (cName)
{
case 'c_picToolStrecke_new3':
ret = new nBildertool.strecke (child);
break;
default:
ret = nBildertool.xmlToObjectArray (child);
}
}
return ret;
}
Loading…
Cancel
Save