r61136 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61135‎ | r61136 | r61137 >
Date:17:40, 16 January 2010
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: JavaScript cleanup
Modified paths:
  • /trunk/extensions/SocialProfile/UserBoard/BoardBlast.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGifts.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfilePage.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserBoard/BoardBlast.js
@@ -1,24 +1,24 @@
2 -function toggle_user( user_id ){
3 - if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-selected' ) ){
 2+function toggle_user( user_id ) {
 3+ if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-selected' ) ) {
44 YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-friend-selected', 'blast-friend-unselected' );
5 - } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-unselected' ) ){
 5+ } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-unselected' ) ) {
66 YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-friend-unselected', 'blast-friend-selected' );
77 }
88
9 - if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-selected' ) ){
 9+ if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-selected' ) ) {
1010 YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-foe-selected', 'blast-foe-unselected' );
11 - } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-unselected' ) ){
 11+ } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-unselected' ) ) {
1212 YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-foe-selected', 'blast-foe-unselected' );
1313 }
1414 }
1515
16 -function toggle_type( method, on, off ){
 16+function toggle_type( method, on, off ) {
1717 list = YAHOO.util.Dom.getElementsByClassName( ( ( method == 1 ) ? off : on ), 'div', 'blast-friends-list' );
1818
19 - for( x = 0; x <= list.length-1; x++ ){
 19+ for( x = 0; x <= list.length - 1; x++ ) {
2020 el = list[x];
21 - if( YAHOO.util.Dom.hasClass( el, on ) || YAHOO.util.Dom.hasClass( el, off ) ){
22 - if( method == 1 ){
 21+ if( YAHOO.util.Dom.hasClass( el, on ) || YAHOO.util.Dom.hasClass( el, off ) ) {
 22+ if( method == 1 ) {
2323 YAHOO.util.Dom.replaceClass( el, off, on );
2424 } else {
2525 YAHOO.util.Dom.replaceClass( el, on, off );
@@ -27,34 +27,35 @@
2828 }
2929 }
3030
31 -function toggle_friends( method ){
 31+function toggle_friends( method ) {
3232 toggle_type( method, 'blast-friend-selected', 'blast-friend-unselected' );
3333 }
3434
35 -function toggle_foes( method ){
 35+function toggle_foes( method ) {
3636 toggle_type( method, 'blast-foe-selected', 'blast-foe-unselected' );
3737 }
3838
39 -function select_all(){
 39+function select_all() {
4040 toggle_friends( 1 );
4141 toggle_foes( 1 );
4242 }
43 -function unselect_all(){
 43+function unselect_all() {
4444 toggle_friends( 0 );
4545 toggle_foes( 0 );
4646 }
4747
4848 submitted = 0;
49 -function send_messages(){
50 - if( submitted == 1 )
 49+function send_messages() {
 50+ if( submitted == 1 ) {
5151 return 0;
 52+ }
5253
53 - submitted = 1
 54+ submitted = 1;
5455 selected = 0;
5556 user_ids_to = '';
5657
5758 list = YAHOO.util.Dom.getElementsByClassName( 'blast-friend-selected', 'div', 'blast-friends-list' );
58 - for( x = 0; x <= list.length-1; x++ ){
 59+ for( x = 0; x <= list.length - 1; x++ ) {
5960 el = list[x];
6061 selected++;
6162 user_id = el.id.replace( 'user-', '' );
@@ -62,28 +63,28 @@
6364 }
6465
6566 list = YAHOO.util.Dom.getElementsByClassName( 'blast-foe-selected', 'div', 'blast-friends-list' );
66 - for( x = 0; x <= list.length-1; x++ ){
 67+ for( x = 0; x <= list.length - 1; x++ ) {
6768 el = list[x];
6869 selected++;
6970 user_id = el.id.replace( 'user-', '' );
7071 user_ids_to += ( ( user_ids_to ) ? ',' : '' ) + user_id;
7172 }
7273
73 - if( selected == 0 ){
74 - alert('Please select at least one person');
 74+ if( selected === 0 ) {
 75+ alert( 'Please select at least one person' );
7576 submitted = 0;
7677 return 0;
7778 }
7879
79 - if( !document.getElementById('message').value ){
80 - alert('Please enter a message');
 80+ if( !document.getElementById('message').value ) {
 81+ alert( 'Please enter a message' );
8182 submitted = 0;
8283 return 0;
8384 }
8485
8586 document.getElementById('ids').value = user_ids_to;
8687
87 - document.blast.message.style.color = "#ccc";
 88+ document.blast.message.style.color = '#ccc';
8889 document.blast.message.readOnly = true;
8990 document.getElementById('blast-friends-list').innerHTML = 'Sending messages...';
9091 document.blast.submit();
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.js
@@ -34,8 +34,8 @@
3535 var oldHtml = '';
3636
3737 function showUploadFrame() {
38 - document.getElementById( 'upload-container' ).style['display'] = 'block';
39 - document.getElementById( 'upload-container' ).style['visibility'] = 'visible';
 38+ document.getElementById( 'upload-container' ).style.display = 'block';
 39+ document.getElementById( 'upload-container' ).style.visibility = 'visible';
4040 }
4141
4242 function uploadError( message ) {
@@ -43,33 +43,34 @@
4444 document.getElementById('upload-frame-errors').innerHTML = message;
4545 document.getElementById('imageUpload-frame').src = 'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75';
4646
47 - document.getElementById( 'upload-container' ).style['display'] = 'block';
48 - document.getElementById( 'upload-container' ).style['visibility'] = 'visible';
 47+ document.getElementById( 'upload-container' ).style.display = 'block';
 48+ document.getElementById( 'upload-container' ).style.visibility = 'visible';
4949 }
5050
5151 function textError( message ) {
5252 document.getElementById( 'upload-frame-errors' ).innerHTML = message;
53 - document.getElementById( 'upload-frame-errors' ).style['display'] = 'block';
54 - document.getElementById( 'upload-frame-errors' ).style['visibility'] = 'visible';
 53+ document.getElementById( 'upload-frame-errors' ).style.display = 'block';
 54+ document.getElementById( 'upload-frame-errors' ).style.visibility = 'visible';
5555 }
5656
5757 function completeImageUpload() {
58 - document.getElementById( 'upload-frame-errors' ).style['display'] = 'none';
59 - document.getElementById( 'upload-frame-errors' ).style['visibility'] = 'hidden';
 58+ document.getElementById( 'upload-frame-errors' ).style.display = 'none';
 59+ document.getElementById( 'upload-frame-errors' ).style.visibility = 'hidden';
6060 document.getElementById('upload-frame-errors').innerHTML = '';
6161 oldHtml = document.getElementById('mini-gallery-' + replaceID).innerHTML;
6262
6363 for( x = 7; x > 0; x-- ) {
64 - document.getElementById('mini-gallery-' + (x) ).innerHTML = document.getElementById('mini-gallery-' + (x-1) ).innerHTML.replace('slideShowLink('+(x-1)+')','slideShowLink('+(x)+')');
 64+ document.getElementById('mini-gallery-' + ( x ) ).innerHTML =
 65+ document.getElementById('mini-gallery-' + ( x - 1 ) ).innerHTML.replace( 'slideShowLink(' + ( x - 1 ) + ')','slideShowLink(' + ( x ) + ')' );
6566 }
6667 document.getElementById('mini-gallery-0').innerHTML = '<a><img height="75" width="75" src="http://images.wikia.com/common/wikiany/images/ajax-loader-white.gif" alt="" /></a>';
6768
6869 if( document.getElementById( 'no-pictures-containers' ) ) {
69 - document.getElementById( 'no-pictures-containers' ).style['display'] = 'none';
70 - document.getElementById( 'no-pictures-containers' ).style['visibility'] = 'hidden';
 70+ document.getElementById( 'no-pictures-containers' ).style.display = 'none';
 71+ document.getElementById( 'no-pictures-containers' ).style.visibility = 'hidden';
7172 }
72 - document.getElementById( 'pictures-containers' ).style['display'] = 'block';
73 - document.getElementById( 'pictures-containers' ).style['visibility'] = 'visible';
 73+ document.getElementById( 'pictures-containers' ).style.display = 'block';
 74+ document.getElementById( 'pictures-containers' ).style.visibility = 'visible';
7475 }
7576
7677 function uploadComplete( imgSrc, imgName, imgDesc ) {
Index: trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js
@@ -3,13 +3,29 @@
44 * Displays the "State" dropdown menu if selected country is the United States
55 */
66 var countries = new Array();
7 -countries[0] = {country:"United States",name:"State",sections:["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","Washington, D.C.","West Virginia","Wisconsin","Wyoming"]}
 7+countries[0] = {
 8+ country: 'United States',
 9+ name: 'State',
 10+ sections: [
 11+ 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado',
 12+ 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho',
 13+ 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
 14+ 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
 15+ 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada',
 16+ 'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
 17+ 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon',
 18+ 'Pennsylvania', 'Puerto Rico', 'Rhode Island', 'South Carolina',
 19+ 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia',
 20+ 'Washington', 'Washington, D.C.', 'West Virginia', 'Wisconsin', 'Wyoming'
 21+ ]
 22+};
823
924 function displaySection( id, country, section ) {
1025 country_id = -1;
1126 for( x = 0; x <= countries.length-1; x++ ) {
12 - if( country == countries[x].country )
 27+ if( country == countries[x].country ) {
1328 country_id = x;
 29+ }
1430 }
1531
1632 section_select = '';
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js
@@ -2,11 +2,11 @@
33 * JavaScript for UserRelationship
44 * Used on Special:ViewRelationshipRequests
55 */
6 -function requestResponse( response, id ){
7 - document.getElementById( 'request_action_' + id ).style['display'] = 'none';
8 - document.getElementById( 'request_action_' + id ).style['visibility'] = 'hidden';
 6+function requestResponse( response, id ) {
 7+ document.getElementById( 'request_action_' + id ).style.display = 'none';
 8+ document.getElementById( 'request_action_' + id ).style.visibility = 'hidden';
99 sajax_request_type = 'POST';
10 - sajax_do_call( 'wfRelationshipRequestResponse', [ response, id ], function( request ){
 10+ sajax_do_call( 'wfRelationshipRequestResponse', [ response, id ], function( request ) {
1111 document.getElementById( 'request_action_' + id ).innerHTML = request.responseText;
1212 YAHOO.widget.Effects.Appear( 'request_action_' + id, { duration:2.0 } );
1313 } );
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.js
@@ -1,8 +1,8 @@
22 var selected_gift = 0;
33
4 -function selectGift( id ){
 4+function selectGift( id ) {
55 // Un-select previously selected gift
6 - if( selected_gift ){
 6+ if( selected_gift ) {
77 YAHOO.util.Dom.removeClass( 'give_gift_' + selected_gift, 'g-give-all-selected' );
88 }
99
@@ -12,16 +12,16 @@
1313 selected_gift = id;
1414 }
1515
16 -function highlightGift( id ){
 16+function highlightGift( id ) {
1717 YAHOO.util.Dom.addClass( 'give_gift_' + id, 'g-give-all-highlight' );
1818 }
1919
20 -function unHighlightGift( id ){
 20+function unHighlightGift( id ) {
2121 YAHOO.util.Dom.removeClass( 'give_gift_' + id, 'g-give-all-highlight' );
2222 }
2323
24 -function sendGift(){
25 - if( !selected_gift ){
 24+function sendGift() {
 25+ if( !selected_gift ) {
2626 alert( 'Please select a gift' );
2727 return false;
2828 }
@@ -29,7 +29,7 @@
3030 document.gift.submit();
3131 }
3232
33 -function chooseFriend( friend ){
 33+function chooseFriend( friend ) {
3434 // Now, this is a rather nasty hack since the original (commented out below) wouldn't work when $wgScriptPath was set
3535 //window.location = window.location + "&user=" + friend;
3636 window.location = wgServer + wgScript + '?title=Special:GiveGift' + '&user=' + friend;

Status & tagging log