From 0acf4e0774e0daeed2c386e4d9c0ac36da70a244 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Mon, 5 Sep 2016 19:55:53 +0200 Subject: you can now search by name --- public/javascripts/getUsers.js | 51 +++--------------------------------------- 1 file changed, 3 insertions(+), 48 deletions(-) (limited to 'public/javascripts/getUsers.js') diff --git a/public/javascripts/getUsers.js b/public/javascripts/getUsers.js index ac09ef4..ca86108 100644 --- a/public/javascripts/getUsers.js +++ b/public/javascripts/getUsers.js @@ -1,53 +1,8 @@ const Promise = require('bluebird') -const cheerio = require('cheerio') +// const cheerio = require('cheerio') const request = Promise.promisify(require('request')) module.exports = function () { - return new Promise(function (resolve, reject) { - request(`http://${window.location.host}/meetingpointProxy/Roosters-AL%2Fdoc%2Fdagroosters%2Fframes%2Fnavbar.htm`) - .then(function (page) { - page = page.body - - const $ = cheerio.load(page) - const $script = $('script').eq(1) - const scriptText = $script.text() - - const regexs = [/var classes = \[(.+)\];/, /var teachers = \[(.+)\];/, /var rooms = \[(.+)\];/, /var students = \[(.+)\];/] - const items = regexs.map(function (regex) { - return scriptText.match(regex)[1].split(',').map(function (item) { - return item.replace(/"/g, '') - }) - }) - - resolve([] - .concat(items[0].map(function (item, index) { - return { - type: 'c', - value: item, - index: index - } - })) - .concat(items[1].map(function (item, index) { - return { - type: 't', - value: item, - index: index - } - })) - .concat(items[2].map(function (item, index) { - return { - type: 'r', - value: item, - index: index - } - })) - .concat(items[3].map(function (item, index) { - return { - type: 's', - value: item, - index: index - } - }))) - }) - }) + return request(`http://${window.location.host}/getUserIndex`) + .then(data => JSON.parse(data.body)) } -- cgit v1.1