ΠΠΎΠ²ΡΠΉ ΠΏΡΠΎΡΠΈΠ»Ρ
@@ -606,6 +619,62 @@ function doDel(){
}
ed.setValue(nls.join('\\n'));
}
+
+function showRename() {
+ var ls = ed.getValue().split(/\\r?\\n/);
+ var prs = [], inP = 0;
+ for (var l of ls) {
+ if (l.match(/^proxies:/)) inP = 1;
+ if (inP && l.match(/^[a-zA-Z]/) && !l.match(/^proxies:/)) inP = 0;
+ if (inP) {
+ var m = l.match(/^\s+-\s+name:\s+(.*)/);
+ if (m) prs.push(m[1].trim().replace(/^['"]|['"]$/g, ''))
+ }
+ }
+ var s = document.getElementById('sel-ren-proxy');
+ s.innerHTML = '';
+ prs.forEach(p => {
+ var o = document.createElement('option');
+ o.text = p;
+ s.add(o)
+ });
+ document.getElementById('inp-ren-newname').value = '';
+ document.getElementById('m-ren').style.display = 'flex';
+}
+
+function doRename() {
+ var oldName = document.getElementById('sel-ren-proxy').value;
+ var newName = document.getElementById('inp-ren-newname').value.trim();
+ if (!newName) {
+ alert("ΠΠΎΠ²ΠΎΠ΅ ΠΈΠΌΡ Π½Π΅ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΡΡΡΡΠΌ.");
+ return;
+ }
+ if (!oldName) {
+ alert("ΠΡΠΎΠΊΡΠΈ Π½Π΅ Π²ΡΠ±ΡΠ°Π½.");
+ return;
+ }
+
+ var content = ed.getValue();
+ var params = new URLSearchParams();
+ params.append('act', 'rename_proxy');
+ params.append('old_name', oldName);
+ params.append('new_name', newName);
+ params.append('content', content);
+
+ fetch('/', { method: 'POST', body: params })
+ .then(r => r.json())
+ .then(d => {
+ if (d.error) {
+ alert('ΠΡΠΈΠ±ΠΊΠ°: ' + d.error);
+ } else {
+ ed.setValue(d.new_content);
+ ed.clearSelection();
+ closeM('m-ren');
+ showToast("βοΈ ΠΡΠΎΠΊΡΠΈ ΠΏΠ΅ΡΠ΅ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½!");
+ }
+ })
+ .catch(e => alert("Π‘Π΅ΡΠ΅Π²Π°Ρ ΠΎΡΠΈΠ±ΠΊΠ°: " + e));
+}