router.get('/first', function (req, res) { var RegNo = req.query.regno; var DoB = req.query.dob; var onGetData = function (err, data) { res.send(data); }; api_data.getData(RegNo.toUpperCase(), DoB, true, onGetData) });
function publishSeries () { spinner.start('Publishing series') theme.compileSeriesHome(meta.getData('series'), globalData) Object.keys(changed.series).forEach(slug => { theme.compileSeries(changed.series[slug], cache.getData('series')[slug] || [], globalData) }) spinner.succeed('Publishing series') }
function publishTags () { spinner.start('Publishing tags') theme.compileTagsHome(meta.getData('tags'), globalData) Object.keys(changed.tags).forEach(slug => { theme.compileTag(changed.tags[slug], cache.getData('tags')[slug] || [], globalData) }) spinner.succeed('Publishing tags') }
sources.forEach(function(source) { try { var sourceModule = require('./sources/' + source); sourceModule.getData(handleResponse); } catch (err) { cb('Unknown source provided: ' + source); } });
callback : function(req, res) { var param = req.body; if(param.refresh) { LOL.getChampions(function(error, data) { if(error) { _loge.error("================================================="); _loge.error("time : " + new Date().toString()); _loge.error("name : LOLRouter lol_getChampions"); _loge.error("-------------------------------------------------"); _loge.error(err.stack); _loge.error("================================================="); res.end(JSON.stringify({code : _code.ERROR, data : error})); } else { var dataVo = new DataVo(); dataVo.id = "lol_champions"; dataVo.data = JSON.stringify(data); DataDao.getData(dataVo.id, function(response) { if(response) { DataDao.updateData(dataVo, function(response) { res.end(JSON.stringify({code : _code.SUCCESS, data : {data : dataVo.data}})); }); } else { DataDao.insertData(dataVo, function(response) { res.end(JSON.stringify({code : _code.SUCCESS, data : {data : dataVo.data}})); }); } }); } }); } else { DataDao.getData("lol_champions", function(data) { if(data) { res.end(JSON.stringify({code : _code.SUCCESS, data : data})); } else { res.end(JSON.stringify({code : _code.ERROR})); } }); } }
router.get('/first', function (req, res) { var RegNo = req.query.regno; var onGetData = function (err, data) { res.send(data); }; api_data.getData(RegNo, true, onGetData) });
module.exports.data = function($, el, param, req, next) { var template = this.getTemplate($, el); DataDao.getData(param.id, function(data) { $(el).html(template(data)); next(); }); };
function checkCompletedness (challenge) { data = userData.getData() if (data.contents[challenge].completed) { document.getElementById(challenge).classList.add('completed') var header = document.getElementsByTagName('header')[0] header.className += ' challenge-is-completed' // If completed, show clear button and disable verify button enableClearStatus(challenge) disableVerifyButtons(true) } else removeClearStatus() }
self._composeServiceDataFromInstallServiceData( serviceData, function(error, data) { if (error) { return callback(error); } var serviceForm = new ServiceForm(data); if (serviceForm.isValid()) { logger.debug('Create service'); return self.createService(req, serviceForm.getData(), callback); } else { return callback(serviceForm.errors); } });
server.app.post('/api', urlencodedParser, function(req, res) { console.log('post rec\'d'); if (req.body) console.log(req.body); if (req.params) console.log(req.params); /* SHOW */ if (req.body.show) { worker.getData(function(err, data) { if (err) res.status(500).json({error: true, message: err}); res.status(200).json({error: false, message: "data dispatched!", devices: data}); }); } /* FIND */ else if (req.body.find) { if (typeof req.body.mac === 'undefined') res.status(400).json({error: true, message: 'mac address was not received'}); if (!/(?:[a-f0-9]{2}:){5}[a-f0-9]{2}/.test(req.body.mac)) throw new Error('mac address not valid'); worker.getDevice(req.body.mac, function(err, data) { if (err) res.status(500).json({error: true, message: err}); res.status(200).json({error: false, message: "found device!", found: data}); }); } /* ADD */ else if (req.body.add) { if (typeof req.body.name === 'undefined') res.status(400).json({eror: true, message: 'name was not in request body'}); if (typeof req.body.mac === 'undefined') res.status(400).json({error: true, message: 'mac as not in request body'}); worker.addName(req.body.name, req.body.mac, function(err, numAdded) { if (err) res.status(500).json({error: true, message: err}); res.status(200).json({error: false, message: 'Name added to databse', added: numAdded}); }); } /* DEFAULT */ else { res.status(500).json({error: true, message: 'api command was not specified in HTTP request body'}); } });
function publishRss () { const rss = new RSS({ title: blogConfig.site.title, description: blogConfig.site.description, feed_url: `${blogConfig.site.url}${urlBuilder.rss()}`, site_url: blogConfig.site.url, pubDate: moment().format('YYYY-MM-DD HH:mm:ss') }) const posts = cache.getData('posts').slice(0, blogConfig.pageSize.rss) const dir = path.join(__dirname, '../', blogConfig.output.public) posts.forEach((post, index) => { rss.item({ title: post.title, url: `${blogConfig.site.url}${post.url}`, description: post.excerpt, categories: post.categories.map(category => category.name), date: post.publishedAt }) }) fs.writeFileSync(`${dir}/rss.xml`, rss.xml({ indent: ' ' }) + '\n') }
SysController.prototype.getProfile = function(req, res){ var id = req.params.id; loginFact.getData(id, function(err, result){ var viewData = { identify:'SysProfile', menu:'SysUserList', title: 'Profile', userID: result.Object.ID, userNickName: result.Object.NickName, userName: result.Object.UserName, userCreateByName: result.Object.CreateByName || 'System', userIsActive: (result.Object.IsActive[0] == 1) ? true : false, userCreateDate: Moment(result.Object.CreateDate).format('YYYY-MM-DD HH:mm:ss'), userLastLoginDate: Moment(result.Object.LastLoginDate).format('YYYY-MM-DD HH:mm:ss'), profilePhoto: result.Object.ProfilePhoto || '/EventsAdmin/assets/images/RD2-1.png' }; res.render('Sys/profile', viewData); }); };
LOL.getChampionsOfSummoner(function(error, data) { if(error) { _loge.error("================================================="); _loge.error("time : " + new Date().toString()); _loge.error("name : LOLRouter lol_getChampionsOfSummoner"); _loge.error("-------------------------------------------------"); _loge.error(err.stack); _loge.error("================================================="); res.end(JSON.stringify({code : _code.ERROR, data : error})); } else { var dataVo = new DataVo(); dataVo.id = "lol_champions_summoner"; dataVo.data = JSON.stringify(data); DataDao.getData(dataVo.id, function(response) { if(response) { DataDao.updateData(dataVo, function(response) { res.end(JSON.stringify({code : _code.SUCCESS, data : {data : dataVo.data}})); }); } else { DataDao.insertData(dataVo, function(response) { res.end(JSON.stringify({code : _code.SUCCESS, data : {data : dataVo.data}})); }); } }); } });
document.addEventListener('DOMContentLoaded', function (event) { var data = userData.getData() // Buttons var clearAllButtons = document.querySelectorAll('.js-clear-all-challenges') var leftOffButton = document.getElementById('left-off-from') // Sections var showFirstRun = document.getElementById('show-first-run') var showWipRun = document.getElementById('show-wip-run') var showFinishedRun = document.getElementById('show-finished-run') updateIndex(data.contents) // Listen for Clear All Button Events, trigger confirmation dialog for (var i = 0; i < clearAllButtons.length; i++) { clearAllButtons[i].addEventListener('click', function () { ipc.send('confirm-clear') }, false) } ipc.on('confirm-clear-response', function (event, response) { if (response === 1) return else clearAllChallenges(data) }) // Go through each challenge in user data to see which are completed function updateIndex (data) { var circles = document.querySelectorAll('.progress-circle') var counter = 0 var completed = 0 for (var chal in data) { if (data[chal].completed) { // A challenge is completed so show the WIP run HTML showWipRun.style.display = 'block' showFirstRun.style.display = 'none' showFinishedRun.style.display = 'none' // Mark the corresponding circle as completed circles[counter].classList.add('completed') // Show the button to go to next challenge leftOffButton.href = path.join(__dirname, '..', 'challenges', data[chal].next_challenge + '.html') completed++ counter++ } else { counter++ } } if (completed === 0) { // No challenges are complete, show the first run HTML showFirstRun.style.display = 'block' showWipRun.style.display = 'none' showFinishedRun.style.display = 'none' } if (completed === Object.keys(data).length) { // All of the challenges are complete! Show the finished run HTML showFirstRun.style.display = 'none' showWipRun.style.display = 'none' showFinishedRun.style.display = 'block' } } function clearAllChallenges (data) { for (var chal in data.contents) { if (data.contents[chal].completed) { data.contents[chal].completed = false } } fs.writeFileSync(data.path, JSON.stringify(data.contents, null, 2)) // If they clear all challenges, go back to first run HTML var circles = document.querySelectorAll('.progress-circle') Array.prototype.forEach.call(circles, function (el) { el.classList.remove('completed') }) showFirstRun.style.display = 'block' showWipRun.style.display = 'none' showFinishedRun.style.display = 'none' } })
function publishHome () { spinner.start('Publishing home') theme.compileHome(cache.getData('posts'), globalData) spinner.succeed('Publishing home') }
worker.on('parsed', function() { worker.getData(function(err, data) { if (err) throw err; ws.send(JSON.stringify({devices: data})); }); });
Object.keys(changed.tags).forEach(slug => { theme.compileTag(changed.tags[slug], cache.getData('tags')[slug] || [], globalData) })
Object.keys(changed.categories).forEach(slug => { theme.compileCategory(changed.categories[slug], cache.getData('categories')[slug] || [], globalData) })
Object.keys(changed.series).forEach(slug => { theme.compileSeries(changed.series[slug], cache.getData('series')[slug] || [], globalData) })
function publishArchives () { spinner.start('Publishing archives') theme.compileArchives(cache.getData('posts'), globalData) spinner.succeed('Publishing archives') }