<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/icon.png" type="image/x-icon">
    <meta name="description"
        content="A completely free web hosting site that provides you with an amazing VS Code like editor and unlimited requests!">
    <meta name="keywords"
        content="code share, code sharing, free code hosting, free web hosting, unlimited web hosting, free web editor, free code editor">
    <title>Create New Code - Share Code</title>
    <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/StephanWagner/jBox/dist/jBox.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/StephanWagner/jBox/dist/jBox.min.css">
    <script src="https://cdn.jsdelivr.net/gh/sanchogodinhoapps/sanchogodinhoapps.github.io/ads/prebid.js"></script>

    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-CJNVRR27NK"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments); }
        gtag('js', new Date());

        gtag('config', 'G-CJNVRR27NK');
    </script>

    <!-- Microsoft Clarity -->
    <script type="text/javascript">
        (function (c, l, a, r, i, t, y) {
            c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
            t = l.createElement(r); t.async = 1; t.src = "https://www.clarity.ms/tag/" + i;
            y = l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t, y);
        })(window, document, "clarity", "script", "gg1o7msyq7");
    </script>
</head>

<body>
    <div class="loader">
        <img src="/icon.png" alt="">
        <b>Share Code</b>
        <span>Loading Editor</span>
    </div>

    <div id="editor"></div>
    <div class="btns">
        <div class="btn preview-btn">Preview</div>
        <div class="btn share-btn">Publish</div>
    </div>

    <div class="preview-frame">
        <div class="top">Share Code Preview
            <img src="https://img.icons8.com/ios-glyphs/30/null/delete-sign.png" class="close-preview" alt="close" />
        </div>
        <iframe frameborder="0" class="preview"></iframe>
    </div>

    <div class="share-dialog-overlay">
        <div class="share-dialog">
            <div class="titlebar">
                <div class="text">Share This Code</div>
                <img src="https://img.icons8.com/ios-glyphs/30/null/delete-sign.png" class="close-share-popup"
                    alt="close" />
            </div>
            <div class="body">
                <div class="section" style="margin-bottom:20px;">
                    <label for="code-password">Enter Code Access Password (Required)</label>
                    <br>
                    <input type="password" id="code-password">
                </div>

                <div class="section">
                    <label for="code-name">Name Of Your Code (Optional)</label>
                    <br>
                    <input type="text" id="code-name">
                </div>

                <div class="section" style="margin-top:10px;">
                    <label for="email-id">Email (Required)</label>
                    <br>
                    <input type="email" id="email-id">
                </div>

                <div
                    style="width:calc(100% - 10px);margin-left:10px;margin-right:10px;margin-top:5px;display:flex;align-items:center;font-family:'Barlow',sans-serif;">
                    Ads Will Not Be Displayed On Your Site
                    <img src="https://img.icons8.com/ios-glyphs/30/null/info--v1.png" alt="info" loading="lazy"
                        width="17" style="cursor:pointer;" onclick="new jBox('Modal', {
                        title: '<b style=\'font-family:Barlow,sans-serif;\'>Info</b>',
                        content: '<div style=\'font-family:Barlow,sans-serif;\'>We won\'t put any kind of ad on your site. Instead, ads will only be displayed in the editor while editing your code so that we can pay for the requests received from your codes!<div>',
                        overlay: false,
                        draggable: true,
                        maxWidth: 500
                    }).open();" />
                </div>
                <p
                    style="width:calc(100% - 10px);font-family:'Barlow',sans-serif;margin:0;margin-top:5px;margin-left:10px;margin-right:10px;">
                    Your
                    Password
                    Is Securely <a href="https://www.cloudflare.com/learning/ssl/what-is-encryption/"
                        target="_blank">Encrypted</a> With
                    HMacSHA512 + MD5 Algorithms!</p>

                <b
                    style="width:calc(100% - 10px);margin:0;margin-top:10px;margin-left:5px;margin-right:5px;font-family:'Barlow',sans-serif;white-space:nowrap;overflow:auto;">
                    By publishing your code, you accept our <a style="color:blue;cursor:pointer;" onclick="new jBox('Modal', {
                        title: '<b style=\'font-family:Barlow,sans-serif;\'>Terms Of Service</b>',
                        content: '<div style=\'font-family:Barlow,sans-serif;\'>We Have Kept This Terms Simple As Possible So That You May Comply To It Easily.<br><br>1. Your Code Will Automatically Get Deleted After 1 Year Of Inactiveness That Means, If No One Visits Your Code For 1 Year Than Your Last Visit Of Your Code, It Would Automatiaclly Get Deleted Since It Shows That The Code Is Not Required Anymore! Also, We May Contact You Anytime If Needed Due To Which We Collect Email Address!<br><br>2. Codes Would Not Be Recoverable In Case Of Lack Of Collection Of Funds To Run This Site Beause This Hosting Site Entirely Runs On Ads And No Other Source Of Earning The Code Developers Would Most Probably Be Emailed In Such A Case. If You Would Like To Add Your Contribution, You May DM Me On Sololearn (Sancho Godinho).<br><br>3. By Publishing With Us, You Agree That We May Add Or Remove Features From Your Site Too.<br><br>4. Setting Cron Jobs To Your Site Hosted Here Is Not Allowed Since It Would Be Considered Useless Traffic And May Lead To Site Deletion.<br><br>5. These Terms Subject To Change Anytime With/Without The Notice Of The Publishers.<div>',
                        overlay: false,
                        draggable: true,
                        maxWidth: 500
                    }).open();">terms & conditions</a>
                </b>
                <div class="share-complete">Publish Code!</div>
            </div>
        </div>
    </div>
    <div class="ads" style="display: flex;align-items: center;justify-content: center;"></div>
