Tip: Click lines to highlight, hold ctrl/cmd to multi-select

http://codedumper.com/utopa (29-Jul @ 20:43)

Syntax Highlighted Code

  1. function getWeatherFeed() {
  2.     $.ajax({
  3.         url: 'http://web18.accuweather.com/widget/weatheralarm/weatheralarm.asp?location=16801',
  4.         type: 'GET',
  5.         dataType: 'xml',
  6.         timeout: 2000,
  7.         beforeSend: function() {},
  8.         error: function(e) {
  9.             $('#widget').css('background', 'green');
  10.             $('#temp').html(e);
  11.         },
  12.         success: function(xml) {
  13.             currentCity = $(xml).find('city').text();
  14.             currentState = $(xml).find('state').text();
  15.             currentIcon = $(xml).find('weathericon:first').text();
  16.             currentTemp = $(xml).find('temp').text();
  17.             currentHigh = $(xml).find('high:first').text();
  18.             currentLow = $(xml).find('low:first').text();    
  19.             alertTotal = $(xml).find('alerttotal').text();
  20.             alertURL = $(xml).find('url').slice(1, 2).text();
  21.            
  22.             numAlarms = $(xml).find('numalarms').text();
  23.             numAlerts = $(xml).find('alerttotal').text();
  24.            
  25.             var i = 0;
  26.             $(xml).find('alarm').each(function() {
  27.                 alarmType[i] = $(this).find('type').text()
  28.                 alarmNumDays[i] = $(this).find('numdays').text();
  29.                 alarmDay[i] = new Array();
  30.                 alarmDayURL[i] = new Array();
  31.                 var z = 0;
  32.                 $(this).find('day').each(function() {
  33.                     alarmDay[i][z] = $(this).text();
  34.                     alarmDayURL[i][z] = $(this).attr('url');
  35.                     z++;
  36.                 });
  37.                 i++;
  38.             });
  39.            
  40.             var i = 0;
  41.             $(xml).find('alert').each(function() {
  42.                 alertURL = $(this).find('url').text();
  43.                 alertDescrip[i] = $(this).find('description').text();
  44.                 i++;
  45.             });
  46.                            
  47.             if (currentState.length > 2) {
  48.                 isInternational = true;
  49.             } else {
  50.                 isInternational = false;
  51.             }
  52.            
  53.             updateConditions();
  54.         }
  55.     });
  56. }
  57.  
  58. function updateConditions() {
  59.     $('#temp').html(currentTemp);
  60. }

Plain Code

function getWeatherFeed() {
    $.ajax({
        url: 'http://web18.accuweather.com/widget/weatheralarm/weatheralarm.asp?location=16801',
        type: 'GET',
        dataType: 'xml',
        timeout: 2000,
        beforeSend: function() {},
        error: function(e) {
            $('#widget').css('background', 'green');
            $('#temp').html(e);
        },
        success: function(xml) {
            currentCity = $(xml).find('city').text();
            currentState = $(xml).find('state').text();
            currentIcon = $(xml).find('weathericon:first').text();
            currentTemp = $(xml).find('temp').text();
            currentHigh = $(xml).find('high:first').text();
            currentLow = $(xml).find('low:first').text();    
            alertTotal = $(xml).find('alerttotal').text();
            alertURL = $(xml).find('url').slice(1, 2).text();
            
            numAlarms = $(xml).find('numalarms').text();
            numAlerts = $(xml).find('alerttotal').text();
            
            var i = 0;
            $(xml).find('alarm').each(function() {
                alarmType[i] = $(this).find('type').text()
                alarmNumDays[i] = $(this).find('numdays').text();
                alarmDay[i] = new Array();
                alarmDayURL[i] = new Array();
                var z = 0;
                $(this).find('day').each(function() {
                    alarmDay[i][z] = $(this).text();
                    alarmDayURL[i][z] = $(this).attr('url');
                    z++;
                });
                i++;
            });
            
            var i = 0;
            $(xml).find('alert').each(function() {
                alertURL = $(this).find('url').text();
                alertDescrip[i] = $(this).find('description').text();
                i++;
            });
                            
            if (currentState.length > 2) { 
                isInternational = true;
            } else { 
                isInternational = false; 
            }
            
            updateConditions();
        }
    });
}

function updateConditions() {
    $('#temp').html(currentTemp);
}

Permalink: http://codedumper.com/utopa