?

Log in

No account? Create an account
[theme] - [flexisquares] - [add buttons to header] - S2 Layers [entries|archive|friends|userinfo]
S2 Layers

[ website | advanced customization ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| how to post tags page ]
[affiliated communities| fblayers ]

[theme] - [flexisquares] - [add buttons to header] [Dec. 14th, 2005|02:35 pm]
S2 Layers

s2layers

[kunzite1]
[Tags|, , ]

function Page::lay_print_header() "Prints header" {	
  # get title
  var string title = $this->title();

  # start header <div> and <ul>
  """
  <div id="header">		
    <ul class="navheader">""";

  # create helper vars for text and urls for links
  var string text = "";
  var string url  = "";

  # get website name and url
  $text = $.journal.website_name ? $.journal.website_name : $*text_website_default_name;
  $url  = $.journal.website_url;

  # if website, print it
  if($url != "") {
    println """<li><a href="$url">$text</a></li>""";
  }

  # cycle thru views order
  foreach var string v ($.views_order) {
    # get text and url
    $text = lang_viewname($v);
    $url  = $.view_url{$v};

    # if current view, just print text
    if ($.view == $v) {
      """<li class="view">$text</li>""";
    } else {
      # if not current view, print link
      println """<li><a href="$url">$text</a></li>""";
    }
  } 

  # close viewlinks <ul> and open new <ul> for buttons
  """
    </ul>
    <ul class="navheader">""";

  # create arrays for buttons, also create index meter
  var string[] imgs  = [];
  var string[] alts  = [];
  var string[] urls  = [];
  var int      index = 0;

  # create helper var for img urls and alt texts
  var string   img   = "";
  var string   alt   = "";

  # set one
  $imgs[$index] = "http://pics.livejournal.com/kunzite1/pic/000886wy";
  $alts[$index] = "LiveJournal";
  $urls[$index] = "http://www.livejournal.com/";
  $index++;

  # set two
  $imgs[$index] = "http://stat.livejournal.com/img/openid-badge.gif";
  $alts[$index] = "OpenID";
  $urls[$index] = "http://www.openid.net/";
  $index++;

  # cycle thru buttons
  foreach var int i (0 .. size($imgs)) {
    # get text and url
    $img = $imgs[$i];
    $alt = $alts[$i];
    $url = $urls[$i];

    # print button
    if($img != "") {
      "<li>";

      # if link, open <a>
      if($url != "") {
        """<a href="$url">""";
      }

      """<img src="$img" alt="$alt" title="$alt" border="0" />""";

      # if link, close <a>
      if($url != "") {
        "</a>";
      }
      "</li>";
    }
  }

  # close <ul>, print title <div>
  """
    </ul>    		
    <div class="title">
      $title
    </div>
  """;

  # print subtitle if it exists and we're not on friends view
  if($.global_subtitle != "" and $.view != "friends") {
    """
    <div class="subtitle">
      $.global_subtitle
    </div>
    """;
  }

  # close header <div>
  """
  </div>
  """;	
}
linkReply

Comments:
[User Picture]From: waitsian
2005-12-15 08:19 pm (UTC)
you stolded my code.
(Reply) (Thread)
[User Picture]From: kunzite1
2005-12-15 08:20 pm (UTC)

stolded your idea. i made it pretty. you said that it would catch on. if it was going to catch on, i wanted my pretty code to be used. ;)
(Reply) (Parent) (Thread)
[User Picture]From: waitsian
2005-12-15 09:52 pm (UTC)
..der. okay. forgot. code-nazi. yeah.
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2005-12-15 10:21 pm (UTC)

code nazi. yes.
(Reply) (Parent) (Thread)