"+cstoryjson+""; } else if(sharetype==1) //url share { cstoryjson = generate_compressed_story(false,localsettings.export_settings,false); console.log("Export Len: " + cstoryjson.length); document.getElementById("sharecontainertitle").innerText = "Share Story as URL"; if (cstoryjson.length >= 4800) { document.getElementById("sharewarning").classList.remove("hidden"); } let fullurl = "https://lite.koboldai.net/?s=" + cstoryjson; document.getElementById("sharestorytext").innerHTML = "" + fullurl + ""; } else { cstoryjson = share_plaintext(); cstoryjson = replaceAll(cstoryjson,"\n","
",false); console.log("Export Len: " + cstoryjson.length); document.getElementById("sharecontainertitle").innerText = "Share Story as Plaintext"; document.getElementById("sharestorytext").innerHTML = "

"+cstoryjson+""; } document.getElementById("choosesharecontainer").classList.add("hidden"); } function copy_share_url() { var copyText = document.getElementById("sharestorytext"); // Select the text field select_element_contents(copyText); // Copy the text inside the text field navigator.clipboard.writeText(copyText.innerText); } function generate_base_storyobj() { //if we have no savefile, this generates a very simple one (old format) var gs = { "gamestarted": true, "prompt": "", "memory": "", "authorsnote": "", "anotetemplate": "", "actions": [], "actions_metadata": {}, "worldinfo": [], "wifolders_d": {}, "wifolders_l": [], }; return gs; } function load_bgimg_button() { document.getElementById('loadbgimg').click(); } function load_bg_img(event) { let input = event.target; if (input.files.length > 0) { let selectedImg = null; selectedImg = input.files[0]; const objectURL = URL.createObjectURL(selectedImg); compressImage(objectURL, (compressedImageURI, aspectratio)=>{ selectedImg = `url('${compressedImageURI}')`; document.body.style.backgroundImage = selectedImg; document.getElementById("gamescreen").classList.add("translucentbg"); document.getElementById("enhancedchatinterface").classList.add("transparentbg"); document.getElementById("enhancedchatinterface_inner").classList.add("transparentbg"); indexeddb_save("bgimg", compressedImageURI); }, false, 1024, 0.5); } }; function clear_bg_img() { document.body.style.backgroundImage = "none"; document.getElementById("gamescreen").classList.remove("translucentbg"); document.getElementById("enhancedchatinterface").classList.remove("transparentbg"); document.getElementById("enhancedchatinterface_inner").classList.remove("transparentbg"); indexeddb_save("bgimg", ""); } function load_file_button() { document.getElementById('loadfileinput').click(); } var tempfileurl = null; var tempfileobj = generate_base_storyobj(); var newfilename = ""; function savenowfn() { var a = document.getElementById("tempfile"); var file = new Blob([JSON.stringify(tempfileobj)], { type: 'application/json' }); console.log("Normal save handling") if (tempfileurl) { window.URL.revokeObjectURL(tempfileurl); } tempfileurl = window.URL.createObjectURL(file); a.href = tempfileurl; a.target = '_blank'; a.download = newfilename; setTimeout(function(){a.click()},20); } function save_file_button(use_existing_save=false) //for triggering an optional popup. if use save is true, assume temp obj is set { warn_unsaved = false; const save_file = function() { if(!use_existing_save) { tempfileobj = generate_savefile(localsettings.save_images, localsettings.export_settings, localsettings.export_settings); } newfilename = last_known_filename; window.URL = window.URL || window.webkitURL; var userAgent = window.navigator.userAgent; if (userAgent.match(/AppleWebKit/) && (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i))) { let ststr = JSON.stringify(tempfileobj); var file = new Blob([ststr], { type: 'application/octet-stream' }); var file2 = new Blob([ststr], { type: 'application/json' }); console.log("Special save handling for iphones") // iPad or iPhone needs an extra download var reader = new FileReader(); var reader2 = new FileReader(); let datblob = window.URL.createObjectURL(file2); reader.onload = function (e) { reader2.readAsDataURL(file2); reader2.onload = function (e) { msgbox(`