Skip to content

Commit bd1a75f

Browse files
committed
fully functional on home and get_started pages, including reloading social icons on page reload.
1 parent df9e610 commit bd1a75f

File tree

2 files changed

+127
-98
lines changed

2 files changed

+127
-98
lines changed

war/index.html

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ <h1>Aiming for the best.</h1>
207207
<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
208208
<!--div id="tip"></div>-->
209209
</div><!-- /.carousel -->
210+
211+
212+
<!-- ======== social links ========== -->
210213
<div class="bs-docs-social">
211214
<div class="container">
212215
<ul class="bs-docs-social-buttons">
@@ -235,10 +238,12 @@ <h1>Aiming for the best.</h1>
235238
</ul>
236239
</div>
237240
</div>
238-
<div>
239241

240-
<div class="container">
242+
241243

244+
<!-- ======== main body ========== -->
245+
<div>
246+
<div class="container">
242247
<div class="marketing">
243248
<h1>Enter the worm.</h1>
244249
<p class="marketing-byline">
@@ -256,18 +261,6 @@ <h2>Latest news</h2>
256261
<h2>Social stream</h2>
257262
<a class="twitter-timeline" href="https://twitter.com/OpenWorm" data-widget-id="293717776768569344">Tweets
258263
by @OpenWorm</a>
259-
<script>
260-
!function (d, s, id) {
261-
var js, fjs = d.getElementsByTagName(s)[0];
262-
if (!d.getElementById(id)) {
263-
js = d.createElement(s);
264-
js.id = id;
265-
js.src = "//platform.twitter.com/widgets.js";
266-
fjs.parentNode.insertBefore(js, fjs);
267-
}
268-
}(document, "script", "twitter-wjs");
269-
</script>
270-
271264
</div>
272265
</div>
273266
</div>
@@ -413,9 +406,9 @@ <h1>Meet with us</h1> <br>
413406
<!-- Le javascript
414407
================================================== -->
415408
<!-- Placed at the end of the document so the pages load faster -->
416-
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
409+
<script src="http://platform.twitter.com/widgets.js"></script>
417410
<script src="js/bootstrap.js"></script>
418-
<script type="text/javascript" src="js/jquery.parss.uncompressed.js"></script>
411+
<script src="js/jquery.parss.uncompressed.js"></script>
419412

420413
<!-- <script src="js/jquery.colorbox-min.js"></script>-->
421414
<script src="js/main.js"></script>
@@ -427,39 +420,29 @@ <h1>Meet with us</h1> <br>
427420
$.get('footer-content.html', function(data) {
428421
$('#foot-nav').html(data);
429422
});
430-
</script>
431-
432-
<script type="text/javascript">
433-
var _gaq = _gaq || [];
434-
_gaq.push(['_setAccount', 'UA-29668455-1']);
435-
_gaq.push(['_trackPageview']);
436-
437-
function loadGoogle() {
438-
var ga = document.createElement('script');
439-
ga.type = 'text/javascript';
440-
ga.async = true;
441-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
442-
'.google-analytics.com/ga.js';
443-
var s = document.getElementsByTagName('script')[0];
444-
s.parentNode.insertBefore(ga, s);
445-
}
446423

447-
function loadFacebook() {
448-
var js, fjs = document.getElementsByTagName('script')[0];
449-
if (document.getElementById('facebook-jssdk')) return;
450-
js = document.createElement('script');
451-
js.id = 'facebook-jssdk';
452-
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
453-
fjs.parentNode.insertBefore(js, fjs);
454-
}
455-
456424
$(document).on('pjax:complete', function() {
457425
// do stuff when pjax finished
458-
alert('pjaxed that page!');
459-
loadGoogle();
460-
loadFacebook();
426+
if (window.location.pathname === '/index.html') {
427+
reloadSocial();
428+
$("#news-feed").PaRSS("http://openworm.tumblr.com/rss", // url to the feed
429+
6, // number of items to retrieve
430+
"M jS Y, g:i a", // date format
431+
false, // include descriptions
432+
function() {
433+
// don't do anything
434+
})
435+
}
461436
})
462437

438+
$(window).load(function () {
439+
// this works:
440+
// alert('inital load!');
441+
loadGooglePlus();
442+
loadGoogleAnalytics();
443+
loadFacebook();
444+
loadTwitterWidget();
445+
})
463446
</script>
464447
</body>
465448

war/js/main.js

