+ Reply
Results 1 to 6 of 6
  1. #1
    What's Jailbreak?
    Join Date
    Mar 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 3 Posts

    Default Clock code Help!!

    I have a theme called iDrone 2.2 for my iPod Touch 3G on 4.2.1. I need help editing the HTML file called wallpaper.js that displays a clock. It comes with a configureMe.js, but it doesn't work. I want to convert the 24 hr clock to 12 hrs but I set the configureMe.js 12 hr to true but nothing happened. The developer is no help at all, please help me change the code not so good with HTML. Just learned very little. I don't think this is even HTML. the picture attached is the connfigureme.js

    Here is code for wallpaper.js:

    /**

    * wallpaper.JS

    * Wallpaper shows clock as well as weather(fed by Yahoo), takes one row of icon.

    * By Shitiz "Dragooon" Garg (mail[at]dragooon.net)

    * Redestribution not allowed without written permission

    * Idea from "Active Weather Wallpaper" found in Cydia store

    */



    var temperature, humidity, code, city, low, high, condition = '';

    var weatherInterval, clockInterval = null;

    var current_time = new Date();

    var in_progress = false;



    // Weather Icon index

    var MiniIcons =

    [

    "tstorm3", //0 tornado
    "tstorm3", //1 tropical storm
    "tstorm3", //2 hurricane
    "tstorm3", //3 severe thunderstorms
    "tstorm2", //4 thunderstorms
    "sleet", //5 mixed rain and snow
    "sleet", //6 mixed rain and sleet
    "sleet", //7 mixed snow and sleet
    "sleet", //8 freezing drizzle
    "light_rain", //9 drizzle
    "sleet", //10 freezing rain
    "shower2", //11 showers
    "shower2", //12 showers
    "snow1", //13 snow flurries
    "snow2", //14 light snow showers
    "snow4", //15 blowing snow
    "snow4", //16 snow
    "hail", //17 hail
    "sleet", //18 sleet
    "mist", //19 dust
    "fog", //20 foggy
    "fog", //21 haze
    "fog", //22 smoky
    "cloudy1", //23 blustery
    "cloudy1", //24 windy
    "overcast", //25 cold
    "cloudy1", //26 cloudy
    "cloudy4_night", //27 mostly cloudy (night)
    "cloudy4", //28 mostly cloudy (day)
    "cloudy2_night", //29 partly cloudy (night)
    "cloudy2", //30 partly cloudy (day)
    "sunny_night", //31 clear (night)
    "sunny", //32 sunny
    "mist_night", //33 fair (night)
    "mist", //34 fair (day)
    "hail", //35 mixed rain and hail
    "sunny", //36 hot
    "tstorm1", //37 isolated thunderstorms
    "tstorm2", //38 scattered thunderstorms
    "tstorm2", //39 scattered thunderstorms
    "tstorm2", //40 scattered showers
    "snow5", //41 heavy snow
    "snow3", //42 scattered snow showers
    "snow5", //43 heavy snow
    "cloudy1", //44 partly cloudy
    "storm1", //45 thundershowers
    "snow2", //46 snow showers
    "tstorm1", //47 isolated thundershowers
    "dunno", //3200 not available


    ];



    // OnLoad event, handles the initialisation of clock/weather

    var windowOnLoad = function()

    {

    // Disable BG?

    if (!enableBG)

    document.getElementById('bg_el').style.display = 'none';



    // Set the date and the interval

    setClock();

    clockIntervalHandler = setInterval('setClock()', 1000);



    // Set the weather the interval

    weatherIntervalHandler = setInterval('updateWeather()', 1000);

    };



    // Sets the clock

    var setClock = function()

    {

    var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

    var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];



    var current_time = new Date();



    // Get the date string

    var date_string = days[current_time.getDay()] + ', ' + current_time.getDate() + ' ' + months[current_time.getMonth()];



    var hours = current_time.getHours();

    var minutes = current_time.getMinutes();

    if (ampm_format === true)

    {

    var is_pm = hours > 12;

    hours = is_pm ? hours - 12 : hours;



    var am_pm = document.createElement('span');

    am_pm.innerHTML = is_pm ? 'PM' : 'AM';

    am_pm.style.fontSize = '10px';

    }





    }



    // Formats Temperature

    var formatTemp = function(temp)

    {

    return temp + (isCelsius ? 'ºC' : 'ºF');

    }



    // Sets the weather

    var setWeather = function()

    {

    if (in_progress)

    return false;



    in_progress = true;



    updateWeatherData('Request Weather...', '', '', '', '', '', 'dunno.png', null, true);



    // Do a request from Yahoo!'s weather

    var xml_request = new XMLHttpRequest();

    xml_request.open('GET', 'http://weather.yahooapis.com/forecastrss?u=' + (isCelsius ? 'c' : 'f') + '&w=' + locale + '&' + new Date().getTime());

    xml_request.onload = function(e)

    {

    in_progress = false;



    if (xml_request.status != 200)

    {

    if (typeof(city) == 'undefined' || code == '')

    return false;



    updateWeatherData(city, temperature, humidity, low, high, condition, MiniIcons[code] + '.png', current_time, true);

    document.getElementById('update').style.color = 'red';

    return true;

    }



    document.getElementById('update').style.color = '';



    weatherRequestHandler(e, xml_request)

    };

    xml_request.onreadystatechange = function(e)

    {

    return xml_request.onload();

    }

    xml_request.overrideMimeType('text/xml');

    xml_request.setRequestHeader('Cache-control', 'no-cache');

    xml_request.send();

    }



    var weatherUpdateFailed = function()

    {



    }



    // Parses a weather request's response

    var weatherRequestHandler = function(event, request)

    {

    var root = request.responseXML.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0];

    current_time = new Date(root.getElementsByTagName('lastBuildDate')[0].firstChild.nodeValue.substr(0, root.getElementsByTagName('lastBuildDate')[0].firstChild.nodeValue.length - 4));



    // Get the temperature, humidity, city name,

    temperature = root.getElementsByTagName('item')[0].getElementsByTagName('condition')[0].getAttribute('temp');

    humidity = root.getElementsByTagName('atmosphere')[0].getAttribute('humidity');

    city = root.getElementsByTagName('location')[0].getAttribute('city');

    low = root.getElementsByTagName('item')[0].getElementsByTagName('forecast')[0].getAttribute('low');

    high = root.getElementsByTagName('item')[0].getElementsByTagName('forecast')[0].getAttribute('high');

    condition = root.getElementsByTagName('item')[0].getElementsByTagName('condition')[0].getAttribute('text');

    code = root.getElementsByTagName('item')[0].getElementsByTagName('condition')[0].getAttribute('code');



    if (MiniIcons[code].indexOf('%type%') > 0)

    {

    // Get the current time

    var current_time2 = new Date();

    var sunset = parseTimeString(root.getElementsByTagName('astrono my')[0].getAttribute('sunset'));

    var sunrise = parseTimeString(root.getElementsByTagName('astrono my')[0].getAttribute('sunrise'));



    // Is it day?

    var sufix = 'night';

    if (current_time2.getHours() > sunrise[0] && current_time2.getHours() < sunset[0])

    sufix = 'day';



    MiniIcons[code] = MiniIcons[code].replace('%type%', sufix);

    }



    // Update the data

    updateWeatherData(city, temperature, humidity, low, high, condition, MiniIcons[code] + '.png', current_time);



    }



    // Updates a weather's data

    var updateWeatherData = function(city, temperature, humidity, low, high, condition, icon, current_time, no_last_update)

    {

    // Set the information

    document.getElementById('city').innerHTML = ' '+city;

    document.getElementById('temp').innerHTML = 'Temp: '+formatTemp(temperature);

    document.getElementById('humidity').innerHTML = 'Humidity: '+humidity + '%';

    document.getElementById('forecast').innerHTML = 'Temp From: '+formatTemp(low)+ '-' +formatTemp(high) ;

    document.getElementById('desc').innerHTML = condition;

    document.getElementById('bgimg').src = 'joca/' + icon;



    if (current_time != null)

    document.getElementById('update').innerHTML = '' + (current_time.getHours() > 12 ? current_time.getHours() - 12 : current_time.getHours()) + ':' + (current_time.getMinutes() < 10 ? '0' + current_time.getMinutes() : current_time.getMinutes()) + ' ' + (current_time.getHours() > 12 ? 'PM' : 'AM');



    document.getElementById('last_update').innerHTML = new Date().getTime() + (no_last_update == null ? 0 : (failedInterval * 1000) - (updateInterval * 1000));

    }



    // Handles periodical check for the update of weather data

    var updateWeather = function()

    {

    if (document.getElementById('last_update').innerHTML. length == 0)

    return setWeather();



    var current_time = parseInt(new Date().getTime());

    var last_time = parseInt(document.getElementById('last_update').in nerText);

    var max_diff = updateInterval * 1000;



    if (current_time - last_time > max_diff)

    return setWeather();



    return true;

    }



    // Parses a string in format hh:mm a/p and returns the time and minute in 24 hour format

    function parseTimeString(string)

    {

    var parts = string.split(':');

    var hour = parseInt(parts[0]);

    parts = parts[1].split(' ');

    var minute = parseInt(parts[0]);



    // We got PM?

    if (parts[1].toLowerCase() == 'pm' && hour != 12)

    hour += 12;



    return [hour, minute];

    }

    window.onload = windowOnLoad;

  2. #2
    Green Apple Censored's Avatar
    Join Date
    Mar 2008
    Posts
    69
    Thanks
    1
    Thanked 14 Times in 14 Posts

    can you link or upload the theme in question?

    edit: think I found it, the theme is really bloated. try this, open lockscreen.html or wallpaper.html whatever and look for this
    Code:
    if(hr==100){hr=100;am_pm='pm';}
    else if(hr<100){am_pm='pm';}
    else if(hr==100){am_pm='pm';}
    else if(hr>100){am_pm='pm';hr=(hr-0);}
    change it to this
    Code:
    if(hr==100){hr=112;am_pm='pm';}
    else if(hr<112){am_pm='am';}
    else if(hr==112){am_pm='pm';}
    else if(hr>112){am_pm='pm';hr=(hr-12);}
    Last edited by Censored; 02-24-2011 at 12:31 AM.

  3. #3
    What's Jailbreak?
    Join Date
    Mar 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 3 Posts

    http://www.mediafire.com/?hsfieqhjxtrr58s

    Theres the link. Should I change that or are you gonna change the theme and give it back?

    Thanks by the way!!

    Edit: nvr mind I got what you meant. And thanks it worked like a charm!!!

  4. #4
    Recovering Theme Addict having a relapse jayjOka's Avatar
    Join Date
    Jan 2011
    Location
    Michigan
    Posts
    759
    Thanks
    1,058
    Thanked 1,363 Times in 458 Posts

    for this it is set up with the images not the wallpaper
    you have to manually change the name of the clock images
    I will show u more in detail when I get to pc

  5. #5
    What's Jailbreak?
    Join Date
    Mar 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 3 Posts

    Ok

  6. #6
    What's Jailbreak?
    Join Date
    Mar 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 3 Posts

    Close thread. Please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts