Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
1.5 kB
7
Indexable
Never
const vName = req.body.verticalName;
        const category = req.body.category;
        const source = req.body.source;
        const image = req.body.imgLink;
        const titlex  = req.body.title;
        const templates = await TemplateSchema.find({verticalName:vName}, {htmlCode: 1, title: 1, _id: 1});
        var templatesArray = [];


        for(var i = 0;i < templates.length;i++){
            const html = retain(templates[i].htmlCode);
            var cols = document.getElementsByClassName('cls-1');
            for(i = 0; i < cols.length; i++) {
                cols[i].style.fill = accent;
            }
            const titley = titlex.replace("{", " <span  style='color: "+accent+";'> ");
            const title = titley.replace("}", " </span>");
            const html = htmlx.replace(/\\/g, "");
            const $ = cheerio.load(html);
            
            // $('.accent').css('fill',accent);
            // $('.accent').css('border-color',accent);
            $('#headline').text(title);
            $('#categoryText').text(category);
            $('#sourceText').text(source);
            $('#bgSource').removeAttr("src");
            $('#bgSource').attr("src", image);
            
            $.html();
            var node = $.html();
     
            templatesArray.push({id: templates[i]._id, title:templates[i].title, htmlCode:node })
        }

        res.setHeader('Content-Type', 'application/json');
        res.status(200).send(JSON.stringify({images: templatesArray}));