-
Notifications
You must be signed in to change notification settings - Fork 1
/
resources.js
31 lines (25 loc) · 1.07 KB
/
resources.js
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 renderResource(f) {
return _.map(util.trim(f.contentsection).replace(/[\u201C\u201D]/g, '"').split('\n'), line => `${line}<br />`).join('');
}
// setup resources
sheet.load(SPREADSHEET_ID, 4, rows => {
var resources = _.map(rows, row => {
return sheet.parseRow(row);
}),
introHeader = resources[0].introheader,
sideColumn = _.map(resources[0].sidecolumn.split('\n'), l => `<li>${l}</li>`);
$('.resources-intro').html(introHeader);
$('.resources-aside').html(sideColumn);
$('.resources-index').html(
_.map(resources, (f, i) => `<li><a href="#q${i}">${f.contentheader.toUpperCase()}</a></li>`).join(''));
$('.resources-resources').html(
_.map(resources, (f, i) => `<li>
<a name="q${i}" class="resources-resource">${f.contentheader.toUpperCase()}</a>
<p>${renderResource(f)}</p>
<a href="#top" class="back-to-top">back to top</a>`).join(''));
});