יצירת שלוחות והעלאת קבצים המסודרים בתקיות במחשב
הקוד מצורף
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="UTF-8">
<title>מעלה תיקיות ומבנה שלוחות - ימות המשיח</title>
<style>
:root {
--primary: #3498db;
--success: #2ecc71;
--danger: #e74c3c;
--bg: #f4f7f6;
--dark: #2c3e50;
}
body { font-family: 'Segoe UI', Arial, sans-serif; margin: 0; background-color: var(--bg); color: var(--dark); text-align: right; }
.wrapper { max-width: 900px; margin: 40px auto; padding: 0 20px; position: relative; }
.reset-btn {
position: absolute;
top: -10px;
left: 20px;
background: var(--danger);
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
transition: all 0.3s;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.reset-btn:hover { opacity: 0.8; transform: translateY(-1px); }
.card { background: white; padding: 30px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); margin-bottom: 25px; border: 1px solid #eee; }
h2 { margin-top: 0; color: var(--dark); border-bottom: 3px solid var(--primary); display: inline-block; padding-bottom: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
label { font-weight: bold; font-size: 14px; }
input { padding: 12px; border: 2px solid #eee; border-radius: 8px; font-size: 16px; transition: border 0.3s; }
input:focus { border-color: var(--primary); outline: none; }
.full-width { grid-column: 1 / -1; }
.btn-main {
background: var(--primary); color: white; border: none; padding: 15px;
border-radius: 8px; cursor: pointer; font-size: 18px; font-weight: bold;
margin-top: 10px; width: 100%; transition: all 0.3s;
box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
}
.btn-main:hover { background: #2980b9; transform: translateY(-1px); }
.btn-main:disabled { background: #bdc3c7; cursor: not-allowed; transform: none; }
/* אזור התקדמות משודרג */
.progress-wrapper { margin-top: 25px; display: none; padding: 15px; background: #fafafa; border-radius: 10px; border: 1px solid #eee; }
.progress-container {
width: 100%;
background: #e0e0e0;
height: 35px;
border-radius: 20px;
overflow: hidden;
position: relative;
box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
border: 1px solid #ccc;
}
.progress-bar {
height: 100%;
width: 0%;
background: linear-gradient(45deg, #2ecc71 25%, #27ae60 25%, #27ae60 50%, #2ecc71 50%, #2ecc71 75%, #27ae60 75%, #27ae60);
background-size: 40px 40px;
animation: move-stripes 2s linear infinite;
transition: width 0.4s cubic-bezier(0.17, 0.67, 0.83, 0.67);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
@keyframes move-stripes {
from { background-position: 40px 0; }
to { background-position: 0 0; }
}
.progress-text {
position: absolute;
width: 100%;
text-align: center;
top: 0;
line-height: 35px;
color: #fff;
font-weight: 900;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
font-size: 16px;
}
.log-header { font-weight: bold; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; color: var(--dark); }
.log-box {
background: #1e1e1e; color: #d4d4d4; padding: 20px; border-radius: 10px;
font-family: 'Consolas', monospace; height: 300px; overflow-y: auto;
font-size: 13px; line-height: 1.6; border: 4px solid #333;
box-shadow: inset 0 5px 15px rgba(0,0,0,0.5);
}
.log-info { color: #5dade2; }
.log-success { color: #58d68d; font-weight: bold; }
.log-error { color: #ec7063; }
.log-warn { color: #f4d03f; }
.log-tts { color: #bb8fce; }
</style>
</head>
<body>
<div class="wrapper">
<button class="reset-btn" onclick="resetAll()">✕ איפוס תהליך</button>
<div class="card">
<h2>העלאת מבנה תיקיות לימות המשיח</h2>
<div class="grid">
<div class="input-group">
<label>טוקן מערכת:</label>
<input type="text" id="token" placeholder="הכנס טוקן כאן...">
</div>
<div class="input-group">
<label>שלוחת יעד ראשית:</label>
<input type="text" id="targetPath" placeholder="לדוגמה: 1">
</div>
<div class="input-group full-width">
<label>בחר תיקייה מהמחשב:</label>
<input type="file" id="folderInput" webkitdirectory>
</div>
<div class="full-width">
<button id="startBtn" class="btn-main" onclick="processUpload()">התחל העלאה למערכת</button>
</div>
</div>
<div class="progress-wrapper" id="progBox">
<div class="log-header">🔄 סטטוס התקדמות:</div>
<div class="progress-container">
<div class="progress-bar" id="progBar"></div>
<div class="progress-text" id="progText">0%</div>
</div>
</div>
</div>
<div class="card">
<div class="log-header">📜 תיעוד פעולות (Log):</div>
<div class="log-box" id="logBox">ממתין לתחילת עבודה...</div>
</div>
</div>
<script>
const sleep = ms => new Promise(res => setTimeout(res, ms));
function addLog(msg, type = "info") {
const logBox = document.getElementById('logBox');
let className = "log-info";
if (type === "success") className = "log-success";
if (type === "error") className = "log-error";
if (type === "warn") className = "log-warn";
if (type === "tts") className = "log-tts";
logBox.innerHTML += `<div class="${className}">> ${msg}</div>`;
logBox.scrollTop = logBox.scrollHeight;
}
function resetAll() {
if(!confirm("האם אתה בטוח שברצונך לאפס את כל הנתונים?")) return;
document.getElementById('token').value = "";
document.getElementById('targetPath').value = "";
document.getElementById('folderInput').value = "";
document.getElementById('logBox').innerHTML = "המערכת אופסה. ממתין לפעולה...";
document.getElementById('progBox').style.display = "none";
document.getElementById('progBar').style.width = "0%";
document.getElementById('progText').innerText = "0%";
document.getElementById('startBtn').disabled = false;
addLog("בוצע איפוס נתונים.");
}
async function processUpload() {
const token = document.getElementById('token').value;
const targetPath = document.getElementById('targetPath').value;
const fileList = document.getElementById('folderInput').files;
if (!token || !fileList.length) {
alert("חובה למלא טוקן ולבחור תיקייה");
return;
}
document.getElementById('startBtn').disabled = true;
document.getElementById('progBox').style.display = 'block';
const progBar = document.getElementById('progBar');
const progText = document.getElementById('progText');
document.getElementById('logBox').innerHTML = "";
addLog("מתחיל בניית מבנה נתונים...", "info");
const folderStructure = {};
for (let file of fileList) {
const parts = file.webkitRelativePath.split('/');
parts.shift();
const fileName = parts.pop();
const folderPath = parts.join('/');
if (!folderStructure[folderPath]) folderStructure[folderPath] = [];
folderStructure[folderPath].push({ name: fileName, file: file });
}
const sortedPaths = Object.keys(folderStructure).sort((a, b) => {
const depthA = a === "" ? 0 : a.split('/').length;
const depthB = b === "" ? 0 : b.split('/').length;
return depthA - depthB;
});
for (let i = 0; i < sortedPaths.length; i++) {
const folderPath = sortedPaths[i];
const currentIvrPath = folderPath ? `${targetPath}/${folderPath}` : targetPath;
const folderFiles = folderStructure[folderPath];
const isRoot = (folderPath === "");
addLog(`מעבד שלוחה: ${currentIvrPath}`, "warn");
const extFileObj = folderFiles.find(f => f.name.toLowerCase().split('.')[0] === 'ext');
let extContent = "";
if (extFileObj) {
extContent = await extFileObj.file.text();
} else {
extContent = isRoot ? "type=menu" : "type=playfile";
}
const extBlob = new Blob([extContent], { type: 'text/plain' });
await uploadFile(token, `${currentIvrPath}/ext.ini`, extBlob);
await sleep(400);
for (let fObj of folderFiles) {
const fileNameLower = fObj.name.toLowerCase();
if (fileNameLower.split('.')[0] === 'ext') continue;
const isAudio = /\.(wav|mp3|ogg|wma)$/i.test(fileNameLower);
let destName = "";
let blobToSend;
if (isAudio) {
destName = fObj.name.replace(/\.[^/.]+$/, ".wav");
blobToSend = fObj.file;
addLog(`מעלה שמע: ${destName}`, "info");
} else if (fileNameLower.includes('.tts')) {
let cleanName = fObj.name.replace(/\.tts/gi, "");
cleanName = cleanName.replace(/\.[^/.]+$/, "");
destName = cleanName + ".tts";
const text = await fObj.file.text();
blobToSend = new Blob([text], { type: 'text/plain' });
addLog(`מעלה קובץ TTS: ${destName}`, "tts");
} else {
destName = fObj.name.replace(/\.[^/.]+$/, "") + ".ini";
const text = await fObj.file.text();
blobToSend = new Blob([text], { type: 'text/plain' });
addLog(`מעלה הגדרות: ${destName}`, "info");
}
await uploadFile(token, `${currentIvrPath}/${destName}`, blobToSend);
}
const pct = Math.round(((i + 1) / sortedPaths.length) * 100);
progBar.style.width = pct + '%';
progText.innerText = pct + '%';
}
addLog("סיום מוצלח! כל הקבצים הועלו.", "success");
document.getElementById('startBtn').disabled = false;
}
async function uploadFile(token, fullPath, blob) {
const fd = new FormData();
fd.append('token', token);
fd.append('path', `ivr2:${fullPath}`);
fd.append('qqfile', blob, fullPath.split('/').pop());
try {
const res = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, {
method: 'POST',
body: fd
});
const data = await res.json();
if(data.responseStatus !== "OK") addLog(`שגיאה ב-${fullPath}: ${data.message}`, "error");
return data;
} catch (e) {
addLog(`כישלון תקשורת ב-${fullPath}`, "error");
}
}
</script>
</body>
</html>
קרדיט: @אA