</body>

<style>
    @import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500&display=swap');

    .share-dialog-overlay {
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgb(0, 0, 0, 0.5);
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .share-dialog {
        width: calc(100% - 20px);
        height: 390px;
        background-color: white;
        border-radius: 5px;
        overflow: hidden;
        max-width: 500px;
    }

    .share-dialog .titlebar {
        width: 100%;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: 'Barlow', sans-serif;
        background-color: rgb(231, 231, 231);
        user-select: none;
        margin-bottom: 10px;
    }

    .share-dialog .text {
        width: 100%;
        text-align: center;
        margin-left: 20px;
    }

    .share-dialog .close-share-popup {
        width: 20px;
        padding-right: 5px;
        position: static;
    }

    .share-dialog .body {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        flex-direction: column;
    }

    .share-dialog .body>* {
        flex-shrink: 0;
    }

    .share-dialog .body .section {
        width: calc(100% - 10px);
        margin-left: 5px;
        margin-right: 5px;
    }

    .share-dialog .body .section label {
        font-family: 'Barlow', sans-serif;
        font-size: 15px;
    }

    .share-dialog .body .section input {
        width: calc(100% - 15px);
        padding: 5px;
        border: 1px solid darkgrey;
        border-radius: 5px;
        font-size: 17px;
        font-family: 'Barlow', sans-serif;
    }

    .share-complete {
        width: calc(100% - 10px);
        height: 40px;
        color: white;
        font-family: 'Barlow', sans-serif;
        background-color: blueviolet;
        border-radius: 5px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 10px;
        user-select: none;
        cursor: pointer;
        transition: all .10s linear;
    }

    .share-complete:active {
        background-color: rgb(125, 40, 206);
    }

    html {
        overflow: hidden;
    }

    body {
        width: 100vw;
        height: 100vh;
        padding: 0;
        margin: 0;
        overflow: hidden;
        display: flex;
        align-items: center;
        flex-direction: column;
        background-color: rgb(53, 53, 53);
    }

    .loader {
        width: 100%;
        height: 100%;
        font-family: 'Barlow';
        position: fixed;
        top: 0;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        z-index: 100000;
        background-color: white;
    }

    .loader b {
        font-size: 25px;
    }

    #editor {
        width: 100%;
        height: calc(100% - 40px);
        font-size: 17px;
    }

    .btns {
        width: 100%;
        display: flex;
        align-items: center;
    }

    .btns>* {
        flex-shrink: 0;
    }

    .btn {
        width: calc(50% - 20px);
        height: 20px;
        padding: 10px;
        color: white;
        background-color: blueviolet;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        user-select: none;
        font-family: 'Barlow', sans-serif;
        transition: all .10s linear;
    }

    .share-btn {
        width: calc(50% - 21px);
        margin-left: 1px;
    }

    .btn:active {
        background-color: rgb(125, 40, 206);
    }

    .preview-frame {
        width: 100%;
        height: 100%;
        z-index: 9999;
        position: fixed;
        top: 0;
        left: 0;
        background-color: white;
        display: none;
    }

    .preview-frame .top {
        width: 100%;
        height: 30px;
        border-bottom: 1px solid darkgrey;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: 'Barlow', sans-serif;
        user-select: none;
    }

    .preview-frame .top img {
        width: 20px;
        position: fixed;
        right: 0px;
        padding-right: 10px;
    }

    .preview {
        width: 100%;
        height: calc(100% - 30px);
    }

    * {
        outline: none;
        -webkit-tap-highlight-color: transparent;
    }
</style>

