Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as HTML by 1stshift ( 15 years ago )
<link rel="stylesheet" href="Animation.css">    
 [removed]
<body
 <div id="sunray">
  <img src="Sunray.png" />
 </div>

<?xml version="1.0" encoding="UTF-8"?>

<html><head>

    <base href="Private/"/>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>



    <style>

 body {

     background-color: transparent;

     margin: 0;

     padding: 20px 0 0 0;

     height: 480px;

     width: 320px;
  
  background-image:url("/var/mobile/Library/SpringBoard/HomeBackground.jpg");
  
  background-size: 320px 480px;
            background-repeat:no-repeat;

 }

 </style>



[removed]

 [removed]





// The location field should be a relatively machine-legible string

// if using the default, Apple/AccuWeather parser (originally from Leopard's Weather.wdgt)

var locale = "85641" //e.g. 'North Attleboro, Massachusetts'|'Moscow, Russia'|'Ledyard, AT'|'London, UK'



// Set to 'false' if you'd prefer Farenheit

var isCelsius = false //true|false



// Use 'Real Feel' temperatures where possible, taking into account Wind Chill, Humidity etc.

var useRealFeel = false //true|false



/**/

//Enable Wallpaper and/or Lock Screen

var enableWallpaper = true; //true|false

var enableLockScreen = false; //true|false [Currently, it is suggested that the lockScreen is disabled.]



// Supplied styles are 'originalBubble', 'myopia', 'iconOnly' and 'split'.

// (Add your own to the CSS folder!)

var stylesheetWall = 'insp' //'originalBubble'|'myopia'|'iconOnly'|'split'|'oneLine'

var stylesheetLock = 'iconOnly' //See above.



// The only supplied icon set is 'klear'

// Images must follow the same naming schema as the 'springboard' set (borrowed from KWeather)

var iconSetWall = 'Icon' //'springboard'|'Lockscreen'

var iconExtWall = ".gif" //'.png'|.'gif' etc.

var iconSetLock = 'Icon' //See above.

var iconExtLock = '.gif' //See above.





/**/



// The other available source is 'yahooWeather' which for the 'locale'

// requires a US zip or location code (e.g. UKXX0085 or CHXX0008) from http://weather.yahoo.com

var source = 'yahooWeather' //'appleAccuweatherStolen'|'yahooWeather'



// Please endeavour to set this to a sensible value if you really must change it...

var updateInterval = 25 //Minutes

       



var postal;

var demoMode = false;

var enabled;



if (location.href.indexOf("LockBackground")  == -1){

 stylesheet = stylesheetWall;

 iconSet = iconSetWall;

 iconExt = iconExtWall;

 enabled = enableWallpaper;

}else{

 stylesheet = stylesheetLock;

 iconSet = iconSetLock;

 iconExt = iconExtLock;

 enabled = enableLockScreen;

}



if(enabled == true){

if(iconSet == null || iconSet == 'null' || iconSet == ""){

 var iconSet = stylesheet;

}



var headID = document.getElementsByTagName("head")[0];        

var styleNode = document.createElement('link');

styleNode.type = 'text/css';

styleNode.rel = 'stylesheet';

styleNode.href = 'Stylesheets/'+stylesheet+'.css';

headID.appendChild(styleNode);



var scriptNode = document.createElement('script');

scriptNode.type = 'text/javascript';

scriptNode.src = 'Sources/'+source+'.js';

headID.appendChild(scriptNode);

}



function onLoad(){

 if (enabled == true){ 

 if (demoMode == true){

  document.getElementById("weatherIcon").src="IconSets/"+iconSet+"/"+"cloudy1"+iconExt;

  document.getElementById("city").innerText="Somewhere";

  document.getElementById("desc").innerText="Partly Cloudy";

  document.getElementById("temp").innerText="100º";

  

 }else{ 

 document.getElementById("weatherIcon").src="IconSets/"+iconSet+"/"+"dunno"+iconExt;

 validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)

 }

 }else{

  document.getElementsByTagName("body")[0].innerText='';

 }

}



function convertTemp(num)

{

 if (isCelsius == true)

  return Math.round ((num - 32) * 5 / 9);

 else

  return num;

}



function setPostal(obj){

 

 if (obj.error == false){

  if(obj.cities.length > 0){

   postal = escape(obj.cities[0].zip).replace(/^%u/g, "%")

   document.getElementById("WeatherContainer").className = ""; 

   weatherRefresherTemp();

  }else{

   document.getElementById("city").innerText="Not Found";

   document.getElementById("WeatherContainer").className = "errorLocaleNotFound"; 

  }

 }else{

  document.getElementById("city").innerText=obj.errorString;

  document.getElementById("WeatherContainer").className = "errorLocaleValidate"; 

  setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));

 }

}



