{"version":3,"names":["window","location","href","footer","document","querySelector","style","display","header","includes","createElement","innerHTML","head","appendChild","showTitleField","console","log","editor","inputEl","classList","add","urlPattern","checkElementAndURL","titleInput","getElementById","isArticleCategory","observer","disconnect","value","trim","dispatchEvent","Event","bubbles","config","childList","subtree","callback","mutationsList","mutation","type","MutationObserver","targetNode","body","observe"],"sources":["theme-4-inline-common-body_tag.js"],"sourcesContent":["\n\n//fill title field with placeholder\n\n\n  // Check if the current URL matches the signup or login page\nif (window.location.href === \"https://taamjib.hd.co.th/signup\" || window.location.href === \"https://taamjib.hd.co.th/login\") {\n    // Select the footer and hide it\n    const footer = document.querySelector('footer');\n    if (footer) {\n        footer.style.display = 'none';\n    }\n\n    // Select the header and hide it\n    const header = document.querySelector('header.b-header');\n    if (header) {\n        header.style.display = 'none';\n    }\n}\n\n// Check if the URL contains \"https://taamjib.hd.co.th/t/topic/\"\nif (window.location.href.includes(\"topic\")) {\n    // Create a style element\n    const style = document.createElement('style');\n    style.innerHTML = `\n        .badge-category {\n            background: var(--color-primary-light) !important;\n            color: var(--color-text-dark) !important;\n            padding: 0.5em 1.5em;\n            border-radius: 100px;\n        }\n    `;\n    // Append the style to the head of the document\n    document.head.appendChild(style);\n}\n\nfunction showTitleField() {\n  console.log(\"Target element found and URL matches!\");\n  const editor = document.querySelector(\".d-editor\");\n  const inputEl = editor.querySelector(\"#reply-title\");\n\n  if (!editor || !inputEl) return;\n\n  inputEl.classList.add(\"is-article\");\n}\n\nconst urlPattern = \"/c/articles\";\n\n//original\n// function checkElementAndURL() {\n//   const targetElement = document.getElementById(\"reply-title\");\n\n//   if (targetElement) {\n//     if (window.location.href.includes(urlPattern)) {\n//       console.log(\"Element #reply-title found.\");\n//       showTitleField();\n//       observer.disconnect();\n//     }\n//   }\n// }\n\n// Function to check for the element and URL\nfunction checkElementAndURL() {\n  const titleInput = document.getElementById(\"reply-title\");\n\n  if (titleInput) {\n    const isArticleCategory = window.location.href.includes(\"/c/articles\");\n\n    if (isArticleCategory) {\n      console.log(\"Element #reply-title found in article category.\");\n      showTitleField(); // Show it and leave it alone\n      observer.disconnect();\n    } else {\n      console.log(\"Non-article post.\");\n\n      // Set a placeholder value to satisfy Discourse title validation\n      if (!titleInput.value.trim()) {\n        titleInput.value = \"unanswered question\";\n        titleInput.dispatchEvent(new Event(\"input\", { bubbles: true }));\n        console.log(titleInput.value)\n        titleInput.dispatchEvent(new Event(\"change\", { bubbles: true }));\n        \n      }\n\n      observer.disconnect();\n    }\n  }\n}\n\n\n// Options for the observer (which mutations to observe)\nconst config = { childList: true, subtree: true };\n\n// Callback function to execute when mutations are observed\nconst callback = function (mutationsList, observer) {\n  for (const mutation of mutationsList) {\n    if (mutation.type === \"childList\") {\n      checkElementAndURL();\n      break; \n    }\n  }\n};\n\nconst observer = new MutationObserver(callback);\nconst targetNode = document.body;\nobserver.observe(targetNode, config);\n\ncheckElementAndURL();\n\n\n"],"mappings":"AAEA;;AAGE;AACF,IAAIA,MAAM,CAACC,QAAQ,CAACC,IAAI,KAAK,iCAAiC,IAAIF,MAAM,CAACC,QAAQ,CAACC,IAAI,KAAK,gCAAgC,EAAE;EACzH;EACA,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/C,IAAIF,MAAM,EAAE;IACRA,MAAM,CAACG,KAAK,CAACC,OAAO,GAAG,MAAM;EACjC;;EAEA;EACA,MAAMC,MAAM,GAAGJ,QAAQ,CAACC,aAAa,CAAC,iBAAiB,CAAC;EACxD,IAAIG,MAAM,EAAE;IACRA,MAAM,CAACF,KAAK,CAACC,OAAO,GAAG,MAAM;EACjC;AACJ;;AAEA;AACA,IAAIP,MAAM,CAACC,QAAQ,CAACC,IAAI,CAACO,QAAQ,CAAC,OAAO,CAAC,EAAE;EACxC;EACA,MAAMH,KAAK,GAAGF,QAAQ,CAACM,aAAa,CAAC,OAAO,CAAC;EAC7CJ,KAAK,CAACK,SAAS,GAAG;AACtB;AACA;AACA;AACA;AACA;AACA;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