@בעזרת-השם
תעשה ע"ז ניסיון.
תעתיק את הקוד תכניס לקובץ טקסט במחשב ואז קובץ שמור בשם ותוסיף בסוף שם הקובץ נקודה ואז html ושמור ואז תפתח את הקובץ שנוצר בתקייה
קוד
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="UTF-8">
<title>מעלה קבצים - פורמט תאריך עברי</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; line-height: 1.6; background-color: #f4f4f9; }
.container { max-width: 800px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); margin: auto; }
h2 { color: #333; border-bottom: 2px solid #007bff; padding-bottom: 10px; }
.field { margin-bottom: 15px; }
label { display: block; font-weight: bold; margin-bottom: 5px; }
input[type="text"], input[type="file"], select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
button { background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
button:hover { background-color: #0056b3; }
#log { margin-top: 20px; padding: 10px; border: 1px solid #ddd; background: #eee; height: 200px; overflow-y: auto; font-size: 13px; }
.progress-bar { height: 20px; background: #e0e0e0; border-radius: 10px; overflow: hidden; margin-top: 10px; display: none; }
.progress-fill { height: 100%; background: #28a745; width: 0%; transition: width 0.3s; }
</style>
</head>
<body>
<div class="container">
<h2>העלאת קבצים עם מספור תאריך עברי</h2>
<div class="field">
<label>טוקן (Token):</label>
<input type="text" id="token" placeholder="הכנס טוקן כאן...">
</div>
<div class="field">
<label>נתיב להעלאה (למשל ivr2:5):</label>
<input type="text" id="path" placeholder="ivr2:5">
</div>
<div class="field">
<label>בחר קבצים:</label>
<input type="file" id="fileInput" multiple>
</div>
<div class="field">
<label>המרת אודיו ל-WAV?</label>
<select id="convertAudio">
<option value="0">לא</option>
<option value="1">כן (מומלץ למערכות טלפוניות)</option>
</select>
</div>
<button onclick="startUpload()">התחל העלאה</button>
<div class="progress-bar" id="progressContainer">
<div class="progress-fill" id="progressFill"></div>
</div>
<div id="log">מוכן לפעולה...</div>
</div>
<script>
// פונקציית עזר לחישוב גימטריה בסיסית לשנה (תשפ"ו = 5786)
// הערה: לצורך הפשטות בקוד הלקוח, המשתמש יכול להזין או שהמערכת תחשב
function getHebrewDatePrefix() {
const now = new Date();
// כאן ניתן להטמיע ספריה כמו Hebcal, כרגע נשתמש בחישוב סטטי לשנה הנוכחית/נבחרת
// הפורמט המבוקש: YYYYMMDD
return "57860701"; // דוגמה: תשפ"ו, ניסן, א'
}
const CHUNK_SIZE = 45 * 1024 * 1024; // 45MB לביטחון
async function startUpload() {
const files = document.getElementById('fileInput').files;
const token = document.getElementById('token').value;
const basePath = document.getElementById('path').value;
const convert = document.getElementById('convertAudio').value;
const log = document.getElementById('log');
const progressBar = document.getElementById('progressFill');
const progressContainer = document.getElementById('progressContainer');
if (!files.length || !token || !basePath) {
alert("נא למלא את כל השדות ולבחור קבצים");
return;
}
progressContainer.style.display = 'block';
log.innerHTML = "מתחיל בהעלאה...<br>";
let prefix = getHebrewDatePrefix();
for (let i = 0; i < files.length; i++) {
let file = files[i];
let fileExt = convert === "1" ? ".wav" : file.name.split('.').pop();
let newFileName = `${prefix}${i + 1}.${fileExt}`;
let fullPath = `${basePath}/${newFileName}`;
log.innerHTML += `מעלה את ${file.name} כשם: ${newFileName}...<br>`;
await uploadInChunks(file, fullPath, token, convert);
let percent = ((i + 1) / files.length) * 100;
progressBar.style.width = percent + "%";
}
log.innerHTML += "<strong>הסתיים בהצלחה!</strong>";
}
async function uploadInChunks(file, path, token, convert) {
const qquuid = self.crypto.randomUUID();
const totalParts = Math.ceil(file.size / CHUNK_SIZE);
for (let part = 0; part < totalParts; part++) {
const start = part * CHUNK_SIZE;
const end = Math.min(start + CHUNK_SIZE, file.size);
const blob = file.slice(start, end);
const formData = new FormData();
formData.append('token', token);
formData.append('path', path);
formData.append('qqfile', blob);
formData.append('qquuid', qquuid);
formData.append('qqpartindex', part);
formData.append('qqpartbyteoffset', start);
formData.append('qqchunksize', end - start);
formData.append('qqtotalparts', totalParts);
formData.append('qqtotalfilesize', file.size);
formData.append('qqfilename', file.name);
formData.append('convertAudio', convert);
await fetch('https://www.call2all.co.il/ym/api/UploadFile', {
method: 'POST',
body: formData
});
}
// סגירת העלאה (Done)
await fetch(`https://www.call2all.co.il/ym/api/UploadFile?done&token=${token}&path=${path}&qquuid=${qquuid}&qqfilename=${file.name}&qqtotalfilesize=${file.size}&qqtotalparts=${totalParts}&convertAudio=${convert}`);
}
</script>
</body>
</html>