{"id":19226,"date":"2024-02-16T16:53:31","date_gmt":"2024-02-16T07:53:31","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=19226"},"modified":"2024-02-16T16:53:32","modified_gmt":"2024-02-16T07:53:32","slug":"%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8d%e3%82%a2%e3%83%97%e3%83%aa%e3%80%8celder%e3%80%8d","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=19226","title":{"rendered":"\u3064\u3076\u3084\u304d\u30a2\u30d7\u30ea\u300cELDER\u300d"},"content":{"rendered":"\n<p>index.html<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-html\" data-lang=\"HTML\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;ja&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &lt;title&gt;ELDER&lt;\/title&gt;\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;header&gt;\n        &lt;h1&gt;ELDER&lt;\/h1&gt;\n    &lt;\/header&gt;\n\n    &lt;main&gt;\n        &lt;section id=&quot;post-form&quot;&gt;\n            &lt;h2&gt;\u3064\u3076\u3084\u304f&lt;\/h2&gt;\n            &lt;form id=&quot;tweet-form&quot;&gt;\n                &lt;input type=&quot;text&quot; id=&quot;user-name&quot; placeholder=&quot;\u30e6\u30fc\u30b6\u30fc\u540d&quot;&gt;\n                &lt;textarea id=&quot;tweet-content&quot; placeholder=&quot;\u4eca\u4f55\u3092\u3064\u3076\u3084\u304f\uff1f&quot; maxlength=&quot;280&quot;&gt;&lt;\/textarea&gt;\n                &lt;div id=&quot;counter&quot;&gt;0 \/ 280&lt;\/div&gt;\n                &lt;button type=&quot;submit&quot;&gt;\u3064\u3076\u3084\u304f&lt;\/button&gt;\n            &lt;\/form&gt;\n        &lt;\/section&gt;\n\n        &lt;section id=&quot;tweets&quot;&gt;\n            &lt;h2&gt;\u3064\u3076\u3084\u304d&lt;\/h2&gt;\n            &lt;!-- \u3064\u3076\u3084\u304d\u306e\u8868\u793a\u9818\u57df --&gt;\n        &lt;\/section&gt;\n    &lt;\/main&gt;\n\n    &lt;footer&gt;\n        &lt;p&gt;&copy; 2024 ELDER&lt;\/p&gt;\n    &lt;\/footer&gt;\n\n    &lt;script src=&quot;script.js&quot;&gt;&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre><\/div>\n\n\n\n<p>styles.css<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-css\" data-lang=\"CSS\"><code>\/* Reset CSS *\/\r\nbody, h1, h2, form, textarea, button, input {\r\n    margin: 0;\r\n    padding: 0;\r\n}\r\n\r\nbody {\r\n    font-family: Arial, sans-serif;\r\n    line-height: 1.6;\r\n    background-color: #f0f0f0;\r\n}\r\n\r\nheader {\r\n    background-color: #333;\r\n    color: #fff;\r\n    text-align: center;\r\n    padding: 10px 0;\r\n}\r\n\r\nmain {\r\n    margin-top: 20px;\r\n}\r\n\r\n#post-form, #tweets {\r\n    background-color: #fff;\r\n    padding: 20px;\r\n    margin-bottom: 20px;\r\n    border-radius: 5px;\r\n}\r\n\r\ninput[type=&quot;text&quot;], textarea {\r\n    width: 100%;\r\n    padding: 10px;\r\n    margin-bottom: 10px;\r\n    border: 1px solid #ccc;\r\n    border-radius: 3px;\r\n    resize: vertical;\r\n}\r\n\r\n#counter {\r\n    margin-bottom: 10px;\r\n    color: #666;\r\n}\r\n\r\nbutton {\r\n    padding: 10px 20px;\r\n    background-color: #333;\r\n    color: #fff;\r\n    border: none;\r\n    border-radius: 3px;\r\n    cursor: pointer;\r\n}\r\n\r\nbutton:hover {\r\n    background-color: #555;\r\n}\r\n\r\n.tweet {\r\n    border-bottom: 1px solid #ccc;\r\n    padding: 10px 0;\r\n}\r\n\r\n.tweet-content {\r\n    margin-bottom: 5px;\r\n}\r\n\r\n.tweet-actions {\r\n    display: flex;\r\n    justify-content: space-between;\r\n    align-items: center;\r\n}\r\n\r\n.like-button, .comment-button {\r\n    background-color: transparent;\r\n    border: none;\r\n    color: #666;\r\n    cursor: pointer;\r\n}\r\n\r\n.like-button:hover, .comment-button:hover {\r\n    color: #333;\r\n}\r\n\r\n.comments {\r\n    margin-top: 10px;\r\n    padding: 10px;\r\n    background-color: #f9f9f9;\r\n    border-radius: 3px;\r\n}\r\n\r\n.comment-input {\r\n    width: calc(100% - 80px);\r\n    margin-bottom: 10px;\r\n}\r\n\r\n.comment-list {\r\n    list-style: none;\r\n    padding: 0;\r\n}\r\n\r\n.comment-item {\r\n    border-bottom: 1px solid #ccc;\r\n    padding: 5px 0;\r\n}\r\n\r\n.comment-author {\r\n    font-weight: bold;\r\n    margin-bottom: 5px;\r\n}\r\n\r\n.comment-content {\r\n    margin-left: 20px;\r\n}\r\n<\/code><\/pre><\/div>\n\n\n\n<p>script.js<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-js\" data-lang=\"JavaScript\"><code>document.addEventListener(&quot;DOMContentLoaded&quot;, function() {\r\n    const tweetForm = document.getElementById(&quot;tweet-form&quot;);\r\n    const userNameInput = document.getElementById(&quot;user-name&quot;);\r\n    const tweetContent = document.getElementById(&quot;tweet-content&quot;);\r\n    const tweetsSection = document.getElementById(&quot;tweets&quot;);\r\n    const counter = document.getElementById(&quot;counter&quot;);\r\n\r\n    \/\/ \u30ed\u30fc\u30ab\u30eb\u30b9\u30c8\u30ec\u30fc\u30b8\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\r\n    let tweets = JSON.parse(localStorage.getItem(&quot;tweets&quot;)) || [];\r\n\r\n    \/\/ \u30da\u30fc\u30b8\u8aad\u307f\u8fbc\u307f\u6642\u306b\u4fdd\u5b58\u3055\u308c\u305f\u3064\u3076\u3084\u304d\u3092\u8868\u793a\r\n    tweets.forEach(function(tweet) {\r\n        displayTweet(tweet);\r\n    });\r\n\r\n    \/\/ \u3064\u3076\u3084\u304d\u3092\u6295\u7a3f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\u30ea\u30b9\u30ca\u30fc\r\n    tweetForm.addEventListener(&quot;submit&quot;, function(event) {\r\n        event.preventDefault(); \/\/ \u30d5\u30a9\u30fc\u30e0\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u52d5\u4f5c\u3092\u30ad\u30e3\u30f3\u30bb\u30eb\r\n\r\n        const content = tweetContent.value.trim();\r\n        const userName = userNameInput.value.trim();\r\n        if (userName === &quot;&quot;) {\r\n            alert(&quot;\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\uff01&quot;);\r\n            return;\r\n        }\r\n        if (content === &quot;&quot;) {\r\n            alert(&quot;\u3064\u3076\u3084\u304d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\uff01&quot;);\r\n            return;\r\n        }\r\n\r\n        if (content.length &gt; 280) {\r\n            alert(&quot;\u3064\u3076\u3084\u304d\u306f280\u6587\u5b57\u4ee5\u5185\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\uff01&quot;);\r\n            return;\r\n        }\r\n\r\n        \/\/ \u3064\u3076\u3084\u304d\u3092\u8868\u793a\u3059\u308b\r\n        displayTweet({userName: userName, content: content, likes: 0});\r\n\r\n        \/\/ \u30ed\u30fc\u30ab\u30eb\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\r\n        tweets.push({userName: userName, content: content, likes: 0});\r\n        localStorage.setItem(&quot;tweets&quot;, JSON.stringify(tweets));\r\n\r\n        \/\/ \u30d5\u30a9\u30fc\u30e0\u3092\u30af\u30ea\u30a2\u3059\u308b\r\n        tweetContent.value = &quot;&quot;;\r\n        userNameInput.value = &quot;&quot;;\r\n        counter.textContent = &quot;0 \/ 280&quot;;\r\n    });\r\n\r\n    \/\/ \u6587\u5b57\u6570\u30ab\u30a6\u30f3\u30bf\u30fc\u306e\u66f4\u65b0\r\n    tweetContent.addEventListener(&quot;input&quot;, function() {\r\n        const contentLength = tweetContent.value.length;\r\n        counter.textContent = contentLength + &quot; \/ 280&quot;;\r\n    });\r\n\r\n    \/\/ \u3064\u3076\u3084\u304d\u3092\u8868\u793a\u3059\u308b\u95a2\u6570\r\n    function displayTweet(tweet) {\r\n        const tweetDiv = document.createElement(&quot;div&quot;);\r\n        tweetDiv.classList.add(&quot;tweet&quot;);\r\n\r\n        const tweetContentDiv = document.createElement(&quot;div&quot;);\r\n        tweetContentDiv.classList.add(&quot;tweet-content&quot;);\r\n        tweetContentDiv.textContent = tweet.content;\r\n\r\n        const tweetActionsDiv = document.createElement(&quot;div&quot;);\r\n        tweetActionsDiv.classList.add(&quot;tweet-actions&quot;);\r\n\r\n        const likeButton = document.createElement(&quot;button&quot;);\r\n        likeButton.classList.add(&quot;like-button&quot;);\r\n        likeButton.textContent = &quot;\u3044\u3044\u306d&quot;;\r\n        likeButton.addEventListener(&quot;click&quot;, function() {\r\n            tweet.likes++;\r\n            localStorage.setItem(&quot;tweets&quot;, JSON.stringify(tweets));\r\n            updateTweet(tweet, tweetDiv);\r\n        });\r\n\r\n        const commentButton = document.createElement(&quot;button&quot;);\r\n        commentButton.classList.add(&quot;comment-button&quot;);\r\n        commentButton.textContent = &quot;\u30b3\u30e1\u30f3\u30c8&quot;;\r\n\r\n        tweetActionsDiv.appendChild(likeButton);\r\n        tweetActionsDiv.appendChild(commentButton);\r\n\r\n        tweetDiv.appendChild(tweetContentDiv);\r\n        tweetDiv.appendChild(tweetActionsDiv);\r\n\r\n        updateTweet(tweet, tweetDiv);\r\n\r\n        tweetsSection.prepend(tweetDiv); \/\/ \u65b0\u3057\u3044\u3064\u3076\u3084\u304d\u3092\u4e0a\u306b\u8868\u793a\r\n    }\r\n\r\n    \/\/ \u3064\u3076\u3084\u304d\u306e\u8868\u793a\u3092\u66f4\u65b0\u3059\u308b\u95a2\u6570\r\n    function updateTweet(tweet, tweetDiv) {\r\n        tweetDiv.innerHTML = &quot;&quot;; \/\/ \u65e2\u5b58\u306e\u8868\u793a\u3092\u30af\u30ea\u30a2\r\n\r\n        const tweetContentDiv = document.createElement(&quot;div&quot;);\r\n        tweetContentDiv.classList.add(&quot;tweet-content&quot;);\r\n        tweetContentDiv.textContent = `${tweet.userName}: ${tweet.content}`;\r\n\r\n        const tweetActionsDiv = document.createElement(&quot;div&quot;);\r\n        tweetActionsDiv.classList.add(&quot;tweet-actions&quot;);\r\n        const likeButton = document.createElement(&quot;button&quot;);\r\n        likeButton.classList.add(&quot;like-button&quot;);\r\n        likeButton.textContent = `\u3044\u3044\u306d (${tweet.likes})`;\r\n        likeButton.addEventListener(&quot;click&quot;, function() {\r\n            tweet.likes++;\r\n            localStorage.setItem(&quot;tweets&quot;, JSON.stringify(tweets));\r\n            updateTweet(tweet, tweetDiv);\r\n        });\r\n\r\n        const commentButton = document.createElement(&quot;button&quot;);\r\n        commentButton.classList.add(&quot;comment-button&quot;);\r\n        commentButton.textContent = &quot;\u30b3\u30e1\u30f3\u30c8&quot;;\r\n\r\n        tweetActionsDiv.appendChild(likeButton);\r\n        tweetActionsDiv.appendChild(commentButton);\r\n\r\n        tweetDiv.appendChild(tweetContentDiv);\r\n        tweetDiv.appendChild(tweetActionsDiv);\r\n    }\r\n});\r\n<\/code><\/pre><\/div>\n\n\n\n<p>http:\/\/tyosuke20xx.com\/ELDER\/index.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>index.html styles.css script.js http:\/\/tyosuke20xx.com\/ELDER\/index.html<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-19226","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/19226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19226"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/19226\/revisions"}],"predecessor-version":[{"id":19227,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/19226\/revisions\/19227"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19226"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}