pinout.vvzero.com/tools/micropin.jquery.js

66 lines
2.3 KiB
JavaScript
Raw Normal View History

2015-05-07 19:35:27 +08:00
$(document).ready(function(){
$('a').each(function(idx, obj){
var href = $(obj).attr('href');
if( href.indexOf('http://pi.gadgetoid.com/pinout/pin') == 0){
var pin = parseInt(href.replace('http://pi.gadgetoid.com/pinout/pin','').split('_')[0]);
console.log(href,pin);
$(obj).data('pin', pin).css({position:'relative'});
$(obj).hover(
function(){$(this).find('.pinout_popup').slideDown(100);},
function(){$(this).find('.pinout_popup').slideUp(100);}
);
var pinout_popup = $('<div>')
.css({
position: 'absolute',
width: 24,
overflow: 'hidden',
marginLeft: -12,
left: '50%',
top: $(this).css('line-height'),
background: '#073642',
padding: 2,
border: '5px solid #5F8645',
borderLeft: '10px solid #5F8645'
})
.addClass('pinout_popup')
.hide();
for( var x = 1; x <= 40; x++ ){
var bgcol = '#859900';
if( $.inArray(x, [1,8,10,17]) > -1 ){
bgcol = '#B58900';
}
else if( $.inArray(x, [3,5,27,28]) > -1 ){
bgcol = '#268BD2';
}
else if( $.inArray(x, [2, 4]) > -1 ){
bgcol = '#DC322F';
}
else if( $.inArray(x, [19,21,23,24,26,35,38,40]) > -1 ){
bgcol = '#D33682';
}
else if( $.inArray(x, [6,9,14,20,25,30,34,39]) > -1 ){
bgcol = '#002B36';
}
$('<div>')
.css({
float: 'left',
width: 6,
height: 6,
margin: 2,
background: x==pin ? '#FFFFFF' : bgcol,
borderRadius:x==1 ? 0 : 4,
border: '1px solid #FFFFFF'
})
.appendTo(pinout_popup);
}
$(obj).append(pinout_popup);
}
});
});