Skip to content

Instantly share code, notes, and snippets.

@nichesan
nichesan / open_comment.js
Created February 8, 2013 13:35
フォームの開閉など。html上の<onclick = "open_comment(this.className)" class = "~">を含む要素をクリックする度に、<id = "~"> を含む要素のdisplay値をnone<->blockに切り替えます。
function open_comment (className) {
var norb = document.getElementById(className).style.display;
if (norb == 'none') {
document.getElementById(className).style.display = 'block';
} else {
document.getElementById(className).style.display = 'none';
}
}
@nichesan
nichesan / bbs.rb
Created February 7, 2013 15:32
RubyとSQLiteを使った掲示板。 タイトルが bbs.rb と表示されていますが、実際は bbs.cgi という名前で動かしました。 メインの表示部分は114行目から。 テーブルの構成は以下の通り。 (id integer PRIMARY KEY AUTOINCREMENT, name text DEFAULT 'No Name', title text DEFAULT 'No Title', message text NOT NULL, date TIMESTAMP DEFAULT (DATETIME('now','localtime')));
require 'sqlite3'
require 'cgi'
cgi = CGI.new
#フォームから受け取った値を変数に入れる
vname = cgi["name"]
vtitle = cgi["title"]
vmessage = cgi["message"]
#URLクエリのページ値