iPhone Is anyone here good with coding?

Discussion in 'Jailbreaks and iOS Hacks' started by AndrewR23, Mar 21, 2014.

  1. AndrewR23 macrumors 68040

    Joined:
    Jun 24, 2010
    #1
  2. seanwebb68 macrumors 6502

    Joined:
    Jul 27, 2010
  3. AndrewR23 thread starter macrumors 68040

    Joined:
    Jun 24, 2010
    #3
    <html>

    <head>

    <script>





    // go to http://www.weather.com/ and put your city into the search bar, hit enter.

    // copy the code from the end of the url

    // example for Toronto, Canada: http://www.weather.com/weather/right-now/Toronto+Canada+CAXX0504

    // copy "CAXX0504"

    // paste code from url below between the quotation marks

    //

    var locale = "CAXX0504";

    //

    //

    // If you want fahrenheit, on the next line, change the word "true" to "false"

    var isCelsius = true;

    //

    //

    //

    //

    //





    </script>

    <title>pebbly</title>

    <style type="text/css">



    * {

    padding: 0;

    margin: 0;

    }

    @font-face {

    font-family: 'roboto-black-webfont';

    src: url('roboto-black-webfont.eot');

    src: url('roboto-black-webfont.woff') format('woff');

    font-weight: normal;

    font-style: normal;

    }

    @font-face {

    font-family: 'roboto-thin-webfont';

    src: url('roboto-thin-webfont.eot');

    src: url('roboto-thin-webfont.woff') format('woff');

    font-weight: normal;

    font-style: normal;

    }

    body {

    background:#161718 url(bg.png) no-repeat center center;;

    color: #d3d5c3;

    background-size: 100%;

    font-size:16px;

    }

    #hour {

    font-family: 'roboto-black-webfont', sans-serif;

    font-size: 250%;

    text-transform:lowercase;

    }

    #minute, #temp, #tempplus1, #tempplus2, #tempplus3, #tempplus4 {

    font-family: 'roboto-thin-webfont', sans-serif;

    font-size: 120%;

    text-transform:lowercase;

    margin-top:-5px;

    }

    #date, #WeatherContainer {

    font-family: 'roboto-thin-webfont', sans-serif;

    font-size: 80%;

    margin-top:10px;

    padding-top:10px;

    border-top:1px solid #333;

    }

    #container {

    margin: auto;

    width: 200px;

    padding: 80px 0 0 0;

    }

    #weathericon {

    position:relative;

    left:43px;

    width:100px;

    }

    .forecast {

    margin-top:20px;

    }

    .forecast li {

    width:35px;

    height:35px;

    background:#000;

    float:left;

    margin-left:6px;

    text-align: center;

    line-height:45px;

    margin-top:-10px;

    }

    .forecast li:first-child {

    margin:0;

    margin-top:-10px;

    }

    .forecastdays li:first-child {

    margin:0;

    }

    .forecastdays li {

    width:35px;

    float:left;

    margin-left:6px;

    text-align: center;

    line-height:45px;

    }

    .rainy {

    background: #387ce4 url(rain.png) no-repeat top left !important;

    }

    .snowy {

    background: #e9f8f8 url(snow.png) no-repeat top left !important;

    color:#161718 !important;

    }

    .sunny {

    background:#e29342 url(sun.png) no-repeat top left !important;

    color:#161718 !important;

    }

    .swipe {

    position:fixed;

    bottom:30;

    width:200px;

    text-align:center;

    border-top:1px solid #333;

    }

    </style>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0">

    </head>



    <body>

    <!-- <base href="Private"/>-->

    <base href="Weather/"/>

    <div id="container">

    <p id="hour"></p>

    <p id="minute"></p>

    <p id="date"></p>

    <div id="WeatherContainer">

    <div id="TextContainer">

    <div id="icon">

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

    </div>

    <ul class="forecastdays">

    <li id="tempplus1day">a</li>

    <li id="tempplus2day">b</li>

    <li id="tempplus3day">c</li>

    <li id="tempplus4day">d</li>

    <li id="tempplus5day">e</li>

    </ul>

    <ul class="forecast">

    <li id="today"><p id="temp">?°</p></li>

    <li id="tomorrow"><p id="tempplus1">?°</p></li>

    <li id="day3"><p id="tempplus2">?°</p></li>

    <li id="day4"><p id="tempplus3">?°</p></li>

    <li id="day5"><p id="tempplus4">?°</p></li>

    </ul>

    </div>

    </div>

    <div class="swipe"></div>

    </div>



    <script>

    var useRealFeel = false;

    var stylesheet = 'mini'

    var iconSet = 'yahoo'

    var iconExt = '.png'

    var source = 'yahooWeather'

    var updateInterval = 15

    var postal;

    var MiniIcons =

    [

    "0", //0 tornado

    "1", //1 tropical storm

    "2", //2 hurricane

    "3", //3 severe thunderstorms

    "4", //4 thunderstorms

    "5", //5 mixed rain and snow

    "6", //6 mixed rain and sleet

    "7", //7 mixed snow and sleet

    "8", //8 freezing drizzle

    "9", //9 drizzle

    "10", //10 freezing rain

    "11", //11 showers

    "12", //12 showers

    "13", //13 snow flurries

    "14", //14 light snow showers

    "15", //15 blowing snow

    "16", //16 snow

    "17", //17 hail

    "18", //18 sleet

    "19", //19 dust

    "20", //20 foggy

    "21", //21 haze

    "22", //22 smoky

    "23", //23 blustery

    "24", //24 windy

    "25", //25 cold

    "26", //26 cloudy

    "27", //27 mostly cloudy (night)

    "28", //28 mostly cloudy (day)

    "29", //29 partly cloudy (night)

    "30", //30 partly cloudy (day)

    "31", //31 clear (night)

    "32", //32 sunny

    "33", //33 fair (night)

    "34", //34 fair (day)

    "35", //35 mixed rain and hail

    "36", //36 hot

    "37", //37 isolated thunderstorms

    "38", //38 scattered thunderstorms

    "39", //39 scattered thunderstorms

    "40", //40 scattered showers

    "41", //41 heavy snow

    "42", //42 scattered snow showers

    "43", //43 heavy snow

    "44", //44 partly cloudy

    "45", //45 thundershowers

    "46", //46 snow showers

    "47", //47 isolated thundershowers

    "dunno", //3200 not available

    ]



    function enableWeather() {

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

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

    };



    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("WeatherContainer").className = "errorLocaleNotFound";

    }



    }

    else {

    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){



    if(useRealFeel == true){

    tempValue = convertTemp(obj.realFeel);

    }

    else {
     
  4. AndrewR23 thread starter macrumors 68040

    Joined:
    Jun 24, 2010
    #4
    tempValue = convertTemp(obj.temp)

    }



    var xl = convertTemp(obj.plus1low);

    var xxl = convertTemp(obj.plus2low);

    var xxxl = convertTemp(obj.plus3low);

    var xxxxl = convertTemp(obj.plus4low);

    var xh = convertTemp(obj.plus1high);

    var xxh = convertTemp(obj.plus2high);

    var xxxh = convertTemp(obj.plus3high);

    var xxxxh = convertTemp(obj.plus4high);



    var average1 = Math.round(((xl) + (xh)) / 2);

    var average2 = Math.round(((xxl) + (xxh)) / 2);

    var average3 = Math.round(((xxxl) + (xxxh)) / 2);

    var average4 = Math.round(((xxxxl) + (xxxxh)) / 2);



    var rain = [0,1,2,3,4,5,6,7,8,9,10,11,12,35,37,38,39,40,45,47];

    var snow = [13,14,15,16,17,18,41,42,43,46];

    var sunny = [32,36];



    // today

    for (var valueLoop = 0; valueLoop < rain.length; valueLoop++) {

    if (obj.plus0code == rain[valueLoop]) {

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

    } else {

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

    }

    }

    for (var valueLoop = 0; valueLoop < snow.length; valueLoop++) {

    if (obj.plus0code == snow[valueLoop]) {

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

    } else {

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

    }

    }

    for (var valueLoop = 0; valueLoop < sunny.length; valueLoop++) {

    if (obj.plus0code == sunny[valueLoop]) {

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

    } else {

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

    }

    }

    // tomorrow

    for (var valueLoop = 0; valueLoop < rain.length; valueLoop++) {

    if (obj.plus1code == rain[valueLoop]) {

    document.getElementById("tomorrow").className = "rainy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < snow.length; valueLoop++) {

    if (obj.plus1code == snow[valueLoop]) {

    document.getElementById("tomorrow").className = "snowy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < sunny.length; valueLoop++) {

    if (obj.plus1code == sunny[valueLoop]) {

    document.getElementById("tomorrow").className = "sunny";

    } else {



    }

    }

    // day3

    for (var valueLoop = 0; valueLoop < rain.length; valueLoop++) {

    if (obj.plus2code == rain[valueLoop]) {

    document.getElementById("day3").className = "rainy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < snow.length; valueLoop++) {

    if (obj.plus2code == snow[valueLoop]) {

    document.getElementById("day3").className = "snowy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < sunny.length; valueLoop++) {

    if (obj.plus2code == sunny[valueLoop]) {

    document.getElementById("day3").className = "sunny";

    } else {



    }

    }

    // day4

    for (var valueLoop = 0; valueLoop < rain.length; valueLoop++) {

    if (obj.plus3code == rain[valueLoop]) {

    document.getElementById("day4").className = "rainy";

    }

    }

    for (var valueLoop = 0; valueLoop < snow.length; valueLoop++) {

    if (obj.plus3code == snow[valueLoop]) {

    document.getElementById("day4").className = "snowy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < sunny.length; valueLoop++) {

    if (obj.plus3code == sunny[valueLoop]) {

    document.getElementById("day4").className = "sunny";

    } else {



    }

    }

    // day5

    for (var valueLoop = 0; valueLoop < rain.length; valueLoop++) {

    if (obj.plus4code == rain[valueLoop]) {

    document.getElementById("day5").className = "rainy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < snow.length; valueLoop++) {

    if (obj.plus4code == snow[valueLoop]) {

    document.getElementById("day5").className = "snowy";

    } else {



    }

    }

    for (var valueLoop = 0; valueLoop < sunny.length; valueLoop++) {

    if (obj.plus4code == sunny[valueLoop]) {

    document.getElementById("day5").className = "sunny";

    } else {



    }

    }



    document.getElementById("temp").innerHTML=tempValue+ "°";



    document.getElementById("tempplus1").innerHTML=average1+ "°";

    document.getElementById("tempplus2").innerHTML=average2+ "°";

    document.getElementById("tempplus3").innerHTML=average3+ "°";

    document.getElementById("tempplus4").innerHTML=average4+ "°";



    document.getElementById("tempplus1day").innerHTML = obj.plus0day;

    document.getElementById("tempplus2day").innerHTML = obj.plus1day;

    document.getElementById("tempplus3day").innerHTML = obj.plus2day;

    document.getElementById("tempplus4day").innerHTML = obj.plus3day;

    document.getElementById("tempplus5day").innerHTML = obj.plus4day;



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

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

    }else{

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

    }

    };



    function weatherRefresherTemp() {

    fetchWeatherData(dealWithWeather,postal);

    setTimeout(weatherRefresherTemp, 60*1000*updateInterval);

    };



    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://xml.weather.yahoo.com/forecastrss/" //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");

    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.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");

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

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

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



    //forecastTag = findChild(findChild(effectiveRoot, "item"), "yweather:forecast");



    //forecastTag = request.responseXML.getElementsByTagName("forecast")[1];



    obj.plus1low = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("low");

    obj.plus2low = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("low");

    obj.plus3low = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("low");

    obj.plus4low = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("low");



    obj.plus1high = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("high");

    obj.plus2high = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("high");

    obj.plus3high = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("high");

    obj.plus4high = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("high");



    obj.plus0day = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("day");

    obj.plus1day = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("day");

    obj.plus2day = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("day");

    obj.plus3day = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("day");

    obj.plus4day = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("day");



    obj.plus0code = request.responseXML.getElementsByTagName("forecast")[0].getAttribute("code");

    obj.plus1code = request.responseXML.getElementsByTagName("forecast")[1].getAttribute("code");

    obj.plus2code = request.responseXML.getElementsByTagName("forecast")[2].getAttribute("code");

    obj.plus3code = request.responseXML.getElementsByTagName("forecast")[3].getAttribute("code");

    obj.plus4code = request.responseXML.getElementsByTagName("forecast")[4].getAttribute("code");





    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);



    };



    function convertTemp(num) {

    if (isCelsius == true)

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

    else

    return parseInt(num);

    };



    enableWeather();



    </script>

    <script type="text/javascript">



    function calculateTime() {

    var Make_It_12_Hour = true;



    var currentTime = new Date();

    var hour = currentTime.getHours();

    var minute = currentTime.getMinutes();



    hour = hour % 12;

    hour = (hour) ? hour : 12;



    if (hour < 0) { hour = "11"; }

    if (minute < 0) { minute = "59"; }

    if (minute < 10) { minute = "0" + minute; }





    var hours = ["ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE"];

    var minutes = ["Oh One", "Oh Two", "Oh Three", "Oh Four", "Oh Five", "Oh Six", "Oh Seven", "Oh Eight", "Oh Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Twenty-One", "Twenty-Two", "Twenty-Three", "Twenty-Four", "Twenty-Five", "Twenty-Six", "Twenty-Seven", "Twenty-Eight", "Twenty-Nine", "Thirty", "Thirty-One", "Thirty-Two", "Thirty-Three", "Thirty-Four", "Thirty-Five", "Thirty-Six", "Thirty-Seven", "Thirty-Eight", "Thirty-Nine", "Forty", "Forty-One", "Forty-Two", "Forty-Three", "Forty-Four", "Forty-Five", "Forty-Six", "Forty-Seven", "Forty-Eight", "Forty-Nine", "Fifty", "Fifty-One", "Fifty-Two", "Fifty-Three", "Fifty-Four", "Fifty-Five", "Fifty-Six", "Fifty-Seven", "Fifty-Eight", "Fifty-Nine", "O'Clock"];



    if (minute == 15) {

    document.getElementById("hour").innerText = "Quarter After";

    document.getElementById("minute").innerText = hours[hour-1];

    } else if (minute == 10) {

    document.getElementById("hour").innerText = "Ten After";

    document.getElementById("minute").innerText = hours[hour-1];

    } else if (minute == 30) {

    document.getElementById("hour").innerText = "Half Past";

    document.getElementById("minute").innerText = hours[hour-1];

    } else if (minute == 45) {

    document.getElementById("hour").innerText = "Quarter To";

    document.getElementById("minute").innerText = hours[hour];

    } else if (minute == 50) {

    document.getElementById("hour").innerText = "Ten To";

    document.getElementById("minute").innerText = hours[hour];

    } else if (minute == 00) {

    document.getElementById("hour").innerText = hours[hour-1];

    document.getElementById("minute").innerText = "O'Clock";

    } else {

    document.getElementById("hour").innerText = hours[hour-1];

    document.getElementById("minute").innerText = minutes[minute-1];

    }







    }



    function calculateDate() {

    var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

    var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

    var currentTime = new Date();

    var day = currentTime.getDate().toString();

    var month = currentTime.getMonth();

    var weekday = currentTime.getDay();



    var n = day.charAt(day.length - 1);



    if (n == 1) {

    if (day == 11) {

    day+="th";

    } else {

    day+="st";

    }

    } else if (n == 2) {

    if (day == 12) {

    day+="th";

    } else {

    day+="nd";

    }

    } else if (n == 3) {

    if (day == 13) {

    day+="th";

    } else {

    day+="rd";

    }

    } else {

    day+="th";

    }



    if (day.length == 1) { day1 = "0" + day; }





    document.getElementById("date").innerText = weekdays[weekday] + ", " + months[month] + " " + day;

    }



    calculateTime();

    calculateDate();

    setInterval(calculateTime, 2000);

    setInterval(calculateDate, 60000);



    </script>



    </body>

    </html>
     

Share This Page