<commit_before><?php

/*
*  Copyright (c) Codiad & <NAME> (codiad.com), distributed
*  as-is and without warranty under the MIT License. See 
*  [root]/license.txt for more. This information must remain intact.
*/

require_once('../../config.php');

//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////

checkSession();

?>
<form onsubmit="return false;">
<?php

switch($_GET['action']){

    //////////////////////////////////////////////////////////////////
    // Confirm Close Unsaved File
    //////////////////////////////////////////////////////////////////
    case 'confirm':
    $path = $_GET['path'];
    ?>
    <label>Close Unsaved File?</label>
    
    <pre><?php echo($path); ?></pre>

    <button class="btn-left" onclick="save_and_close('<?php echo($path); ?>'); return false;">Save &amp; Close</button><button class="btn-mid" onclick="close_without_save('<?php echo($path); ?>'); return false;">Discard Changes</button><button class="btn-right" onclick="codiad.modal.unload(); return false;">Cancel</button>
    <?php
    break;
    
}

?>
</form>
<script>

    function save_and_close(path){
        var id = codiad.editor.getId(path);
        var content = codiad.editor.getContent(id);
        codiad.filemanager.saveFile(path,content, {
            success: function(){
                $('#active-files a[data-path="'+path+'"]').removeClass('changed');
                codiad.active.removeDraft(path);
            }
        });<commit_msg>Fix 'Save & Close' dialog<commit_after><?php

/*
*  Copyright (c) Codiad & <NAME> (codiad.com), distributed
*  as-is and without warranty under the MIT License. See 
*  [root]/license.txt for more. This information must remain intact.
*/

require_once('../../config.php');

//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////

checkSession();

?>
<form onsubmit="return false;">
<?php

switch($_GET['action']){

    //////////////////////////////////////////////////////////////////
    // Confirm Close Unsaved File
    //////////////////////////////////////////////////////////////////
    case 'confirm':
    $path = $_GET['path'];
    ?>
    <label>Close Unsaved File?</label>
    
    <pre><?php echo($path); ?></pre>

    <button class="btn-left" onclick="save_and_close('<?php echo($path); ?>'); return false;">Save &amp; Close</button><button class="btn-mid" onclick="close_without_save('<?php echo($path); ?>'); return false;">Discard Changes</button><button class="btn-right" onclick="codiad.modal.unload(); return false;">Cancel</button>
    <?php
    break;
    
}

?>
</form>
<script>

    function save_and_close(path){
        /*var id = codiad.editor.getId(path);
        var content = codiad.editor.getContent(id);
        codiad.filemanager.saveFile(path,content, {
            success: function(){
                $('#active-files a[data-path="'+path+'"]').removeClass('changed');
                codiad.active.removeDraft(path);
            }
        });*/
        codiad.active.save(path);
{'fraction_non_alphanumeric': 0.31909547738693467, 'fraction_numerical': 0.0, 'mean_word_length': 1.7315608919382504, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4199735', 'n_tokens_mistral': 851, 'n_tokens_neox': 848, 'n_words': 174}