<!DOCTYPE html>
<html>
<head>
<title>Pro Code Editor</title>
<meta http-equiv="x-ua-compatible" content="ie=11">
<meta charset="utf-8">
<hta:application id="app" applicationname="ProEditor" scroll="no" singleinstance="yes"></hta:application>
<style>
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: #282a36; font-family: 'Segoe UI', sans-serif; }
#menubar { background-color: #1e1f29; height: 25px; border-bottom: 1px solid #000; padding: 0 5px; }
.menu-item { float: left; color: #f8f8f2; padding: 0 10px; line-height: 25px; font-size: 11px; cursor: pointer; position: relative; }
.menu-item:hover { background-color: #44475a; }
.dropdown { display: none; position: absolute; top: 25px; left: 0; background: #282a36; border: 1px solid #44475a; min-width: 185px; z-index: 9999; }
.menu-item:hover .dropdown { display: block; }
.dropdown a { color: #f8f8f2; padding: 5px 12px; text-decoration: none; display: block; font-size: 11px; border-bottom: 1px solid #343746; white-space: nowrap; }
.dropdown a:hover { background: #6272a4; }
#currentFileName { float: right; line-height: 25px; font-size: 10px; font-style: italic; padding-right: 10px; color: #6272a4; }
#saveStatus { float: right; line-height: 25px; font-size: 10px; font-weight: bold; padding-right: 15px; }
.CodeMirror { height: calc(100vh - 25px) !important; font-size: 13px; }
.check { display: inline-block; width: 15px; color: #50fa7b; font-weight: bold; }
.recovery-alert { color: #ff5555; font-weight: bold; }
.CodeMirror-activeline-background { background: #3d3f4d !important; }
.cm-matchhighlight { background-color: #6272a4 !important; }
.diff-added { background-color: rgba(80, 250, 123, 0.3); border-bottom: 1px dashed #50fa7b; }
.CodeMirror-dialog { position: absolute; left: 0; right: 0; top: 0; background: #282a36; color: #f8f8f2; padding: 5px 10px; border-bottom: 2px solid #bd93f9; z-index: 1000; font-size: 12px; font-family: sans-serif; }
.CodeMirror-dialog input { background: #1e1f29; color: #50fa7b; border: 1px solid #6272a4; margin: 0 5px; outline: none; padding: 2px; }
/* PasteBin Modal Styles */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 2000; }
.modal-box { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #282a36; border: 2px solid #6272a4; color: #f8f8f2; padding: 20px; width: 400px; font-family: 'Segoe UI', sans-serif; box-shadow: 0px 0px 15px #000; }
.modal-title { font-size: 16px; font-weight: bold; margin-bottom: 15px; color: #50fa7b; border-bottom: 1px solid #44475a; padding-bottom: 5px; }
.modal-box label { display: block; font-size: 11px; margin-top: 10px; color: #8be9fd; }
.modal-box input, .modal-box select { width: 100%; box-sizing: border-box; background: #1e1f29; color: #f8f8f2; border: 1px solid #44475a; padding: 5px; margin-top: 5px; outline: none; }
.modal-buttons { margin-top: 20px; text-align: right; }
.btn { background: #44475a; color: #f8f8f2; border: 1px solid #6272a4; padding: 5px 15px; cursor: pointer; margin-left: 10px; }
.btn:hover { background: #6272a4; }
.btn-primary { background: #50fa7b; color: #282a36; border: 1px solid #50fa7b; font-weight: bold; }
.btn-primary:hover { background: #8be9fd; }
</style>
<link rel="stylesheet" href="codemirror/codemirror.min.css">
<link rel="stylesheet" href="codemirror/foldgutter.min.css">
<link rel="stylesheet" href="codemirror/dracula.min.css">
<script src="codemirror/codemirror.min.js"></script>
<script src="codemirror/xml.min.js"></script>
<script src="codemirror/css.min.js"></script>
<script src="codemirror/javascript.min.js"></script>
<script src="codemirror/vbscript.min.js"></script>
<script src="codemirror/htmlmixed.min.js"></script>
<script src="codemirror/commonlisp.min.js"></script>
<script src="codemirror/dialog.min.js"></script>
<script src="codemirror/searchcursor.min.js"></script>
<script src="codemirror/search.min.js"></script>
<script src="codemirror/foldcode.min.js"></script>
<script src="codemirror/foldgutter.min.js"></script>
<script src="codemirror/brace-fold.min.js"></script>
<script src="codemirror/xml-fold.min.js"></script>
<script src="codemirror/active-line.min.js"></script>
<script src="codemirror/match-highlighter.min.js"></script>
<script src="codemirror/annotatescrollbar.min.js"></script>
<script src="codemirror/diff_match_patch.js"></script>
</head>
<body onkeydown="interceptKeys()">
<input type="file" id="nativeFileOpen" style="display:none;" accept=".js,.vbs,.lsp,.html,.htm,.hta,.txt">
<div id="menubar">
<div class="menu-item">File
<div class="dropdown">
<a href="#" onclick="newFile()">New</a>
<a href="#" onclick="showOpenDialog()">Open</a>
<a href="#" onclick="saveFile()">Save</a>
<a href="#" onclick="window.close()">Exit</a>
</div>
</div>
<div class="menu-item">Edit
<div class="dropdown">
<a href="#" onclick="myCodeEditor.undo()">Undo</a>
<a href="#" onclick="myCodeEditor.redo()">Redo</a>
</div>
</div>
<div class="menu-item">Find
<div class="dropdown">
<a href="#" onclick="doFind('find')">Find (Ctrl+F)</a>
<a href="#" onclick="doFind('findNext')">Find Next (F3)</a>
<a href="#" onclick="doFind('findPrev')">Find Prev (Shift+F3)</a>
<a href="#" onclick="doFind('replace')">Replace (Ctrl+H)</a>
<a href="#" onclick="doFind('replaceAll')">Replace All</a>
</div>
</div>
<div class="menu-item">View
<div class="dropdown">
<a href="#" onclick="toggleWordWrap()"><span id="wrapCheck" class="check"></span> Word Wrap</a>
<a href="#" onclick="toggleActiveLine()"><span id="activeLineCheck" class="check"></span> Highlight Active Line</a>
<a href="#" onclick="toggleMatchHighlight()"><span id="matchCheck" class="check"></span> Word Highlighting</a>
<hr style="border:0; border-top:1px solid #44475a; margin:4px 0;">
<a href="#" onclick="myCodeEditor.execCommand('foldAll')">Fold All</a>
<a href="#" onclick="myCodeEditor.execCommand('unfoldAll')">Unfold All</a>
<hr style="border:0; border-top:1px solid #44475a; margin:4px 0;">
<a href="#" onclick="clearDiffHighlights()" style="color: #50fa7b;">Clear Diff Highlights</a>
</div>
</div>
<div class="menu-item">PasteBin
<div class="dropdown">
<a href="#" onclick="openModal('pbSettingsModal')">Settings</a>
<a href="#" onclick="alert('Paste Fetching & Listing UI coming next!')">My Pastes</a>
<a href="#" onclick="openModal('pbCommitModal')">Commit (Save)</a>
</div>
</div>
<div class="menu-item">Tools
<div class="dropdown">
<a href="#" onclick="formatCode()">Format / Auto-Indent Code</a>
</div>
</div>
<div class="menu-item">Language (<span id="activeLang">None</span>)
<div class="dropdown">
<a href="#" onclick="setLang('null','None')">Plain Text</a>
<a href="#" onclick="setLang('javascript','JS')">JavaScript</a>
<a href="#" onclick="setLang('vbscript','VBS')">VBScript</a>
<a href="#" onclick="setLang('commonlisp','LISP')">AutoLISP</a>
<a href="#" onclick="setLang('htmlmixed','HTML/HTA')">HTML/HTA</a>
</div>
</div>
<span id="currentFileName">Untitled</span>
<span id="saveStatus"></span>
</div>
<textarea id="editorArea"></textarea>
<div id="pbSettingsModal" class="modal-overlay">
<div class="modal-box">
<div class="modal-title">PasteBin Settings</div>
<label>API Developer Key (Required)</label>
<input type="text" id="pbDevKey" placeholder="Paste your API Developer Key here">
<label>Username (Required for managing pastes)</label>
<input type="text" id="pbUser">
<label>Password</label>
<input type="password" id="pbPass">
<div class="modal-buttons">
<button class="btn" onclick="closeModal('pbSettingsModal')">Cancel</button>
<button class="btn btn-primary" onclick="savePbSettings()">Save Login</button>
</div>
</div>
</div>
<div id="pbCommitModal" class="modal-overlay">
<div class="modal-box">
<div class="modal-title">Commit to PasteBin</div>
<label>Paste Name</label>
<input type="text" id="pbPasteName" placeholder="Untitled">
<label>Syntax Format</label>
<select id="pbFormat">
<option value="text">None / Plain Text</option>
<option value="javascript">JavaScript</option>
<option value="vbscript">VBScript</option>
<option value="html5">HTML 5</option>
</select>
<label>Expiration</label>
<select id="pbExpire">
<option value="N">Never</option>
<option value="10M">10 Minutes</option>
<option value="1D">1 Day</option>
<option value="1W">1 Week</option>
</select>
<label>Privacy</label>
<select id="pbPrivacy">
<option value="0">Public</option>
<option value="1">Unlisted</option>
<option value="2">Private</option>
</select>
<div class="modal-buttons">
<button class="btn" onclick="closeModal('pbCommitModal')">Cancel</button>
<button class="btn btn-primary" onclick="commitPaste()">Push to PasteBin</button>
</div>
</div>
</div>
<script>
// --- GLOBAL VARIABLES ---
var myCodeEditor;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
var currentFilePath = "";
var lastOpenedFilePath = "";
var diffMarkers = [];
var wrapEnabled = false;
var activeLineEnabled = false;
var matchHighlightEnabled = true;
// PasteBin Globals
var pbDevKey = "";
var pbUserKey = "";
var currentPasteKey = "";
var appDataDir = shell.ExpandEnvironmentStrings("%APPDATA%");
var settingsPath = appDataDir + "\\proeditor_settings.json";
var tempDir = fso.GetSpecialFolder(2).Path;
var autoSaveCodePath = tempDir + "\\proeditor_autosave_code.tmp";
var autoSaveFilePath = tempDir + "\\proeditor_autosave_path.tmp";
var autoSaveTimer;
// --- CORE INITIALIZATION ---
window.onload = function() {
myCodeEditor = CodeMirror.fromTextArea(document.getElementById("editorArea"), {
lineNumbers: true, mode: "null", theme: "dracula", matchBrackets: true, lineWrapping: false,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], foldGutter: true, styleActiveLine: false,
extraKeys: {"Ctrl-F": "find", "F3": "findNext", "Shift-F3": "findPrev", "Ctrl-H": "replace", "Shift-Ctrl-H": "replaceAll"},
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }
});
loadSettings();
myCodeEditor.on("change", function() {
clearTimeout(autoSaveTimer);
document.getElementById("saveStatus").innerText = "Unsaved...";
document.getElementById("saveStatus").style.color = "#8be9fd";
autoSaveTimer = setTimeout(function() {
if (!myCodeEditor.isClean()) { saveToTemp(); }
}, 1000);
});
setTimeout(function() {
if (fso.FileExists(autoSaveCodePath)) {
loadFromTemp();
} else {
myCodeEditor.markClean(); clearRecoveryFiles();
if (lastOpenedFilePath !== "" && fso.FileExists(lastOpenedFilePath)) { loadFile(lastOpenedFilePath); }
}
myCodeEditor.refresh(); myCodeEditor.focus();
}, 250);
};
// --- KEY INTERCEPTION ---
function interceptKeys() {
var e = window.event;
if (e.ctrlKey && e.keyCode === 70) { e.preventDefault ? e.preventDefault() : (e.returnValue = false); myCodeEditor.execCommand('find'); }
if (e.ctrlKey && e.keyCode === 72) { e.preventDefault ? e.preventDefault() : (e.returnValue = false); myCodeEditor.execCommand('replace'); }
}
function doFind(cmd) { myCodeEditor.focus(); myCodeEditor.execCommand(cmd); }
// --- FORMATTING TOOLS ---
function formatCode() {
var totalLines = myCodeEditor.lineCount();
myCodeEditor.operation(function() {
for (var i = 0; i < totalLines; ++i) { myCodeEditor.indentLine(i, "smart"); }
});
document.getElementById("saveStatus").innerText = "Code Formatted!";
document.getElementById("saveStatus").style.color = "#50fa7b";
setTimeout(function(){ document.getElementById("saveStatus").innerText = ""; }, 2000);
}
// --- PASTEBIN UI & ENGINE ---
function openModal(id) {
document.getElementById(id).style.display = 'block';
if (id === 'pbCommitModal') {
if (currentPasteKey !== "") {
document.getElementById('pbCommitModal').getElementsByClassName('modal-title')[0].innerText = "Update Existing Paste (" + currentPasteKey + ")";
} else {
document.getElementById('pbCommitModal').getElementsByClassName('modal-title')[0].innerText = "Commit New Paste";
document.getElementById('pbPasteName').value = "";
}
}
}
function closeModal(id) { document.getElementById(id).style.display = 'none'; }
function savePbSettings() {
var devKey = document.getElementById("pbDevKey").value;
var user = document.getElementById("pbUser").value;
var pass = document.getElementById("pbPass").value;
if (!devKey) { alert("Developer Key is required!"); return; }
document.getElementById("saveStatus").innerText = "Authenticating...";
document.getElementById("saveStatus").style.color = "#f1fa8c";
if (user && pass) {
var xhr = new ActiveXObject("MSXML2.XMLHTTP");
xhr.open("POST", "https://pastebin.com/api/api_login.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var payload = "api_dev_key=" + encodeURIComponent(devKey) + "&api_user_name=" + encodeURIComponent(user) + "&api_user_password=" + encodeURIComponent(pass);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.responseText.indexOf("Bad API request") === -1) {
pbUserKey = xhr.responseText; pbDevKey = devKey;
saveSettings(); alert("PasteBin Authenticated!");
} else { alert("Login Failed: " + xhr.responseText); }
document.getElementById("saveStatus").innerText = ""; closeModal('pbSettingsModal');
}
};
xhr.send(payload);
} else {
pbDevKey = devKey; pbUserKey = ""; saveSettings();
alert("Settings Saved (Anonymous Posting)");
document.getElementById("saveStatus").innerText = ""; closeModal('pbSettingsModal');
}
}
function commitPaste() {
if (!pbDevKey) { alert("Please set your Developer Key in Settings."); return; }
var code = myCodeEditor.getValue();
if (!code) { alert("Cannot commit an empty file."); return; }
var title = document.getElementById("pbPasteName").value || "Untitled";
var format = document.getElementById("pbFormat").value;
var expire = document.getElementById("pbExpire").value;
var privacy = document.getElementById("pbPrivacy").value;
document.getElementById("saveStatus").innerText = "Pushing...";
document.getElementById("saveStatus").style.color = "#ffb86c";
// If updating, delete the old one synchronously first
if (currentPasteKey !== "" && pbUserKey !== "") {
try {
var delXhr = new ActiveXObject("MSXML2.XMLHTTP");
delXhr.open("POST", "https://pastebin.com/api/api_post.php", false);
delXhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var delPayload = "api_dev_key=" + encodeURIComponent(pbDevKey) + "&api_user_key=" + encodeURIComponent(pbUserKey) + "&api_paste_key=" + encodeURIComponent(currentPasteKey) + "&api_option=delete";
delXhr.send(delPayload);
} catch(err) { /* Ignore delete errors */ }
}
// Create new paste
var xhr = new ActiveXObject("MSXML2.XMLHTTP");
xhr.open("POST", "https://pastebin.com/api/api_post.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var payload = "api_dev_key=" + encodeURIComponent(pbDevKey) + "&api_option=paste" + "&api_paste_code=" + encodeURIComponent(code) + "&api_paste_name=" + encodeURIComponent(title) + "&api_paste_format=" + encodeURIComponent(format) + "&api_paste_private=" + encodeURIComponent(privacy) + "&api_paste_expire_date=" + encodeURIComponent(expire);
if (pbUserKey !== "") { payload += "&api_user_key=" + encodeURIComponent(pbUserKey); }
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.responseText.indexOf("http") > -1) {
var newKey = xhr.responseText.split('/').pop();
currentPasteKey = newKey;
document.getElementById("currentFileName").innerText = "[PasteBin] " + title;
document.getElementById("saveStatus").innerText = "Committed!";
document.getElementById("saveStatus").style.color = "#50fa7b";
setTimeout(function(){ document.getElementById("saveStatus").innerText = ""; }, 3000);
closeModal('pbCommitModal');
} else {
alert("Error committing: " + xhr.responseText);
document.getElementById("saveStatus").innerText = "";
}
}
};
xhr.send(payload);
}
// --- FILE OPS & SETTINGS ---
document.getElementById("nativeFileOpen").onchange = function() { var path = this.value; if (path) { loadFileWithIndicator(path); } this.value = ""; };
function toggleWordWrap() { wrapEnabled = !wrapEnabled; applyWordWrap(wrapEnabled); saveSettings(); }
function applyWordWrap(state) { myCodeEditor.setOption("lineWrapping", state); document.getElementById("wrapCheck").innerHTML = state ? "✓" : ""; myCodeEditor.refresh(); }
function toggleActiveLine() { activeLineEnabled = !activeLineEnabled; applyActiveLine(activeLineEnabled); saveSettings(); }
function applyActiveLine(state) { myCodeEditor.setOption("styleActiveLine", state); document.getElementById("activeLineCheck").innerHTML = state ? "✓" : ""; }
function toggleMatchHighlight() { matchHighlightEnabled = !matchHighlightEnabled; applyMatchHighlight(matchHighlightEnabled); saveSettings(); }
function applyMatchHighlight(state) { myCodeEditor.setOption("highlightSelectionMatches", state ? { showToken: /\w/, annotateScrollbar: true } : false); document.getElementById("matchCheck").innerHTML = state ? "✓" : ""; }
function showSaveDialog() {
try {
var objShell = new ActiveXObject("Shell.Application");
var objFile = objShell.BrowseForFolder(0, "Select save location:", 0x4000, 0);
if (objFile) { var fileName = prompt("Enter file name (e.g., script.js):", "Untitled.js"); if (fileName) { return objFile.Items().Item().Path + "\\" + fileName; } }
} catch(err) { return null; }
return null;
}
function checkUnsavedChanges() {
if (!myCodeEditor.isClean()) {
var result = shell.Popup("Save changes?", 0, "Pro Editor", 3 + 32);
if (result === 6) { return saveFile() ? 6 : 2; } if (result === 7) { return 7; } return 2;
}
return 0;
}
function showOpenDialog() { if (checkUnsavedChanges() !== 2) { document.getElementById("nativeFileOpen").click(); } }
function saveFile() {
var path = currentFilePath || showSaveDialog();
if (path) {
try {
var file = fso.OpenTextFile(path, 2, true); file.Write(myCodeEditor.getValue()); file.Close();
currentFilePath = path; myCodeEditor.markClean(); clearRecoveryFiles(); clearDiffHighlights();
document.getElementById("currentFileName").innerText = fso.GetFileName(path);
document.getElementById("saveStatus").innerText = "Saved!"; setTimeout(function(){ document.getElementById("saveStatus").innerText = ""; }, 2000);
saveSettings(); return true;
} catch(e) { alert("Save Error"); return false; }
} return false;
}
function newFile() {
if (checkUnsavedChanges() !== 2) {
myCodeEditor.setValue(""); myCodeEditor.markClean(); clearRecoveryFiles(); clearDiffHighlights();
currentFilePath = ""; currentPasteKey = ""; document.getElementById("currentFileName").innerText = "Untitled";
setLang('null', 'None'); saveSettings();
}
}
function loadFileWithIndicator(path) { document.getElementById("saveStatus").innerText = "LOADING..."; setTimeout(function() { loadFile(path); }, 50); }
function loadFile(path) {
try {
var file = fso.OpenTextFile(path, 1); myCodeEditor.setValue(file.AtEndOfStream ? "" : file.ReadAll()); file.Close();
myCodeEditor.markClean(); clearRecoveryFiles(); clearDiffHighlights();
currentFilePath = path; currentPasteKey = ""; document.getElementById("currentFileName").innerText = fso.GetFileName(path);
document.getElementById("saveStatus").innerText = ""; autoDetectLang(path); saveSettings();
} catch(err) { alert("Error: " + err.message); }
}
// --- DIFF ENGINE ---
function highlightRecoveredChanges(originalText) {
if (typeof diff_match_patch === 'undefined') return;
var currentText = myCodeEditor.getValue(); if (originalText === currentText) return;
var dmp = new diff_match_patch(); var diffs = dmp.diff_main(originalText, currentText); dmp.diff_cleanupSemantic(diffs);
var currentIndex = 0;
for (var i = 0; i < diffs.length; i++) {
var type = diffs[i][0]; var text = diffs[i][1];
if (type === 0) { currentIndex += text.length; }
else if (type === 1) {
var startPos = myCodeEditor.doc.posFromIndex(currentIndex); currentIndex += text.length; var endPos = myCodeEditor.doc.posFromIndex(currentIndex);
var marker = myCodeEditor.markText(startPos, endPos, {className: "diff-added"}); diffMarkers.push(marker);
}
}
}
function clearDiffHighlights() { for (var i = 0; i < diffMarkers.length; i++) { diffMarkers[i].clear(); } diffMarkers = []; }
function saveToTemp() { try { var file = fso.OpenTextFile(autoSaveCodePath, 2, true); file.Write(myCodeEditor.getValue()); file.Close(); var pFile = fso.OpenTextFile(autoSaveFilePath, 2, true); pFile.Write(currentFilePath || "UNTITLED"); pFile.Close(); } catch(e) {} }
function loadFromTemp() {
try {
var file = fso.OpenTextFile(autoSaveCodePath, 1); myCodeEditor.setValue(file.ReadAll()); file.Close();
var savedPath = ""; if (fso.FileExists(autoSaveFilePath)) { var pFile = fso.OpenTextFile(autoSaveFilePath, 1); savedPath = pFile.ReadAll(); pFile.Close(); }
currentFilePath = (savedPath === "UNTITLED") ? "" : savedPath;
if (currentFilePath !== "" && fso.FileExists(currentFilePath)) {
var origFile = fso.OpenTextFile(currentFilePath, 1); var origText = origFile.AtEndOfStream ? "" : origFile.ReadAll(); origFile.Close();
highlightRecoveredChanges(origText);
}
document.getElementById("currentFileName").innerHTML = (currentFilePath ? fso.GetFileName(currentFilePath) : "Untitled") + " <span class='recovery-alert'>[Restored]</span>";
if (currentFilePath !== "") autoDetectLang(currentFilePath);
} catch(e) {}
}
function clearRecoveryFiles() { try { if(fso.FileExists(autoSaveCodePath)) fso.DeleteFile(autoSaveCodePath); if(fso.FileExists(autoSaveFilePath)) fso.DeleteFile(autoSaveFilePath); } catch(e) {} }
// --- MULTI-LINE SAVESETTINGS ---
function loadSettings() {
try {
if (fso.FileExists(settingsPath)) {
var file = fso.OpenTextFile(settingsPath, 1); var data = JSON.parse(file.ReadAll()); file.Close();
window.resizeTo(data.width, data.height); window.moveTo(data.left, data.top);
wrapEnabled = data.wordWrap || false; applyWordWrap(wrapEnabled);
activeLineEnabled = data.activeLine || false; applyActiveLine(activeLineEnabled);
matchHighlightEnabled = (data.matchHighlight === undefined) ? true : data.matchHighlight; applyMatchHighlight(matchHighlightEnabled);
lastOpenedFilePath = data.lastFile || "";
pbDevKey = data.pbDevKey || "";
pbUserKey = data.pbUserKey || "";
if (pbDevKey) { document.getElementById("pbDevKey").value = pbDevKey; }
} else { window.resizeTo(900, 600); }
} catch(e) { window.resizeTo(900, 600); }
}
function saveSettings() {
try {
var data = {
width: document.documentElement.offsetWidth,
height: document.documentElement.offsetHeight,
top: window.screenTop,
left: window.screenLeft,
wordWrap: wrapEnabled,
activeLine: activeLineEnabled,
matchHighlight: matchHighlightEnabled,
lastFile: currentFilePath,
pbDevKey: pbDevKey,
pbUserKey: pbUserKey
};
var file = fso.OpenTextFile(settingsPath, 2, true);
file.Write(JSON.stringify(data));
file.Close();
} catch(e) {}
}
function autoDetectLang(path) { var ext = path.split('.').pop().toLowerCase(); if (ext == "js") setLang("javascript","JS"); else if (ext == "vbs") setLang("vbscript","VBS"); else if (ext == "lsp" || ext == "lisp") setLang("commonlisp","LISP"); else if (ext == "html" || ext == "htm" || ext == "hta") setLang("htmlmixed","HTML/HTA"); else setLang("null", "None"); }
function setLang(mode, label) { myCodeEditor.setOption("mode", mode); document.getElementById("activeLang").innerText = label; }
window.onbeforeunload = function() { saveSettings(); if (!myCodeEditor.isClean()) saveToTemp(); };
</script>
</body>
</html>