function dealWithWeather(obj){



 if (obj.error == false){

  document.getElementById("city").innerText=obj.city;

  document.getElementById("desc").innerText=obj.description.toLowerCase();

  

  if(useRealFeel == true){

   tempValue = convertTemp(obj.realFeel);

  }else{

   tempValue = convertTemp(obj.temp)

  }

  document.getElementById("temp").innerText=tempValue+"º";

  document.getElementById("weatherIcon").src="IconSets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt;

  document.getElementById("WeatherContainer").className = ""; 



  

 }else{

    document.getElementById("WeatherContainer").className = "errorWeatherDataFetch"; 

 }

 

 

}



function weatherRefresherTemp(){ //this is one of my nice works so far... dont forget to find me and thank me "ibnyaffa".

 fetchWeatherData(dealWithWeather,postal);

 setTimeout(weatherRefresherTemp, 60*1000*updateInterval);

}

//"ibnyaffa"

 

       

var MiniIcons =

[

       "thunder@2x",  //0 tornado

 "thunder@2x",  //1 tropical storm

 "thunder@2x",  //2 hurricane

 "thunder@2x",  //3 severe thunderstorms

 "thunder@2x",  //4 thunderstorms

 "rain-and-snow@2x",    //5    mixed rain and snow
 
 "rain-and-sleet@2x",     //6     mixed rain and sleet

 "rain-and-snow@2x",    //7    mixed snow and sleet

 "freezing-rain@2x",    //8    freezing drizzle

 "light-rain@2x",       //9     drizzle

 "freezing-rain@2x",    //10    freezing rain

 "light-rain@2x",       //11    showers

 "rain@2x", //12 showers

 "flurries@2x",  //13 snow flurries

 "snow@2x", //14 light snow showers

 "heavy-snow@2x",       //15    blowing snow

 "snow@2x",   //16   snow

 "hail@2x", //17 hail

 "sleet@2x",    //18    sleet

 "haze@2x", //19 dust

 "fog@2x",  //20 foggy

 "fog@2x",  //21 haze

 "fog@2x",  //22 smoky

 "strong-wind@2x",      //23    blustery

 "wind@2x",      //24    windy

 "cold@2x",     //25    cold

 "Cloudy@2x",        //26    cloudy 

 "cloudy moon@2x",      //27    mostly cloudy (night)

 "mostly cloudy@2x",       //28    mostly cloudy (day)

 "cloudy moon@2x",  //29 partly cloudy (night)

 "partly-cloudy@2x",   //30  partly cloudy (day)

 "moon1@2x",    //31    clear (night)

 "sun@2x",  //32 sunny

 "clear-moon@2x",   //33  fair (night)

 "clear day@2x",      //34    fair (day)

 "hail@2x", //35 mixed rain and hail

 "hot@2x",  //36 hot

 "thunder@2x",  //37 isolated thunderstorms

 "thunder@2x",  //38 scattered thunderstorms

 "thunder@2x",  //39 scattered thunderstorms

 "thunder@2x",  //40 scattered showers

 "heavy-snow@2x",   //41   heavy snow

 "flurries@2x", //42 scattered snow showers

 "heavy-snow@2x", //43 heavy snow

 "partly-cloudy@2x",  //44    partly cloudy

 "thunder@2x",   //45  thundershowers

 "flurries@2x",  //46 snow showers

 "thunder@2x",  //47 isolated thundershowers

       "nothing@2x",    //3200  not available



]



function constructError (string)

{

 return {error:true, errorString:string};

}



function findChild (element, nodeName)

{

 var child;

 

 for (child = element.firstChild; child != null; child = child.nextSibling)

 {

  if (child.nodeName == nodeName)

   return child;

 }

 

 return null;

}





function fetchWeatherData (callback, zip)

{

 url="http://weather.yahooapis.com/forecastrss?u=f&p=" //u=Farenheit, because accuWeather sucks

 

 var xml_request = new XMLHttpRequest();

 xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}

 xml_request.overrideMimeType("text/xml");

 xml_request.open("GET", url+zip);

 xml_request.setRequestHeader("Cache-Control", "no-cache");

 xml_request.send(null); 

 

 return xml_request;

}



function xml_loaded (event, request, callback)

{

 if (request.responseXML)

 {

  var obj = {error:false, errorString:null};

  var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel");

  obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city");

  obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");//Only accounts for windChill

  

  conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");

  obj.temp = conditionTag.getAttribute("temp");

  obj.icon = conditionTag.getAttribute("code");

  obj.description = conditionTag.getAttribute("text"); 

  callback (obj); 

 }else{

  callback ({error:true, errorString:"XML request failed. no responseXML"});

 }

}





function validateWeatherLocation (location, callback)

{

 var obj = {error:false, errorString:null, cities: new Array};

 obj.cities[0] = {zip: location}; //Not very clever, are we?

 callback (obj);

}

       [removed]

</head>

<body>



<div id="WeatherContainer">

<div id="TextContainer">

<p id="city">Gimmie a damn minute...</p>

<p id="temp">-º</p>

<p id="desc">-</p>

</div>

<img id="weatherIcon" src=""/>

</div>

<body background="wallpaper.png">
   </html>



</html>

 

Revise this Paste

Parent: 24379
Children: 24385
Your Name: Code Language: