-
Notifications
You must be signed in to change notification settings - Fork 3
/
pinout.js
85 lines (70 loc) · 2.46 KB
/
pinout.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
jQuery(document).ready(function(){
var History = window.History;
var homepage = jQuery('article.homepage').index();
var pincount = 40;
History.Adapter.bind(window,'statechange',function(){
var State = History.getState();
var url = State.url.replace('http://pi.gadgetoid.com','');
if( url == '/pinout' )
{
jQuery('h1').click();
}
else
{
jQuery('a[href="' + url + '"]').click();
}
})
window.prettyPrint&&prettyPrint();
jQuery('#pages').cycle({
timeout:0,
slideExpr:'article',
startingSlide:homepage,
speed:200,
containerResize:0
});
jQuery('.legend li a').on('click',function(e){
e.preventDefault();
jQuery('nav#gpio li').removeClass('legend active');
var title = jQuery(this).attr('title');
var url = jQuery(this).attr('href');
jQuery('span.default').show();
jQuery('span.alternate').hide();
var legend = jQuery(this).parent().attr('class');
var page = jQuery('article.' + legend).index();
var pins = [];
if( jQuery(this).parent().data('pins') ){
pins = jQuery(this).parent().data('pins').split(',');
}
jQuery('span.' + legend).show().parent().parent().addClass('legend').find('span.default').hide();
var x = pins.length;
while(x--){
jQuery('.pin' + pins[x]).addClass('legend');
}
jQuery('#pages').cycle(page);
History.pushState({legend:jQuery(this).attr('class'),url:jQuery(this).attr('href')}, 'Raspberry Pi Pinout - ' + title, url)
});
function showPage(object,offset){
jQuery('span.default').show();
jQuery('span.alternate').hide();
jQuery('nav#gpio li').removeClass('legend active');
jQuery('#pages').cycle(offset+object.parent().index());
object.parent().addClass('active');
title = 'Pin ' + object.find('span.default').text().replace(' ',': ');
History.pushState({pin:offset+object.parent().index(),url:object.attr('href')}, title, object.attr('href'));
}
jQuery('nav#gpio ul.bottom a').on('click',function(e){
e.preventDefault();showPage(jQuery(this),0);
});
jQuery('nav#gpio ul.top a').on('click',function(e){
e.preventDefault();showPage(jQuery(this),pincount/2);
});
jQuery('h1').on('click',function(){
jQuery('span.default').show();
jQuery('span.alternate').hide();
jQuery('nav#gpio li').removeClass('legend active');
jQuery('#pages').cycle(homepage);
History.pushState({pin:homepage,url:'http://pi.gadgetoid.com/pinout'}, 'Raspberry Pi Pinout', '/pinout');
});
url = window.location.href.replace('http://pi.gadgetoid.com/','/');
jQuery('a[href="' + url + '"]').click();
});