Skip to content

Commit

Permalink
We are jQuery free!
Browse files Browse the repository at this point in the history
  • Loading branch information
keitharm committed Apr 6, 2016
1 parent a5a60f4 commit 82b9a12
Show file tree
Hide file tree
Showing 29 changed files with 501 additions and 489 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Expand Up @@ -20,7 +20,7 @@ gulp.task('spec', ['testEnv'], () => {
});

gulp.task('compress', () => {
return gulp.src(['public/js/jquery.js', 'public/js/*.js'])
return gulp.src(['public/js/ready.min.js', 'public/js/pegasus.min.js', '!public/js/highcharts.js', 'public/js/*.js'])
.pipe(uglify('all.js'))
.pipe(gulp.dest('public/dist/'));
});
Expand Down
4 changes: 2 additions & 2 deletions public/css/base.css
@@ -1,4 +1,4 @@
@import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500);
@import url(https://fonts.googleapis.com/css?family=Ubuntu:300);
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
Expand Down Expand Up @@ -966,7 +966,7 @@ pre span {
text-align: center;
font-size: 42px;
}
.stats iframe {
.stats#charts {
width: 100%;
height: 400px;
border: none;
Expand Down
30 changes: 0 additions & 30 deletions public/css/fonts.css

This file was deleted.

Binary file added public/img/creator_arron.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/img/creator_arron.png
Binary file not shown.
Binary file added public/img/creator_keith.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/img/creator_keith.png
Binary file not shown.
Binary file removed public/img/creator_keith_old.png
Binary file not shown.
Binary file removed public/img/logo_white.png
Binary file not shown.
Binary file removed public/img/poweredby.png
Binary file not shown.
Binary file removed public/img/poweredbywhite.png
Binary file not shown.
Binary file removed public/img/poweredbywhiteold.png
Binary file not shown.
Binary file modified public/img/twitter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 17 additions & 15 deletions public/js/api-status.js
@@ -1,18 +1,20 @@
$.ajax({
url: 'https://randomuser.me/api/?randomapi',
dataType: 'json',
success: function(data) {
(function() {
if (document.title.indexOf('home') !== -1) {
var result = pegasus('https://randomuser.me/api/?randomapi');
result.then(function(data) {
error(data);
},function (data) {
error(data);
});

var error = function(data) {
if (data['error']) {
var _errorBanner = document.createElement('div');
_errorBanner.className = 'alert';
_errorBanner.innerHTML = 'API Status: OFFLINE. Please tweet us <a href="https://twitter.com/randomapi">@randomapi</a> if you are seeing this message.';
$('body').prepend(_errorBanner);
_errorBanner.className = 'alert';
_errorBanner.innerHTML = 'API Status: OFFLINE. Please tweet us <a href="https://twitter.com/randomapi">@randomapi</a> if you are seeing this message.';
var body = document.getElementsByTagName('body')[0];
body.insertBefore(_errorBanner, body.firstChild);
}
},
error: function(data) {
var _errorBanner = document.createElement('div');
_errorBanner.className = 'alert';
_errorBanner.innerHTML = 'API Status: OFFLINE. Please tweet us <a href="https://twitter.com/randomapi">@randomapi</a> if you are seeing this message.';
$('body').prepend(_errorBanner);
}
});
};
}
})();
45 changes: 45 additions & 0 deletions public/js/charts.js
@@ -0,0 +1,45 @@
(function() {
domready(function() {
if (window.location.href.indexOf('stats') !== -1) {
new Highcharts.Chart({
chart: {
renderTo: document.getElementById("charts")
},
title: {
text: '30 days',
x: -20 //center
},
xAxis: {
title: {
text: 'Date'
},
categories: ["3.07", "3.08", "3.09", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "3.16", "3.17", "3.18", "3.19", "3.20", "3.21", "3.22", "3.23", "3.24", "3.25", "3.26", "3.27", "3.28", "3.29", "3.30", "3.31", "4.01", "4.02", "4.03", "4.04"]},
yAxis: [{
min: 0,
title: {
text: 'Values'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
}],
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Total',
data: [1279674, 1372594, 2946605, 2621451, 1972811, 1649625, 2038890, 1774476, 1735823, 1709348, 1406762, 1633831, 2662855, 1589869, 1599016, 1003070, 944028, 884739, 4232470, 6826524, 2572823, 5721567, 2655161, 788038, 633055, 566234, 254669, 290714, 371588],
color: '#0F0'
}],
tooltip: {
shared: true
}
});
}
});
})();
99 changes: 56 additions & 43 deletions public/js/create_user.js
@@ -1,52 +1,65 @@
$(document).ready(function(){
(function() {
domready(function() {
if (document.title.indexOf('Home') !== -1) {
getNewUser();

api_url = 'https://randomuser.me/api/0.4/?randomapi';
var liList = Array.prototype.slice.call(document.getElementById("values_list").getElementsByTagName('li'));
liList.forEach(function(el) {
el.addEventListener('mouseover', function() {
liList.forEach(function(el) {
el.className = el.className.replace(/\bactive\b/,'');
});
var item = this;
item.className += ' active';

getNewUser(api_url);

$('#values_list li').hover(function(){
$('#values_list li').removeClass('active');
var item = $(this);
item.addClass('active');
$('#user_title').html(item.attr('data-title'));
$('#user_value').html(item.attr('data-value'));
document.getElementById('user_title').innerHTML = item.getAttribute('data-title');
document.getElementById('user_value').innerHTML = item.getAttribute('data-value');

if(item.attr('data-caps')){
$('#user_value').css({'text-transform': 'lowercase'});
if(item.getAttribute('data-caps')){
document.getElementById('user_value').style.textTransform = "lowercase";
} else {
$('#user_value').css({'text-transform': 'capitalize'});
document.getElementById('user_value').style.textTransform = "capitalize";
}
});
});

function getNewUser(location){
$.ajax({
url: location,
dataType: 'json',
success: function(data){
if(!data['error']){
var user = data.results[0].user;
// Update to SSL picture
user.picture = user.picture.replace('http://api.', 'https://');
user.picture = user.picture.replace('.me/', '.me/api/');
});
});
}
});
})();

function getNewUser(){
var result = pegasus('https://randomuser.me/api/0.4/?randomapi');

result.then(function(data) {
if(!data['error']){
var user = data.results[0].user;
// Update to SSL picture
user.picture = user.picture.replace('http://api.', 'https://');
user.picture = user.picture.replace('.me/', '.me/api/');

// Assign Data
document.getElementById('user_photo').getElementsByTagName('img')[0].src = user.picture;

// Assign Data
$('#user_photo img').attr('src', user.picture.replace('portraits/', 'portraits/'));

$('li[data-label="name"]').attr('data-value', user.name.first+' '+user.name.last);
$('#user_value').html(user.name.first+' '+user.name.last);

$('li[data-label="email"]').attr('data-value', user.email);

var birthday = new Date(user.dob*1000);
$('li[data-label="birthday"]').attr('data-value', birthday.getMonth()+1+'/'+(birthday.getDay()+1)+'/19'+birthday.getYear());

$('li[data-label="location"]').attr('data-value', user.location.street);
$('li[data-label="phone"]').attr('data-value', user.cell);
$('li[data-label="pass"]').attr('data-value', user.password);
} else {
// Error
}
setData('name', user.name.first+' '+user.name.last);

document.getElementById('user_value').innerHTML = user.name.first+' '+user.name.last;

setData('email', user.email);

var birthday = new Date(user.dob*1000);
setData('birthday', birthday.getMonth()+1+'/'+(birthday.getDay()+1)+'/19'+birthday.getYear());
setData('location', user.location.street);
setData('phone', user.cell);
setData('pass', user.password);
} else {
// Error
}
});

function setData(label, value) {
var liList = Array.prototype.slice.call(document.getElementsByTagName('li'));

liList.find(function(el) {
return el.getAttribute('data-label') === label;
}).setAttribute('data-value', value);
}
}

0 comments on commit 82b9a12

Please sign in to comment.