Lines changed: 100 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ $(function() {
22
var $window = $(window)
33

44
$("#news-feed").PaRSS("http://openworm.tumblr.com/rss", // url to the feed
5-
6, // number of items to retrieve
6-
"M jS Y, g:i a", // date format
7-
false, // include descriptions
8-
function() {
9-
/*
10-
* optional callback function performed after list is appended to the
11-
* page
12-
*/
13-
});
5+
6, // number of items to retrieve
6+
"M jS Y, g:i a", // date format
7+
false, // include descriptions
8+
function() {
9+
/*
10+
* optional callback function performed after list is appended to the
11+
* page
12+
*/
13+
});
1414

1515
// side bar
1616
$('.bs-docs-sidenav').affix({
@@ -31,27 +31,27 @@ $(function() {
3131
});
3232

3333
$('.minilogo').tooltip();
34-
34+
3535
$(".donation").click(function(){
3636
$(".donation").removeClass("active");
3737
$("#otherAmount").removeClass("active");
3838
$("#amountSent").attr("value",$(this).html().replace("$",""));
3939
$(this).addClass("active");
4040
});
41-
41+
4242
$(".other").click(function(){
4343
$("#otherAmount").addClass("active");
4444
$("#amountSent").attr("value",$(this).val());
4545
$("#otherAmount").focus();
4646
});
47-
47+
4848
$("#otherAmount").click(function(){
4949
$("#otherAmount").addClass("active");
5050
$(".donation").removeClass("active");
5151
$("#amountSent").attr("value",$(this).val());
5252
$(".other").addClass("active");
5353
});
54-
54+
5555
$("#otherAmount").on("input",function(){
5656
$("#amountSent").attr("value",$(this).val());
5757
});
@@ -66,17 +66,17 @@ $(function() {
6666
else if(amount=="25"){
6767
$("#d25").click();
6868
}
69-
else if(amount=="50"){
70-
$("#d50").click();
71-
}
72-
else if(amount=="100"){
73-
$("#d100").click();
74-
}
75-
else{
76-
$(".other").click();
77-
$("#otherAmount").val(amount);
78-
$("#amountSent").attr("value",amount);
79-
}
69+
else if(amount=="50"){
70+
$("#d50").click();
71+
}
72+
else if(amount=="100"){
73+
$("#d100").click();
74+
}
75+
else{
76+
$(".other").click();
77+
$("#otherAmount").val(amount);
78+
$("#amountSent").attr("value",amount);
79+
}
8080

8181
});
8282

@@ -100,15 +100,6 @@ window.___gcfg = {
100100
lang: 'en-GB'
101101
};
102102

103-
(function() {
104-
var po = document.createElement('script');
105-
po.type = 'text/javascript';
106-
po.async = true;
107-
po.src = 'https://apis.google.com/js/plusone.js';
108-
var s = document.getElementsByTagName('script')[0];
109-
s.parentNode.insertBefore(po, s);
110-
})();
111-
112103
function donate(){
113104
var amount = $(".donation.active");
114105
if(amount.hasClass("other")){
@@ -120,31 +111,86 @@ function donate(){
120111
window.location="\donate.html?amount="+amount;
121112
}
122113

123-
// countdown time to kickstarter
124-
function showRemainingDays(end) {
125-
var _second = 1000;
126-
var _minute = _second * 60;
127-
var _hour = _minute * 60;
128-
var _day = _hour * 24;
129-
130-
var now = new Date();
131-
var distance = end - now;
132-
if (distance < 0) {
133-
document.getElementById('countdown').innerHTML = 'EXPIRED!';
134-
return;
135-
}
136-
var days = Math.floor(distance / _day);
137-
var hours = Math.floor((distance % _day) / _hour);
138-
var minutes = Math.floor((distance % _hour) / _minute);
139-
var seconds = Math.floor((distance % _minute) / _second);
140-
141-
document.getElementById('countdown').innerHTML = days + ' days';
142-
}
143-
144114
function detectmob() {
145115
if (window.innerWidth <= 800 && window.innerHeight <= 600) {
146116
return true;
147117
} else {
148118
return false;
149119
}
150120
}
121+
122+
var _gaq = _gaq || [];
123+
_gaq.push(['_setAccount', 'UA-29668455-1']);
124+
_gaq.push(['_trackPageview']);
125+
126+
127+
128+
129+
function loadGoogleAnalytics() {
130+
var ga = document.createElement('script');
131+
ga.type = 'text/javascript';
132+
ga.id = 'googleWidget';
133+
ga.async = true;
134+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
135+
'.google-analytics.com/ga.js';
136+
var s = document.getElementsByTagName('script')[0];
137+
s.parentNode.insertBefore(ga, s);
138+
}
139+
140+
function loadFacebook() {
141+
var js, fjs = document.getElementsByTagName('script')[0];
142+
if (document.getElementById('facebook-jssdk')) return;
143+
js = document.createElement('script');
144+
//js.async = true;
145+
js.id = 'facebook-jssdk';
146+
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
147+
fjs.parentNode.insertBefore(js, fjs);
148+
}
149+
150+
function loadTwitterWidget () {
151+
var js, fjs = document.getElementsByTagName("script")[0];
152+
if (document.getElementById("twitter-wjs")) return;
153+
js = document.createElement("script");
154+
js.async = true;
155+
js.id = "twitter-wjs";
156+
js.src = "//platform.twitter.com/widgets.js";
157+
fjs.parentNode.insertBefore(js, fjs);
158+
}
159+
160+
161+
function loadGooglePlus() {
162+
var po = document.createElement('script');
163+
po.type = 'text/javascript';
164+
po.async = true;
165+
po.src = 'https://apis.google.com/js/plusone.js';
166+
var s = document.getElementsByTagName('script')[0];
167+
s.parentNode.insertBefore(po, s);
168+
}
169+
170+
171+
function reloadSocial() {
172+
// http://www.blackfishweb.com/blog/asynchronously-loading-twitter-google-facebook-and-linkedin-buttons-and-widgets-ajax-bonus
173+
174+
// Twitter widget
175+
if (typeof (twttr) != 'undefined') {
176+
twttr.widgets.load();
177+
} else {
178+
$.getScript('//platform.twitter.com/widgets.js');
179+
}
180+
181+
// Facebook
182+
if (typeof (FB) != 'undefined') {
183+
delete FB;
184+
$('#facebook-jssdk').remove();
185+
$.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
186+
FB.init({ status: true, cookie: true, xfbml: true });
187+
})
188+
}
189+
190+
// Google - Note that the google button will not show if you are opening the page from disk
191+
// it needs to be http(s)
192+
if (typeof (gapi) != 'undefined') {
193+
delete gapi;
194+
$.getScript('//apis.google.com/js/plusone.js');
195+
}
196+
}

0 commit comments

Comments
 (0)