{"id":25965,"date":"2025-04-10T04:31:45","date_gmt":"2025-04-09T19:31:45","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=25965"},"modified":"2025-04-10T04:31:47","modified_gmt":"2025-04-09T19:31:47","slug":"%e5%b0%8f%e8%aa%ac%e6%8a%95%e7%a8%bf%e3%82%b5%e3%82%a4%e3%83%88","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=25965","title":{"rendered":"\u5c0f\u8aac\u6295\u7a3f\u30b5\u30a4\u30c8"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\n&lt;html lang=\"ja\">\n&lt;head>\n  &lt;meta charset=\"UTF-8\">\n  &lt;title>\u5c0f\u8aac\u6295\u7a3f\u30b5\u30a4\u30c8&lt;\/title>\n  &lt;style>\n    body {\n      font-family: sans-serif;\n      padding: 20px;\n      max-width: 800px;\n      margin: auto;\n      background: #f2f2f2;\n    }\n\n    h1 {\n      text-align: center;\n    }\n\n    form {\n      background: white;\n      padding: 20px;\n      border-radius: 10px;\n      margin-bottom: 30px;\n      box-shadow: 0 0 10px rgba(0,0,0,0.1);\n    }\n\n    input, textarea {\n      width: 100%;\n      margin-bottom: 10px;\n      padding: 10px;\n      border-radius: 5px;\n      border: 1px solid #ccc;\n    }\n\n    button {\n      padding: 10px 20px;\n      background-color: #007bff;\n      color: white;\n      border: none;\n      border-radius: 5px;\n      cursor: pointer;\n    }\n\n    .post {\n      background: white;\n      padding: 15px;\n      border-left: 5px solid #007bff;\n      margin-bottom: 20px;\n      border-radius: 5px;\n    }\n\n    .post h2 {\n      margin: 0 0 10px;\n    }\n\n    .meta {\n      color: gray;\n      font-size: 0.9em;\n      margin-bottom: 10px;\n    }\n\n    .delete-btn {\n      background-color: #dc3545;\n      color: white;\n      border: none;\n      padding: 5px 10px;\n      border-radius: 4px;\n      float: right;\n      cursor: pointer;\n    }\n  &lt;\/style>\n&lt;\/head>\n&lt;body>\n  &lt;h1>\u5c0f\u8aac\u6295\u7a3f\u30b5\u30a4\u30c8&lt;\/h1>\n\n  &lt;form id=\"novelForm\">\n    &lt;input type=\"text\" id=\"author\" placeholder=\"\u8457\u8005\u540d\" required>\n    &lt;input type=\"text\" id=\"title\" placeholder=\"\u30bf\u30a4\u30c8\u30eb\" required>\n    &lt;textarea id=\"content\" rows=\"8\" placeholder=\"\u672c\u6587\" required>&lt;\/textarea>\n    &lt;button type=\"submit\">\u6295\u7a3f\u3059\u308b&lt;\/button>\n  &lt;\/form>\n\n  &lt;div id=\"postList\">&lt;\/div>\n\n  &lt;script>\n    const form = document.getElementById('novelForm');\n    const postList = document.getElementById('postList');\n    let posts = JSON.parse(localStorage.getItem('novels')) || &#91;];\n\n    function saveAndRender() {\n      localStorage.setItem('novels', JSON.stringify(posts));\n      renderPosts();\n    }\n\n    function renderPosts() {\n      postList.innerHTML = '';\n      &#91;...posts].reverse().forEach((post, index) => {\n        const div = document.createElement('div');\n        div.className = 'post';\n        div.innerHTML = `\n          &lt;button class=\"delete-btn\" onclick=\"deletePost(${index})\">\u524a\u9664&lt;\/button>\n          &lt;h2>${post.title}&lt;\/h2>\n          &lt;div class=\"meta\">\u8457\u8005: ${post.author} | \u6295\u7a3f\u65e5: ${post.date}&lt;\/div>\n          &lt;p>${post.content.replace(\/\\n\/g, '&lt;br>')}&lt;\/p>\n        `;\n        postList.appendChild(div);\n      });\n    }\n\n    form.addEventListener('submit', e => {\n      e.preventDefault();\n      const title = document.getElementById('title').value;\n      const content = document.getElementById('content').value;\n      const author = document.getElementById('author').value;\n      const date = new Date().toLocaleString();\n\n      posts.push({ title, content, author, date });\n      form.reset();\n      saveAndRender();\n    });\n\n    window.deletePost = function(index) {\n      posts.splice(posts.length - 1 - index, 1); \/\/ reverse\u3057\u3066\u308b\u305f\u3081\n      saveAndRender();\n    }\n\n    renderPosts();\n  &lt;\/script>\n&lt;\/body>\n&lt;\/html>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","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":[6,87],"tags":[],"class_list":["post-25965","post","type-post","status-publish","format-standard","hentry","category-web"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25965","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=25965"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25965\/revisions"}],"predecessor-version":[{"id":25966,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25965\/revisions\/25966"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25965"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}