Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (98 sloc) 4.04 KB
<!DOCTYPE HTML>
<html>
<head>
<title>Wiki Loves Monuments Mobile Uploads</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="p.css">
</head>
<body>
<div id="display"></div>
<a href="https://github.com/jdlrobson/polaroiderizer">
<img style="position: absolute; top: 0; left: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png" alt="Fork me on GitHub">
</a>
<a class="googleplay" href="https://play.google.com/store/apps/details?id=org.wikipedia.wlm&feature=search_result">
<img src="android.png" alt="download android app">
</a>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="polaroiderizer.js"></script>
<script type="text/javascript">
(function() {
var button, i, countries,
$btn,
buttons = [
{
category: 'Category:Images_from_Wiki_Loves_Monuments_2012', label: '2012'
},
{
category: 'Category:Uploaded_with_Android_WLM_App', label: '2012 (mobile)'
},
{
category: 'Category:Images_from_Wiki_Loves_Monuments_2011',
label: '2011'
},
{
category: 'Category:Images_from_Wiki_Loves_Monuments_2010',
label: '2010'
}
];
$( '<ul id="buttons">' ).appendTo( document.body );
// countrie specific
countries = [ 'Andorra', 'Argentina', 'Austria', 'Belarus', 'Belgium', 'Canada', 'Chile', 'Colombia', 'the Czech Republic', 'Denmark', 'Estonia', 'France', 'Germany', 'Ghana', 'India', 'Israel', 'Italy', 'Kenya', 'Liechtenstein', 'Luxembourg', 'Mexico', 'the Netherlands', 'Norway', 'Panama', 'the Philippines', 'Poland', 'Romania', 'Russia', 'Serbia', 'South Africa', 'Spain', 'Sweden', 'Switzerland', 'Ukraine', 'the United States' ];
for ( i = 0; i < countries.length; i++ ) {
buttons.push( {
category: 'Category:Images_from_Wiki_Loves_Monuments_2012_in_' + countries[ i ].replace( ' ', '_'),
label: countries[ i ].replace( 'the ', '' )
} );
}
for( i = 0; i < buttons.length; i++ ) {
button = buttons[ i ];
$( '<button class="query">' ).
addClass( window.location.hash.substr( 1 ) === button.label ? 'active' : '' ).
data( 'data', {
iiurlwidth: '320px',
action: 'query',
gcmsort: 'timestamp', gcmdir: 'desc',
gcmlimit: 500, gcmtitle: button.category,
generator: 'categorymembers', format: 'json', prop: 'imageinfo', iiprop: 'url|user'
} ).data( 'options', {
dropDelay: 3000,
source: 'commons', rotationRange: 15
} ).text( button.label ).appendTo( $( '<li>' ).appendTo( '#buttons' ) );
}
$( '<button class="colorChanger">' ).text( 'toggle background' ).appendTo( $( '<li>' ).appendTo( '#buttons' ) );
}());
// setup click handler
$( '#buttons button.query' ).click( function() {
window.location.hash = $( this ).text();
$( '#buttons button.query' ).attr( 'disabled', false );
$( this ).attr( 'disabled', true );
var data = $( this ).data( 'data' );
var options = $( this ).data( 'options' );
polaroiderizer( $( '#display' ), data, options );
} );
$btn = $( '#buttons button.active' )[ 0 ] ? $( '#buttons button.active' ).eq( 0 ) : $( '#buttons button' ).eq( 0 );
$btn.trigger( 'click' );
var backgrounds = [ '', '#707070' ];
function pushRandomBackground() {
r = parseInt( Math.random() * 255, 10 );
b = parseInt( Math.random() * 255, 10 );
g = parseInt( Math.random() * 255, 10 );
backgrounds.push( 'rgb(' + r + ',' + g + ',' + b + ')' );
}
for( var i = 0; i < 10; i++ ) {
pushRandomBackground();
}
var currentBg = backgrounds.length - 1;
$( '#buttons button.colorChanger' ).click( function() {
currentBg = currentBg === backgrounds.length - 1 ? 0 : currentBg + 1;
var bg = backgrounds[ currentBg ];
var nextBg = backgrounds[ currentBg === backgrounds.length - 1 ? 0 : currentBg + 1 ];
$( '#display' ).css( 'background-color', bg );
$( this ).css( 'background-color', nextBg );
} );
$( '#buttons button.colorChanger' ).trigger( 'click' );
</script>
</body>
</html>