Ejemplo n.º 1
0
uduvudu.helper.loadMatcher = function (matcherClass, matcherFunction) {
    if (uduvudu.options.styles) {
        var styles = uduvudu.options.styles;
        styles.match(null, rdf.resolve('a'), rdf.resolve(matcherClass)).forEach( function (m) {
            var propArray = [];
            styles.match(m.subject, null, null).forEach( function (p) {
                propArray.push([uduvudu.helper.getTerm(p.predicate.toString()), p.object.toString()]);
            });

            // fold duplicated properties into an array
            var def = _.object(
                _.map(
                    _.groupBy(
                        propArray,
                        function(a) {return _.first(a);}
                    ),
                    function (b) {
                        if (b.length == 1){
                            return _.first(b);
                        } else {
                            return [_.first(_.first(b)), _.map(b, function(c) {return _.last(c);})];
                        }
                    })
                );
            // use factory function to create new matcher
            uduvudu.helper.addMatcher(matcherFunction(def));
        });
    };
}
Ejemplo n.º 2
0
uduvudu.helper.getTemplate = function (templateName, device, language) {
    var templateContent = ''
    // get templates from stylesStore
    if (uduvudu.options.styles) {
        var styles = uduvudu.options.styles;

        styles.match(null, rdf.resolve('uv:abstractTemplate'), templateName).forEach(function (t) {
            styles.match(t.subject, rdf.resolve('uv:template'), null).forEach(function (t) {
                    templateContent = t.object.toString();
            });
        });
    }

    // fallback look for template in html
    var elem = document.getElementById(templateName);
    if (elem) {
        templateContent =  elem.innerHTML;
    }
    return templateContent || null;
};
Ejemplo n.º 3
0
 styles.match(null, rdf.resolve('uv:abstractTemplate'), templateName).forEach(function (t) {
     styles.match(t.subject, rdf.resolve('uv:template'), null).forEach(function (t) {
             templateContent = t.object.toString();
     });
 });