-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
130 lines (119 loc) · 4.91 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*jslint browser: true*/
/*global $, jQuery, console */
(function () {
"use strict";
var kardans = {
init: function () {
this.setupNav();
this.setupCover();
// this.setupTweets();
// this.setupBookmarks();
this.logForTheCurious();
},
logForTheCurious: function () {
var quotes = [
'We are what we repeatedly do. Excellence, then, is not an act, but a habit. / Aristotele',
'It is the mark of an educated mind to be able to entertain a thought without accepting it. / Aristoteles',
'I\'ve suffered a great many catastrophies in my life. Most of them never happened. / Mark Twain',
'Be a yardstick of quality. Some people aren\'t used to an environment where excellence is expected. / Steve Jobs',
'Stay hungry, stay foolish. / Steve Jobs',
'Fortune favours the brave. / Terence',
'Sow a thought and you reap an action; sow an act and you reap a habit; sow a habit and you reap a character; sow a character and you reap a destiny. / Ralph Waldo Emerson'
];
console.log(quotes[Math.floor(Math.random() * quotes.length)]);
},
setupNav: function () {
$("nav ul li a").hover(function () {
$(this).animate({paddingLeft: '48px', marginRight: '0px'}, 'fast');
}, function () {
$(this).animate({paddingLeft: '24px', marginRight: '24px'}, 'fast');
});
},
setupCover: function () {
$.get("e.jpeg", function (data) {
$('#wrap').removeAttr("style");
$('#wrap').css({
'background': 'url(e.jpeg) no-repeat center center fixed',
'-webkit-background-size': 'cover',
'-moz-background-size': 'cover',
'-o-background-size': 'cover',
'background-size': 'cover'
});
$('#wrap').attr('id', '#wrap2');
$('body').css({
'background': 'url(e.jpeg) no-repeat center center fixed',
'-webkit-background-size': 'cover',
'-moz-background-size': 'cover',
'-o-background-size': 'cover',
'background-size': 'cover'
});
// $('#wrap').removeAttr('style');
});
$('#wrap').removeAttr('style');
$('#wrap').removeClass('wrap');
$('#wrap').addClass('wrap2');
},
setupTweets: function () {
this.getTweets(function (tweets) {
var i, j;
if (tweets.length !== 0) {
$('#noise').show();
for (i = 0, j = tweets.length; i < j; i += 1) {
$('#the_noice').append('<a href=\"' + tweets[i].url + '">' + tweets[i].text + '</a> ');
}
}
});
},
getTweets: function (callback) {
$.ajax({
url: 'http://search.twitter.com/search.json?q=from:kardan',
jsonp: 'callback',
dataType: 'jsonp',
success: function (data) {
var items = [];
$.each(data.results, function (key, val) {
items.push({
'id': val.id,
'text': val.text,
'date': val.created_at,
'url': 'http://twitter.com/' + val.from_user + '/status/' + val.id + '/'
});
});
callback(items);
}
});
},
setupBookmarks: function () {
this.getBookmarks(function (bookmarks) {
var i, j;
if (bookmarks.length !== 0) {
$('#noise').show();
for (i = 0, j = bookmarks.length; i < j; i += 1) {
$('#the_noice').append('<a href=\"' + bookmarks[i].url + '">' + bookmarks[i].title + '</a> ');
}
}
});
},
getBookmarks: function (callback) {
$.ajax({
url: 'http://feeds.pinboard.in/json/u:kardan?count=5',
jsonp: 'cb',
dataType: 'jsonp',
success: function (data) {
var items = [];
$.each(data, function (key, val) {
items.push({
'title': val.d,
'date': val.dt,
'url': val.u
});
});
callback(items);
}
});
}
};
$(document).ready(function () {
kardans.init();
});
}());