<style> .postBody input, .postBody textarea { background: transparent !important; color: white; border-color: red !important; border-style: solid; padding: 5px !important; border-radius: 0px !important; } .postBody textarea { width: 100%; height: 250px; overflow: none; resize:none; } #imgupload { display: inline-block; margin-bottom: -3px; margin-right: 5px; width: 17px; height: 17px; } </style> <form class='formpost' action='javascript:verifyPost();'> <h4>Title</h4> <input name='title' placeholder='Title (10 - 80 characters)' type='text' required minlength='10' maxlength='80'/> <h4>Description</h4><small>(*) Writing the description, you can insert the link in your article and it will be parsed in the post.</small><br><br> <textarea name='description' placeholder='Description'></textarea> <h4>Images</h4><small>(*) You can upload multiple images, but you can upload 1 image at a time.</small><br><br> <div id='form_attached_images'></div> <input name='images' id='imgupload1' required accept="image/png, image/gif, image/jpeg, image/bmp" type="file" /> <br><br> <!-- Community Feeds H --> <ins class="adsbygoogle" style="display:inline-block;width:100%;height:90px" data-ad-client="ca-pub-6328531102448868" data-ad-slot="8763156309"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <br><br> <button style='padding: 0 10px 0 10px;' name='submit' class='button ln' type='submit'>POST</button> </form> <script> let imgCount = 0; let thumb_src = ''; let title_value = document.querySelector('.formpost input'); let description_value = document.querySelector('.formpost textarea'); let postBtn = document.querySelector('.formpost button'); let datetime = ''; if(!localStorage.getItem('ptc_credentials')) window.location.href = 'https://storehaccounts.blogspot.com/p/login_20.html'; function decodeCredentials(id) { let data = JSON.parse(localStorage.getItem('ptc_credentials')); return data[id]; } function traverseImages() { let a = document.querySelectorAll('#form_attached_images img'); let imgs = []; for(i=0; i<a.length; i++) { imgs.push(a[i].src); } return imgs; } function postSuccess() { window.location.href = 'https://storehaccounts.blogspot.com/p/post-official.html?' + datetime; } function verifyPost() { document.querySelector('.formpost').style.opacity = 0.3; document.querySelector('.formpost').style.pointerEvents = 'none'; let date = new Date(); datetime = new Date().getTime(); let data = { [datetime]: { "post": { "title": title_value.value, "description": description_value.value, "thumbnail": thumb_src, "images": traverseImages(), "date": date }, "author": { "name": decodeCredentials('name'), "username": decodeCredentials('username'), "img": decodeCredentials('img') }, "reactions": { "happy": [], "views": [1], }, "comments": [] } } PUTsend('https://getpantry.cloud/apiv1/pantry/91c9a2f3-be20-4b3b-8c9e-94a81264de7a/basket/blog_feeds', data, null, postSuccess); } const file = document.getElementById("imgupload1") file.addEventListener("change", ev => { try{ img_uploading = true; document.querySelector('#imgupload1').style.pointerEvents = 'none'; document.querySelector('#imgupload1').style.opacity = '0.3'; let numImgs = 0; const formdata = new FormData() formdata.append("image", ev.target.files[0]) fetch("https://api.imgur.com/3/image/", { method: "post", headers: { Authorization: "Client-ID 7804a29d3ccda1c" }, body: formdata }).then(data => data.json()).then(data => { let url = data.data.link.split('.'); url[2] = url[2] + 's'; url = url.join('.'); document.querySelector('#imgupload1').style.pointerEvents = 'auto'; document.querySelector('#imgupload1').style.opacity = '1'; let img = document.createElement('img'); if(imgCount == 0) thumb_src = url; img.src = data.data.link; img.setAttribute('style', 'display: inline-block; margin: 5px; width: 150px !important'); document.querySelector('#form_attached_images').appendChild(img); imgCount++; }) }catch(err) { window.alert(err); } }); function PUTsend(pantry, data, logs, callback) { data = JSON.stringify(data); let req = new XMLHttpRequest(); req.open('PUT', pantry, true); req.setRequestHeader('Content-Type', 'application/json'); req.onload = () => { if(req.readyState == XMLHttpRequest.DONE) if(req.status == 200) { if(logs != null) logs.innerText = 'Accepted by server..'; callback(); } } req.onerror = () => { if(logs != null) logs.innerText = 'Server overloads retrying in 5 seconds...'; setTimeout(function() { PUTsend(pantry, data, logs, callback); }, 5000); } try { req.send(data); } catch(err) { if(logs != null) logs.innerText = 'Server overloads retrying in 5 seconds... ' + err; setTimeout(function() { PUTsend(pantry, data, logs, callback); }, 5000); } } </script>