<script>
    (() => {
        (async () => {
            if (window.adsAllowed != null && window.adsAllowed == true) {
                let AdUnit = document.createElement('script');
                let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
                if (width >= 730) {
                    AdUnit.innerHTML += `atOptions = {'key':'0f052e4483fb32c7b1622768dbbf2e93','format':'iframe','height':90,'width':728,'params':{}};document.write('<scr' + 'ipt async defer type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://sophomoreprimarilyprey.com/0f052e4483fb32c7b1622768dbbf2e93/invoke.js"></scr' + 'ipt>');`;
                } else {
                    AdUnit.innerHTML += `atOptions = {'key':'4024c6b900bca2d702e07f5f8bc726cb','format':'iframe','height':50,'width':320,'params':{}};document.write('<scr' + 'ipt async defer type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://sophomoreprimarilyprey.com/4024c6b900bca2d702e07f5f8bc726cb/invoke.js"></scr' + 'ipt>');`;
                }
                document.querySelector('.ads').appendChild(AdUnit);
            } else {
                alert('Please ðŸ™� Disable Your Ad Blocker For Me To Pay For Your Website Reqests ðŸ˜­');
            }
        })();

        let editor;
        let fetching = false;
        $(document).ready(() => {
            document.body.style.height = window.innerHeight + 'px';
            $('.share-dialog-overlay').hide();

            editor = ace.edit("editor");
            editor.setTheme("ace/theme/monokai");
            editor.session.setMode("ace/mode/html");
            editor.setShowPrintMargin(false);

            $(window).on('resize', () => {
                $(document.body).css('height', window.innerHeight + 'px');
            });
        });

        $(window).on('load', () => {
            $('.loader').fadeOut(500, () => {
                editor.focus();
            });
        });

        $('.preview-btn').click(() => {
            console.log($('#editor').val())
            $('.preview').attr('srcdoc', editor.getValue());
            $('.preview-frame').fadeIn(500);

        });

        $('.close-preview').click(() => {
            $('.preview-frame').fadeOut(500, () => {
                editor.focus();
                $('.preview').attr('srcdoc', '');
            });
        });

        $('.share-btn').click(() => {
            $('.share-dialog-overlay').fadeIn(500);
        });

        $('.share-dialog-overlay').click((event) => {
            if ($(event.target).hasClass('share-dialog-overlay')) {
                $('.share-dialog-overlay').fadeOut(500);
            }
        });

        $('.share-dialog-overlay .close-share-popup').click(() => {
            $('.share-dialog-overlay').fadeOut(500);
        });

        $(document).on('keydown', (key) => {
            if (key.ctrlKey == true && key.key == 's') {
                key.preventDefault();
                $('.share-btn').click();
            }
        });

        $('.share-complete').click(() => {
            let password = $('#code-password').val();
            let codeName = $('#code-name').val();
            let email = $('#email-id').val();
            if (editor.getValue().length < 405522) {
                if (password != null && password.trim() != '') {
                    if (email != null && email.trim() != '' && email.includes('@')) {
                        $.ajax({
                            url: '/share',
                            method: 'POST',
                            data: {
                                password: password,
                                code: editor.getValue(),
                                id: codeName,
                                email: email
                            }
                        }).done((data) => {
                            if (data.success != null && data.success == true) {
                                window.location.href = 'https://share-code.top/edit?id=' + data.id + '&password=' + $('#code-password').val();
                            }
                            else {
                                new jBox('Modal', {
                                    title: '<b style="font-family:\'Barlow\',sans-serif;">Error!</b>',
                                    content: '<div style="font-family:\'Barlow\',sans-serif;">' + data.error + '</div>',
                                    overlay: false,
                                    draggable: true
                                }).open();
                            }
                        }).fail(() => {
                            new jBox('Modal', {
                                title: '<b style="font-family:\'Barlow\',sans-serif;">Error!</b>',
                                content: '<div style="font-family:\'Barlow\',sans-serif;">Failed To Send The Request To The Server!</div>',
                                overlay: false,
                                draggable: true
                            }).open();
                        });
                    }
                    else {
                        $('#email-id').css('border', '1px solid red');
                    }
                }
                else {
                    $('#code-password').css('border', '1px solid red');
                }
            }
            else {
                new jBox('Modal', {
                    title: '<b style="font-family:\'Barlow\',sans-serif;">Error!</b>',
                    content: '<div style="font-family:\'Barlow\',sans-serif;">Request Size Too Big<br>Maximum Characters: 405522</div>',
                    overlay: false,
                    draggable: true,
                    onClose: () => {
                        requestOn = false
                    }
                }).open();
            }
        });
    })();
</script>

</html>