Skip to content

Commit

Permalink
good-enough fix for directory page
Browse files Browse the repository at this point in the history
  • Loading branch information
benthemonkey committed Nov 3, 2015
1 parent 4348505 commit deadf71
Showing 1 changed file with 48 additions and 37 deletions.
85 changes: 48 additions & 37 deletions js/directory.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,60 @@
/* eslint strict:0 */

$(function() {
jQuery(function() {
'use strict';

$.getJSON('/points/ajax/getDirectory.php', function(data) {
var i;
var path = 'http://slivka.northwestern.edu/points/img/slivkans/';

for (i = 0; i < data.length; i++) {
data[i][5] = [
'<img class="directoryphoto" src="', path, data[i][5], '"',
'title="', data[i][0], ' ', data[i][1], '"',
'style="height: 100px; display: none;" />'
].join('');
var checkForDataTables = function() {
if (typeof($().DataTable) === 'undefined') {
setTimeout(checkForDataTables, 100);
} else {
init();
}
},
init = function() {
$.getJSON('/points/ajax/getDirectory.php', function(data) {
var i;
var path = 'http://slivka.northwestern.edu/points/img/slivkans/';

$('#directory').dataTable( {
data: data,
columns: [
{ title: 'First Name' },
{ title: 'Last Name' },
{ title: 'Year' },
{ title: 'Major' },
{ title: 'Suite' },
{ title: 'Photo', orderable: false }
],
order: [[0, 'asc']],
paging: false
});
for (i = 0; i < data.length; i++) {
data[i][5] = [
'<img class="directoryphoto" src="', path, data[i][5], '"',
'title="', data[i][0], ' ', data[i][1], '"',
'style="height: 100px; display: none;" />'
].join('');
}

// directory password
// This is a very insecure measure, mostly so the photos
// aren't displayed by default and you have to know javascript to display them
$('#submitdirectorypass').click(function() {
if ('discoverslivka' === $('#directorypass').val()) {
$('.directoryphoto').show();
$('#directory').dataTable( {
data: data,
columns: [
{ title: 'First Name' },
{ title: 'Last Name' },
{ title: 'Year' },
{ title: 'Major' },
{ title: 'Suite' },
{ title: 'Photo', orderable: false }
],
order: [[0, 'asc']],
paging: false
});

// dumb but works: saving password in localstorage
localStorage.directorypass = 'discoverslivka';
// directory password
// This is a very insecure measure, mostly so the photos
// aren't displayed by default and you have to know javascript to display them
$('#submitdirectorypass').click(function() {
if ('discoverslivka' === $('#directorypass').val()) {
$('.directoryphoto').show();

// dumb but works: saving password in localstorage
localStorage.directorypass = 'discoverslivka';
}
});

if (localStorage.directorypass) {
$('#directorypass').val(localStorage.directorypass);
$('#submitdirectorypass').click();
}
});
}

if (localStorage.directorypass) {
$('#directorypass').val(localStorage.directorypass);
$('#submitdirectorypass').click();
}
});
$.getScript('/points/node_modules/datatables/media/js/jquery.dataTables.min.js', checkForDataTables);
});

0 comments on commit deadf71

Please sign in to comment.