r109303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109302‎ | r109303 | r109304 >
Date:04:28, 18 January 2012
Author:yuvipanda
Status:ok (Comments)
Tags:
Comment:
Added geo-targetted sharing options
Modified paths:
  • /trunk/extensions/CongressLookup/SpecialCongressLookup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CongressLookup/SpecialCongressLookup.php
@@ -47,8 +47,6 @@
4848
4949 // Output beginning of the page
5050 $htmlOut .= <<<HTML
51 -
52 -
5351 <!DOCTYPE html>
5452 <html lang="en" dir="ltr" class="client-nojs">
5553 <head>
@@ -56,6 +54,52 @@
5755 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5856 <meta http-equiv="Content-Style-Type" content="text/css" />
5957 <meta name="generator" content="MediaWiki 1.18wmf1" />
 58+<script src="//geoiplookup.wikimedia.org/" type="text/javascript"></script>
 59+<script type="text/javascript" src="/mediawiki/load.php?lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20111213T185322Z"> </script>
 60+<script type="text/javascript">
 61+
 62+$(document).ready(function() {
 63+
 64+ var geoHasUsRep = [
 65+ 'US', // USA
 66+ 'PR', // Puerto Rico
 67+ 'VI', // Virgin Islands
 68+ 'MP', // Northern Mariana Islands
 69+ 'AS', // American Samoa
 70+ 'GU' // Guam
 71+ ];
 72+
 73+ // Fake country from get param
 74+ // Parse out GET params from the URL
 75+ var urlParams = {};
 76+ (function () {
 77+ var e,
 78+ a = /\+/g,
 79+ r = /([^&=]+)=?([^&]*)/g,
 80+ d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
 81+ q = window.location.search.substring(1);
 82+
 83+ while (e = r.exec(q)) {
 84+ urlParams[d(e[1])] = d(e[2]);
 85+ }
 86+ })();
 87+
 88+ // Defaults to the US, so if we can't determine location, show form
 89+ var country = 'US';
 90+ if ( urlParams.country ) {
 91+ country = urlParams.country;
 92+ } else if ( window.Geo && window.Geo.country ) {
 93+ country = window.Geo.country;
 94+ }
 95+
 96+ var hasUsRep = ( $.inArray( country, geoHasUsRep ) === 0 );
 97+ if( !hasUsRep ) {
 98+ $("#sopaShareOptions").show();
 99+ $("#sopaZipForm").hide();
 100+ }
 101+
 102+});
 103+</script>
60104 <style type="text/css">
61105 body {
62106 color: #dedede;
@@ -98,9 +142,9 @@
99143 }
100144 div#contacts {
101145 position: absolute;
102 - top: 50px;
103 - left: 50px;
104 - width: 320px;
 146+ top: 350px;
 147+ left: 110px;
 148+ width: 260px;
105149 background-color: #161616;
106150 padding: 5px 20px 20px 20px;
107151 filter:alpha(opacity=90);
@@ -144,6 +188,19 @@
145189 font-size: 1.2em;
146190 margin-bottom: 0.2em;
147191 }
 192+.sopaSocial {
 193+ float: left;
 194+ text-align: center;
 195+ margin-right: 12px;
 196+ margin-bttom: 3px;
 197+ font-size: small;
 198+}
 199+.sopaActionHead {
 200+ font-weight: bold
 201+}
 202+#sopaShareOptions {
 203+ display: none;
 204+}
