r51052 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51051‎ | r51052 | r51053 >
Date:09:07, 27 May 2009
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: rewrote some js bits to be less dependent on YUI
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfilePage.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.js
@@ -1,30 +1,30 @@
 2+/**
 3+ * JavaScript functions used by UserProfile
 4+ */
25 var posted = 0;
36 function send_message(){
4 - if($("message").value && !posted){
 7+ if( document.getElementById('message').value && !posted ){
58 posted = 1;
6 - var url = "index.php?action=ajax";
7 - var pars = 'rs=wfSendBoardMessage&rsargs[]=' + $("user_name_to").value +'&rsargs[]=' + encodeURIComponent($("message").value) + '&rsargs[]=' + $("message_type").value +'&rsargs[]=10'
8 - var callback = {
9 - success: function(originalRequest){
10 - $("user-page-board").innerHTML = originalRequest.responseText
 9+ sajax_request_type = 'POST';
 10+ sajax_do_call( 'wfSendBoardMessage', [
 11+ document.getElementById('user_name_to').value,
 12+ encodeURIComponent( document.getElementById('message').value ),
 13+ document.getElementById('message_type').value,
 14+ 10 ], function( originalRequest ){
 15+ document.getElementById('user-page-board').innerHTML = originalRequest.responseText;
1116 posted = 0;
12 - $("message").value='';
 17+ document.getElementById('message').value = '';
1318 }
14 - };
15 - var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, pars);
 19+ );
1620 }
1721 }
1822
19 -function delete_message(id){
20 - if(confirm('Are you sure you want to delete this message?')){
21 - var url = "index.php?action=ajax";
22 - var pars = 'rs=wfDeleteBoardMessage&rsargs[]=' + id
23 - var callback = {
24 - success: function(originalRequest){
25 - window.location.reload();
26 - }
27 - };
28 - var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, pars);
 23+function delete_message( id ){
 24+ if( confirm( 'Are you sure you want to delete this message?' ) ){
 25+ sajax_request_type = 'POST';
 26+ sajax_do_call( 'wfDeleteBoardMessage', [ id ], function( originalRequest ){
 27+ window.location.reload();
 28+ } );
2929 }
3030 }
3131
@@ -37,66 +37,65 @@
3838 new YAHOO.widget.Effects.Show('upload-container');
3939 }
4040
41 -function uploadError(message){
42 - $('mini-gallery-' + replaceID).innerHTML = oldHtml;
43 - $('upload-frame-errors').innerHTML = message;
44 - $('imageUpload-frame').src = 'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75';
 41+function uploadError( message ){
 42+ document.getElementById('mini-gallery-' + replaceID).innerHTML = oldHtml;
 43+ document.getElementById('upload-frame-errors').innerHTML = message;
 44+ document.getElementById('imageUpload-frame').src = 'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75';
4545
4646 new YAHOO.widget.Effects.Show('upload-container');
4747 }
4848
49 -function textError(message){
50 - $('upload-frame-errors').innerHTML = message;
 49+function textError( message ){
 50+ document.getElementById('upload-frame-errors').innerHTML = message;
5151 new YAHOO.widget.Effects.Show('upload-frame-errors');
5252 }
5353
5454 function completeImageUpload(){
5555 new YAHOO.widget.Effects.Hide('upload-frame-errors');
56 - $('upload-frame-errors').innerHTML = '';
57 - oldHtml = $('mini-gallery-' + replaceID).innerHTML;
 56+ document.getElementById('upload-frame-errors').innerHTML = '';
 57+ oldHtml = document.getElementById('mini-gallery-' + replaceID).innerHTML;
5858
59 - for(x=7;x>0;x--){
60 - $('mini-gallery-' + (x) ).innerHTML = $('mini-gallery-' + (x-1) ).innerHTML.replace('slideShowLink('+(x-1)+')','slideShowLink('+(x)+')')
 59+ for( x = 7; x > 0; x-- ){
 60+ document.getElementById('mini-gallery-' + (x) ).innerHTML = document.getElementById('mini-gallery-' + (x-1) ).innerHTML.replace('slideShowLink('+(x-1)+')','slideShowLink('+(x)+')');
6161 }
62 - $('mini-gallery-0').innerHTML ='<a><img height=\"75\" width=\"75\" src=\"http://images.wikia.com/common/wikiany/images/ajax-loader-white.gif\"/></a>';
 62+ 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>';
6363
6464 //new YAHOO.widget.Effects.Hide('mini-gallery-nopics');
65 - if($('no-pictures-containers')) {
66 - new YAHOO.widget.Effects.Hide('no-pictures-containers');
 65+ if( document.getElementById( 'no-pictures-containers' ) ) {
 66+ new YAHOO.widget.Effects.Hide( 'no-pictures-containers' );
6767 }
68 - new YAHOO.widget.Effects.Show('pictures-containers');
 68+ new YAHOO.widget.Effects.Show( 'pictures-containers' );
6969 }
7070
71 -function uploadComplete(imgSrc, imgName, imgDesc){
 71+function uploadComplete( imgSrc, imgName, imgDesc ){
7272 replaceSrc = imgSrc;
7373
74 - $('upload-frame-errors').innerHTML = '';
 74+ document.getElementById('upload-frame-errors').innerHTML = '';
7575
76 - //$('imageUpload-frame').onload = function(){
 76+ //document.getElementById('imageUpload-frame').onload = function(){
7777 var idOffset = -1 - numReplaces;
7878 //$D.addClass('mini-gallery-0','mini-gallery');
79 - //$('mini-gallery-0').innerHTML = '<a href=\"javascript:slideShowLink(' + idOffset + ')\">' + replaceSrc + '</a>';
80 - $('mini-gallery-0').innerHTML = '<a href=\"' + __image_prefix + imgName + '\">' + replaceSrc + '</a>';
 79+ //document.getElementById('mini-gallery-0').innerHTML = '<a href=\"javascript:slideShowLink(' + idOffset + ')\">' + replaceSrc + '</a>';
 80+ document.getElementById('mini-gallery-0').innerHTML = '<a href=\"' + __image_prefix + imgName + '\">' + replaceSrc + '</a>';
8181
8282 //replaceID = (replaceID == 7) ? 0 : (replaceID + 1);
8383 numReplaces += 1;
8484
8585 //}
86 - //if ($('imageUpload-frame').captureEvents) $('imageUpload-frame').captureEvents(Event.LOAD);
 86+ //if (document.getElementById('imageUpload-frame').captureEvents) document.getElementById('imageUpload-frame').captureEvents(Event.LOAD);
8787
88 - $('imageUpload-frame').src = 'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75&extra=' + numReplaces;
 88+ document.getElementById('imageUpload-frame').src = 'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75&extra=' + numReplaces;
8989 }
9090
91 -function slideShowLink(id){
 91+function slideShowLink( id ){
9292 //window.location = 'index.php?title=Special:UserSlideShow&user=' + __slideshow_user + '&picture=' + ( numReplaces + id );
9393 window.location = 'Image:' + id;
9494 }
9595
96 -function doHover(divID) {
 96+function doHover( divID ) {
9797 $El(divID).setStyle('backgroundColor', '#4B9AF6');
98 -
9998 }
10099
101 -function endHover(divID){
 100+function endHover( divID ){
102101 $El(divID).setStyle('backgroundColor', '');
103 -}
 102+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js
@@ -1,19 +1,27 @@
2 -var countries = new Array();
 2+/**
 3+ * JavaScript used on Special:UpdateProfile
 4+ * Displays the "State" dropdown menu if selected country is the United States
 5+ */
 6+var countries = new Array();
37 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"]}
48
5 -function displaySection(id,country,section){
 9+function displaySection( id, country, section ){
610 country_id = -1;
7 - for(x=0;x<=countries.length-1;x++){if(country==countries[x].country)country_id=x}
 11+ for( x = 0; x <= countries.length-1; x++ ){
 12+ if( country == countries[x].country )
 13+ country_id = x;
 14+ }
815
9 - section_select = "";
10 - if(countries[country_id]){
11 - $(id+"_label").innerHTML = countries[country_id].name
12 - section_select += "<select class='profile-form' name=" + id + " id=" + id + "><option></option>"
13 - for(x=0;x<=countries[country_id].sections.length-1;x++){
14 - section_select += "<option value=\"" + countries[country_id].sections[x] + "\"" + ((countries[country_id].sections[x]==section)?" selected":"") + ">" + countries[country_id].sections[x] + "</option>";
 16+ section_select = '';
 17+ if( countries[country_id] ){
 18+ document.getElementById( id + '_label' ).innerHTML = countries[country_id].name;
 19+ section_select += '<select class="profile-form" name="' + id + '" id="' + id + '"><option></option>';
 20+ for( x = 0; x <= countries[country_id].sections.length-1; x++ ){
 21+ section_select += '<option value="' + countries[country_id].sections[x] + '"' +
 22+ ( ( countries[country_id].sections[x] == section ) ? ' selected="selected"' : '' ) + '">' + countries[country_id].sections[x] + '</option>';
1523 }
16 - section_select += "</select>";
 24+ section_select += '</select>';
1725 }
1826
19 - $(id+"_form").innerHTML = section_select
20 -}
 27+ document.getElementById( id + '_form' ).innerHTML = section_select;
 28+}
\ No newline at end of file

Status & tagging log