<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'> <style> body { font-family: 'Poppins' !important; } .container { background: #2D3844; padding: 8px 16px 8px 16px; min-width: 270px; line-height: 1.2rem; max-width: 800px; opacity: 0.8; font-size: 14px; } div.headings { font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.6); margin-bottom: 10px; } div.ql-editor { font-size: 18px !important; line-height: 1.2rem !important; font-weight: 500 !important; min-height: 250px !important; color: #fff; background: #414A4E; } div.tbox-container { padding: 5px; border-bottom: 1px solid rgba(255,255,255,0.6); } div.tbox-container select { font-size: 18px; } div.tbox-container span.tbox-title { font-weight: 500; } div.tbox-container input { background: #414A4E; color: #00FF41; font-weight: 600; line-height: 1.2rem; padding: 5px; width: 100%; font-size: 18px; } #file_attachments { background: #2A333D !important; color: white !important; font-style: italic !important; } #ptcTitle::placeholder { color: #fff !important; font-style: italic; font-weight: 400; opacity: 0.7; } #ptcTitle::-ms-input-placeholder { /* Edge 12-18 */ color: #fff !important; opacity: 0.7; } span.italize { font-style: italic; } .tox.tox-silver-sink.tox-tinymce-aux { display: none; } span.notee { font-weight: 700; color: #00FF41; } span.warningg { font-weight: 700; color: orange; } div.tbox-container select option { background:#2D3844; color: white; padding-left: 5px; padding-right: 5px; } div.tbox-container select { background:#2D3844; color: white; cursor: pointer; margin-top: 5px; margin-bottom: 5px; } div.tbox-container button { position: relative; background:#2D3844; padding-left: 5px; padding-right: 5px; color: white; font-size: 16px; font-weight: 600; cursor: pointer; } div.pInf, div.brdCmb, h1.pTtl { display: none; } </style> <form id='formCreator' class='container' style='display: none;' action='javascript:submitPost();'> <div class='headings'>Create a Post</div> <div class='tbox-container'> <span class='notee'>(*) Title</span> <span class='tbox-title italize'>create a catchy title so audience can know this content.</span><br> <span class='warningg'> (20 to 100 characters only!)</span> <br> <input id='ptcTitle' required minlength="10" maxlength="100" placeholder="Create a title"/> </div> <div class='tbox-container'> <span class='notee'>(*) Body</span> <span class='tbox-title italize'>post all your content here including paragraph and texts.</span><br> <span class='notee'>(*) Links</span> <span class='tbox-title italize'>to add link, just put it in the editor as text. Thanks!</span><br> <span class='warningg'> (5 to 1000 words only!)</span> <br> <div id='ptcBody'></div> </div> <div class='tbox-container'> <span class='notee'>(*) Images Attachment</span> <span class='tbox-title italize'>upload all your images here.</span><br> <div id='img-attachs'></div> <input id="file_attachments" type="file" accept="image/png, image/gif, image/jpeg, image/bmp" placeholder="Change Profile Picture" /> </div> <div class='tbox-container'> <span class='notee'>(*) ACTION</span> <span class='tbox-title italize'>the action describes the motive of your posting and hence will be filtered in future.</span><br> <select required id="ptcAction"> <option selected disabled>SELECT</option> <option>ASKING</option> <option>FLEXING</option> <option>SHARING</option> <option>REPORTING</option> </select> </div> <div class='tbox-container'> <span class='notee'>(*) General Category</span> <span class='tbox-title italize'>Select which general categories your post falls into.</span><br> <select required id="ptcCategory"> <option selected disabled>SELECT</option> <option>Accounts</option> <option>Content Creators</option> <option>Battle Cats</option> <option>Battle Cats Ultimate</option> <option>Battle Cats Ultimate Packs</option> <option>Battle Cats Ultimate Sprites</option> <option>Battle Cats Mods</option> <option>Game Guardian (Script)</option>> <option>Fan Made Units</option> <option>Off Topic</option> <option>Website Help</option> </select> </div> <div class='tbox-container'> <span class='warningg'>Save and Post</span> <span class='tbox-title italize'>Please check all the details above before posting. Once you hit the button below, a thread will start.</span><br> <button id='ptcSubmit' type='submit'>Save and Post</button> </div> </form> <div class='tbox-container'> <span class='tbox-title italize'>All warnings will show here below!</span><br> <span id='ptcLogs' class='warningg'></span> </div> <script> window.addEventListener('load', async function () { if (await getUserInfo()) { //tinyMCE_Editor.setupEditor('ptcBody'); quillEditor.init('ptcBody'); document.querySelector('form.container').style.display = 'block'; } else { window.location.href = 'https://storehaccounts.blogspot.com/p/login_20.html'; } }); let ptcTitle; let ptcBody; let ptcAction; let ptcCategory; let warningStr = ''; let jsonThread; let jsonUser; let blob_userid; let postdate; let discordData; let discordThumbnail; function giveWarning(str) { warningStr += str + '<br/>'; query('ptcLogs').innerHTML = warningStr; } async function submitPost() { // check the title // check the body // check the action // check the category postdate = new Date().getTime(); query('formCreator').style.pointerEvents = 'none'; query('ptcSubmit').innerText = 'Posting...'; window.alert("Your post is being published now..."); checkTitle(); checkBody(); checkAction(); checkCategory(); warningStr = ''; console.log(ptcBody); console.log(ptcAction); console.log(ptcCategory); // build json if (validString(ptcTitle) && validString(ptcBody) && validString(ptcAction) && validString(ptcCategory)) { // build JSON now console.log('IN!'); // get all images let imgs = []; let allImgs = query('img-attachs').querySelectorAll('img'); for (let a = 0; a < allImgs.length; a++) imgs.push(allImgs[a].src); // time to create json blob let contentjson = { "title": ptcTitle, "description": ptcBody, "imgs": imgs } // creating a record in jblob JBLOBFunctions.createRecordBlob(JSON.stringify(contentjson), async function (data) { // preparing the data to be uploaded in firebase let discord_thumb_img = query('img-attachs').querySelector('img'); if(discord_thumb_img) discord_thumb_img = discord_thumb_img.src; if (!discord_thumb_img) discord_thumb_img = 'https://i.imgur.com/BNtV52K.png'; discordJSON_data = { "username": jsonUser.nickname, "profile_img": jsonUser.prof_image, "profile_url": "https://storehaccounts.blogspot.com/p/your-account-page.html?" + blob_userid, "title": ptcTitle, "description": "@everyone " + (query('ptcBody').innerText.length > 150 ? query('ptcBody').innerText.substring(0, 150) + '...' : query('ptcBody').innerText), "thumbnail": discord_thumb_img, "post_url": 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + postdate } jsonThread = { [postdate]: { "author": { "userid": blob_userid, "prof_img": jsonUser.prof_image }, "action": { "val": ptcAction }, "content": { "title": ptcTitle, "body": data.split('jsonBlob/')[1] }, "category": ptcCategory, "details": { "date": postdate, "upvote": 1, "comments": [] } } }; discordData = jsonThread; let result = await FirebaseModule.patch('https://storehaccounts-threads-default-rtdb.firebaseio.com/threads.json', JSON.stringify(jsonThread)); // updating the score of the user blob JBLOBFunctions.PUTRecordBlob('https://jsonblob.com/api/jsonBlob/' + blob_userid, function (data) { if (data.hasOwnProperty('threads')) { data.threads = parseInt(data.threads) + 1; } else { data["threads"] = 1; } return data; }, function (data) { // this is another callback to create and store the logs activity of the user. JBLOBFunctions.PUTRecordBlob('https://jsonblob.com/api/jsonBlob/' + blob_userid, function (new_data) { let thumb_img = query('img-attachs').querySelector('img'); if(thumb_img) thumb_img = thumb_img.src; if (!thumb_img) thumb_img = document.querySelectorAll('img')[1].src; let logs_data = { "thumbnail": thumb_img, "action": "created a thread", "title": ptcTitle, "link": 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + postdate, "date": postdate }; if (new_data.hasOwnProperty('logs')) { new_data.logs.push(logs_data); } else { new_data["logs"] = [logs_data]; } return new_data; }, function (new_data) { postToDiscord('https://discord.com/api/webhooks/1308070850754252890/kiyXpj_SL-P69WOT_eQdRqINRVBDmFI-a05OnDD39uwPGVgyWxTEbJvpXisQMW7g0-Fn', discordJSON_data); // Posting to PTC Mods Community Discord Server postToDiscord('https://discord.com/api/webhooks/1215519044443316255/6Tg2eY17aVwnT5ZQf_gtVAhyLzbl6xKPhpWeqoxBPbVrZG72_NgjMnYdw5wODFa2SnNO', discordJSON_data); // Posting to PTC PinoyTossCoin Discord Server postToDiscord('https://discord.com/api/webhooks/1138118144783822939/cBoifk9qZjq49n_yR-IylePH8c65P_iOO0efRL7cqiEUf6jurI2-O9hufdgPUZQ3HHbJ', discordJSON_data); // Posting to PTC PinoyTossCoin Discord Server }); }); }); } else { console.log('not in!'); query('formCreator').style.pointerEvents = 'auto'; query('ptcSubmit').innerText = 'Save and Post'; } } function postToDiscord(webhook, discordData) { fetch(webhook, { body: JSON.stringify({ embeds: [{ "author": { "name": discordData.username, "url": discordData.profile_url, "icon_url": discordData.profile_img }, "title": discordData.title, "description": discordData.description, "thumbnail": { "url": discordData.thumbnail }, "url": discordData.post_url } ] }), headers: { "Content-Type": "application/json", }, method: "POST", }) .then(function (res) { console.log(res); window.location.href = 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + postdate; }) .catch(function (res) { console.log(res); }); } function validString(str) { if (str && str.length > 0) return true; else return false; } function checkTitle() { ptcTitle = query('ptcTitle').value; } function checkBody() { let wordCount = quillEditor.getText(); if(wordCount.includes('\n')) wordCount = wordCount.replaceAll('\n', ' '); wordCount = wordCount.split(' ').length; if (wordCount < 5 || wordCount > 1000) giveWarning('Please add more word to your body! Words: ' + wordCount + '/5'); else ptcBody = "<div class='ql-editor'>" + query('ptcBody').querySelector('div').innerHTML + "</div>"; } function checkAction() { if (query('ptcAction').selectedIndex != 0) ptcAction = query('ptcAction').options[query('ptcAction').selectedIndex].text; else giveWarning('Please select Action!'); } function checkCategory() { if (query('ptcCategory').selectedIndex != 0) ptcCategory = query('ptcCategory').options[query('ptcCategory').selectedIndex].text; else giveWarning('Please select Category!'); } function query(id) { return document.getElementById(id); } async function getUserInfo() { await initFunctions(['JBLOBFunctions', 'FirebaseModule']); if ('localStorage' in window && localStorage) { if (localStorage.getItem('ptc_user')) { let tempdata = JSON.parse(localStorage.getItem('ptc_user')); let userdata = await JBLOBFunctions.getBlobRecordSync('https://jsonblob.com/api/jsonBlob/' + tempdata.user, null); blob_userid = tempdata.user; if (userdata == 404) { window.alert('the user requested id was expired or deleted or not found!'); return false; } else { userdata = JSON.parse(userdata); jsonUser = userdata; return true; } } else { window.alert('Please log in first!'); return false; } } else { window.alert('Sorry but this browser does not support localstorage! Try Chrome instead!'); return false; } } file_attachments.addEventListener("change", ev => { query('ptcSubmit').style.pointerEvents = 'none'; query('ptcSubmit').style.opacity = '0.7'; 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 = '200px'; img.style.objectFit = 'cover'; img.style.marginRight = '5px'; img.style.border = '3px solid white'; query('img-attachs').appendChild(img); query('ptcSubmit').style.pointerEvents = 'auto'; query('ptcSubmit').style.opacity = '1'; }).catch((data) => { window.alert("Error in uploading! Try again."); query('ptcSubmit').style.pointerEvents = 'auto'; query('ptcSubmit').style.opacity = '1'; }); }); </script>