Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/utopa (29-Jul @ 20:43)
Syntax Highlighted 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);
- }
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);
}