temporary hack to bring over functions from the old application.js

git-svn-id: http://svn.openlayers.org/trunk/openlayers@192 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-19 18:40:32 +00:00
parent de294029b5
commit bfece3fc4e

View File

@@ -3,8 +3,8 @@
/** Parse a feature from an XML node
* MC specific at the moment
*/
ol.Feature = Class.create();
ol.Feature.prototype= {
OpenLayers.Feature = Class.create();
OpenLayers.Feature.prototype= {
// Object
listeners:null,
@@ -31,25 +31,25 @@ ol.Feature.prototype= {
initialize: function(fNode) {
this.listeners = new Object();
var docpt = ol.Application.getNodes(fNode, "docpoint")[0];
var docpt = OpenLayers.getNodes(fNode, "docpoint")[0];
this.fid = docpt.getAttribute('fid');
this.id = this.fid;
var node = ol.Application.getNodes(docpt, "position")[0];
node = ol.Application.getNodes(node, "gml:Point")[0];
var node = OpenLayers.getNodes(docpt, "position")[0];
node = OpenLayers.getNodes(node, "gml:Point")[0];
this.srsName = node.getAttribute('srsName');
var temp = ol.Application.getTagText(node, "gml:coordinates");
var temp = OpenLayers.getTagText(node, "gml:coordinates");
this._latlon = ol.LatLon.fromString(temp);
this.title = ol.Application.getTagText(docpt, "title");
this.location = ol.Application.getTagText(docpt, "locationName");
this.docurl = ol.Application.getTagText(docpt, "documentUrl");
this.extract = ol.Application.getTagText(docpt, "extract");
this.geoExtract = ol.Application.getTagText(docpt, "geoextract");
this.relevance = ol.Application.getTagText(docpt, "relevance");
this.geoRelevance = ol.Application.getTagText(docpt, "georelevance");
this.title = OpenLayers.getTagText(docpt, "title");
this.location = OpenLayers.getTagText(docpt, "locationName");
this.docurl = OpenLayers.getTagText(docpt, "documentUrl");
this.extract = OpenLayers.getTagText(docpt, "extract");
this.geoExtract = OpenLayers.getTagText(docpt, "geoextract");
this.relevance = OpenLayers.getTagText(docpt, "relevance");
this.geoRelevance = OpenLayers.getTagText(docpt, "georelevance");
this.markerImage = ol.Application.getTagText(docpt, "markerImage");
this.markerImage = OpenLayers.getTagText(docpt, "markerImage");
this.size = new ol.Size(20, 25); // TODO: Fix this hard coded value.
},
@@ -157,3 +157,66 @@ ol.Feature.prototype= {
who:function(){return ("Feature.js");} //last
};
/**
* @param {Array} nodes
* @param {str} tagName
*
* @return {Array}
*/
OpenLayers._getNodes=function(nodes, tagName) {
var retArray = new Array();
for (var i=0;i<nodes.length;i++) {
if (nodes[i].nodeName==tagName) {
retArray.push(nodes[i]);
}
}
return retArray;
};
/** These could/should be made namespace aware?
*
* @param {} p
* @param {str} tagName
*
* @return {Array}
*/
OpenLayers.getNodes=function(p, tagName) {
var nodes = Try.these(
function () {
return OpenLayers._getNodes(p.documentElement.childNodes,
tagName);
},
function () {
return OpenLayers._getNodes(p.childNodes, tagName);
}
);
return nodes;
};
/**
* @param {} parent
* @param {str} item
* @param {int} index
*
* @return {str}
*/
OpenLayers.getTagText = function (parent, item, index) {
var result = OpenLayers.getNodes(parent, item);
if (result && (result.length > 0))
{
if (!index) {
index=0;
}
if (result[index].childNodes.length > 1) {
return result.childNodes[1].nodeValue;
}
else if (result[index].childNodes.length == 1) {
return result[index].firstChild.nodeValue;
}
} else {
return "";
}
};