148205 </style>
149206 </head>
150207 <body>
@@ -179,6 +236,7 @@
180237 $htmlOut .= $this->getCongressTables();
181238 } else {
182239 $htmlOut .= $this->getZipForm();
 240+ $htmlOut .= $this->getSocialMedia();
183241 }
184242
185243 // Output end of the page
@@ -300,8 +358,8 @@
301359 */
302360 private function getZipForm( $isError=false ) {
303361 $htmlOut = <<<HTML
 362+<div id="sopaZipForm" class="sopaActionDiv">
304363 <h4>Contact your representatives</h4>
305 -<div class="sopaActionDiv">
306364 HTML;
307365 if ( $isError ) {
308366 $htmlOut .= Html::element( 'p', array( 'class' => 'error' ), wfMsg( 'congresslookup-zipcode-error' ));
@@ -322,32 +380,56 @@
323381 * @return string HTML for social media links
324382 */
325383 private function getSocialMedia() {
 384+ // Update links here. Currently pointing to example.com
326385 $htmlOut = <<<HTML
327 -<div class="sopaActionDiv">
328 - <div>
329 - <div class="sopaSocial">
330 - <a style="text-decoration: none;" href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fexample.com%2F">
331 - <img width="33" height="33" src="//upload.wikimedia.org/wikipedia/commons/2/2a/WP_SOPA_sm_icon_facebook_dedede.png">
332 - </a>
333 - <br/>
334 - <a style="text-decoration: none;" href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fexample.com%2F">Facebook</a>
335 - </div>
336 - <div class="sopaSocial">
337 - <a style="text-decoration: none;" href="https://m.google.com/app/plus/x/?v=compose&content=Google%20Plus%20Post%20Here%20http%3A%2F%2Fexample.com%2F">
338 - <img width="33" height="33" src="//upload.wikimedia.org/wikipedia/commons/0/08/WP_SOPA_sm_icon_gplus_dedede.png">
339 - </a>
340 - <br/>
341 - <a style="text-decoration: none; color:" href="https://m.google.com/app/plus/x/?v=compose&content=Google%20Plus%20Post%20Here%20http%3A%2F%2Fexample.com%2F">Google+</a>
342 - </div>
343 - <div class="sopaSocial">
344 - <a style="text-decoration: none;" href="https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ftest.wikipedia.org%2Fwiki%2FMain_Page%3Fbanner%3Dblackout&text=Tweet%20here%20%23WikipediaBlackout%20http%3A%2F%2Fexample.com%2F">
345 - <img width="33" height="33" src="//upload.wikimedia.org/wikipedia/commons/4/45/WP_SOPA_sm_icon_twitter_dedede.png">
346 - </a>
347 - <br/>
348 - <a style="text-decoration: none;" href="https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ftest.wikipedia.org%2Fwiki%2FMain_Page%3Fbanner%3Dblackout&text=Tweet%20here%20%23WikipediaBlackout%20http%3A%2F%2Fexample.com%2F">Twitter</a>
349 - </div>
350 - </div>
351 - <div style="clear: both;"></div>
 386+<div id="sopaShareOptions" class="sopaActionDiv">
 387+<p class="sopaActionHead">Make your voice heard</p>
 388+ <div>
 389+ <div class="sopaSocial">
 390+ <a style="text-decoration: none;"
 391+ href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fexample.com%2F"
 392+ target="wpblackout_Facebook_share"><img width="33"
 393+ height="33"
 394+ src=
 395+ "//upload.wikimedia.org/wikipedia/commons/2/2a/WP_SOPA_sm_icon_facebook_dedede.png"></a><br>
 396+
 397+ <a style="text-decoration: none; color: rgb(222, 222, 222);"
 398+ href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fexample.com%2F"
 399+ target="wpblackout_Facebook_share">Facebook</a>
 400+ </div>
 401+
 402+ <div class="sopaSocial">
 403+ <a style="text-decoration: none;"
 404+ href=
 405+ "https://m.google.com/app/plus/x/?v=compose&amp;content=Google%20Plus%20Post%20Here%20http%3A%2F%2Fexample.com%2F">
 406+ <img width="33"
 407+ height="33"
 408+ src=
 409+ "//upload.wikimedia.org/wikipedia/commons/0/08/WP_SOPA_sm_icon_gplus_dedede.png"></a><br>
 410+
 411+ <a style="text-decoration: none;"
 412+ href=
 413+ "https://m.google.com/app/plus/x/?v=compose&amp;content=Google%20Plus%20Post%20Here%20http%3A%2F%2Fexample.com%2F">
 414+ Google+</a>
 415+ </div>
 416+
 417+ <div class="sopaSocial">
 418+ <a style="text-decoration: none;"
 419+ href=
 420+ "https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ftest.wikipedia.org%2Fwiki%2FMain_Page%3Fbanner%3Dblackout%26country%3DUK&amp;text=Tweet%20here%20%23WikipediaBlackout%20http%3A%2F%2Fexample.com%2F"
 421+ target="wpblackout_Twitter_share"><img width="33"
 422+ height="33"
 423+ src=
 424+ "//upload.wikimedia.org/wikipedia/commons/4/45/WP_SOPA_sm_icon_twitter_dedede.png"></a><br>
 425+
 426+ <a style="text-decoration: none; color: rgb(222, 222, 222);"
 427+ href=
 428+ "https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ftest.wikipedia.org%2Fwiki%2FMain_Page%3Fbanner%3Dblackout%26country%3DUK&amp;text=Tweet%20here%20%23WikipediaBlackout%20http%3A%2F%2Fexample.com%2F"
 429+ target="wpblackout_Twitter_share">Twitter</a>
 430+ </div>
 431+ </div>
 432+
 433+ <div style="clear: both;"></div>
352434 </div>
353435 HTML;
354436 return $htmlOut;

Comments

#Comment by Jpostlethwaite (talk | contribs)   04:32, 18 January 2012

The links need to be fixed on this. It all points to test.wikimedia.org

Status & tagging log