「h1」を含む日記 RSS

はてなキーワード: h1とは

2007-05-22

replaceが好み

http://anond.hatelabo.jp/20070522105212

好みの問題だけど、私ならh1要素のinnerHTMLをreplaceで置き換えちゃうな。

でも、結局静的なことなので、エディタマクロか何かの機能で書き換えちゃう手をとるかも。

http://anond.hatelabo.jp/20070522034339

今時font color=""はなぁと思って書いてみたら妙に長くなってしまった。我ながらなんという資源の無駄。日付を手打ちしてるなら、むしろ日付全体を生成するほうが全然楽だけど、一応この形で足掻いてみた結果コメント入れまくってるから省けば多少は見やすくなるかもよ。

なお文書内のh1は全て同一フォーマットの日付であることが前提。形式は多少変わってもOKで、右から何文字目が曜日かって部分だけを書き換えれば動くはず。

<html>
<head>
  <title>曜日テスト</title>
  <style type="text/css"><!--
    span.sun{ /* 日曜日 */
      color:  red;
    }
    span.sat{ /* 土曜日 */
      color:  blue;
    }
  --></style>
  <script type="text/javascript"><!--
   // 日付フォーマット中、右から何文字目が曜日か(曜日1文字の場合にしか対応してない)
    var DAY_POSITION_FROM_RIGHT = 2;

    /*
     * <h1>yyyy年mmdd日(曜)</h1> を
     * <h1>yyyy年mmdd日<span class="xxx">(曜)</span></h1> に変換する。
     * onloadで実行して塗り替え。
     */
    function colorDay(){
      var targetList = document.getElementsByTagName("h1"); // h1要素のリストを取る
      for(i=0; i<targetList.length; i++){ // h1の数だけぶん回す
       // h1の中身を三枚に下ろす(左側、曜日部分、右側)
        var nodeValue = targetList[i].firstChild.nodeValue; // h1の子であるテキストノードの値(日付)を取る
        var nodeValueLeft = nodeValue.substring(0,nodeValue.length - DAY_POSITION_FROM_RIGHT); // 左側
        var day = nodeValue.charAt(nodeValue.length - DAY_POSITION_FROM_RIGHT); // 曜日
        var nodeValueRight = nodeValue.substring(nodeValue.length - DAY_POSITION_FROM_RIGHT + 1, nodeValue.length); // 右側

        var dayType = ""; // 曜日に付与するクラス名を算出(平日なら空)
        if(day == "日"){
          dayType = "sun";
        }
        else if(day == "土"){
          dayType = "sat";
        }

        var dayObj = document.createElement("span"); // 曜日を入れるspanノードを生成
        dayObj.appendChild(document.createTextNode(day)); // 中身文字列は三枚の真ん中(曜日
        dayObj.className = dayType; // クラスを付与

        // h1の中身作り直し
        targetList[i].firstChild.nodeValue = nodeValueLeft; // 元々の値を三枚の左側部分のみにする
        targetList[i].appendChild(dayObj); // その後ろに作った曜日のspanを足す
        targetList[i].appendChild(document.createTextNode(nodeValueRight)); // その後ろに三枚の右側を足す
      }
    }
  //--></script>
</head>
<body onload="colorDay();">
  <h1>2007年05月25日(金)</h1>
  <h1>2007年05月26日(土)</h1>
  <h1>2007年05月27日(日)</h1>
  <h1>2007年05月28日(月)</h1>
</body>
</html>

こんな感じかい?

http://anond.hatelabo.jp/20070522023230

<html>
<head>
    <title>Test</title>
    <script>
    dayString = new Array('<font color="#ff0000">日</font>','月','火','水','木','金','<font color="#0000ff">土</font>');
  
    function init() {
        h1s = document.getElementsByTagName("h1");
        for(var i=0; i < h1s.length; i++) {
            var h1 = h1s[i];
            if (h1.innerHTML.match(/([0-9]+)年([0-9]+)月([0-9]+)日/)) { 
                var yy = RegExp.$1;
                var mm = RegExp.$2;
                var dd = RegExp.$3;
                var day = new Date(yy,mm-1,dd).getDay();
                h1.innerHTML = yy+"年"+mm+"月"+dd+"日("+dayString[day]+")";
            }   
        }        
    }     
    </script>
</head>

<body onload="init()">
<h1>2007年05月10日</h1>
<h1>2007年05月18日</h1>
<h1>2007年05月19日</h1>
<h1>2007年05月20日</h1>
</body>

素人なのでよくわからないぜ。

追記: バグっていたので直しました。ごめん。 > http://anond.hatelabo.jp/20070522034339

CSSで、

<h1>2007年05月22日(火)</h1>とした時、月~金は黒文字で表示させて、土曜は青文字、日曜は赤文字表記に勝手にするように出来ますか?

ジャバスクリプトとかでもムリポ

日付は耐えられそうなんだけど、曜日の色を毎度手打ちするのはおそらく面倒なんだよね。助けてエロイ人!

毎度手打ちなわけじゃなくて、基本黒だから、土曜と日曜の設定だけでいいのか。手打ちでやるかなぁ。なんというローテク。

2007-04-20

[]RubyRuby on Rails

Ruby RDoc Documentation

rubyとは - はてなダイアリー Rubyとは - はてなダイアリー

はてなブックマーク - はてな - Rubyとは

「ruby」を含む日記 - はてなダイアリー

Ruby

「Ruby」に関する画像、動画、ブログ記事のタグ検索結果

Google ブログ検索

買売システム開発記録とか何とか

Rubyで投資システムを作る日記

