Eduardo (eduthepenguin) wrote in component_help,
Eduardo
eduthepenguin
component_help

  • Mood:

Clock in Profile code

Hi everyone, at the request of niteshayd, here is the code to insert kunzite1's Clock code in your modified profile component. Basically 49% is his, 49% is from whoever did the modified profile code, and 2% is mine. ^_^

This is the prettied up, more efficient, and hopefully final version of the code. Thanks to kunzite1's suggestions it's now less complicated for beginners to just copy/paste the damn thing, with minimal modifications from your part. You can only edit the stuff in red at the top! ^_^ Enjoy!

function print_profile(Page p) {

####################################################
# Clock                                            #
# by kunzite1                                      #
# (adapted from lj:xevinx's post to journal script)#
####################################################
# USER SETTINGS                                    #
#                                                  #
# Basically this all you have to change to your    #
# own settings.                                    #
#                                                  #
# set this to your time zone difference            #
  var int k1time_difference  = -3;
# set this to 1 if it is between spring and fall   #
  var int k1daylight_savings = 0;
# set this to 1 if you want 24 hr time             #
  var int k1military_time    = 0;
# set this to 1 if you want the date shown         #
  var int k1show_date        = 1;
# set this to the date seperator that you wish     #
# for example, a "/" or a "-"                      #
  var string k1seperator     = "/";
# set the name you want displayed here(e.g. "Mark" #
  var string k1name = "Mark";
# put the age you want displayed here (e.g. 18)    #
  var string k1age = "18";
# set the location you want displayed here         #
  var string k1location = "Miami, FL";
####################################################
# CLOCK START #
###############
# DON'T need to mess with anything below
var int k1year  = $p.time.year;
var int k1day   = $p.time.day;
var int k1hour  = $p.time.hour + $k1time_difference;
var int k1min   = $p.time.min;
var int k1month = $p.time.month;
var string k1meridian = "";
if($k1daylight_savings){
  $k1hour = $k1hour + 1;
}
# figure out days in month
var int k1mondays = 31;
if($k1month == 4 or $k1month == 6  or $k1month == 9 or $k1month == 11) {
  $k1mondays = 30;
} elseif($k1month == 2) {
  $k1mondays = ($k1year % 4 == 0) ? 29 : 28;
}
if($k1hour > 24) {            # if your timezone is the day after system...
    $k1hour = $k1hour - 24;     # figure out new hour value
    $k1day = $k1day + 1;        # make sure to change day value
  if($k1day > $k1mondays) {     # if your day is in the next month...
    $k1day = $k1day - $k1mondays; # figure out the new day
    $k1month = $k1month + 1;    # change the month value
    if($k1month > 12) {       # if your month is in the next year...
      $k1month = 1;           # change the month value and
      $k1year = $k1year + 1;    # change the year value
    }
  }
} elseif($k1hour < 0) {    # otherwise, if your day is the day before...
  $k1hour = 24 + $k1hour;    # change the hour and
  $k1day = $k1day - 1;       # change the day value
  if($k1day < 1) {         # if that puts you in the previous month...
    $k1month = $k1month - 1; # decrement the month value
    if($k1month < 1) {     # if that puts you in the previous year...
      $k1month = 12;       # set the new month value and
      $k1year = $k1year - 1; # decrement the year value
    }
    $k1mondays = 31; # figure out how many days are in this new month
    if($k1month == 4 or $k1month == 6  or $k1month == 9 or $k1month == 11) {
      $k1mondays = 30;
    } elseif($k1month == 2) {
      $k1mondays = ($k1year % 4) == 0 ? 29 : 28;
    }
    $k1day = $k1mondays; # and change your day value to that.
  }
}
#############
# CLOCK END #
#############

###########################
# SOME PROFILE DATA STUFF #
###########################

if($p.journal.website_url){
  var string websiteString = "<a href='$p.journal.website_url'>";
  if($p.journal.website_name){
    $websiteString = $websiteString + $p.journal.website_name;
}
    $websiteString = $websiteString + "</a>";

##########################
# END PROFILE DATA STUFF #
##########################

print_comp_header($*profile_text);
"""
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="50%" align="center">
<div class="shortLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></div>
<div class="shortLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></div>
</td>
<td align="center"><a href="http://www.livejournal.com/allpics.bml?user=$p.journal.username"><img src="$p.journal.default_pic.url" alt="$p.journal.username's user-pics" /> </a></td>
<td width="50%" align="center">
<div class="shortLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></div>
<div class="shortLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></div>
</td>
</tr>
<tr>
<td colspan="3" class="compContent">
<div><b>User:</b> <span class='ljuser' style='white-space:nowrap;'><a href='http://www.livejournal.com/userinfo.bml?user=$p.journal.username'><img src='http://stat.livejournal.com/img/userinfo.gif' alt="$p.journal.username's info" width='17' height='17' style='vertical-align:bottom;border:0;' /></a><a href='http://www.livejournal.com/users/$p.journal.username/'><b>$p.journal.username</b></a></span></div>
<div><b>Name:</b> $k1name</div>
<div><b>Website:</b> $websiteString</div>
<div><b>Age:</b> $k1age</div>
<div><b>Location:</b> $k1location</div>
<div><b>Date: </b>""";
if($k1show_date == 1){
  if($k1month < 10){
    """0$k1month""";
  } else {
    """$k1month""";
  }
  """$k1seperator""";
  if($k1day < 10){
    """0$k1day""";
  } else {
    """$k1day""";
  }
  """$k1seperator$k1year<br /></div>""";
}
"""<div><b>Time: </b>""";
if($k1military_time == 0){
  if($k1hour < 12){
    $k1meridian = "am";
  } else {
    $k1meridian = "pm";
  }
}
if($k1military_time == 1){
  if($k1hour < 10){
    """0$k1hour""";
  } else {
    """$k1hour""";
  }
} else {
  if($k1hour > 12){
    $k1hour = $k1hour - 12;
  }
  if($k1hour == 0){
    $k1hour = 12;
  }
  if($k1hour < 10){
    """0$k1hour""";
  } else {
    """$k1hour""";
  }
}
""":""";

if($k1min < 10){
"""0$k1min""";
  } else {
    """$k1min""";
  }
    """$k1meridian""";

"""</div>""";
"""
</td>
</tr>
</table>
""";
}
print_comp_footer();
}

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 18 comments