-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfaq.js
More file actions
30 lines (25 loc) · 971 Bytes
/
faq.js
File metadata and controls
30 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import $ from 'jquery';
import _ from 'underscore';
import util from './app/Util';
import sheet from './app/Sheet';
const SPREADSHEET_ID = '1ZbpkjdrrAH95xHWKxjp-bb6nvoKZIZLhXrDwBREa_PA';
function renderQuestion(f) {
return _.map(util.trim(f.question).split('\n'), line => `${line}<br />`).join('');
}
// setup faq
sheet.load(SPREADSHEET_ID, 3, rows => {
var faq = _.map(rows, row => {
return sheet.parseRow(row);
}),
introHeader = faq[0].introheader,
sideColumn = _.map(faq[0].sidecolumn.split('\n'), l => `<li>${l}</li>`);
$('.faq-intro').html(introHeader);
$('.faq-aside').html(sideColumn);
$('.faq-questions').html(
_.map(faq, (f, i) => `<li><a href="#q${i}">- ${renderQuestion(f)}</a></li>`).join(''));
$('.faq-answers').html(
_.map(faq, (f, i) => `<li>
<a name="q${i}" class="faq-answer-question">${renderQuestion(f)}</a>
<p>${f.answer}</p>
<a href="#top" class="back-to-top">back to top</a>`).join(''));
});