dl
Version:
DreamLab Libs
59 lines (47 loc) • 1.47 kB
JavaScript
var Class = require("core").Class;
var CdfTag = require("./CdfTag.js").CdfTag;
/**
* @class CdfInsert
* @extends CdfTag
*/
var CdfInsert = function () {
this.Extends = CdfTag;
//
// this.src = null;
this.initialize = function (data) {
this.parent(data);
this.src = null;
if (data) {
this._parse();
}
};
this._parse = function () {
var matches = this.token.match(/^<cdf:insert([^>]+)>/i);
var attrMatches = matches[1].match(/\S+=\\{0,1}"\S+?\\{0,1}"/ig);
var match = null;
var valuePair = null;
for (var i = 0 ,max = attrMatches.length; i < max; i++) {
match = attrMatches[i];
valuePair = match.match(/(\S+)=\\{0,1}"(\S+?)\\{0,1}"/i);
this._parseParam(valuePair[1], valuePair[2]);
}
};
this._parseParam = function (name, value) {
switch (name) {
case "src":
this.src = value;
break;
default:
console.log('ERROR: CdfInsert::_parseParam : unsupported param name: '+name);
break;
}
};
/**
* Zwraca kompletnego stringa
*/
this.toString = function () {
return '<cdf:insert src="'+this.src+'"></cdf:insert>';
};
};
CdfInsert = new Class(new CdfInsert());
exports.CdfInsert = CdfInsert;