Add a "word clock" to a theme?

Discussion in 'Jailbreaks and iOS Hacks' started by brayhite, Jul 31, 2011.

  1. brayhite macrumors 6502a

    Joined:
    Jun 21, 2010
    Location:
    N. Kentucky
    #1
    I have a theme with a word clock on the lock screen, and I'd like to add it to a theme I had for my springboard. I tried copying and pasting what I thought was the code for the word clock into the clock area code for the springboard, but it just eliminated the clock from showing at all. Any tips or suggestions? Does the method for inserting a word clock instead of a regular clock vary theme to theme, or is it a general step for all themes on how to insert a change like that?
     
  2. IrishVixen macrumors 68020

    IrishVixen

    Joined:
    Jun 20, 2010
    #2
    All themes are not alike, though most have some similarities. To actually swap elements between widgets like that, you're probably going to have to get very familiar with HTML/CSS first. But what you're working with may be relatively easily edited. It depends. Without some screenshots of what you're trying to accomplish and links to the widgets involved, all I can say is it could be anywhere from editing a few words or characters in the code to making wholesale changes involving a hundred lines or more.
     
  3. brayhite thread starter macrumors 6502a

    Joined:
    Jun 21, 2010
    Location:
    N. Kentucky
    #3
    The first picture is an example of the word clock I want, but not the theme I have. The one I have is called LS Word Clock, found on Cydia. The second picture is gary's theme that I currently have on my springboard, however I'd like to make the clock a word clock in the top left.
     

    Attached Files:

  4. IrishVixen macrumors 68020

    IrishVixen

    Joined:
    Jun 20, 2010
    #4
    Shouldn't be too hard. This is what you're looking for in both widgets:

    Code:
    	var currentHours_name_array = new Array ("12", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
    
    
    
    	var currentMinutes_name_array = new Array ("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28","29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60")
    
    (The above code is from the springboard widget you have--or at least from my copy of it, which may be edited slightly differently.)

    Basically, what you want to do is replace all the items in parentheses with the words of your choice. So under hours, it would look like:

    Code:
    	var currentHours_name_array = new Array ("Twelve", "One", "Two", ...
    
    
    And under minutes:

    Code:
    	
    	var currentMinutes_name_array = new Array ("o'clock", "o-one", "o-two", ... )
    
    or whatever format you prefer. If the name arrays in your word clock look like these, you can simply cut and past from one to the other, otherwise you may need to recreate the exact format you want. If you want all caps, enter everything in all caps, if you want all lowercase, enter it in all lowercase, etc. (These attributes can also be changed in CSS or the style section of the HTML.) If you want unusual punctuation for breaks, that needs to be included as well--for example, I have one on my phone right now that reads "[ELEVEN]fiftySIX"--all the hours are written "[ALLCAPS]" and all the minutes are "lowercaseUPPERCASE" in the code.

    A word of warning. When you get to something like "twelve twenty-eight", it's probably not going to fit into the space where your current time does without editing the font size or placement. Otherwise, it will likely overlap your weather icon. And near the top of the code, under SPAN#ampm, add the following beneath the first bracket:

    Code:
    display: none;
    That will take out the AM/PM. You can always put it back if you want by typing // before that line.

    (SAVE the original HTML first! You may want it at some point.)
     
  5. brayhite thread starter macrumors 6502a

    Joined:
    Jun 21, 2010
    Location:
    N. Kentucky
    #5
    As always, thanks so much Irish. One question though:
    The hours name array has several twelves. I would assume this is for military time (00:00-23:59). If I would like to make one twelve say midnight, another noon, how do I know which ones to modify? The first twelve is midnight, I'd assume. Second noon. Is the last one also midnight? Also, when it's midnight or noon, is there way to tell my clock to only say "midnight" or "noon", without it saying "noon o'four" or something like that?
     
  6. IrishVixen macrumors 68020

    IrishVixen

    Joined:
    Jun 20, 2010
    #6
    On the first point, I'm going to guess--midnight-noon-midnight is the order of the 12's in the code. On the second point, you'd have to add lines of code to make that work, lines that examined the time each hour, the HTML equivalent of an if/then statement: if 12 PM, then "noon", if 12:01 PM, then "twelve o'one". And I'm not certain exactly what the code would have to look like to make it work that way. Best bet would be to find a theme with that built in, but I don't know that I've seen one. All the word clocks I have in my stash use the word "twelve".

    It should be doable, mind you, and I'd assume someone somewhere has done it already. A google search with the right keywords might turn it up; code snippets are often readily available on the web; just not sure what keywords you'd need to use to find this one. Hopefully someone here already knows.
     
  7. brayhite thread starter macrumors 6502a

    Joined:
    Jun 21, 2010
    Location:
    N. Kentucky
    #7
    Welp, I got it to work! As a temporary solution until I think of something else or change the font size, I just made it say "four 40eight" for the longer times.

    I do have another question though about the same theme: is there a way to make the weather show conditions for current location, or is strictly limited to only showing weather for the Yahoo! weather location code?
     
  8. IrishVixen macrumors 68020

    IrishVixen

    Joined:
    Jun 20, 2010
    #8
    Current code for that widget (and virtually all others I've seen) limits you to using the YahooWeather code (or the equivalent for AccuWeather). To track your current location would require using location services, and I've yet to see a widget for the iPhone that includes that function. Wouldn't want it, personally, as having that sort of thing run persistently in the background would suck your battery life down as well. I keep a list of the major locations I go when I travel and just change the code/respring when I get there.
     

Share This Page