つぶやきアプリ「ELDER」

index.html

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ELDER</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>ELDER</h1>
    </header>

    <main>
        <section id="post-form">
            <h2>つぶやく</h2>
            <form id="tweet-form">
                <input type="text" id="user-name" placeholder="ユーザー名">
                <textarea id="tweet-content" placeholder="今何をつぶやく?" maxlength="280"></textarea>
                <div id="counter">0 / 280</div>
                <button type="submit">つぶやく</button>
            </form>
        </section>

        <section id="tweets">
            <h2>つぶやき</h2>
            <!-- つぶやきの表示領域 -->
        </section>
    </main>

    <footer>
        <p>© 2024 ELDER</p>
    </footer>

    <script src="script.js"></script>
</body>
</html>

styles.css

/* Reset CSS */
body, h1, h2, form, textarea, button, input {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f0f0f0;
}

header {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 10px 0;
}

main {
    margin-top: 20px;
}

#post-form, #tweets {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}

input[type="text"], textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    resize: vertical;
}

#counter {
    margin-bottom: 10px;
    color: #666;
}

button {
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

button:hover {
    background-color: #555;
}

.tweet {
    border-bottom: 1px solid #ccc;
    padding: 10px 0;
}

.tweet-content {
    margin-bottom: 5px;
}

.tweet-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.like-button, .comment-button {
    background-color: transparent;
    border: none;
    color: #666;
    cursor: pointer;
}

.like-button:hover, .comment-button:hover {
    color: #333;
}

.comments {
    margin-top: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 3px;
}

.comment-input {
    width: calc(100% - 80px);
    margin-bottom: 10px;
}

.comment-list {
    list-style: none;
    padding: 0;
}

.comment-item {
    border-bottom: 1px solid #ccc;
    padding: 5px 0;
}

.comment-author {
    font-weight: bold;
    margin-bottom: 5px;
}

.comment-content {
    margin-left: 20px;
}

script.js

document.addEventListener("DOMContentLoaded", function() {
    const tweetForm = document.getElementById("tweet-form");
    const userNameInput = document.getElementById("user-name");
    const tweetContent = document.getElementById("tweet-content");
    const tweetsSection = document.getElementById("tweets");
    const counter = document.getElementById("counter");

    // ローカルストレージからデータを取得
    let tweets = JSON.parse(localStorage.getItem("tweets")) || [];

    // ページ読み込み時に保存されたつぶやきを表示
    tweets.forEach(function(tweet) {
        displayTweet(tweet);
    });

    // つぶやきを投稿するイベントリスナー
    tweetForm.addEventListener("submit", function(event) {
        event.preventDefault(); // フォームのデフォルトの動作をキャンセル

        const content = tweetContent.value.trim();
        const userName = userNameInput.value.trim();
        if (userName === "") {
            alert("ユーザー名を入力してください!");
            return;
        }
        if (content === "") {
            alert("つぶやきを入力してください!");
            return;
        }

        if (content.length > 280) {
            alert("つぶやきは280文字以内で入力してください!");
            return;
        }

        // つぶやきを表示する
        displayTweet({userName: userName, content: content, likes: 0});

        // ローカルストレージにデータを保存
        tweets.push({userName: userName, content: content, likes: 0});
        localStorage.setItem("tweets", JSON.stringify(tweets));

        // フォームをクリアする
        tweetContent.value = "";
        userNameInput.value = "";
        counter.textContent = "0 / 280";
    });

    // 文字数カウンターの更新
    tweetContent.addEventListener("input", function() {
        const contentLength = tweetContent.value.length;
        counter.textContent = contentLength + " / 280";
    });

    // つぶやきを表示する関数
    function displayTweet(tweet) {
        const tweetDiv = document.createElement("div");
        tweetDiv.classList.add("tweet");

        const tweetContentDiv = document.createElement("div");
        tweetContentDiv.classList.add("tweet-content");
        tweetContentDiv.textContent = tweet.content;

        const tweetActionsDiv = document.createElement("div");
        tweetActionsDiv.classList.add("tweet-actions");

        const likeButton = document.createElement("button");
        likeButton.classList.add("like-button");
        likeButton.textContent = "いいね";
        likeButton.addEventListener("click", function() {
            tweet.likes++;
            localStorage.setItem("tweets", JSON.stringify(tweets));
            updateTweet(tweet, tweetDiv);
        });

        const commentButton = document.createElement("button");
        commentButton.classList.add("comment-button");
        commentButton.textContent = "コメント";

        tweetActionsDiv.appendChild(likeButton);
        tweetActionsDiv.appendChild(commentButton);

        tweetDiv.appendChild(tweetContentDiv);
        tweetDiv.appendChild(tweetActionsDiv);

        updateTweet(tweet, tweetDiv);

        tweetsSection.prepend(tweetDiv); // 新しいつぶやきを上に表示
    }

    // つぶやきの表示を更新する関数
    function updateTweet(tweet, tweetDiv) {
        tweetDiv.innerHTML = ""; // 既存の表示をクリア

        const tweetContentDiv = document.createElement("div");
        tweetContentDiv.classList.add("tweet-content");
        tweetContentDiv.textContent = `${tweet.userName}: ${tweet.content}`;

        const tweetActionsDiv = document.createElement("div");
        tweetActionsDiv.classList.add("tweet-actions");
        const likeButton = document.createElement("button");
        likeButton.classList.add("like-button");
        likeButton.textContent = `いいね (${tweet.likes})`;
        likeButton.addEventListener("click", function() {
            tweet.likes++;
            localStorage.setItem("tweets", JSON.stringify(tweets));
            updateTweet(tweet, tweetDiv);
        });

        const commentButton = document.createElement("button");
        commentButton.classList.add("comment-button");
        commentButton.textContent = "コメント";

        tweetActionsDiv.appendChild(likeButton);
        tweetActionsDiv.appendChild(commentButton);

        tweetDiv.appendChild(tweetContentDiv);
        tweetDiv.appendChild(tweetActionsDiv);
    }
});

http://tyosuke20xx.com/ELDER/index.html

「ここでしか手に入らない」と書かれていたのに…… 角川「くじ引き堂」への不満訴える投稿に注目集まる 運営元と弁護士の見解は

「ここでしか手に入らないオリジナルグッズ」と書かれていたのに――オンラインくじでゲームのグッズを購入後、同じグッズが海外で個別販売されたとして不満を訴える投稿に共感が集まっています。購入者やくじの運営元、弁護士に取材しました。 購入者が注意喚起を投稿したくじ引き堂の「コーヒートーク オンラインくじ」…

Posted from: this blog via Microsoft Power Automate.

天使の輪が死人を表す漫画的表現になっているのって変だな 人が死んでも天..

天使の輪が死人を表す漫画的表現になっているのって変だな 人が死んでも天使になるわけじゃない、キリスト教的世界観においても この表現を多用している一番有名な漫画はおそらくドラゴンボールだろう どこかで発想の飛躍があったのかな 気になるねえ、ぐぐりましょうねえ 天使に限らず聖人などを描いた絵画にも、聖人の…

Posted from: this blog via Microsoft Power Automate.

日本の画期的カキ陸上養殖に仏紙「久米島で革命が起きている」 | その牡蠣は“あたらない”らしい…

食中毒の心配なしに食べられる「あたらない牡蠣」の生産を目指し、沖縄県・久米島で開発が進む牡蠣の陸上養殖。日本と同じく生牡蠣を愛する国、フランスの「ル・モンド」紙特派員が久米島へ、世界初の試みの現場を訪ねた。 プレハブの事務所、いけすのある温室、謎めいたコンクリートの建物……。日本の南端にある小さな島…

Posted from: this blog via Microsoft Power Automate.

忙しい中で仕事を効率よく切り上げ、「自分の時間」を楽しむために私が工夫していること #趣味と仕事 – りっすん by イーアイデム

出勤日は仕事ばかりで1日が終わり、せっかくの休みも疲れでぐったり……。忙しく働く中で、そんなふうに過ごしている人は少なくないでしょう。 スタートアップ企業で働く会社員でブロガーの円錐さんも、かつてはそんな余裕のない日々を送っていました。しかし大好きな趣味ができたことから、「平日も休日も自分の時間を楽…

Posted from: this blog via Microsoft Power Automate.

「日本料理がおいしいの日本人が慣れてるだけ」「日本料理は切っただけ煮ただけ焼いただけでスパイスが貧弱」に反論が集まった話

なも@また凍結 @namosyotakon4 日本の食事は世界一美味しいみたいな言説かなり疑問視してる 出身地が日本で日本の料理に慣れているから一番美味しく感じるだけでしょ 2024-02-14 19:42:58 なも@また凍結 @namosyotakon4 補足しますと、日本人が食事をするなら日本の食事が世界で一番美味しいと思います。 しかしそれが外…

Posted from: this blog via Microsoft Power Automate.

ねぇ、本当に歳をとった!!!!

すごくセックスしたい!!が、相手がマジでいない!!!! 若い頃は楽だったなー。 若い頃はな… 一軒目が終わるくらいの夜の繁華街で、公園で1人、花壇のふちに腰掛けて、タバコを吹かしてれば、いくらでも声がかかった。 道行く人で好みのタイプがいれば、じっと見つめてみれば、相手から声をかけてくれた。 バーに入っ…

Posted from: this blog via Microsoft Power Automate.

はてな匿名ダイアリー内のキーワードリンクが表示されない不具合を修正しました – はてラボ 開発者ブログ

2/15(木)11時頃~2/16(金)10時頃まで、はてな匿名ダイアリー内のキーワードリンクが表示されない不具合が発生しておりました。 現在は修正済みです。 今後ともはてな匿名ダイアリーをよろしくお願いいたします。 anond.hatelabo.jp

Posted from: this blog via Microsoft Power Automate.

【令和最新版】タイトルに数字が入ってる曲【はてな民版もあるよ】

【令和最新版】(カラオケランキングより抜粋) 115万キロのフィルム(Official髭男dism) 366日 3月9日 一途 千本桜 M七八 【はてな民版】 Majiで恋する5秒前 1/3の純情な感情 夏の日の1993 銀河鉄道999 LOVE2000 1/2 勇気100% 15の夜 17歳の地図 2億4千万の瞳 他にあったらおしえてね!

Posted from: this blog via Microsoft Power Automate.

政治家はどこで酒を飲むのか

「料亭に行きたい」、初当選直後のインタビューで答え、話題となった新人議員がいた(今はいない)。カツラメーカーのコマーシャルは政治家をモチーフにしているが、やはり料亭の一室での密談のシーンだ。映画やテレビドラマの影響で、「政治家が飲むところ=料亭」というのがお決まりとなっている。しかし、実際のところ…

Posted from: this blog via Microsoft Power Automate.