<link async="async" rel="stylesheet" href="https://rawcdn.githack.com/ptcreborn/ptcreborn/c6a0f6348f4a0f904e51162f59338776024964d0/createpost.css?min=1" /> <script async='async' src='https://rawcdn.githack.com/ptcreborn/ptcreborn/7c98e7d3201ae92d6e1b11a79d3fe2413c2289b8/stackfunctions.js'></script> <script async='async' src='https://rawcdn.githack.com/ptcreborn/ptcreborn/1c6109f12904c7304fce18c1b0b34ac134225ddb/jsonblobfunctions.js'></script> <script async='async' src='https://rawcdn.githack.com/ptcreborn/ptcreborn/c394983382b8783c0bec85c47c6943e194cbcedf/pantryfunctions.js'></script> <style> div.pInf, div.brdCmb, h1.pTtl { display: none; } </style> <form id='postForm' style='opacity: 0.7' class="pCrContainer" action='javascript:submitTask()'> <h2>Create Post</h2> <div class="pCrTtlDesc"> <div class="pCrCategory"> <label for="pCrCategorySelect">ACTION: </label> <select required id="ptcCategory"> <option selected disabled>SELECT ACTION</option> <option>ASKING</option> <option>FLEXING</option> <option>SHARING</option> <option>REPORTING</option> </select> </div> <div class="pCrCategory"> <label for="pCrCategorySelect">CATEGORY: </label> <select required id="ptcMods"> <option selected disabled>SELECT CATEGORY</option> <option>Accounts</option> <option>Game Guardian Script</option> <option>Original Battle Cats</option> <option>Battle Dogs</option> <option>Battle Cats Mod</option> <option>Battle Cats SB</option> <option>Battle Cats Custom Edition (CE)</option> <option>Battle Cats Ethereal</option> <option>Battle Cats +</option> <option>Battle Cats TMTSG</option> <option>NoXPCF</option> <option>Nova Pro</option> <option>OFF TOPIC</option> </select> </div> <input required minlength="5" type="text" id="ptcTitle" placeholder="Title" style='font-size: 22px !important'/> <br /> <textarea required minlength="15" type="text" id="ptcDescription" placeholder="Description" style='font-size: 16px !important; line-height: 1.2rem !important; height: 300px !important;' ></textarea> <img alt="Untitled-2" border="0" loading="lazy" src="https://i.ibb.co/TBRnPV3/Untitled-2.png" /> </div> <div id='previewImgs'></div> <div class="pCrImages"> <label >Add Image <input id='file' type="file" accept="image/png, image/gif, image/jpeg, image/bmp" /> </label> <button id='btn_submit' type="submit" value="Submit">Post</button> </div> </form> <script> var user_blob = ''; var blob_id = ''; var pantry_posts = 'https://getpantry.cloud/apiv1/pantry/8c1037f6-bf4b-443d-9941-a9f9c6a99671/basket/posts'; window.addEventListener('load', function() { // check if the user is login ??/ if(localStorage.getItem('ptc_user')) { let temp_data = JSON.parse(localStorage.getItem('ptc_user')); console.log('user is logged in.'); user_blob = temp_data.user.replace('/r', '').replace('\n', ''); console.log('with an id of ' + user_blob); StackFunctions.execute(); query('postForm').style.opacity = '1'; } else { window.alert('You are not logged in. Please login first!'); } }, false); function query(id) { return document.querySelector('#' + id); } file.addEventListener("change", ev => { document.querySelector('#btn_submit').style.pointerEvents = 'none'; query('previewImgs').src = 'https://i.giphy.com/uIJBFZoOaifHf52MER.webp'; query('btn_submit').innerText = 'Please wait uploading image...'; const formdata = new FormData() formdata.append("image", ev.target.files[0]) fetch("https://api.imgbb.com/1/upload?key=07f1351d4e674784012d92ae6e03b49d", { method: "post", body: formdata }).then(data => data.json()).then(data => { let url = data.data.image.url; let img = document.createElement('img'); img.src = url; img.style.maxWidth = "150px"; query('previewImgs').appendChild(img); document.querySelector('#btn_submit').style.pointerEvents = 'auto'; query('btn_submit').innerText = 'Submit Request'; }).catch((data) => { window.alert("Error in uploading! Try again."); successImgUp = false; }); }); function disableElem(isTrue, elem, caption) { if(isTrue) { elem.style.pointerEvents = 'none'; elem.style.opacity = '0.7'; if(caption.length > 0) elem.innerText = caption; } else { elem.style.pointerEvents = 'auto'; elem.style.opacity = '1'; if(caption.length > 0) elem.innerText = caption; } } function submitTask() { let imgs = query('previewImgs').querySelectorAll('img'); let allImgs = []; disableElem(true, query('btn_submit'), "Posting..."); disableElem(true, query('postForm'), ""); imgs.forEach(function (item, index) { allImgs.push(item.src); }); let category = query('ptcCategory').options[query('ptcCategory').selectedIndex].text; let mods = query('ptcMods').options[query('ptcMods').selectedIndex].text; let data = { "category": category, "mod": mods, "user": user_blob, "date": new Date().getTime(), "title": query('ptcTitle').value, "description": query('ptcDescription').value, "images": allImgs, "comments": [], "reactions": 1 } if (query('ptcCategory').selectedIndex != 0 && query('ptcMods').selectedIndex != 0) { JBLOBFunctions.createRecordBlob(JSON.stringify(data), function (data) { data = data.replace('\n', '').replace('\r', ''); console.log(data); blob_id = data.split('jsonBlob/')[1]; }); try { StackFunctions.pushTask(sentPost); } catch (err) { window.alert("Error has been detected, please screenshot the next warning message!"); window.alert(err); disableElem(false, query('btn_submit'), "Post"); } } else { window.alert('Please select action and categories!'); disableElem(false, query('btn_submit'), "Post"); disableElem(false, query('postForm'), ""); } } function sentPost() { Pantry.createPantryData(JSON.stringify({ "d": [{ "p": blob_id } ] }), pantry_posts, function (data) { window.location.href = 'https://storehaccounts.blogspot.com/p/battle-cats-gamer-community.html' }) } </script>