Message from JavaScript discussions

June 2019

— Never liked it.. But regretted.. It would have saved me a lot of hard coding.. I am trying nodejs.. And express

Message permanent page

— 

The good thing is: time invested in vuejs is not wasted compared to e.g. angular. It is supportive enough to leave enough free room to have you do all the data management and organizing. Plus, events are original Dom events. Whereas angular tries to do and manage everything. But that is another topic. In nodejs it is similar with learning: frameworks like express also send you the original httpstream.

— Var head,newLine,el,title,link,ToC="<nav class='table-of-contents' role='navigation'><h4 onclick='toc()'>Contents</h4><ul style='display:none'>";$("article h2, article h3, article h4, article h5").attr("id",function(arr){return "point" + arr;});$("article h2, article h3, article h4, article h5").each(function(){el=$(this),title=el.text(),link="#"+el.attr("id"),ToC+=newLine="<li><a href='"+link+"'>"+title+"</a></li>"}),ToC+="</ul></nav>",$(".toc-pro").prepend(ToC);function toc() {$(".table-of-contents ul").toggle();}

Message permanent page

— Does this code contain jQuery ??

— I have to convert it to pure JavaScript pls help me

— Yes it contains jquery - you mostly recognize jquery by the $ variable

— 1. to better understand the code: feed into js beautifier (either via vs-code or online service: https://beautifier.io/)
2. create a helper function for browser native document function:
const $ = document.querySelectorAll.bind(document)
3. replace .attr("id", ...) with .forEach((element, index) => element.id = `point${index})
and since we are already in the loop, you can do the rest of the operations.

Message permanent page

— And instead of "article h2, article h3, article h4, article h5" you might as well do: [2,3,4,5].map(h => `article h${h})`

Message permanent page

— Hi guys

— How can i send this different query results to the same view page

— Promises :) It'll be hard to orchestrate multiple callbacks to finish, unless you do everything in serial.

Message permanent page

— 

const {promisify} = require('util')
const query = promisify(sql.query)

Vibe.queryVibe = async function() {
const [ total, fail, allToday, success ] = await Promise.all([
query(`Select count(*) as total from mfmbs.funds_transfer_transaction`,
query("SELECT count(*) as fail FROM mfmbs.funds_transfer_transaction where DATE(FTTRANTIME)=DATE(NOW()) and ERRMSG LIKE '%Core banking down%'",
query("SELECT count(*) as allToday FROM mfmbs.funds_transfer_transaction where DATE(FTTRANTIME)=DATE(NOW())",
query("SELECT count(*) as success FROM mfmbs.funds_transfer_transaction where DATE(FTTRANTIME)=DATE(NOW()) and FTRESULT='Success'",
])
return { total, fail, allToday, success }


}

Message permanent page