spacecadetの日記

RubyForge: One-Click Ruby Installer: Project Info

RDE(Ruby Development Environment) - Ruby??J??????????

#!/usr/bin/ruby -Ks

# print "Content-Type: text/html;charset=UTF-8\n\n"

p "表示"


Rails Rails Framework Documentation

http://127.0.0.1/mysql/

http://127.0.0.1:3000/ http://127.0.0.1:3000/recipe/list

http://127.0.0.1:3001/ http://127.0.0.1:3001/recipe/list

http://127.0.0.1:3001/account/signup http://127.0.0.1:3001/test

http://127.0.0.1:3001/item

Hot Chips (delete) Snacks 2004-11-11

Ice Water (delete) Beverages 2004-11-11

Killer Mushrooms (delete) Snacks 2005-09-13

満足せる豚。眠たげなポチ。:Rolling with Ruby on Rails - Japanese Translation - p1

満足せる豚。眠たげなポチ。:Rolling on Ruby on Rails - Japanese Translation - p5

BookmarkOnInstantRails

ITmedia エンタープライズ:第1回 Instant Railsで始めるWindows環境のRails (1/2)

developerWorks Japan

developerWorks Japan

DROP TABLE IF EXISTS `items`;

CREATE TABLE items (

id int(11) NOT NULL auto_increment,

login varchar(80) default NULL,

password varchar(40) default NULL,

PRIMARY KEY (id)

);

えぇてるのぉと:Railsでログイン認証 - livedoor Blog(ブログ)

8 app/views/test/index.rhtmlの編集

<h1>Test#index</h1>

Welcom <%= @session['user'].login %>!

Login Generator (1) - Nowhere Near

config/environment.rb に以下の行を追加する。

module LoginEngine

config :salt, "your-salt-here"

end

Engines.start :login

http://techno.hippy.jp/rorwiki/?Wiki%A4%F2%BA%EE%A4%C3%A4%C6%A4%DF%A4%EB%2F%A5%E6%A1%BC%A5%B6%A1%BC%A4%F2%C7%A7%BE%DA%A4%B9%A4%EB

パパブログ: RoR : login_generator : login中のユーザ情報の取得

@session['user'].id

@session['user'].login

@session['user'].password

で、idやloginが取得できる。

ちなみにidActiveRecordおなじみのidで、

loginがログイン名、passwordパスワードになる。


MySQL-Front download

環境変数

;C:\nonidata\InstantRails\ruby\bin;

cd C:\nonidata\InstantRails\ruby\bin

C:\nonidata\InstantRails\ruby\bin>gem install login_generator

Successfully installed login_generator-1.2.2

C:\nonidata\InstantRails>cd C:\nonidata\InstantRails\rails_apps\cookbook

C:\nonidata\InstantRails\rails_apps\cookbook>ruby script/generate login Account

create lib/login_system.rb

C:\nonidata\InstantRails\rails_apps>cd C:\nonidata\InstantRails\rails_apps\cookbook

C:\nonidata\InstantRails\rails_apps\cookbook>ruby script/generate controller test

exists app/controllers/

[Ruby] Rails(ActiveRecord)の多対多関連 - yuum3のお仕事日記

has_one

has_many

belongs_to

has_and_belongs_to_many

habtm と has_many :through (ActiveRecord)

ヽ( ・∀・)ノくまくまー(2006-01-20)

ActiveRecord の歩き方 - Association 編(1) - Rails で行こう! - Ruby on Rails を学ぶ has_many :comments

developerWorks Japan  has_one :address

Rubyist Magazine - RubyOnRails を使ってみる 【第 3 回】 ActiveRecord

create メソッドを使うこともできます。create は new したあと save (DB に格納) します。


Rubyist Magazine - RubyOnRails を使ってみる 【第 4 回】 ActionPack

find(:all, :conditions => ["user_name = ?", user_name])

find_all(["user_name = ?", user_name])

find_all_by_user_name(user_name)


Part2 Rubyに学ぶ「Ruby on Railsの正体」:ITpro

book = Product.find_or_create_by_name_and_price('book', 2079)

リスト7●productsテーブルからnameが'book',priceが2079であるようなProductオブジェクトを読み取り,存在しなかった場合はデータベースレコードを新規作成する処理


RoR Wiki 翻訳 Wiki - HowToUseLegacySchemas

恣意的で複雑なクエリや、主キーを持たないテーブルにはfind_by_sqlを使う

テーブルが論理的な主キーを持たないなら、

find_by_sqlを使えば主キーを全く指定しない曖昧で複雑なクエリを実行も実行できる。

Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]


エディタ utf8

文字化け

ヽ( ・∀・)ノくまくまー(2006-10-11)

チュートリアルを動かしてみる - 肩書「シニアコンサルタント」のつぶやき

Railsでソーシャルブックマークを作ってみようか(第1回) - 坊やがゆく

ようこそ<%= @session['user'].login %>さん

@session['user'].id


Railsでソーシャルブックマークを作ってみようか(第2回) - 坊やがゆく

Railsでお馴染み37signalsのURLが凄い件について:TKMR.blog.show

URLにキーワードを含めことでSEO対策になるかも、でもそれだけ:TKMR.blog.show

http://127.0.0.1:3001

http://127.0.0.1:3001/recipe/list

tetraの外部記憶箱 - Instant Railsのインストール , 追記:phpMyAdminの日本語環境設定 , 未踏ソフト記事

[Ruby]PHP VS Rails (Ruby on Rails)

ログイン ユーザー登録
ようこそ ゲスト さん