• דף הבית
    • אינדקס קישורים
    • פוסטים אחרונים
    • משתמשים
    • חיפוש בהגדרות המתקדמות
    • חיפוש גוגל בפורום
    • ניהול המערכת
    • ניהול המערכת - שרת private
    • הרשמה
    • התחברות

    תקיות לשלוחות לפי מסכת פרק ומשנה

    מתוזמן נעוץ נעול הועבר שאלות ועזרה הדדית
    19 פוסטים 2 כותבים 55 צפיות 2 עוקבים
    טוען פוסטים נוספים
    • מהישן לחדש
    • מהחדש לישן
    • הכי הרבה הצבעות
    תגובה
    • תגובה כנושא
    התחברו כדי לפרסם תגובה
    נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
    • ב מנותק
      בעזרת השם @lavitoren הטי"ל
      נערך לאחרונה על ידי

      @lavitoren-הטי-ל זה הקוד עם האפשרות לחלוק לששה סדרים ולמשניות,
      השארתי את האופציה שעשית לבחור כמה שלוחות של השמעת קבצים תהיה בשוחה האחרונה, ניתן לבחור בתוך ההגדרות של השלוחה

      <!DOCTYPE html>
      <html lang="he" dir="rtl">
      <head>
      <meta charset="UTF-8">
      <title>הטי"ל - הכלי הטלפוני ליצירת ספריות v1.4</title>
      <style>
      :root {
      --bg-dark: #121212;
      --surface: #1e1e1e;
      --surface-light: #2d2d2d;
      --primary: #3b82f6;
      --primary-hover: #2563eb;
      --accent: #f59e0b;
      --danger: #ef4444;
      --text-main: #e2e8f0;
      --text-dim: #94a3b8;
      --border: #334155;
      --success: #10b981;
      }

          body { 
              font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
              background-color: var(--bg-dark); 
              color: var(--text-main); 
              margin: 0; 
              padding: 20px; 
              line-height: 1.5;
              text-align: right;
          }
      
          .wrapper { max-width: 1200px; margin: 0 auto; }
      
          header { 
              border-bottom: 1px solid var(--border); 
              padding-bottom: 20px; 
              margin-bottom: 30px; 
              display: flex; 
              justify-content: space-between; 
              align-items: center; 
          }
      
          h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
          .version { font-size: 14px; background: var(--border); padding: 4px 10px; border-radius: 4px; color: #fff; margin-right: 10px; }
      
          .dashboard { display: grid; grid-template-columns: 350px 1fr; gap: 20px; }
      
          .card { 
              background: var(--surface); 
              border: 1px solid var(--border); 
              border-radius: 12px; 
              padding: 20px; 
              box-shadow: 0 4px 20px rgba(0,0,0,0.5);
          }
      
          .lib-selector { 
              display: grid; 
              grid-template-columns: 1fr; 
              gap: 10px; 
              margin-bottom: 20px; 
          }
      
          .lib-btn { 
              background: var(--surface-light); 
              border: 1px solid var(--border); 
              color: var(--text-main); 
              padding: 12px; 
              border-radius: 8px; 
              cursor: pointer; 
              text-align: right; 
              font-weight: 600; 
              transition: all 0.2s;
              display: flex;
              align-items: center;
              gap: 10px;
              font-size: 15px;
          }
      
          .lib-btn:hover { border-color: var(--primary); background: #252525; }
          .lib-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
      
          .form-group { margin-bottom: 15px; }
          label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
          
          input, select { 
              width: 100%; 
              background: var(--bg-dark); 
              border: 1px solid var(--border); 
              border-radius: 6px; 
              padding: 10px; 
              color: white; 
              box-sizing: border-box;
              outline: none;
              font-family: inherit;
          }
      
          input:focus { border-color: var(--primary); }
      
          .options-panel { 
              background: #1a202c; 
              border-right: 4px solid var(--accent); 
              padding: 15px; 
              border-radius: 6px; 
              margin-bottom: 20px; 
          }
      
          .scroll-area { 
              height: 500px; 
              overflow-y: auto; 
              border: 1px solid var(--border); 
              background: var(--bg-dark); 
              padding: 10px; 
              border-radius: 8px; 
              display: grid; 
              grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); 
              gap: 8px; 
          }
      
          .masechet-item { 
              background: var(--surface-light); 
              padding: 8px; 
              border-radius: 4px; 
              display: flex; 
              align-items: center; 
              gap: 8px; 
              font-size: 13px;
          }
          .masechet-item input { width: auto; cursor: pointer; }
      
          .seder-title { 
              grid-column: 1 / -1; 
              background: var(--border); 
              padding: 4px 10px; 
              font-size: 12px; 
              font-weight: 800; 
              color: var(--accent); 
              margin-top: 10px;
              border-radius: 4px;
              display: flex;
              justify-content: space-between;
              align-items: center;
          }
      
          .seder-checkbox {
              width: auto !important;
              margin: 0;
              cursor: pointer;
          }
      
          .btn-run { 
              background: var(--primary); color: white; border: none; padding: 15px; border-radius: 8px; 
              font-weight: 800; cursor: pointer; width: 100%; font-size: 17px; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
          }
          .btn-stop { background: var(--danger); color: white; border: none; padding: 15px; border-radius: 8px; font-weight: 800; cursor: pointer; width: 100%; display: none; font-size: 17px; }
      
          .progress-wrapper { margin-top: 20px; }
          .progress-bar-bg { background: var(--surface-light); height: 14px; border-radius: 7px; overflow: hidden; }
          .progress-bar-fill { background: linear-gradient(90deg, var(--success), #34d399); height: 100%; width: 0%; transition: width 0.3s; }
          .progress-status { font-size: 12px; color: var(--text-dim); margin-top: 8px; display: flex; justify-content: space-between; }
      
          .log-container { 
              margin-top: 20px; background: #000; color: #00ff00; font-family: 'Consolas', monospace; 
              font-size: 12px; padding: 15px; border-radius: 8px; height: 220px; overflow-y: auto; border: 1px solid var(--border);
              direction: ltr; text-align: left;
          }
      
          ::-webkit-scrollbar { width: 8px; }
          ::-webkit-scrollbar-track { background: var(--bg-dark); }
          ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
      </style>
      

      </head>
      <body>

      <div class="wrapper">
      <header>
      <h1>פתיחת ספריה תורנית מטורפת עצומת מימדים לקו שלכם <span class="version">הטי"ל V1.4</span></h1>
      <div id="connectionStatus" style="color: var(--success); font-size: 13px;">● מוכן לביצוע</div>
      </header>

      <div class="dashboard">
          <div class="card">
              <label>סוג תוכן להקמה</label>
              <div class="lib-selector">
                  <button class="lib-btn active" onclick="loadLibrary('bavli', this)">📖 ש"ס בבלי</button>
                  <button class="lib-btn" onclick="loadLibrary('yerushalmi', this)">🕍 ש"ס ירושלמי</button>
                  <button class="lib-btn" onclick="loadLibrary('torah', this)">📜 תורה (חומשים ופרשיות)</button>
                  <button class="lib-btn" onclick="loadLibrary('chagim', this)">🎉 חגים ומועדים</button>
                  <button class="lib-btn" onclick="loadLibrary('tanakh', this)">📚 תנ"ך (כ"ד ספרים)</button>
                  <button class="lib-btn" onclick="loadLibrary('mishnah', this)">🗳️ משניות</button>
                  <button class="lib-btn" onclick="loadLibrary('rambam', this)">⚖️ רמב"ם (היד החזקה)</button>
                  <button class="lib-btn" onclick="loadLibrary('shulchan', this)">🖋️ שולחן ערוך</button>
              </div>
      
              <div class="form-group">
                  <label>סוג שלוחת הקצה (היחידה הקטנה ביותר)</label>
                  <select id="endFolderType">
                      <option value="playfile">השמעת קבצים (playfile)</option>
                      <option value="record">הקלטת הודעות (record)</option>
                  </select>
              </div>
      
              <div class="form-group" id="groupHierarchical" style="display:none;">
                  <input type="checkbox" id="hierarchicalSedarim" style="width:auto; margin-left:10px;"> 
                  <label style="display:inline; color: white;" for="hierarchicalSedarim">הקם לפי סדרים (יוצר תת-תיקיות לפי סדרים)</label>
              </div>
      
              <div class="form-group">
                  <label>טוקן גישה API</label>
                  <input type="text" id="token" placeholder="0770000000:123456">
              </div>
      
              <div class="form-group">
                  <label>נתיב יעד (תיקייה בקו)</label>
                  <input type="text" id="targetPath" placeholder="למשל: 1/5">
              </div>
      
              <div class="form-group">
                  <label>מספר שלוחה להתחלה</label>
                  <input type="number" id="startNum" value="1">
              </div>
      
              <button class="btn-run" id="startBtn" onclick="process()">🚀 התחל הקמה</button>
              <button class="btn-stop" id="cancelBtn" onclick="abort()">🛑 עצור פעולה</button>
      
              <div class="progress-wrapper" id="progWrapper" style="display:none;">
                  <div class="progress-bar-bg"><div class="progress-bar-fill" id="progBar"></div></div>
                  <div class="progress-status"><span id="progText">0%</span><span id="progCounts">0 / 0</span></div>
              </div>
          </div>
      
          <div class="card">
              <div id="optionsPanel" class="options-panel">
                  <div id="shasOptions">
                      <input type="checkbox" id="splitAmudim" style="width:auto; margin-left:10px;"> 
                      <label style="display:inline; color: white;" for="splitAmudim">פצל דפים לעמוד א' וב'</label>
                  </div>
                  <div id="torahOptions" style="display:none;">
                      <input type="checkbox" id="noAliyot" style="width:auto; margin-left:10px;"> 
                      <label style="display:inline; color: white;" for="noAliyot">ללא עליות לתורה (פרשה היא השמעת קבצים ישירה)</label>
                  </div>
                  <div id="mishnahOptions" style="display:none;">
                      <div style="margin-bottom:8px;">
                          <input type="checkbox" id="mishnahBySedarim" style="width:auto; margin-left:10px;"> 
                          <label style="display:inline; color: white;" for="mishnahBySedarim">חלוקה לפי ששה סדרים</label>
                      </div>
                      <div style="margin-bottom:8px;">
                          <input type="checkbox" id="mishnahSplitMishnot" checked style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsOption()"> 
                          <label style="display:inline; color: white;" for="mishnahSplitMishnot">לחלק כל פרק למשניות</label>
                      </div>
                      <div id="mishnahPartsContainer" style="margin-top:8px; padding-right:20px;">
                          <input type="checkbox" id="mishnahSplitParts" style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsInput()"> 
                          <label style="display:inline; color: white;" for="mishnahSplitParts">פצל כל משנה לתתי-חלקים</label>
                          <div id="mishnahPartsInputBox" style="display:none; margin-top:5px;">
                              <label style="color: var(--text-dim); display:inline;">כמות חלקים לכל משנה: </label>
                              <input type="number" id="mishnahPartsCount" value="2" min="1" style="width:80px; display:inline-block;">
                          </div>
                      </div>
                  </div>
                  <div id="genericSubOptions" style="display:none;">
                      <label style="color: white;">כמות תתי-שלוחות (הלכות/פסוקים):</label>
                      <input type="number" id="mishCount" value="0" style="width:100px;">
                  </div>
                  <div id="shulchanOptions" style="display:none;">
                      <label style="color: white;">כמות סעיפים בכל סימן (0 לסימנים בלבד):</label>
                      <input type="number" id="seifimCount" value="0" style="width:100px;">
                  </div>
              </div>
      
              <div style="display:flex; justify-content: space-between; margin-bottom: 15px;">
                  <label>בחירת ספרים / מסכתות</label>
                  <div>
                      <button onclick="selectAll(true)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px;">בחר הכל</button>
                      <button onclick="selectAll(false)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px; margin-right:5px;">נקה הכל</button>
                  </div>
              </div>
      
              <div class="scroll-area" id="masechtotList"></div>
              <div class="log-container" id="logBox">ממתין לפקודה...</div>
          </div>
      </div>
      

      </div>

      <script>
      let isAborted = false;
      let currentLib = 'bavli';

      const fullDb = {
          torah: [{ seder: "חמישה חומשי תורה", items: [
              { n: "בראשית", p: ["בראשית", "נח", "לך לך", "וירא", "חיי שרה", "תולדות", "ויצא", "וישלח", "וישב", "מקץ", "ויגש", "ויחי"] },
              { n: "שמות", p: ["שמות", "וארא", "בא", "בשלח", "יתרו", "משפטים", "תרומה", "תצוה", "כי תשא", "ויקהל", "פקודי"] },
              { n: "ויקרא", p: ["ויקרא", "צו", "שמיני", "תזריע", "מצורע", "אחרי מות", "קדושים", "אמור", "בהר", "בחקותי"] },
              { n: "במדבר", p: ["במדבר", "נשא", "בהעלותך", "שלח", "קרח", "חקת", "בלק", "פינחס", "מטות", "מסעי"] },
              { n: "דברים", p: ["דברים", "ואתחנן", "עקב", "ראה", "שופטים", "כי תצא", "כי תבוא", "נצבים", "וילך", "האזינו", "וזאת הברכה"] }
          ]}],
          chagim: [
              { seder: "1. ימים נוראים וחגי תשרי", items: [
                  { n: "ראש השנה", p: ["ערב ראש השנה", "תפילות ראש השנה", "תקיעת שופר", "סימני ראש השנה"] },
                  { n: "עשרת ימי תשובה", p: ["סליחות", "שבת תשובה", "כפרות"] },
                  { n: "יום הכיפורים", p: ["ערב יום הכיפורים", "תפילת כל נדרי", "נעילה", "מוצאי יום הכיפורים"] },
                  { n: "סוכות", p: ["בניית סוכה", "ארבעת המינים", "הושענא רבא", "שמיני עצרת ושמחת תורה"] }
              ]},
              { seder: "2. חגים מדרבנן", items: [
                  { n: "חנוכה", p: ["הדלקת נרות", "מעוז צור", "ענייני חנוכה", "סביבון"] },
                  { n: "פורים", p: ["תענית אסתר", "קריאת המגילה", "משלוח מנות ומתנות לאביונים", "סעודת פורים"] }
              ]},
              { seder: "3. חגי ניסן וספירת העומר", items: [
                  { n: "פסח", p: ["בדיקת חמץ וביעורו", "הערב הסדר", "הגדה של פסח", "שביעי של פסח ואיסרו חג"] },
                  { n: "ספירת העומר ול\"ג בעומר", p: ["דיני ספירת העומר", "ימי העומר", "ל\"ג בעומר ומנהגיו"] },
                  { n: "שבועות", p: ["ערב שבועות", "תיקון ליל שבועות", "מגילת רות"] }
              ]},
              { seder: "4. בין המצרים ותעניות השנה", items: [
                  { n: "תעניות השנה", p: ["צום גדליה", "עשרה בטבת", "תענית אסתר", "שבעה עשר בתמוז"] },
                  { n: "בין המצרים ותשעה באב", p: ["שלושת השבועות", "תשעה באב ותיקון חצות", "קינות ומגילת איכה"] }
              ]}
          ],
          tanakh: [{ seder: "תורה", items: [{ n: "בראשית", c: 50 }, { n: "שמות", c: 40 }, { n: "ויקרא", c: 27 }, { n: "במדבר", c: 36 }, { n: "דברים", c: 34 }]}, { seder: "נביאים", items: [{ n: "יהושע", c: 24 }, { n: "שופטים", c: 21 }, { n: "שמואל א", c: 31 }, { n: "שמואל ב", c: 24 }, { n: "מלכים א", c: 22 }, { n: "מלכים ב", c: 25 }, { n: "ישעיהו", c: 66 }, { n: "ירמיהו", c: 52 }, { n: "יחזקאל", c: 48 }, { n: "תרי עשר", c: 67 }]}, { seder: "כתובים", items: [{ n: "תהילים", c: 150 }, { n: "משלי", c: 31 }, { n: "איוב", c: 42 }, { n: "שיר השירים", c: 8 }, { n: "רות", c: 4 }, { n: "איכה", c: 5 }, { n: "קהלת", c: 12 }, { n: "אסתר", c: 10 }, { n: "דניאל", c: 12 }, { n: "עזרא", c: 10 }, { n: "נחמיה", c: 13 }, { n: "דברי הימים א", c: 29 }, { n: "דברי הימים ב", c: 36 }]}],
          mishnah: [
              { seder: "סדר זרעים", items: [
                  { n: "ברכות", c: 9, m: [5, 8, 6, 7, 5, 8, 5, 8, 5] },
                  { n: "פאה", c: 8, m: [6, 8, 8, 11, 8, 11, 8, 9] },
                  { n: "דמאי", c: 7, m: [4, 5, 6, 7, 11, 12, 8] },
                  { n: "כלאיים", c: 9, m: [9, 11, 7, 9, 8, 9, 8, 6, 10] },
                  { n: "שביעית", c: 10, m: [8, 10, 10, 10, 9, 6, 7, 11, 9, 9] },
                  { n: "תרומות", c: 11, m: [10, 6, 9, 11, 9, 6, 7, 12, 7, 12, 10] },
                  { n: "מעשרות", c: 5, m: [8, 8, 10, 6, 8] },
                  { n: "מעשר שני", c: 5, m: [7, 10, 14, 12, 15] },
                  { n: "חלה", c: 4, m: [9, 8, 10, 11] },
                  { n: "ערלה", c: 3, m: [9, 9, 9] },
                  { n: "ביכורים", c: 3, m: [11, 11, 12] }
              ]},
              { seder: "סדר מועד", items: [
                  { n: "שבת", c: 24, m: [11, 7, 6, 2, 4, 10, 4, 7, 7, 6, 6, 6, 7, 4, 3, 8, 8, 3, 6, 5, 3, 6, 5, 5] },
                  { n: "עירובין", c: 10, m: [10, 6, 9, 11, 9, 10, 11, 11, 4, 15] },
                  { n: "פסחים", c: 10, m: [7, 8, 8, 9, 10, 6, 13, 8, 11, 9] },
                  { n: "שקלים", c: 8, m: [7, 5, 4, 9, 6, 6, 7, 8] },
                  { n: "יומא", c: 8, m: [8, 7, 11, 6, 7, 8, 5, 9] },
                  { n: "סוכה", c: 5, m: [11, 9, 15, 10, 8] },
                  { n: "ביצה", c: 5, m: [10, 10, 10, 7, 7] },
                  { n: "ראש השנה", c: 4, m: [9, 9, 9, 9] },
                  { n: "תענית", c: 4, m: [7, 10, 9, 8] },
                  { n: "מגילה", c: 4, m: [11, 6, 6, 10] },
                  { n: "מועד קטן", c: 3, m: [10, 5, 9] },
                  { n: "חגיגה", c: 3, m: [8, 7, 8] }
              ]},
              { seder: "סדר נשים", items: [
                  { n: "יבמות", c: 16, m: [4, 10, 10, 13, 6, 6, 6, 6, 6, 9, 7, 6, 13, 9, 10, 7] },
                  { n: "כתובות", c: 13, m: [10, 10, 9, 12, 9, 7, 10, 8, 9, 6, 6, 4, 11] },
                  { n: "נדרים", c: 11, m: [4, 5, 11, 8, 6, 10, 9, 7, 10, 8, 12] },
                  { n: "נזיר", c: 9, m: [7, 10, 7, 7, 7, 11, 4, 2, 5] },
                  { n: "סוטה", c: 9, m: [9, 6, 8, 5, 5, 4, 8, 7, 15] },
                  { n: "גיטין", c: 9, m: [6, 7, 8, 9, 9, 7, 9, 10, 10] },
                  { n: "קידושין", c: 4, m: [10, 10, 13, 14] }
              ]},
              { seder: "סדר נזיקין", items: [
                  { n: "בבא קמא", c: 10, m: [4, 6, 11, 9, 7, 6, 7, 7, 12, 10] },
                  { n: "בבא מציעא", c: 10, m: [8, 11, 12, 12, 11, 8, 11, 9, 13, 6] },
                  { n: "בבא בתרא", c: 10, m: [6, 14, 8, 9, 11, 8, 4, 8, 10, 8] },
                  { n: "סנהדרין", c: 11, m: [6, 5, 8, 5, 5, 6, 11, 7, 6, 6, 6] },
                  { n: "מכות", c: 3, m: [10, 8, 16] },
                  { n: "שבועות", c: 8, m: [7, 5, 11, 13, 5, 7, 8, 6] },
                  { n: "עדיות", c: 8, m: [14, 10, 12, 12, 7, 3, 9, 7] },
                  { n: "עבודה זרה", c: 5, m: [9, 7, 10, 12, 12] },
                  { n: "אבות", c: 6, m: [18, 16, 18, 22, 23, 11] },
                  { n: "הוריות", c: 3, m: [5, 7, 8] }
              ]},
              { seder: "סדר קדשים", items: [
                  { n: "זבחים", c: 14, m: [4, 5, 6, 6, 8, 7, 6, 12, 7, 8, 8, 6, 8, 10] },
                  { n: "מנחות", c: 13, m: [4, 5, 7, 5, 9, 7, 6, 7, 9, 9, 9, 5, 11] },
                  { n: "חולין", c: 12, m: [7, 10, 7, 7, 5, 7, 6, 6, 8, 4, 2, 5] },
                  { n: "בכורות", c: 9, m: [7, 9, 4, 10, 6, 12, 7, 12, 8] },
                  { n: "ערכין", c: 9, m: [4, 6, 5, 4, 6, 5, 5, 7, 8] },
                  { n: "תמורה", c: 7, m: [6, 3, 5, 4, 6, 5, 6] },
                  { n: "כריתות", c: 6, m: [7, 6, 10, 3, 8, 9] },
                  { n: "מעילה", c: 6, m: [4, 9, 8, 6, 5, 6] },
                  { n: "תמיד", c: 7, m: [4, 5, 9, 3, 6, 3, 4] },
                  { n: "מידות", c: 5, m: [9, 6, 8, 7, 4] },
                  { n: "קינים", c: 3, m: [4, 5, 6] }
              ]},
              { seder: "סדר טהרות", items: [
                  { n: "כלים", c: 30, m: [9, 8, 8, 4, 11, 4, 6, 11, 8, 8, 9, 8, 8, 8, 6, 8, 17, 9, 10, 7, 3, 10, 5, 17, 9, 9, 12, 10, 8, 4] },
                  { n: "אהלות", c: 18, m: [8, 7, 7, 3, 7, 7, 6, 6, 16, 7, 9, 8, 6, 7, 10, 5, 5, 11] },
                  { n: "נגעים", c: 14, m: [6, 5, 8, 11, 5, 8, 5, 10, 3, 10, 12, 7, 12, 13] },
                  { n: "פרה", c: 12, m: [4, 5, 11, 4, 9, 5, 12, 11, 9, 6, 9, 11] },
                  { n: "טהרות", c: 10, m: [9, 8, 8, 13, 9, 10, 9, 9, 9, 8] },
                  { n: "מקואות", c: 10, m: [8, 10, 4, 5, 6, 11, 7, 5, 7, 8] },
                  { n: "נידה", c: 10, m: [7, 7, 7, 7, 9, 14, 5, 4, 11, 8] },
                  { n: "מכשירין", c: 6, m: [6, 11, 8, 10, 11, 8] },
                  { n: "זבים", c: 5, m: [6, 4, 3, 7, 12] },
                  { n: "טבול יום", c: 4, m: [5, 8, 6, 7] },
                  { n: "ידיים", c: 4, m: [5, 4, 5, 8] },
                  { n: "עוקצין", c: 3, m: [6, 10, 12] }
              ]}
          ],
          bavli: [{ seder: "ש\"ס בבלי", items: [{ n: "ברכות", c: 64 }, { n: "שבת", c: 157 }, { n: "עירובין", c: 105 }, { n: "פסחים", c: 121 }, { n: "שקלים", c: 22 }, { n: "יומא", c: 88 }, { n: "סוכה", c: 56 }, { n: "ביצה", c: 40 }, { n: "ראש השנה", c: 35 }, { n: "תענית", c: 31 }, { n: "מגילה", c: 32 }, { n: "מועד קטן", c: 29 }, { n: "חגיגה", c: 27 }, { n: "יבמות", c: 122 }, { n: "כתובות", c: 112 }, { n: "נדרים", c: 91 }, { n: "נזיר", c: 66 }, { n: "סוטה", c: 49 }, { n: "גיטין", c: 90 }, { n: "קידושין", c: 82 }, { n: "בבא קמא", c: 119 }, { n: "בבא מציעא", c: 119 }, { n: "בבא בתרא", c: 176 }, { n: "סנהדרין", c: 113 }, { n: "מכות", c: 24 }, { n: "שבועות", c: 49 }, { n: "עבודה זרה", c: 76 }, { n: "הוריות", c: 14 }, { n: "זבחים", c: 120 }, { n: "מנחות", c: 110 }, { n: "חולין", c: 142 }, { n: "בכורות", c: 61 }, { n: "ערכין", c: 34 }, { n: "תמורה", c: 34 }, { n: "כריתות", c: 28 }, { n: "מעילה", c: 22 }, { n: "תמיד", c: 33, s: 25 }, { n: "מידות", c: 37, s: 34 }, { n: "קינים", c: 25, s: 22 }, { n: "נידה", c: 73 }]}],
          yerushalmi: [{ seder: "ש\"ס ירושלמי", items: [{ n: "ברכות", c: 68 }, { n: "פאה", c: 37 }, { n: "דמאי", c: 34 }, { n: "כלאיים", c: 44 }, { n: "שביעית", c: 31 }, { n: "תרומות", c: 59 }, { n: "מעשרות", c: 26 }, { n: "מעשר שני", c: 33 }, { n: "חלה", c: 28 }, { n: "ערלה", c: 20 }, { n: "ביכורים", c: 13 }, { n: "שבת", c: 92 }, { n: "עירובין", c: 65 }, { n: "פסחים", c: 71 }, { n: "יומא", c: 42 }, { n: "שקלים", c: 33 }, { n: "סוכה", c: 26 }, { n: "ראש השנה", c: 22 }, { n: "ביצה", c: 22 }, { n: "תענית", c: 26 }, { n: "מגילה", c: 34 }, { n: "חגיגה", c: 22 }, { n: "מועד קטן", c: 19 }, { n: "יבמות", c: 85 }, { n: "סוטה", c: 47 }, { n: "כתובות", c: 72 }, { n: "נדרים", c: 40 }, { n: "גיטין", c: 54 }, { n: "נזיר", c: 44 }, { n: "קידושין", c: 48 }, { n: "בבא קמא", c: 44 }, { n: "בבא מציעא", c: 37 }, { n: "בבא בתרא", c: 34 }, { n: "סנהדרין", c: 68 }, { n: "מכות", c: 9 }, { n: "שבועות", c: 44 }, { n: "עבודה זרה", c: 37 }, { n: "הוריות", c: 19 }, { n: "נידה", c: 13 }]}],
          rambam: [{ seder: "רמב\"ם", items: [{ n: "מדע", c: 46 }, { n: "אהבה", c: 46 }, { n: "זמנים", c: 97 }, { n: "נשים", c: 51 }, { n: "קדושה", c: 54 }, { n: "הפלאה", c: 43 }, { n: "זרעים", c: 84 }, { n: "עבודה", c: 97 }, { n: "קרבנות", c: 45 }, { n: "טהרה", c: 172 }, { n: "נזיקין", c: 61 }, { n: "קניין", c: 74 }, { n: "משפטים", c: 75 }, { n: "שופטים", c: 81 }]}],
          shulchan: [{ seder: "שולחן ערוך", items: [{ n: "אורח חיים", c: 697 }, { n: "יורה דעה", c: 403 }, { n: "אבן העזר", c: 178 }, { n: "חושן משפט", c: 427 }]}]
      };
      
      function toHebrew(num) {
          if (num <= 0) return "";
          let str = "";
          const hundreds = ["", "ק", "ר", "ש", "ת"];
          const tens = ["", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ"];
          const realOnes = ["", "א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט"];
          if (num >= 100) { str += hundreds[Math.floor(num / 100)]; num %= 100; }
          if (num === 15) return str + "טו";
          if (num === 16) return str + "טז";
          str += tens[Math.floor(num / 10)];
          str += realOnes[num % 10];
          return str;
      }
      
      function selectAll(val) { document.querySelectorAll('#masechtotList input[type="checkbox"]').forEach(i => i.checked = val); }
      
      function toggleSeder(sourceCheckbox, sederName) {
          const checkboxes = document.querySelectorAll(`.masechet-item[data-seder="${sederName}"] input[type="checkbox"]`);
          checkboxes.forEach(cb => cb.checked = sourceCheckbox.checked);
      }
      
      function toggleMishnahPartsOption() {
          const splitMishnot = document.getElementById('mishnahSplitMishnot').checked;
          document.getElementById('mishnahPartsContainer').style.display = splitMishnot ? 'block' : 'none';
          if (!splitMishnot) {
              document.getElementById('mishnahSplitParts').checked = false;
              toggleMishnahPartsInput();
          }
      }
      
      function toggleMishnahPartsInput() {
          const splitParts = document.getElementById('mishnahSplitParts').checked;
          document.getElementById('mishnahPartsInputBox').style.display = splitParts ? 'block' : 'none';
      }
      
      function loadLibrary(libKey, btn) {
          currentLib = libKey;
          document.querySelectorAll('.lib-btn').forEach(b => b.classList.remove('active'));
          if(btn) btn.classList.add('active');
          
          document.getElementById('shasOptions').style.display = (libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi')) ? 'block' : 'none';
          document.getElementById('torahOptions').style.display = (libKey === 'torah') ? 'block' : 'none';
          document.getElementById('mishnahOptions').style.display = (libKey === 'mishnah') ? 'block' : 'none';
          document.getElementById('genericSubOptions').style.display = (libKey === 'rambam' || libKey === 'tanakh') ? 'block' : 'none';
          document.getElementById('shulchanOptions').style.display = (libKey === 'shulchan') ? 'block' : 'none';
      
          const showHierarchical = (libKey === 'bavli' || libKey === 'yerushalmi');
          document.getElementById('groupHierarchical').style.display = showHierarchical ? 'block' : 'none';
          if(!showHierarchical) document.getElementById('hierarchicalSedarim').checked = false;
      
          const listDiv = document.getElementById('masechtotList');
          listDiv.innerHTML = "";
          let unitLabel = libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi') ? "דפים" : (libKey === 'shulchan' ? "סימנים" : (libKey === 'torah' ? "פרשיות" : (libKey === 'chagim' ? "נושאים" : "פרקים")));
      
          fullDb[libKey].forEach(s => {
              const title = document.createElement('div');
              title.className = 'seder-title';
              title.innerHTML = `<span>${s.seder}</span> <input type="checkbox" class="seder-checkbox" title="בחר הכל בסדר זה" onclick="toggleSeder(this, '${s.seder}')">`;
              listDiv.appendChild(title);
              
              s.items.forEach(m => {
                  const item = document.createElement('div');
                  item.className = 'masechet-item';
                  item.setAttribute('data-seder', s.seder);
                  let countLabel = m.p ? m.p.length : m.c;
                  item.innerHTML = `<input type="checkbox" value="${m.n}" data-seder-name="${s.seder}" data-c="${m.c||0}" data-p='${JSON.stringify(m.p||[])}' data-m='${JSON.stringify(m.m||[])}' data-s="${m.s||(libKey.includes('shas')?2:1)}"> <span>${m.n} (${countLabel} ${unitLabel})</span>`;
                  listDiv.appendChild(item);
              });
          });
      }
      
      function abort() { isAborted = true; }
      
      async function process() {
          isAborted = false;
          const token = document.getElementById('token').value.trim();
          const startFolder = parseInt(document.getElementById('startNum').value);
          const endType = document.getElementById('endFolderType').value;
          const targetPath = document.getElementById('targetPath').value.trim().replace(/^\/|\/$/g, "");
          
          let hierarchical = document.getElementById('hierarchicalSedarim').checked;
          if (currentLib === 'mishnah') {
              hierarchical = document.getElementById('mishnahBySedarim').checked;
          }
      
          const selected = Array.from(document.querySelectorAll('#masechtotList .masechet-item input[type="checkbox"]:checked'));
      
          if(!token || selected.length === 0) return alert("הזן טוקן ובחר פריטים!");
      
          document.getElementById('startBtn').style.display = "none";
          document.getElementById('cancelBtn').style.display = "block";
          document.getElementById('progWrapper').style.display = "block";
          const log = document.getElementById('logBox');
          log.innerHTML = "🏁 מתחיל בתהליך...";
      
          let tasks = [];
          
          if (hierarchical) {
              let sedarimMap = {};
              selected.forEach(input => {
                  const sederName = input.dataset.sederName;
                  if (!sedarimMap[sederName]) sedarimMap[sederName] = [];
                  sedarimMap[sederName].push(input);
              });
      
              let sederKeys = Object.keys(sedarimMap);
              let sederCounter = startFolder;
      
              sederKeys.forEach((sederName) => {
                  const sederItems = sedarimMap[sederName];
                  const autoSederDigits = sederKeys.length >= 10 ? 2 : 1;
                  const sederFolderNum = String(sederCounter).padStart(autoSederDigits, '0');
                  const sederPath = targetPath ? `${targetPath}/${sederFolderNum}` : sederFolderNum;
      
                  tasks.push({ p: sederPath, t: sederName, b: `type=menu\ntitle=${sederName}\ndigits=${sederItems.length >= 10 ? 2 : 1}` });
      
                  let itemCounter = 1;
                  sederItems.forEach(input => {
                      const name = input.value;
                      const subItems = JSON.parse(input.dataset.p);
                      const count = parseInt(input.dataset.c);
                      const start = parseInt(input.dataset.s);
                      const mishArr = JSON.parse(input.dataset.m || "[]");
                      
                      const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                      const autoDigits = totalSubCount >= 10 ? 2 : 1;
      
                      const rootF = String(itemCounter).padStart(sederItems.length >= 10 ? 2 : 1, '0');
                      const rootP = `${sederPath}/${rootF}`;
      
                      tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
      
                      for (let i = start; i <= count; i++) {
                          const sf = String(i).padStart(autoDigits, '0');
                          const sp = `${rootP}/${sf}`;
                          const heb = toHebrew(i);
                          let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : `פרק ${heb}`;
                          
                          const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                          const mishCount = parseInt(document.getElementById('mishCount').value);
                          const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                          
                          let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                          let hasSub = splitS || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                          let subDigits = splitS ? 1 : (curMishCount >= 10 ? 2 : 1);
                          
                          tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
      
                          if(splitS) {
                              tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                              tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                          }
                          if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                              const splitParts = document.getElementById('mishnahSplitParts').checked;
                              const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
      
                              for(let m=1; m<=curMishCount; m++) {
                                  const mPad = curMishCount >= 10 ? 2 : 1;
                                  const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                  const mishTitle = `משנה ${toHebrew(m)}`;
      
                                  if (splitParts && partsCount > 1) {
                                      const partDigits = partsCount >= 10 ? 2 : 1;
                                      tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                      for(let p=1; p<=partsCount; p++) {
                                          const pPad = partsCount >= 10 ? 2 : 1;
                                          tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                      }
                                  } else {
                                      tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                  }
                              }
                          }
                      }
                      itemCounter++;
                  });
                  sederCounter++;
              });
      
          } else {
              let counter = startFolder;
              selected.forEach(input => {
                  const name = input.value;
                  const subItems = JSON.parse(input.dataset.p);
                  const count = parseInt(input.dataset.c);
                  const start = parseInt(input.dataset.s);
                  const mishArr = JSON.parse(input.dataset.m || "[]");
                  
                  const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                  const autoDigits = totalSubCount >= 10 ? 2 : 1;
      
                  const rootF = String(counter).padStart(selected.length > 9 ? 2 : 1, '0');
                  const rootP = targetPath ? `${targetPath}/${rootF}` : rootF;
      
                  tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
      
                  if (currentLib === 'torah') {
                      const noAliyotChecked = document.getElementById('noAliyot').checked;
                      subItems.forEach((pn, pi) => {
                          const pf = String(pi + 1).padStart(autoDigits, '0');
                          const pp = `${rootP}/${pf}`;
                          
                          if (noAliyotChecked) {
                              tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=${endType}\ntitle=פרשת ${pn}` });
                          } else {
                              tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=menu\ntitle=פרשת ${pn}\ndigits=1` });
                              ["ראשון","שני","שלישי","רביעי","חמישי","שישי","שביעי","מפטיר"].forEach((aly, ai) => {
                                  tasks.push({ p: `${pp}/${ai+1}`, t: `עליה ${aly}`, b: `type=${endType}\ntitle=עליה ${aly}` });
                              });
                          }
                      });
                  } else if (currentLib === 'chagim') {
                      subItems.forEach((subName, si) => {
                          const sf = String(si + 1).padStart(autoDigits, '0');
                          const sp = `${rootP}/${sf}`;
                          tasks.push({ p: sp, t: subName, b: `type=${endType}\ntitle=${subName}` });
                      });
                  } else {
                      for (let i = start; i <= count; i++) {
                          const sf = String(i).padStart(autoDigits, '0');
                          const sp = `${rootP}/${sf}`;
                          const heb = toHebrew(i);
                          let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : (currentLib === 'shulchan' ? `סימן ${heb}` : `פרק ${heb}`);
                          
                          const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                          const seifim = parseInt(document.getElementById('seifimCount').value);
                          const mishCount = parseInt(document.getElementById('mishCount').value);
                          const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                          
                          let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                          
                          let hasSub = splitS || (currentLib === 'shulchan' && seifim > 0) || (['rambam','tanakh'].includes(currentLib) && mishCount > 0) || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                          let subDigits = splitS ? 1 : ((currentLib === 'mishnah' ? curMishCount : (currentLib === 'shulchan' ? seifim : mishCount)) >= 10 ? 2 : 1);
                          
                          tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
      
                          if(splitS) {
                              tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                              tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                          }
                          if(currentLib === 'shulchan' && seifim > 0) {
                              for(let s=1; s<=seifim; s++) tasks.push({ p: `${sp}/${String(s).padStart(seifim >= 10 ? 2 : 1, '0')}`, t: `סעיף ${toHebrew(s)}`, b: `type=${endType}\ntitle=סעיף ${toHebrew(s)}` });
                          }
                          if(['rambam','tanakh'].includes(currentLib) && mishCount > 0) {
                              let subL = currentLib === 'rambam' ? "הלכה" : "פסוק";
                              let pad = mishCount >= 10 ? 2 : 1;
                              for(let m=1; m<=mishCount; m++) tasks.push({ p: `${sp}/${String(m).padStart(pad, '0')}`, t: `${subL} ${toHebrew(m)}`, b: `type=${endType}\ntitle=${subL} ${toHebrew(m)}` });
                          }
                          if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                              const splitParts = document.getElementById('mishnahSplitParts').checked;
                              const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
      
                              for(let m=1; m<=curMishCount; m++) {
                                  const mPad = curMishCount >= 10 ? 2 : 1;
                                  const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                  const mishTitle = `משנה ${toHebrew(m)}`;
      
                                  if (splitParts && partsCount > 1) {
                                      const partDigits = partsCount >= 10 ? 2 : 1;
                                      tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                      for(let p=1; p<=partsCount; p++) {
                                          const pPad = partsCount >= 10 ? 2 : 1;
                                          tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                      }
                                  } else {
                                      tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                  }
                              }
                          }
                      }
                  }
                  counter++;
              });
          }
      
          for (let i = 0; i < tasks.length; i++) {
              if (isAborted) break;
              const ok = await upload(token, tasks[i].p, tasks[i].b);
              if(ok) log.innerHTML += `<div>✓ SUCCESS: ${tasks[i].p}</div>`;
              else log.innerHTML += `<div style="color:red">✗ FAILED: ${tasks[i].p}</div>`;
              let pct = Math.round(((i + 1) / tasks.length) * 100);
              document.getElementById('progBar').style.width = pct + "%";
              document.getElementById('progText').innerText = pct + "%";
              document.getElementById('progCounts').innerText = `${i+1} / ${tasks.length}`;
              log.scrollTop = log.scrollHeight;
          }
      
          document.getElementById('startBtn').style.display = "block";
          document.getElementById('cancelBtn').style.display = "none";
      }
      
      async function upload(token, path, body) {
          const fd = new FormData();
          fd.append('token', token);
          fd.append('path', `ivr2:${path}/ext.ini`);
          fd.append('qqfile', new Blob([body], { type: 'text/plain;charset=utf-8' }), 'ext.ini');
          try {
              const r = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, { method: 'POST', body: fd });
              const d = await r.json();
              return d && (d.responseStatus === "OK" || d.status === "OK");
          } catch(e) { return false; }
      }
      
      loadLibrary('bavli');
      

      </script>

      </body>
      </html>

      L 2 תגובות תגובה אחרונה תגובה ציטוט 0
      • L מנותק
        lavitoren הטי"ל @בעזרת השם
        נערך לאחרונה על ידי lavitoren הטי"ל

        @בעזרת-השם
        א. הכנס הכל כקוד למה חלק חלק (כלומר לא רק מה שהבינה הביאה סמן את כל הקוד ותעשה כקוד כלומר שים בהתחלה 3 סימנים כאלו ''' וגם בסוף ואז זה עושה כך

        <!DOCTYPE html>
        <html lang="he" dir="rtl">
        <head>
        <meta charset="UTF-8">
        <title>הטי"ל - הכלי הטלפוני ליצירת ספריות v1.4</title>
        <style>
        :root {
        --bg-dark: #121212;
        --surface: #1e1e1e;
        --surface-light: #2d2d2d;
        --primary: #3b82f6;
        --primary-hover: #2563eb;
        --accent: #f59e0b;
        --danger: #ef4444;
        --text-main: #e2e8f0;
        --text-dim: #94a3b8;
        --border: #334155;
        --success: #10b981;
        }
        
            body { 
                font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
                background-color: var(--bg-dark); 
                color: var(--text-main); 
                margin: 0; 
                padding: 20px; 
                line-height: 1.5;
                text-align: right;
            }
         
            .wrapper { max-width: 1200px; margin: 0 auto; }
         
            header { 
                border-bottom: 1px solid var(--border); 
                padding-bottom: 20px; 
                margin-bottom: 30px; 
                display: flex; 
                justify-content: space-between; 
                align-items: center; 
            }
         
            h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
            .version { font-size: 14px; background: var(--border); padding: 4px 10px; border-radius: 4px; color: #fff; margin-right: 10px; }
         
            .dashboard { display: grid; grid-template-columns: 350px 1fr; gap: 20px; }
         
            .card { 
                background: var(--surface); 
                border: 1px solid var(--border); 
                border-radius: 12px; 
                padding: 20px; 
                box-shadow: 0 4px 20px rgba(0,0,0,0.5);
            }
         
            .lib-selector { 
                display: grid; 
                grid-template-columns: 1fr; 
                gap: 10px; 
                margin-bottom: 20px; 
            }
         
            .lib-btn { 
                background: var(--surface-light); 
                border: 1px solid var(--border); 
                color: var(--text-main); 
                padding: 12px; 
                border-radius: 8px; 
                cursor: pointer; 
                text-align: right; 
                font-weight: 600; 
                transition: all 0.2s;
                display: flex;
                align-items: center;
                gap: 10px;
                font-size: 15px;
            }
         
            .lib-btn:hover { border-color: var(--primary); background: #252525; }
            .lib-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
         
            .form-group { margin-bottom: 15px; }
            label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
            
            input, select { 
                width: 100%; 
                background: var(--bg-dark); 
                border: 1px solid var(--border); 
                border-radius: 6px; 
                padding: 10px; 
                color: white; 
                box-sizing: border-box;
                outline: none;
                font-family: inherit;
            }
         
            input:focus { border-color: var(--primary); }
         
            .options-panel { 
                background: #1a202c; 
                border-right: 4px solid var(--accent); 
                padding: 15px; 
                border-radius: 6px; 
                margin-bottom: 20px; 
            }
         
            .scroll-area { 
                height: 500px; 
                overflow-y: auto; 
                border: 1px solid var(--border); 
                background: var(--bg-dark); 
                padding: 10px; 
                border-radius: 8px; 
                display: grid; 
                grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); 
                gap: 8px; 
            }
         
            .masechet-item { 
                background: var(--surface-light); 
                padding: 8px; 
                border-radius: 4px; 
                display: flex; 
                align-items: center; 
                gap: 8px; 
                font-size: 13px;
            }
            .masechet-item input { width: auto; cursor: pointer; }
         
            .seder-title { 
                grid-column: 1 / -1; 
                background: var(--border); 
                padding: 4px 10px; 
                font-size: 12px; 
                font-weight: 800; 
                color: var(--accent); 
                margin-top: 10px;
                border-radius: 4px;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
         
            .seder-checkbox {
                width: auto !important;
                margin: 0;
                cursor: pointer;
            }
         
            .btn-run { 
                background: var(--primary); color: white; border: none; padding: 15px; border-radius: 8px; 
                font-weight: 800; cursor: pointer; width: 100%; font-size: 17px; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
            }
            .btn-stop { background: var(--danger); color: white; border: none; padding: 15px; border-radius: 8px; font-weight: 800; cursor: pointer; width: 100%; display: none; font-size: 17px; }
         
            .progress-wrapper { margin-top: 20px; }
            .progress-bar-bg { background: var(--surface-light); height: 14px; border-radius: 7px; overflow: hidden; }
            .progress-bar-fill { background: linear-gradient(90deg, var(--success), #34d399); height: 100%; width: 0%; transition: width 0.3s; }
            .progress-status { font-size: 12px; color: var(--text-dim); margin-top: 8px; display: flex; justify-content: space-between; }
         
            .log-container { 
                margin-top: 20px; background: #000; color: #00ff00; font-family: 'Consolas', monospace; 
                font-size: 12px; padding: 15px; border-radius: 8px; height: 220px; overflow-y: auto; border: 1px solid var(--border);
                direction: ltr; text-align: left;
            }
         
            ::-webkit-scrollbar { width: 8px; }
            ::-webkit-scrollbar-track { background: var(--bg-dark); }
            ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
        </style>
        </head>
        <body>
        
        <div class="wrapper">
        <header>
        <h1>פתיחת ספריה תורנית מטורפת עצומת מימדים לקו שלכם <span class="version">הטי"ל V1.4</span></h1>
        <div id="connectionStatus" style="color: var(--success); font-size: 13px;">● מוכן לביצוע</div>
        </header>
        
        <div class="dashboard">
            <div class="card">
                <label>סוג תוכן להקמה</label>
                <div class="lib-selector">
                    <button class="lib-btn active" onclick="loadLibrary('bavli', this)">📖 ש"ס בבלי</button>
                    <button class="lib-btn" onclick="loadLibrary('yerushalmi', this)">🕍 ש"ס ירושלמי</button>
                    <button class="lib-btn" onclick="loadLibrary('torah', this)">📜 תורה (חומשים ופרשיות)</button>
                    <button class="lib-btn" onclick="loadLibrary('chagim', this)">🎉 חגים ומועדים</button>
                    <button class="lib-btn" onclick="loadLibrary('tanakh', this)">📚 תנ"ך (כ"ד ספרים)</button>
                    <button class="lib-btn" onclick="loadLibrary('mishnah', this)">🗳️ משניות</button>
                    <button class="lib-btn" onclick="loadLibrary('rambam', this)">⚖️ רמב"ם (היד החזקה)</button>
                    <button class="lib-btn" onclick="loadLibrary('shulchan', this)">🖋️ שולחן ערוך</button>
                </div>
         
                <div class="form-group">
                    <label>סוג שלוחת הקצה (היחידה הקטנה ביותר)</label>
                    <select id="endFolderType">
                        <option value="playfile">השמעת קבצים (playfile)</option>
                        <option value="record">הקלטת הודעות (record)</option>
                    </select>
                </div>
         
                <div class="form-group" id="groupHierarchical" style="display:none;">
                    <input type="checkbox" id="hierarchicalSedarim" style="width:auto; margin-left:10px;"> 
                    <label style="display:inline; color: white;" for="hierarchicalSedarim">הקם לפי סדרים (יוצר תת-תיקיות לפי סדרים)</label>
                </div>
         
                <div class="form-group">
                    <label>טוקן גישה API</label>
                    <input type="text" id="token" placeholder="0770000000:123456">
                </div>
         
                <div class="form-group">
                    <label>נתיב יעד (תיקייה בקו)</label>
                    <input type="text" id="targetPath" placeholder="למשל: 1/5">
                </div>
         
                <div class="form-group">
                    <label>מספר שלוחה להתחלה</label>
                    <input type="number" id="startNum" value="1">
                </div>
         
                <button class="btn-run" id="startBtn" onclick="process()">🚀 התחל הקמה</button>
                <button class="btn-stop" id="cancelBtn" onclick="abort()">🛑 עצור פעולה</button>
         
                <div class="progress-wrapper" id="progWrapper" style="display:none;">
                    <div class="progress-bar-bg"><div class="progress-bar-fill" id="progBar"></div></div>
                    <div class="progress-status"><span id="progText">0%</span><span id="progCounts">0 / 0</span></div>
                </div>
            </div>
         
            <div class="card">
                <div id="optionsPanel" class="options-panel">
                    <div id="shasOptions">
                        <input type="checkbox" id="splitAmudim" style="width:auto; margin-left:10px;"> 
                        <label style="display:inline; color: white;" for="splitAmudim">פצל דפים לעמוד א' וב'</label>
                    </div>
                    <div id="torahOptions" style="display:none;">
                        <input type="checkbox" id="noAliyot" style="width:auto; margin-left:10px;"> 
                        <label style="display:inline; color: white;" for="noAliyot">ללא עליות לתורה (פרשה היא השמעת קבצים ישירה)</label>
                    </div>
                    <div id="mishnahOptions" style="display:none;">
                        <div style="margin-bottom:8px;">
                            <input type="checkbox" id="mishnahBySedarim" style="width:auto; margin-left:10px;"> 
                            <label style="display:inline; color: white;" for="mishnahBySedarim">חלוקה לפי ששה סדרים</label>
                        </div>
                        <div style="margin-bottom:8px;">
                            <input type="checkbox" id="mishnahSplitMishnot" checked style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsOption()"> 
                            <label style="display:inline; color: white;" for="mishnahSplitMishnot">לחלק כל פרק למשניות</label>
                        </div>
                        <div id="mishnahPartsContainer" style="margin-top:8px; padding-right:20px;">
                            <input type="checkbox" id="mishnahSplitParts" style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsInput()"> 
                            <label style="display:inline; color: white;" for="mishnahSplitParts">פצל כל משנה לתתי-חלקים</label>
                            <div id="mishnahPartsInputBox" style="display:none; margin-top:5px;">
                                <label style="color: var(--text-dim); display:inline;">כמות חלקים לכל משנה: </label>
                                <input type="number" id="mishnahPartsCount" value="2" min="1" style="width:80px; display:inline-block;">
                            </div>
                        </div>
                    </div>
                    <div id="genericSubOptions" style="display:none;">
                        <label style="color: white;">כמות תתי-שלוחות (הלכות/פסוקים):</label>
                        <input type="number" id="mishCount" value="0" style="width:100px;">
                    </div>
                    <div id="shulchanOptions" style="display:none;">
                        <label style="color: white;">כמות סעיפים בכל סימן (0 לסימנים בלבד):</label>
                        <input type="number" id="seifimCount" value="0" style="width:100px;">
                    </div>
                </div>
         
                <div style="display:flex; justify-content: space-between; margin-bottom: 15px;">
                    <label>בחירת ספרים / מסכתות</label>
                    <div>
                        <button onclick="selectAll(true)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px;">בחר הכל</button>
                        <button onclick="selectAll(false)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px; margin-right:5px;">נקה הכל</button>
                    </div>
                </div>
         
                <div class="scroll-area" id="masechtotList"></div>
                <div class="log-container" id="logBox">ממתין לפקודה...</div>
            </div>
        </div>
        </div>
        
        <script>
        let isAborted = false;
        let currentLib = 'bavli';
        
        const fullDb = {
            torah: [{ seder: "חמישה חומשי תורה", items: [
                { n: "בראשית", p: ["בראשית", "נח", "לך לך", "וירא", "חיי שרה", "תולדות", "ויצא", "וישלח", "וישב", "מקץ", "ויגש", "ויחי"] },
                { n: "שמות", p: ["שמות", "וארא", "בא", "בשלח", "יתרו", "משפטים", "תרומה", "תצוה", "כי תשא", "ויקהל", "פקודי"] },
                { n: "ויקרא", p: ["ויקרא", "צו", "שמיני", "תזריע", "מצורע", "אחרי מות", "קדושים", "אמור", "בהר", "בחקותי"] },
                { n: "במדבר", p: ["במדבר", "נשא", "בהעלותך", "שלח", "קרח", "חקת", "בלק", "פינחס", "מטות", "מסעי"] },
                { n: "דברים", p: ["דברים", "ואתחנן", "עקב", "ראה", "שופטים", "כי תצא", "כי תבוא", "נצבים", "וילך", "האזינו", "וזאת הברכה"] }
            ]}],
            chagim: [
                { seder: "1. ימים נוראים וחגי תשרי", items: [
                    { n: "ראש השנה", p: ["ערב ראש השנה", "תפילות ראש השנה", "תקיעת שופר", "סימני ראש השנה"] },
                    { n: "עשרת ימי תשובה", p: ["סליחות", "שבת תשובה", "כפרות"] },
                    { n: "יום הכיפורים", p: ["ערב יום הכיפורים", "תפילת כל נדרי", "נעילה", "מוצאי יום הכיפורים"] },
                    { n: "סוכות", p: ["בניית סוכה", "ארבעת המינים", "הושענא רבא", "שמיני עצרת ושמחת תורה"] }
                ]},
                { seder: "2. חגים מדרבנן", items: [
                    { n: "חנוכה", p: ["הדלקת נרות", "מעוז צור", "ענייני חנוכה", "סביבון"] },
                    { n: "פורים", p: ["תענית אסתר", "קריאת המגילה", "משלוח מנות ומתנות לאביונים", "סעודת פורים"] }
                ]},
                { seder: "3. חגי ניסן וספירת העומר", items: [
                    { n: "פסח", p: ["בדיקת חמץ וביעורו", "הערב הסדר", "הגדה של פסח", "שביעי של פסח ואיסרו חג"] },
                    { n: "ספירת העומר ול\"ג בעומר", p: ["דיני ספירת העומר", "ימי העומר", "ל\"ג בעומר ומנהגיו"] },
                    { n: "שבועות", p: ["ערב שבועות", "תיקון ליל שבועות", "מגילת רות"] }
                ]},
                { seder: "4. בין המצרים ותעניות השנה", items: [
                    { n: "תעניות השנה", p: ["צום גדליה", "עשרה בטבת", "תענית אסתר", "שבעה עשר בתמוז"] },
                    { n: "בין המצרים ותשעה באב", p: ["שלושת השבועות", "תשעה באב ותיקון חצות", "קינות ומגילת איכה"] }
                ]}
            ],
            tanakh: [{ seder: "תורה", items: [{ n: "בראשית", c: 50 }, { n: "שמות", c: 40 }, { n: "ויקרא", c: 27 }, { n: "במדבר", c: 36 }, { n: "דברים", c: 34 }]}, { seder: "נביאים", items: [{ n: "יהושע", c: 24 }, { n: "שופטים", c: 21 }, { n: "שמואל א", c: 31 }, { n: "שמואל ב", c: 24 }, { n: "מלכים א", c: 22 }, { n: "מלכים ב", c: 25 }, { n: "ישעיהו", c: 66 }, { n: "ירמיהו", c: 52 }, { n: "יחזקאל", c: 48 }, { n: "תרי עשר", c: 67 }]}, { seder: "כתובים", items: [{ n: "תהילים", c: 150 }, { n: "משלי", c: 31 }, { n: "איוב", c: 42 }, { n: "שיר השירים", c: 8 }, { n: "רות", c: 4 }, { n: "איכה", c: 5 }, { n: "קהלת", c: 12 }, { n: "אסתר", c: 10 }, { n: "דניאל", c: 12 }, { n: "עזרא", c: 10 }, { n: "נחמיה", c: 13 }, { n: "דברי הימים א", c: 29 }, { n: "דברי הימים ב", c: 36 }]}],
            mishnah: [
                { seder: "סדר זרעים", items: [
                    { n: "ברכות", c: 9, m: [5, 8, 6, 7, 5, 8, 5, 8, 5] },
                    { n: "פאה", c: 8, m: [6, 8, 8, 11, 8, 11, 8, 9] },
                    { n: "דמאי", c: 7, m: [4, 5, 6, 7, 11, 12, 8] },
                    { n: "כלאיים", c: 9, m: [9, 11, 7, 9, 8, 9, 8, 6, 10] },
                    { n: "שביעית", c: 10, m: [8, 10, 10, 10, 9, 6, 7, 11, 9, 9] },
                    { n: "תרומות", c: 11, m: [10, 6, 9, 11, 9, 6, 7, 12, 7, 12, 10] },
                    { n: "מעשרות", c: 5, m: [8, 8, 10, 6, 8] },
                    { n: "מעשר שני", c: 5, m: [7, 10, 14, 12, 15] },
                    { n: "חלה", c: 4, m: [9, 8, 10, 11] },
                    { n: "ערלה", c: 3, m: [9, 9, 9] },
                    { n: "ביכורים", c: 3, m: [11, 11, 12] }
                ]},
                { seder: "סדר מועד", items: [
                    { n: "שבת", c: 24, m: [11, 7, 6, 2, 4, 10, 4, 7, 7, 6, 6, 6, 7, 4, 3, 8, 8, 3, 6, 5, 3, 6, 5, 5] },
                    { n: "עירובין", c: 10, m: [10, 6, 9, 11, 9, 10, 11, 11, 4, 15] },
                    { n: "פסחים", c: 10, m: [7, 8, 8, 9, 10, 6, 13, 8, 11, 9] },
                    { n: "שקלים", c: 8, m: [7, 5, 4, 9, 6, 6, 7, 8] },
                    { n: "יומא", c: 8, m: [8, 7, 11, 6, 7, 8, 5, 9] },
                    { n: "סוכה", c: 5, m: [11, 9, 15, 10, 8] },
                    { n: "ביצה", c: 5, m: [10, 10, 10, 7, 7] },
                    { n: "ראש השנה", c: 4, m: [9, 9, 9, 9] },
                    { n: "תענית", c: 4, m: [7, 10, 9, 8] },
                    { n: "מגילה", c: 4, m: [11, 6, 6, 10] },
                    { n: "מועד קטן", c: 3, m: [10, 5, 9] },
                    { n: "חגיגה", c: 3, m: [8, 7, 8] }
                ]},
                { seder: "סדר נשים", items: [
                    { n: "יבמות", c: 16, m: [4, 10, 10, 13, 6, 6, 6, 6, 6, 9, 7, 6, 13, 9, 10, 7] },
                    { n: "כתובות", c: 13, m: [10, 10, 9, 12, 9, 7, 10, 8, 9, 6, 6, 4, 11] },
                    { n: "נדרים", c: 11, m: [4, 5, 11, 8, 6, 10, 9, 7, 10, 8, 12] },
                    { n: "נזיר", c: 9, m: [7, 10, 7, 7, 7, 11, 4, 2, 5] },
                    { n: "סוטה", c: 9, m: [9, 6, 8, 5, 5, 4, 8, 7, 15] },
                    { n: "גיטין", c: 9, m: [6, 7, 8, 9, 9, 7, 9, 10, 10] },
                    { n: "קידושין", c: 4, m: [10, 10, 13, 14] }
                ]},
                { seder: "סדר נזיקין", items: [
                    { n: "בבא קמא", c: 10, m: [4, 6, 11, 9, 7, 6, 7, 7, 12, 10] },
                    { n: "בבא מציעא", c: 10, m: [8, 11, 12, 12, 11, 8, 11, 9, 13, 6] },
                    { n: "בבא בתרא", c: 10, m: [6, 14, 8, 9, 11, 8, 4, 8, 10, 8] },
                    { n: "סנהדרין", c: 11, m: [6, 5, 8, 5, 5, 6, 11, 7, 6, 6, 6] },
                    { n: "מכות", c: 3, m: [10, 8, 16] },
                    { n: "שבועות", c: 8, m: [7, 5, 11, 13, 5, 7, 8, 6] },
                    { n: "עדיות", c: 8, m: [14, 10, 12, 12, 7, 3, 9, 7] },
                    { n: "עבודה זרה", c: 5, m: [9, 7, 10, 12, 12] },
                    { n: "אבות", c: 6, m: [18, 16, 18, 22, 23, 11] },
                    { n: "הוריות", c: 3, m: [5, 7, 8] }
                ]},
                { seder: "סדר קדשים", items: [
                    { n: "זבחים", c: 14, m: [4, 5, 6, 6, 8, 7, 6, 12, 7, 8, 8, 6, 8, 10] },
                    { n: "מנחות", c: 13, m: [4, 5, 7, 5, 9, 7, 6, 7, 9, 9, 9, 5, 11] },
                    { n: "חולין", c: 12, m: [7, 10, 7, 7, 5, 7, 6, 6, 8, 4, 2, 5] },
                    { n: "בכורות", c: 9, m: [7, 9, 4, 10, 6, 12, 7, 12, 8] },
                    { n: "ערכין", c: 9, m: [4, 6, 5, 4, 6, 5, 5, 7, 8] },
                    { n: "תמורה", c: 7, m: [6, 3, 5, 4, 6, 5, 6] },
                    { n: "כריתות", c: 6, m: [7, 6, 10, 3, 8, 9] },
                    { n: "מעילה", c: 6, m: [4, 9, 8, 6, 5, 6] },
                    { n: "תמיד", c: 7, m: [4, 5, 9, 3, 6, 3, 4] },
                    { n: "מידות", c: 5, m: [9, 6, 8, 7, 4] },
                    { n: "קינים", c: 3, m: [4, 5, 6] }
                ]},
                { seder: "סדר טהרות", items: [
                    { n: "כלים", c: 30, m: [9, 8, 8, 4, 11, 4, 6, 11, 8, 8, 9, 8, 8, 8, 6, 8, 17, 9, 10, 7, 3, 10, 5, 17, 9, 9, 12, 10, 8, 4] },
                    { n: "אהלות", c: 18, m: [8, 7, 7, 3, 7, 7, 6, 6, 16, 7, 9, 8, 6, 7, 10, 5, 5, 11] },
                    { n: "נגעים", c: 14, m: [6, 5, 8, 11, 5, 8, 5, 10, 3, 10, 12, 7, 12, 13] },
                    { n: "פרה", c: 12, m: [4, 5, 11, 4, 9, 5, 12, 11, 9, 6, 9, 11] },
                    { n: "טהרות", c: 10, m: [9, 8, 8, 13, 9, 10, 9, 9, 9, 8] },
                    { n: "מקואות", c: 10, m: [8, 10, 4, 5, 6, 11, 7, 5, 7, 8] },
                    { n: "נידה", c: 10, m: [7, 7, 7, 7, 9, 14, 5, 4, 11, 8] },
                    { n: "מכשירין", c: 6, m: [6, 11, 8, 10, 11, 8] },
                    { n: "זבים", c: 5, m: [6, 4, 3, 7, 12] },
                    { n: "טבול יום", c: 4, m: [5, 8, 6, 7] },
                    { n: "ידיים", c: 4, m: [5, 4, 5, 8] },
                    { n: "עוקצין", c: 3, m: [6, 10, 12] }
                ]}
            ],
            bavli: [{ seder: "ש\"ס בבלי", items: [{ n: "ברכות", c: 64 }, { n: "שבת", c: 157 }, { n: "עירובין", c: 105 }, { n: "פסחים", c: 121 }, { n: "שקלים", c: 22 }, { n: "יומא", c: 88 }, { n: "סוכה", c: 56 }, { n: "ביצה", c: 40 }, { n: "ראש השנה", c: 35 }, { n: "תענית", c: 31 }, { n: "מגילה", c: 32 }, { n: "מועד קטן", c: 29 }, { n: "חגיגה", c: 27 }, { n: "יבמות", c: 122 }, { n: "כתובות", c: 112 }, { n: "נדרים", c: 91 }, { n: "נזיר", c: 66 }, { n: "סוטה", c: 49 }, { n: "גיטין", c: 90 }, { n: "קידושין", c: 82 }, { n: "בבא קמא", c: 119 }, { n: "בבא מציעא", c: 119 }, { n: "בבא בתרא", c: 176 }, { n: "סנהדרין", c: 113 }, { n: "מכות", c: 24 }, { n: "שבועות", c: 49 }, { n: "עבודה זרה", c: 76 }, { n: "הוריות", c: 14 }, { n: "זבחים", c: 120 }, { n: "מנחות", c: 110 }, { n: "חולין", c: 142 }, { n: "בכורות", c: 61 }, { n: "ערכין", c: 34 }, { n: "תמורה", c: 34 }, { n: "כריתות", c: 28 }, { n: "מעילה", c: 22 }, { n: "תמיד", c: 33, s: 25 }, { n: "מידות", c: 37, s: 34 }, { n: "קינים", c: 25, s: 22 }, { n: "נידה", c: 73 }]}],
            yerushalmi: [{ seder: "ש\"ס ירושלמי", items: [{ n: "ברכות", c: 68 }, { n: "פאה", c: 37 }, { n: "דמאי", c: 34 }, { n: "כלאיים", c: 44 }, { n: "שביעית", c: 31 }, { n: "תרומות", c: 59 }, { n: "מעשרות", c: 26 }, { n: "מעשר שני", c: 33 }, { n: "חלה", c: 28 }, { n: "ערלה", c: 20 }, { n: "ביכורים", c: 13 }, { n: "שבת", c: 92 }, { n: "עירובין", c: 65 }, { n: "פסחים", c: 71 }, { n: "יומא", c: 42 }, { n: "שקלים", c: 33 }, { n: "סוכה", c: 26 }, { n: "ראש השנה", c: 22 }, { n: "ביצה", c: 22 }, { n: "תענית", c: 26 }, { n: "מגילה", c: 34 }, { n: "חגיגה", c: 22 }, { n: "מועד קטן", c: 19 }, { n: "יבמות", c: 85 }, { n: "סוטה", c: 47 }, { n: "כתובות", c: 72 }, { n: "נדרים", c: 40 }, { n: "גיטין", c: 54 }, { n: "נזיר", c: 44 }, { n: "קידושין", c: 48 }, { n: "בבא קמא", c: 44 }, { n: "בבא מציעא", c: 37 }, { n: "בבא בתרא", c: 34 }, { n: "סנהדרין", c: 68 }, { n: "מכות", c: 9 }, { n: "שבועות", c: 44 }, { n: "עבודה זרה", c: 37 }, { n: "הוריות", c: 19 }, { n: "נידה", c: 13 }]}],
            rambam: [{ seder: "רמב\"ם", items: [{ n: "מדע", c: 46 }, { n: "אהבה", c: 46 }, { n: "זמנים", c: 97 }, { n: "נשים", c: 51 }, { n: "קדושה", c: 54 }, { n: "הפלאה", c: 43 }, { n: "זרעים", c: 84 }, { n: "עבודה", c: 97 }, { n: "קרבנות", c: 45 }, { n: "טהרה", c: 172 }, { n: "נזיקין", c: 61 }, { n: "קניין", c: 74 }, { n: "משפטים", c: 75 }, { n: "שופטים", c: 81 }]}],
            shulchan: [{ seder: "שולחן ערוך", items: [{ n: "אורח חיים", c: 697 }, { n: "יורה דעה", c: 403 }, { n: "אבן העזר", c: 178 }, { n: "חושן משפט", c: 427 }]}]
        };
         
        function toHebrew(num) {
            if (num <= 0) return "";
            let str = "";
            const hundreds = ["", "ק", "ר", "ש", "ת"];
            const tens = ["", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ"];
            const realOnes = ["", "א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט"];
            if (num >= 100) { str += hundreds[Math.floor(num / 100)]; num %= 100; }
            if (num === 15) return str + "טו";
            if (num === 16) return str + "טז";
            str += tens[Math.floor(num / 10)];
            str += realOnes[num % 10];
            return str;
        }
         
        function selectAll(val) { document.querySelectorAll('#masechtotList input[type="checkbox"]').forEach(i => i.checked = val); }
         
        function toggleSeder(sourceCheckbox, sederName) {
            const checkboxes = document.querySelectorAll(`.masechet-item[data-seder="${sederName}"] input[type="checkbox"]`);
            checkboxes.forEach(cb => cb.checked = sourceCheckbox.checked);
        }
         
        function toggleMishnahPartsOption() {
            const splitMishnot = document.getElementById('mishnahSplitMishnot').checked;
            document.getElementById('mishnahPartsContainer').style.display = splitMishnot ? 'block' : 'none';
            if (!splitMishnot) {
                document.getElementById('mishnahSplitParts').checked = false;
                toggleMishnahPartsInput();
            }
        }
         
        function toggleMishnahPartsInput() {
            const splitParts = document.getElementById('mishnahSplitParts').checked;
            document.getElementById('mishnahPartsInputBox').style.display = splitParts ? 'block' : 'none';
        }
         
        function loadLibrary(libKey, btn) {
            currentLib = libKey;
            document.querySelectorAll('.lib-btn').forEach(b => b.classList.remove('active'));
            if(btn) btn.classList.add('active');
            
            document.getElementById('shasOptions').style.display = (libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi')) ? 'block' : 'none';
            document.getElementById('torahOptions').style.display = (libKey === 'torah') ? 'block' : 'none';
            document.getElementById('mishnahOptions').style.display = (libKey === 'mishnah') ? 'block' : 'none';
            document.getElementById('genericSubOptions').style.display = (libKey === 'rambam' || libKey === 'tanakh') ? 'block' : 'none';
            document.getElementById('shulchanOptions').style.display = (libKey === 'shulchan') ? 'block' : 'none';
         
            const showHierarchical = (libKey === 'bavli' || libKey === 'yerushalmi');
            document.getElementById('groupHierarchical').style.display = showHierarchical ? 'block' : 'none';
            if(!showHierarchical) document.getElementById('hierarchicalSedarim').checked = false;
         
            const listDiv = document.getElementById('masechtotList');
            listDiv.innerHTML = "";
            let unitLabel = libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi') ? "דפים" : (libKey === 'shulchan' ? "סימנים" : (libKey === 'torah' ? "פרשיות" : (libKey === 'chagim' ? "נושאים" : "פרקים")));
         
            fullDb[libKey].forEach(s => {
                const title = document.createElement('div');
                title.className = 'seder-title';
                title.innerHTML = `<span>${s.seder}</span> <input type="checkbox" class="seder-checkbox" title="בחר הכל בסדר זה" onclick="toggleSeder(this, '${s.seder}')">`;
                listDiv.appendChild(title);
                
                s.items.forEach(m => {
                    const item = document.createElement('div');
                    item.className = 'masechet-item';
                    item.setAttribute('data-seder', s.seder);
                    let countLabel = m.p ? m.p.length : m.c;
                    item.innerHTML = `<input type="checkbox" value="${m.n}" data-seder-name="${s.seder}" data-c="${m.c||0}" data-p='${JSON.stringify(m.p||[])}' data-m='${JSON.stringify(m.m||[])}' data-s="${m.s||(libKey.includes('shas')?2:1)}"> <span>${m.n} (${countLabel} ${unitLabel})</span>`;
                    listDiv.appendChild(item);
                });
            });
        }
         
        function abort() { isAborted = true; }
         
        async function process() {
            isAborted = false;
            const token = document.getElementById('token').value.trim();
            const startFolder = parseInt(document.getElementById('startNum').value);
            const endType = document.getElementById('endFolderType').value;
            const targetPath = document.getElementById('targetPath').value.trim().replace(/^\/|\/$/g, "");
            
            let hierarchical = document.getElementById('hierarchicalSedarim').checked;
            if (currentLib === 'mishnah') {
                hierarchical = document.getElementById('mishnahBySedarim').checked;
            }
         
            const selected = Array.from(document.querySelectorAll('#masechtotList .masechet-item input[type="checkbox"]:checked'));
         
            if(!token || selected.length === 0) return alert("הזן טוקן ובחר פריטים!");
         
            document.getElementById('startBtn').style.display = "none";
            document.getElementById('cancelBtn').style.display = "block";
            document.getElementById('progWrapper').style.display = "block";
            const log = document.getElementById('logBox');
            log.innerHTML = "🏁 מתחיל בתהליך...";
         
            let tasks = [];
            
            if (hierarchical) {
                let sedarimMap = {};
                selected.forEach(input => {
                    const sederName = input.dataset.sederName;
                    if (!sedarimMap[sederName]) sedarimMap[sederName] = [];
                    sedarimMap[sederName].push(input);
                });
         
                let sederKeys = Object.keys(sedarimMap);
                let sederCounter = startFolder;
         
                sederKeys.forEach((sederName) => {
                    const sederItems = sedarimMap[sederName];
                    const autoSederDigits = sederKeys.length >= 10 ? 2 : 1;
                    const sederFolderNum = String(sederCounter).padStart(autoSederDigits, '0');
                    const sederPath = targetPath ? `${targetPath}/${sederFolderNum}` : sederFolderNum;
         
                    tasks.push({ p: sederPath, t: sederName, b: `type=menu\ntitle=${sederName}\ndigits=${sederItems.length >= 10 ? 2 : 1}` });
         
                    let itemCounter = 1;
                    sederItems.forEach(input => {
                        const name = input.value;
                        const subItems = JSON.parse(input.dataset.p);
                        const count = parseInt(input.dataset.c);
                        const start = parseInt(input.dataset.s);
                        const mishArr = JSON.parse(input.dataset.m || "[]");
                        
                        const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                        const autoDigits = totalSubCount >= 10 ? 2 : 1;
         
                        const rootF = String(itemCounter).padStart(sederItems.length >= 10 ? 2 : 1, '0');
                        const rootP = `${sederPath}/${rootF}`;
         
                        tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
         
                        for (let i = start; i <= count; i++) {
                            const sf = String(i).padStart(autoDigits, '0');
                            const sp = `${rootP}/${sf}`;
                            const heb = toHebrew(i);
                            let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : `פרק ${heb}`;
                            
                            const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                            const mishCount = parseInt(document.getElementById('mishCount').value);
                            const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                            
                            let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                            let hasSub = splitS || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                            let subDigits = splitS ? 1 : (curMishCount >= 10 ? 2 : 1);
                            
                            tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
         
                            if(splitS) {
                                tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                                tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                            }
                            if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                                const splitParts = document.getElementById('mishnahSplitParts').checked;
                                const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
         
                                for(let m=1; m<=curMishCount; m++) {
                                    const mPad = curMishCount >= 10 ? 2 : 1;
                                    const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                    const mishTitle = `משנה ${toHebrew(m)}`;
         
                                    if (splitParts && partsCount > 1) {
                                        const partDigits = partsCount >= 10 ? 2 : 1;
                                        tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                        for(let p=1; p<=partsCount; p++) {
                                            const pPad = partsCount >= 10 ? 2 : 1;
                                            tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                        }
                                    } else {
                                        tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                    }
                                }
                            }
                        }
                        itemCounter++;
                    });
                    sederCounter++;
                });
         
            } else {
                let counter = startFolder;
                selected.forEach(input => {
                    const name = input.value;
                    const subItems = JSON.parse(input.dataset.p);
                    const count = parseInt(input.dataset.c);
                    const start = parseInt(input.dataset.s);
                    const mishArr = JSON.parse(input.dataset.m || "[]");
                    
                    const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                    const autoDigits = totalSubCount >= 10 ? 2 : 1;
         
                    const rootF = String(counter).padStart(selected.length > 9 ? 2 : 1, '0');
                    const rootP = targetPath ? `${targetPath}/${rootF}` : rootF;
         
                    tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
         
                    if (currentLib === 'torah') {
                        const noAliyotChecked = document.getElementById('noAliyot').checked;
                        subItems.forEach((pn, pi) => {
                            const pf = String(pi + 1).padStart(autoDigits, '0');
                            const pp = `${rootP}/${pf}`;
                            
                            if (noAliyotChecked) {
                                tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=${endType}\ntitle=פרשת ${pn}` });
                            } else {
                                tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=menu\ntitle=פרשת ${pn}\ndigits=1` });
                                ["ראשון","שני","שלישי","רביעי","חמישי","שישי","שביעי","מפטיר"].forEach((aly, ai) => {
                                    tasks.push({ p: `${pp}/${ai+1}`, t: `עליה ${aly}`, b: `type=${endType}\ntitle=עליה ${aly}` });
                                });
                            }
                        });
                    } else if (currentLib === 'chagim') {
                        subItems.forEach((subName, si) => {
                            const sf = String(si + 1).padStart(autoDigits, '0');
                            const sp = `${rootP}/${sf}`;
                            tasks.push({ p: sp, t: subName, b: `type=${endType}\ntitle=${subName}` });
                        });
                    } else {
                        for (let i = start; i <= count; i++) {
                            const sf = String(i).padStart(autoDigits, '0');
                            const sp = `${rootP}/${sf}`;
                            const heb = toHebrew(i);
                            let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : (currentLib === 'shulchan' ? `סימן ${heb}` : `פרק ${heb}`);
                            
                            const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                            const seifim = parseInt(document.getElementById('seifimCount').value);
                            const mishCount = parseInt(document.getElementById('mishCount').value);
                            const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                            
                            let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                            
                            let hasSub = splitS || (currentLib === 'shulchan' && seifim > 0) || (['rambam','tanakh'].includes(currentLib) && mishCount > 0) || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                            let subDigits = splitS ? 1 : ((currentLib === 'mishnah' ? curMishCount : (currentLib === 'shulchan' ? seifim : mishCount)) >= 10 ? 2 : 1);
                            
                            tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
         
                            if(splitS) {
                                tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                                tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                            }
                            if(currentLib === 'shulchan' && seifim > 0) {
                                for(let s=1; s<=seifim; s++) tasks.push({ p: `${sp}/${String(s).padStart(seifim >= 10 ? 2 : 1, '0')}`, t: `סעיף ${toHebrew(s)}`, b: `type=${endType}\ntitle=סעיף ${toHebrew(s)}` });
                            }
                            if(['rambam','tanakh'].includes(currentLib) && mishCount > 0) {
                                let subL = currentLib === 'rambam' ? "הלכה" : "פסוק";
                                let pad = mishCount >= 10 ? 2 : 1;
                                for(let m=1; m<=mishCount; m++) tasks.push({ p: `${sp}/${String(m).padStart(pad, '0')}`, t: `${subL} ${toHebrew(m)}`, b: `type=${endType}\ntitle=${subL} ${toHebrew(m)}` });
                            }
                            if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                                const splitParts = document.getElementById('mishnahSplitParts').checked;
                                const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
         
                                for(let m=1; m<=curMishCount; m++) {
                                    const mPad = curMishCount >= 10 ? 2 : 1;
                                    const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                    const mishTitle = `משנה ${toHebrew(m)}`;
         
                                    if (splitParts && partsCount > 1) {
                                        const partDigits = partsCount >= 10 ? 2 : 1;
                                        tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                        for(let p=1; p<=partsCount; p++) {
                                            const pPad = partsCount >= 10 ? 2 : 1;
                                            tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                        }
                                    } else {
                                        tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                    }
                                }
                            }
                        }
                    }
                    counter++;
                });
            }
         
            for (let i = 0; i < tasks.length; i++) {
                if (isAborted) break;
                const ok = await upload(token, tasks[i].p, tasks[i].b);
                if(ok) log.innerHTML += `<div>✓ SUCCESS: ${tasks[i].p}</div>`;
                else log.innerHTML += `<div style="color:red">✗ FAILED: ${tasks[i].p}</div>`;
                let pct = Math.round(((i + 1) / tasks.length) * 100);
                document.getElementById('progBar').style.width = pct + "%";
                document.getElementById('progText').innerText = pct + "%";
                document.getElementById('progCounts').innerText = `${i+1} / ${tasks.length}`;
                log.scrollTop = log.scrollHeight;
            }
         
            document.getElementById('startBtn').style.display = "block";
            document.getElementById('cancelBtn').style.display = "none";
        }
         
        async function upload(token, path, body) {
            const fd = new FormData();
            fd.append('token', token);
            fd.append('path', `ivr2:${path}/ext.ini`);
            fd.append('qqfile', new Blob([body], { type: 'text/plain;charset=utf-8' }), 'ext.ini');
            try {
                const r = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, { method: 'POST', body: fd });
                const d = await r.json();
                return d && (d.responseStatus === "OK" || d.status === "OK");
            } catch(e) { return false; }
        }
         
        loadLibrary('bavli');
        </script>
        
        </body>
        </html>
        
        ב 3 תגובות תגובה אחרונה תגובה ציטוט 0
        • ב מנותק
          בעזרת השם @lavitoren הטי"ל
          נערך לאחרונה על ידי

          פוסט זה נמחק!
          תגובה 1 תגובה אחרונה תגובה ציטוט 0
          • ב מנותק
            בעזרת השם @lavitoren הטי"ל
            נערך לאחרונה על ידי

            פוסט זה נמחק!
            L תגובה 1 תגובה אחרונה תגובה ציטוט 0
            • L מנותק
              lavitoren הטי"ל @בעזרת השם
              נערך לאחרונה על ידי lavitoren הטי"ל

              @בעזרת-השם עשיתי לך את העבודה תראה את הפוסט שלי

              תגובה 1 תגובה אחרונה תגובה ציטוט 0
              • L מנותק
                lavitoren הטי"ל @בעזרת השם
                נערך לאחרונה על ידי

                @בעזרת-השם דבר נוסף כבר שידרגתי את זה יותר ברוך השם והפונקציה שלך במשניות מאוד יפה אז אולי תבקש מהבינה שתשלב את הקוד החדש המעודכן שלי עם התוספות שלך

                ב תגובה 1 תגובה אחרונה תגובה ציטוט 0
                • ב מנותק
                  בעזרת השם @lavitoren הטי"ל
                  נערך לאחרונה על ידי

                  @lavitoren-הטי-ל
                  '''<!DOCTYPE html>
                  <html lang="he" dir="rtl">
                  <head>
                  <meta charset="UTF-8">
                  <title>הטי"ל - הכלי הטלפוני ליצירת ספריות v1.4</title>
                  <style>
                  :root {
                  --bg-dark: #121212;
                  --surface: #1e1e1e;
                  --surface-light: #2d2d2d;
                  --primary: #3b82f6;
                  --primary-hover: #2563eb;
                  --accent: #f59e0b;
                  --danger: #ef4444;
                  --text-main: #e2e8f0;
                  --text-dim: #94a3b8;
                  --border: #334155;
                  --success: #10b981;
                  }

                      body { 
                          font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
                          background-color: var(--bg-dark); 
                          color: var(--text-main); 
                          margin: 0; 
                          padding: 20px; 
                          line-height: 1.5;
                          text-align: right;
                      }
                  
                      .wrapper { max-width: 1200px; margin: 0 auto; }
                  
                      header { 
                          border-bottom: 1px solid var(--border); 
                          padding-bottom: 20px; 
                          margin-bottom: 30px; 
                          display: flex; 
                          justify-content: space-between; 
                          align-items: center; 
                      }
                  
                      h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
                      .version { font-size: 14px; background: var(--border); padding: 4px 10px; border-radius: 4px; color: #fff; margin-right: 10px; }
                  
                      .dashboard { display: grid; grid-template-columns: 350px 1fr; gap: 20px; }
                  
                      .card { 
                          background: var(--surface); 
                          border: 1px solid var(--border); 
                          border-radius: 12px; 
                          padding: 20px; 
                          box-shadow: 0 4px 20px rgba(0,0,0,0.5);
                      }
                  
                      .lib-selector { 
                          display: grid; 
                          grid-template-columns: 1fr; 
                          gap: 10px; 
                          margin-bottom: 20px; 
                      }
                  
                      .lib-btn { 
                          background: var(--surface-light); 
                          border: 1px solid var(--border); 
                          color: var(--text-main); 
                          padding: 12px; 
                          border-radius: 8px; 
                          cursor: pointer; 
                          text-align: right; 
                          font-weight: 600; 
                          transition: all 0.2s;
                          display: flex;
                          align-items: center;
                          gap: 10px;
                          font-size: 15px;
                      }
                  
                      .lib-btn:hover { border-color: var(--primary); background: #252525; }
                      .lib-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
                  
                      .form-group { margin-bottom: 15px; }
                      label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
                      
                      input, select { 
                          width: 100%; 
                          background: var(--bg-dark); 
                          border: 1px solid var(--border); 
                          border-radius: 6px; 
                          padding: 10px; 
                          color: white; 
                          box-sizing: border-box;
                          outline: none;
                          font-family: inherit;
                      }
                  
                      input:focus { border-color: var(--primary); }
                  
                      .options-panel { 
                          background: #1a202c; 
                          border-right: 4px solid var(--accent); 
                          padding: 15px; 
                          border-radius: 6px; 
                          margin-bottom: 20px; 
                      }
                  
                      .scroll-area { 
                          height: 500px; 
                          overflow-y: auto; 
                          border: 1px solid var(--border); 
                          background: var(--bg-dark); 
                          padding: 10px; 
                          border-radius: 8px; 
                          display: grid; 
                          grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); 
                          gap: 8px; 
                      }
                  
                      .masechet-item { 
                          background: var(--surface-light); 
                          padding: 8px; 
                          border-radius: 4px; 
                          display: flex; 
                          align-items: center; 
                          gap: 8px; 
                          font-size: 13px;
                      }
                      .masechet-item input { width: auto; cursor: pointer; }
                  
                      .seder-title { 
                          grid-column: 1 / -1; 
                          background: var(--border); 
                          padding: 4px 10px; 
                          font-size: 12px; 
                          font-weight: 800; 
                          color: var(--accent); 
                          margin-top: 10px;
                          border-radius: 4px;
                          display: flex;
                          justify-content: space-between;
                          align-items: center;
                      }
                  
                      .seder-checkbox {
                          width: auto !important;
                          margin: 0;
                          cursor: pointer;
                      }
                  
                      .btn-run { 
                          background: var(--primary); color: white; border: none; padding: 15px; border-radius: 8px; 
                          font-weight: 800; cursor: pointer; width: 100%; font-size: 17px; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
                      }
                      .btn-stop { background: var(--danger); color: white; border: none; padding: 15px; border-radius: 8px; font-weight: 800; cursor: pointer; width: 100%; display: none; font-size: 17px; }
                  
                      .progress-wrapper { margin-top: 20px; }
                      .progress-bar-bg { background: var(--surface-light); height: 14px; border-radius: 7px; overflow: hidden; }
                      .progress-bar-fill { background: linear-gradient(90deg, var(--success), #34d399); height: 100%; width: 0%; transition: width 0.3s; }
                      .progress-status { font-size: 12px; color: var(--text-dim); margin-top: 8px; display: flex; justify-content: space-between; }
                  
                      .log-container { 
                          margin-top: 20px; background: #000; color: #00ff00; font-family: 'Consolas', monospace; 
                          font-size: 12px; padding: 15px; border-radius: 8px; height: 220px; overflow-y: auto; border: 1px solid var(--border);
                          direction: ltr; text-align: left;
                      }
                  
                      ::-webkit-scrollbar { width: 8px; }
                      ::-webkit-scrollbar-track { background: var(--bg-dark); }
                      ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
                  </style>
                  

                  </head>
                  <body>

                  <div class="wrapper">
                  <header>
                  <h1>פתיחת ספריה תורנית מטורפת עצומת מימדים לקו שלכם <span class="version">הטי"ל V1.4</span></h1>
                  <div id="connectionStatus" style="color: var(--success); font-size: 13px;">● מוכן לביצוע</div>
                  </header>

                  <div class="dashboard">
                      <div class="card">
                          <label>סוג תוכן להקמה</label>
                          <div class="lib-selector">
                              <button class="lib-btn active" onclick="loadLibrary('bavli', this)">📖 ש"ס בבלי</button>
                              <button class="lib-btn" onclick="loadLibrary('yerushalmi', this)">🕍 ש"ס ירושלמי</button>
                              <button class="lib-btn" onclick="loadLibrary('torah', this)">📜 תורה (חומשים ופרשיות)</button>
                              <button class="lib-btn" onclick="loadLibrary('chagim', this)">🎉 חגים ומועדים</button>
                              <button class="lib-btn" onclick="loadLibrary('tanakh', this)">📚 תנ"ך (כ"ד ספרים)</button>
                              <button class="lib-btn" onclick="loadLibrary('mishnah', this)">🗳️ משניות</button>
                              <button class="lib-btn" onclick="loadLibrary('rambam', this)">⚖️ רמב"ם (היד החזקה)</button>
                              <button class="lib-btn" onclick="loadLibrary('shulchan', this)">🖋️ שולחן ערוך</button>
                          </div>
                  
                          <div class="form-group">
                              <label>סוג שלוחת הקצה (היחידה הקטנה ביותר)</label>
                              <select id="endFolderType">
                                  <option value="playfile">השמעת קבצים (playfile)</option>
                                  <option value="record">הקלטת הודעות (record)</option>
                              </select>
                          </div>
                  
                          <div class="form-group" id="groupHierarchical" style="display:none;">
                              <input type="checkbox" id="hierarchicalSedarim" style="width:auto; margin-left:10px;"> 
                              <label style="display:inline; color: white;" for="hierarchicalSedarim">הקם לפי סדרים (יוצר תת-תיקיות לפי סדרים)</label>
                          </div>
                  
                          <div class="form-group">
                              <label>טוקן גישה API</label>
                              <input type="text" id="token" placeholder="0770000000:123456">
                          </div>
                  
                          <div class="form-group">
                              <label>נתיב יעד (תיקייה בקו)</label>
                              <input type="text" id="targetPath" placeholder="למשל: 1/5">
                          </div>
                  
                          <div class="form-group">
                              <label>מספר שלוחה להתחלה</label>
                              <input type="number" id="startNum" value="1">
                          </div>
                  
                          <button class="btn-run" id="startBtn" onclick="process()">🚀 התחל הקמה</button>
                          <button class="btn-stop" id="cancelBtn" onclick="abort()">🛑 עצור פעולה</button>
                  
                          <div class="progress-wrapper" id="progWrapper" style="display:none;">
                              <div class="progress-bar-bg"><div class="progress-bar-fill" id="progBar"></div></div>
                              <div class="progress-status"><span id="progText">0%</span><span id="progCounts">0 / 0</span></div>
                          </div>
                      </div>
                  
                      <div class="card">
                          <div id="optionsPanel" class="options-panel">
                              <div id="shasOptions">
                                  <input type="checkbox" id="splitAmudim" style="width:auto; margin-left:10px;"> 
                                  <label style="display:inline; color: white;" for="splitAmudim">פצל דפים לעמוד א' וב'</label>
                              </div>
                              <div id="torahOptions" style="display:none;">
                                  <input type="checkbox" id="noAliyot" style="width:auto; margin-left:10px;"> 
                                  <label style="display:inline; color: white;" for="noAliyot">ללא עליות לתורה (פרשה היא השמעת קבצים ישירה)</label>
                              </div>
                              <div id="mishnahOptions" style="display:none;">
                                  <div style="margin-bottom:8px;">
                                      <input type="checkbox" id="mishnahBySedarim" style="width:auto; margin-left:10px;"> 
                                      <label style="display:inline; color: white;" for="mishnahBySedarim">חלוקה לפי ששה סדרים</label>
                                  </div>
                                  <div style="margin-bottom:8px;">
                                      <input type="checkbox" id="mishnahSplitMishnot" checked style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsOption()"> 
                                      <label style="display:inline; color: white;" for="mishnahSplitMishnot">לחלק כל פרק למשניות</label>
                                  </div>
                                  <div id="mishnahPartsContainer" style="margin-top:8px; padding-right:20px;">
                                      <input type="checkbox" id="mishnahSplitParts" style="width:auto; margin-left:10px;" onchange="toggleMishnahPartsInput()"> 
                                      <label style="display:inline; color: white;" for="mishnahSplitParts">פצל כל משנה לתתי-חלקים</label>
                                      <div id="mishnahPartsInputBox" style="display:none; margin-top:5px;">
                                          <label style="color: var(--text-dim); display:inline;">כמות חלקים לכל משנה: </label>
                                          <input type="number" id="mishnahPartsCount" value="2" min="1" style="width:80px; display:inline-block;">
                                      </div>
                                  </div>
                              </div>
                              <div id="genericSubOptions" style="display:none;">
                                  <label style="color: white;">כמות תתי-שלוחות (הלכות/פסוקים):</label>
                                  <input type="number" id="mishCount" value="0" style="width:100px;">
                              </div>
                              <div id="shulchanOptions" style="display:none;">
                                  <label style="color: white;">כמות סעיפים בכל סימן (0 לסימנים בלבד):</label>
                                  <input type="number" id="seifimCount" value="0" style="width:100px;">
                              </div>
                          </div>
                  
                          <div style="display:flex; justify-content: space-between; margin-bottom: 15px;">
                              <label>בחירת ספרים / מסכתות</label>
                              <div>
                                  <button onclick="selectAll(true)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px;">בחר הכל</button>
                                  <button onclick="selectAll(false)" style="background:none; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; padding:2px 10px; border-radius:4px; font-size:11px; margin-right:5px;">נקה הכל</button>
                              </div>
                          </div>
                  
                          <div class="scroll-area" id="masechtotList"></div>
                          <div class="log-container" id="logBox">ממתין לפקודה...</div>
                      </div>
                  </div>
                  

                  </div>

                  <script>
                  let isAborted = false;
                  let currentLib = 'bavli';

                  const fullDb = {
                      torah: [{ seder: "חמישה חומשי תורה", items: [
                          { n: "בראשית", p: ["בראשית", "נח", "לך לך", "וירא", "חיי שרה", "תולדות", "ויצא", "וישלח", "וישב", "מקץ", "ויגש", "ויחי"] },
                          { n: "שמות", p: ["שמות", "וארא", "בא", "בשלח", "יתרו", "משפטים", "תרומה", "תצוה", "כי תשא", "ויקהל", "פקודי"] },
                          { n: "ויקרא", p: ["ויקרא", "צו", "שמיני", "תזריע", "מצורע", "אחרי מות", "קדושים", "אמור", "בהר", "בחקותי"] },
                          { n: "במדבר", p: ["במדבר", "נשא", "בהעלותך", "שלח", "קרח", "חקת", "בלק", "פינחס", "מטות", "מסעי"] },
                          { n: "דברים", p: ["דברים", "ואתחנן", "עקב", "ראה", "שופטים", "כי תצא", "כי תבוא", "נצבים", "וילך", "האזינו", "וזאת הברכה"] }
                      ]}],
                      chagim: [
                          { seder: "1. ימים נוראים וחגי תשרי", items: [
                              { n: "ראש השנה", p: ["ערב ראש השנה", "תפילות ראש השנה", "תקיעת שופר", "סימני ראש השנה"] },
                              { n: "עשרת ימי תשובה", p: ["סליחות", "שבת תשובה", "כפרות"] },
                              { n: "יום הכיפורים", p: ["ערב יום הכיפורים", "תפילת כל נדרי", "נעילה", "מוצאי יום הכיפורים"] },
                              { n: "סוכות", p: ["בניית סוכה", "ארבעת המינים", "הושענא רבא", "שמיני עצרת ושמחת תורה"] }
                          ]},
                          { seder: "2. חגים מדרבנן", items: [
                              { n: "חנוכה", p: ["הדלקת נרות", "מעוז צור", "ענייני חנוכה", "סביבון"] },
                              { n: "פורים", p: ["תענית אסתר", "קריאת המגילה", "משלוח מנות ומתנות לאביונים", "סעודת פורים"] }
                          ]},
                          { seder: "3. חגי ניסן וספירת העומר", items: [
                              { n: "פסח", p: ["בדיקת חמץ וביעורו", "הערב הסדר", "הגדה של פסח", "שביעי של פסח ואיסרו חג"] },
                              { n: "ספירת העומר ול\"ג בעומר", p: ["דיני ספירת העומר", "ימי העומר", "ל\"ג בעומר ומנהגיו"] },
                              { n: "שבועות", p: ["ערב שבועות", "תיקון ליל שבועות", "מגילת רות"] }
                          ]},
                          { seder: "4. בין המצרים ותעניות השנה", items: [
                              { n: "תעניות השנה", p: ["צום גדליה", "עשרה בטבת", "תענית אסתר", "שבעה עשר בתמוז"] },
                              { n: "בין המצרים ותשעה באב", p: ["שלושת השבועות", "תשעה באב ותיקון חצות", "קינות ומגילת איכה"] }
                          ]}
                      ],
                      tanakh: [{ seder: "תורה", items: [{ n: "בראשית", c: 50 }, { n: "שמות", c: 40 }, { n: "ויקרא", c: 27 }, { n: "במדבר", c: 36 }, { n: "דברים", c: 34 }]}, { seder: "נביאים", items: [{ n: "יהושע", c: 24 }, { n: "שופטים", c: 21 }, { n: "שמואל א", c: 31 }, { n: "שמואל ב", c: 24 }, { n: "מלכים א", c: 22 }, { n: "מלכים ב", c: 25 }, { n: "ישעיהו", c: 66 }, { n: "ירמיהו", c: 52 }, { n: "יחזקאל", c: 48 }, { n: "תרי עשר", c: 67 }]}, { seder: "כתובים", items: [{ n: "תהילים", c: 150 }, { n: "משלי", c: 31 }, { n: "איוב", c: 42 }, { n: "שיר השירים", c: 8 }, { n: "רות", c: 4 }, { n: "איכה", c: 5 }, { n: "קהלת", c: 12 }, { n: "אסתר", c: 10 }, { n: "דניאל", c: 12 }, { n: "עזרא", c: 10 }, { n: "נחמיה", c: 13 }, { n: "דברי הימים א", c: 29 }, { n: "דברי הימים ב", c: 36 }]}],
                      mishnah: [
                          { seder: "סדר זרעים", items: [
                              { n: "ברכות", c: 9, m: [5, 8, 6, 7, 5, 8, 5, 8, 5] },
                              { n: "פאה", c: 8, m: [6, 8, 8, 11, 8, 11, 8, 9] },
                              { n: "דמאי", c: 7, m: [4, 5, 6, 7, 11, 12, 8] },
                              { n: "כלאיים", c: 9, m: [9, 11, 7, 9, 8, 9, 8, 6, 10] },
                              { n: "שביעית", c: 10, m: [8, 10, 10, 10, 9, 6, 7, 11, 9, 9] },
                              { n: "תרומות", c: 11, m: [10, 6, 9, 11, 9, 6, 7, 12, 7, 12, 10] },
                              { n: "מעשרות", c: 5, m: [8, 8, 10, 6, 8] },
                              { n: "מעשר שני", c: 5, m: [7, 10, 14, 12, 15] },
                              { n: "חלה", c: 4, m: [9, 8, 10, 11] },
                              { n: "ערלה", c: 3, m: [9, 9, 9] },
                              { n: "ביכורים", c: 3, m: [11, 11, 12] }
                          ]},
                          { seder: "סדר מועד", items: [
                              { n: "שבת", c: 24, m: [11, 7, 6, 2, 4, 10, 4, 7, 7, 6, 6, 6, 7, 4, 3, 8, 8, 3, 6, 5, 3, 6, 5, 5] },
                              { n: "עירובין", c: 10, m: [10, 6, 9, 11, 9, 10, 11, 11, 4, 15] },
                              { n: "פסחים", c: 10, m: [7, 8, 8, 9, 10, 6, 13, 8, 11, 9] },
                              { n: "שקלים", c: 8, m: [7, 5, 4, 9, 6, 6, 7, 8] },
                              { n: "יומא", c: 8, m: [8, 7, 11, 6, 7, 8, 5, 9] },
                              { n: "סוכה", c: 5, m: [11, 9, 15, 10, 8] },
                              { n: "ביצה", c: 5, m: [10, 10, 10, 7, 7] },
                              { n: "ראש השנה", c: 4, m: [9, 9, 9, 9] },
                              { n: "תענית", c: 4, m: [7, 10, 9, 8] },
                              { n: "מגילה", c: 4, m: [11, 6, 6, 10] },
                              { n: "מועד קטן", c: 3, m: [10, 5, 9] },
                              { n: "חגיגה", c: 3, m: [8, 7, 8] }
                          ]},
                          { seder: "סדר נשים", items: [
                              { n: "יבמות", c: 16, m: [4, 10, 10, 13, 6, 6, 6, 6, 6, 9, 7, 6, 13, 9, 10, 7] },
                              { n: "כתובות", c: 13, m: [10, 10, 9, 12, 9, 7, 10, 8, 9, 6, 6, 4, 11] },
                              { n: "נדרים", c: 11, m: [4, 5, 11, 8, 6, 10, 9, 7, 10, 8, 12] },
                              { n: "נזיר", c: 9, m: [7, 10, 7, 7, 7, 11, 4, 2, 5] },
                              { n: "סוטה", c: 9, m: [9, 6, 8, 5, 5, 4, 8, 7, 15] },
                              { n: "גיטין", c: 9, m: [6, 7, 8, 9, 9, 7, 9, 10, 10] },
                              { n: "קידושין", c: 4, m: [10, 10, 13, 14] }
                          ]},
                          { seder: "סדר נזיקין", items: [
                              { n: "בבא קמא", c: 10, m: [4, 6, 11, 9, 7, 6, 7, 7, 12, 10] },
                              { n: "בבא מציעא", c: 10, m: [8, 11, 12, 12, 11, 8, 11, 9, 13, 6] },
                              { n: "בבא בתרא", c: 10, m: [6, 14, 8, 9, 11, 8, 4, 8, 10, 8] },
                              { n: "סנהדרין", c: 11, m: [6, 5, 8, 5, 5, 6, 11, 7, 6, 6, 6] },
                              { n: "מכות", c: 3, m: [10, 8, 16] },
                              { n: "שבועות", c: 8, m: [7, 5, 11, 13, 5, 7, 8, 6] },
                              { n: "עדיות", c: 8, m: [14, 10, 12, 12, 7, 3, 9, 7] },
                              { n: "עבודה זרה", c: 5, m: [9, 7, 10, 12, 12] },
                              { n: "אבות", c: 6, m: [18, 16, 18, 22, 23, 11] },
                              { n: "הוריות", c: 3, m: [5, 7, 8] }
                          ]},
                          { seder: "סדר קדשים", items: [
                              { n: "זבחים", c: 14, m: [4, 5, 6, 6, 8, 7, 6, 12, 7, 8, 8, 6, 8, 10] },
                              { n: "מנחות", c: 13, m: [4, 5, 7, 5, 9, 7, 6, 7, 9, 9, 9, 5, 11] },
                              { n: "חולין", c: 12, m: [7, 10, 7, 7, 5, 7, 6, 6, 8, 4, 2, 5] },
                              { n: "בכורות", c: 9, m: [7, 9, 4, 10, 6, 12, 7, 12, 8] },
                              { n: "ערכין", c: 9, m: [4, 6, 5, 4, 6, 5, 5, 7, 8] },
                              { n: "תמורה", c: 7, m: [6, 3, 5, 4, 6, 5, 6] },
                              { n: "כריתות", c: 6, m: [7, 6, 10, 3, 8, 9] },
                              { n: "מעילה", c: 6, m: [4, 9, 8, 6, 5, 6] },
                              { n: "תמיד", c: 7, m: [4, 5, 9, 3, 6, 3, 4] },
                              { n: "מידות", c: 5, m: [9, 6, 8, 7, 4] },
                              { n: "קינים", c: 3, m: [4, 5, 6] }
                          ]},
                          { seder: "סדר טהרות", items: [
                              { n: "כלים", c: 30, m: [9, 8, 8, 4, 11, 4, 6, 11, 8, 8, 9, 8, 8, 8, 6, 8, 17, 9, 10, 7, 3, 10, 5, 17, 9, 9, 12, 10, 8, 4] },
                              { n: "אהלות", c: 18, m: [8, 7, 7, 3, 7, 7, 6, 6, 16, 7, 9, 8, 6, 7, 10, 5, 5, 11] },
                              { n: "נגעים", c: 14, m: [6, 5, 8, 11, 5, 8, 5, 10, 3, 10, 12, 7, 12, 13] },
                              { n: "פרה", c: 12, m: [4, 5, 11, 4, 9, 5, 12, 11, 9, 6, 9, 11] },
                              { n: "טהרות", c: 10, m: [9, 8, 8, 13, 9, 10, 9, 9, 9, 8] },
                              { n: "מקואות", c: 10, m: [8, 10, 4, 5, 6, 11, 7, 5, 7, 8] },
                              { n: "נידה", c: 10, m: [7, 7, 7, 7, 9, 14, 5, 4, 11, 8] },
                              { n: "מכשירין", c: 6, m: [6, 11, 8, 10, 11, 8] },
                              { n: "זבים", c: 5, m: [6, 4, 3, 7, 12] },
                              { n: "טבול יום", c: 4, m: [5, 8, 6, 7] },
                              { n: "ידיים", c: 4, m: [5, 4, 5, 8] },
                              { n: "עוקצין", c: 3, m: [6, 10, 12] }
                          ]}
                      ],
                      bavli: [{ seder: "ש\"ס בבלי", items: [{ n: "ברכות", c: 64 }, { n: "שבת", c: 157 }, { n: "עירובין", c: 105 }, { n: "פסחים", c: 121 }, { n: "שקלים", c: 22 }, { n: "יומא", c: 88 }, { n: "סוכה", c: 56 }, { n: "ביצה", c: 40 }, { n: "ראש השנה", c: 35 }, { n: "תענית", c: 31 }, { n: "מגילה", c: 32 }, { n: "מועד קטן", c: 29 }, { n: "חגיגה", c: 27 }, { n: "יבמות", c: 122 }, { n: "כתובות", c: 112 }, { n: "נדרים", c: 91 }, { n: "נזיר", c: 66 }, { n: "סוטה", c: 49 }, { n: "גיטין", c: 90 }, { n: "קידושין", c: 82 }, { n: "בבא קמא", c: 119 }, { n: "בבא מציעא", c: 119 }, { n: "בבא בתרא", c: 176 }, { n: "סנהדרין", c: 113 }, { n: "מכות", c: 24 }, { n: "שבועות", c: 49 }, { n: "עבודה זרה", c: 76 }, { n: "הוריות", c: 14 }, { n: "זבחים", c: 120 }, { n: "מנחות", c: 110 }, { n: "חולין", c: 142 }, { n: "בכורות", c: 61 }, { n: "ערכין", c: 34 }, { n: "תמורה", c: 34 }, { n: "כריתות", c: 28 }, { n: "מעילה", c: 22 }, { n: "תמיד", c: 33, s: 25 }, { n: "מידות", c: 37, s: 34 }, { n: "קינים", c: 25, s: 22 }, { n: "נידה", c: 73 }]}],
                      yerushalmi: [{ seder: "ש\"ס ירושלמי", items: [{ n: "ברכות", c: 68 }, { n: "פאה", c: 37 }, { n: "דמאי", c: 34 }, { n: "כלאיים", c: 44 }, { n: "שביעית", c: 31 }, { n: "תרומות", c: 59 }, { n: "מעשרות", c: 26 }, { n: "מעשר שני", c: 33 }, { n: "חלה", c: 28 }, { n: "ערלה", c: 20 }, { n: "ביכורים", c: 13 }, { n: "שבת", c: 92 }, { n: "עירובין", c: 65 }, { n: "פסחים", c: 71 }, { n: "יומא", c: 42 }, { n: "שקלים", c: 33 }, { n: "סוכה", c: 26 }, { n: "ראש השנה", c: 22 }, { n: "ביצה", c: 22 }, { n: "תענית", c: 26 }, { n: "מגילה", c: 34 }, { n: "חגיגה", c: 22 }, { n: "מועד קטן", c: 19 }, { n: "יבמות", c: 85 }, { n: "סוטה", c: 47 }, { n: "כתובות", c: 72 }, { n: "נדרים", c: 40 }, { n: "גיטין", c: 54 }, { n: "נזיר", c: 44 }, { n: "קידושין", c: 48 }, { n: "בבא קמא", c: 44 }, { n: "בבא מציעא", c: 37 }, { n: "בבא בתרא", c: 34 }, { n: "סנהדרין", c: 68 }, { n: "מכות", c: 9 }, { n: "שבועות", c: 44 }, { n: "עבודה זרה", c: 37 }, { n: "הוריות", c: 19 }, { n: "נידה", c: 13 }]}],
                      rambam: [{ seder: "רמב\"ם", items: [{ n: "מדע", c: 46 }, { n: "אהבה", c: 46 }, { n: "זמנים", c: 97 }, { n: "נשים", c: 51 }, { n: "קדושה", c: 54 }, { n: "הפלאה", c: 43 }, { n: "זרעים", c: 84 }, { n: "עבודה", c: 97 }, { n: "קרבנות", c: 45 }, { n: "טהרה", c: 172 }, { n: "נזיקין", c: 61 }, { n: "קניין", c: 74 }, { n: "משפטים", c: 75 }, { n: "שופטים", c: 81 }]}],
                      shulchan: [{ seder: "שולחן ערוך", items: [{ n: "אורח חיים", c: 697 }, { n: "יורה דעה", c: 403 }, { n: "אבן העזר", c: 178 }, { n: "חושן משפט", c: 427 }]}]
                  };
                  
                  function toHebrew(num) {
                      if (num <= 0) return "";
                      let str = "";
                      const hundreds = ["", "ק", "ר", "ש", "ת"];
                      const tens = ["", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ"];
                      const realOnes = ["", "א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט"];
                      if (num >= 100) { str += hundreds[Math.floor(num / 100)]; num %= 100; }
                      if (num === 15) return str + "טו";
                      if (num === 16) return str + "טז";
                      str += tens[Math.floor(num / 10)];
                      str += realOnes[num % 10];
                      return str;
                  }
                  
                  function selectAll(val) { document.querySelectorAll('#masechtotList input[type="checkbox"]').forEach(i => i.checked = val); }
                  
                  function toggleSeder(sourceCheckbox, sederName) {
                      const checkboxes = document.querySelectorAll(`.masechet-item[data-seder="${sederName}"] input[type="checkbox"]`);
                      checkboxes.forEach(cb => cb.checked = sourceCheckbox.checked);
                  }
                  
                  function toggleMishnahPartsOption() {
                      const splitMishnot = document.getElementById('mishnahSplitMishnot').checked;
                      document.getElementById('mishnahPartsContainer').style.display = splitMishnot ? 'block' : 'none';
                      if (!splitMishnot) {
                          document.getElementById('mishnahSplitParts').checked = false;
                          toggleMishnahPartsInput();
                      }
                  }
                  
                  function toggleMishnahPartsInput() {
                      const splitParts = document.getElementById('mishnahSplitParts').checked;
                      document.getElementById('mishnahPartsInputBox').style.display = splitParts ? 'block' : 'none';
                  }
                  
                  function loadLibrary(libKey, btn) {
                      currentLib = libKey;
                      document.querySelectorAll('.lib-btn').forEach(b => b.classList.remove('active'));
                      if(btn) btn.classList.add('active');
                      
                      document.getElementById('shasOptions').style.display = (libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi')) ? 'block' : 'none';
                      document.getElementById('torahOptions').style.display = (libKey === 'torah') ? 'block' : 'none';
                      document.getElementById('mishnahOptions').style.display = (libKey === 'mishnah') ? 'block' : 'none';
                      document.getElementById('genericSubOptions').style.display = (libKey === 'rambam' || libKey === 'tanakh') ? 'block' : 'none';
                      document.getElementById('shulchanOptions').style.display = (libKey === 'shulchan') ? 'block' : 'none';
                  
                      const showHierarchical = (libKey === 'bavli' || libKey === 'yerushalmi');
                      document.getElementById('groupHierarchical').style.display = showHierarchical ? 'block' : 'none';
                      if(!showHierarchical) document.getElementById('hierarchicalSedarim').checked = false;
                  
                      const listDiv = document.getElementById('masechtotList');
                      listDiv.innerHTML = "";
                      let unitLabel = libKey.includes('shas') || libKey.includes('bavli') || libKey.includes('yerushalmi') ? "דפים" : (libKey === 'shulchan' ? "סימנים" : (libKey === 'torah' ? "פרשיות" : (libKey === 'chagim' ? "נושאים" : "פרקים")));
                  
                      fullDb[libKey].forEach(s => {
                          const title = document.createElement('div');
                          title.className = 'seder-title';
                          title.innerHTML = `<span>${s.seder}</span> <input type="checkbox" class="seder-checkbox" title="בחר הכל בסדר זה" onclick="toggleSeder(this, '${s.seder}')">`;
                          listDiv.appendChild(title);
                          
                          s.items.forEach(m => {
                              const item = document.createElement('div');
                              item.className = 'masechet-item';
                              item.setAttribute('data-seder', s.seder);
                              let countLabel = m.p ? m.p.length : m.c;
                              item.innerHTML = `<input type="checkbox" value="${m.n}" data-seder-name="${s.seder}" data-c="${m.c||0}" data-p='${JSON.stringify(m.p||[])}' data-m='${JSON.stringify(m.m||[])}' data-s="${m.s||(libKey.includes('shas')?2:1)}"> <span>${m.n} (${countLabel} ${unitLabel})</span>`;
                              listDiv.appendChild(item);
                          });
                      });
                  }
                  
                  function abort() { isAborted = true; }
                  
                  async function process() {
                      isAborted = false;
                      const token = document.getElementById('token').value.trim();
                      const startFolder = parseInt(document.getElementById('startNum').value);
                      const endType = document.getElementById('endFolderType').value;
                      const targetPath = document.getElementById('targetPath').value.trim().replace(/^\/|\/$/g, "");
                      
                      let hierarchical = document.getElementById('hierarchicalSedarim').checked;
                      if (currentLib === 'mishnah') {
                          hierarchical = document.getElementById('mishnahBySedarim').checked;
                      }
                  
                      const selected = Array.from(document.querySelectorAll('#masechtotList .masechet-item input[type="checkbox"]:checked'));
                  
                      if(!token || selected.length === 0) return alert("הזן טוקן ובחר פריטים!");
                  
                      document.getElementById('startBtn').style.display = "none";
                      document.getElementById('cancelBtn').style.display = "block";
                      document.getElementById('progWrapper').style.display = "block";
                      const log = document.getElementById('logBox');
                      log.innerHTML = "🏁 מתחיל בתהליך...";
                  
                      let tasks = [];
                      
                      if (hierarchical) {
                          let sedarimMap = {};
                          selected.forEach(input => {
                              const sederName = input.dataset.sederName;
                              if (!sedarimMap[sederName]) sedarimMap[sederName] = [];
                              sedarimMap[sederName].push(input);
                          });
                  
                          let sederKeys = Object.keys(sedarimMap);
                          let sederCounter = startFolder;
                  
                          sederKeys.forEach((sederName) => {
                              const sederItems = sedarimMap[sederName];
                              const autoSederDigits = sederKeys.length >= 10 ? 2 : 1;
                              const sederFolderNum = String(sederCounter).padStart(autoSederDigits, '0');
                              const sederPath = targetPath ? `${targetPath}/${sederFolderNum}` : sederFolderNum;
                  
                              tasks.push({ p: sederPath, t: sederName, b: `type=menu\ntitle=${sederName}\ndigits=${sederItems.length >= 10 ? 2 : 1}` });
                  
                              let itemCounter = 1;
                              sederItems.forEach(input => {
                                  const name = input.value;
                                  const subItems = JSON.parse(input.dataset.p);
                                  const count = parseInt(input.dataset.c);
                                  const start = parseInt(input.dataset.s);
                                  const mishArr = JSON.parse(input.dataset.m || "[]");
                                  
                                  const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                                  const autoDigits = totalSubCount >= 10 ? 2 : 1;
                  
                                  const rootF = String(itemCounter).padStart(sederItems.length >= 10 ? 2 : 1, '0');
                                  const rootP = `${sederPath}/${rootF}`;
                  
                                  tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
                  
                                  for (let i = start; i <= count; i++) {
                                      const sf = String(i).padStart(autoDigits, '0');
                                      const sp = `${rootP}/${sf}`;
                                      const heb = toHebrew(i);
                                      let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : `פרק ${heb}`;
                                      
                                      const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                                      const mishCount = parseInt(document.getElementById('mishCount').value);
                                      const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                                      
                                      let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                                      let hasSub = splitS || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                                      let subDigits = splitS ? 1 : (curMishCount >= 10 ? 2 : 1);
                                      
                                      tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
                  
                                      if(splitS) {
                                          tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                                          tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                                      }
                                      if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                                          const splitParts = document.getElementById('mishnahSplitParts').checked;
                                          const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
                  
                                          for(let m=1; m<=curMishCount; m++) {
                                              const mPad = curMishCount >= 10 ? 2 : 1;
                                              const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                              const mishTitle = `משנה ${toHebrew(m)}`;
                  
                                              if (splitParts && partsCount > 1) {
                                                  const partDigits = partsCount >= 10 ? 2 : 1;
                                                  tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                                  for(let p=1; p<=partsCount; p++) {
                                                      const pPad = partsCount >= 10 ? 2 : 1;
                                                      tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                                  }
                                              } else {
                                                  tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                              }
                                          }
                                      }
                                  }
                                  itemCounter++;
                              });
                              sederCounter++;
                          });
                  
                      } else {
                          let counter = startFolder;
                          selected.forEach(input => {
                              const name = input.value;
                              const subItems = JSON.parse(input.dataset.p);
                              const count = parseInt(input.dataset.c);
                              const start = parseInt(input.dataset.s);
                              const mishArr = JSON.parse(input.dataset.m || "[]");
                              
                              const totalSubCount = subItems.length > 0 ? subItems.length : (count - start + 1);
                              const autoDigits = totalSubCount >= 10 ? 2 : 1;
                  
                              const rootF = String(counter).padStart(selected.length > 9 ? 2 : 1, '0');
                              const rootP = targetPath ? `${targetPath}/${rootF}` : rootF;
                  
                              tasks.push({ p: rootP, t: name, b: `type=menu\ntitle=${name}\ndigits=${autoDigits}` });
                  
                              if (currentLib === 'torah') {
                                  const noAliyotChecked = document.getElementById('noAliyot').checked;
                                  subItems.forEach((pn, pi) => {
                                      const pf = String(pi + 1).padStart(autoDigits, '0');
                                      const pp = `${rootP}/${pf}`;
                                      
                                      if (noAliyotChecked) {
                                          tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=${endType}\ntitle=פרשת ${pn}` });
                                      } else {
                                          tasks.push({ p: pp, t: `פרשת ${pn}`, b: `type=menu\ntitle=פרשת ${pn}\ndigits=1` });
                                          ["ראשון","שני","שלישי","רביעי","חמישי","שישי","שביעי","מפטיר"].forEach((aly, ai) => {
                                              tasks.push({ p: `${pp}/${ai+1}`, t: `עליה ${aly}`, b: `type=${endType}\ntitle=עליה ${aly}` });
                                          });
                                      }
                                  });
                              } else if (currentLib === 'chagim') {
                                  subItems.forEach((subName, si) => {
                                      const sf = String(si + 1).padStart(autoDigits, '0');
                                      const sp = `${rootP}/${sf}`;
                                      tasks.push({ p: sp, t: subName, b: `type=${endType}\ntitle=${subName}` });
                                  });
                              } else {
                                  for (let i = start; i <= count; i++) {
                                      const sf = String(i).padStart(autoDigits, '0');
                                      const sp = `${rootP}/${sf}`;
                                      const heb = toHebrew(i);
                                      let title = (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi')) ? `דף ${heb}` : (currentLib === 'shulchan' ? `סימן ${heb}` : `פרק ${heb}`);
                                      
                                      const splitS = document.getElementById('splitAmudim').checked && (currentLib.includes('shas') || currentLib.includes('bavli') || currentLib.includes('yerushalmi'));
                                      const seifim = parseInt(document.getElementById('seifimCount').value);
                                      const mishCount = parseInt(document.getElementById('mishCount').value);
                                      const splitMishnot = currentLib === 'mishnah' ? document.getElementById('mishnahSplitMishnot').checked : true;
                                      
                                      let curMishCount = (currentLib === 'mishnah' && mishArr.length >= i && splitMishnot) ? mishArr[i - 1] : mishCount;
                                      
                                      let hasSub = splitS || (currentLib === 'shulchan' && seifim > 0) || (['rambam','tanakh'].includes(currentLib) && mishCount > 0) || (currentLib === 'mishnah' && curMishCount > 0 && splitMishnot);
                                      let subDigits = splitS ? 1 : ((currentLib === 'mishnah' ? curMishCount : (currentLib === 'shulchan' ? seifim : mishCount)) >= 10 ? 2 : 1);
                                      
                                      tasks.push({ p: sp, t: title, b: `type=${hasSub?'menu':endType}\ntitle=${title}${hasSub ? '\ndigits='+subDigits : ''}` });
                  
                                      if(splitS) {
                                          tasks.push({ p: `${sp}/1`, t: "עמוד א", b: `type=${endType}\ntitle=עמוד א` });
                                          tasks.push({ p: `${sp}/2`, t: "עמוד ב", b: `type=${endType}\ntitle=עמוד ב` });
                                      }
                                      if(currentLib === 'shulchan' && seifim > 0) {
                                          for(let s=1; s<=seifim; s++) tasks.push({ p: `${sp}/${String(s).padStart(seifim >= 10 ? 2 : 1, '0')}`, t: `סעיף ${toHebrew(s)}`, b: `type=${endType}\ntitle=סעיף ${toHebrew(s)}` });
                                      }
                                      if(['rambam','tanakh'].includes(currentLib) && mishCount > 0) {
                                          let subL = currentLib === 'rambam' ? "הלכה" : "פסוק";
                                          let pad = mishCount >= 10 ? 2 : 1;
                                          for(let m=1; m<=mishCount; m++) tasks.push({ p: `${sp}/${String(m).padStart(pad, '0')}`, t: `${subL} ${toHebrew(m)}`, b: `type=${endType}\ntitle=${subL} ${toHebrew(m)}` });
                                      }
                                      if(currentLib === 'mishnah' && curMishCount > 0 && splitMishnot) {
                                          const splitParts = document.getElementById('mishnahSplitParts').checked;
                                          const partsCount = parseInt(document.getElementById('mishnahPartsCount').value) || 1;
                  
                                          for(let m=1; m<=curMishCount; m++) {
                                              const mPad = curMishCount >= 10 ? 2 : 1;
                                              const mishPath = `${sp}/${String(m).padStart(mPad, '0')}`;
                                              const mishTitle = `משנה ${toHebrew(m)}`;
                  
                                              if (splitParts && partsCount > 1) {
                                                  const partDigits = partsCount >= 10 ? 2 : 1;
                                                  tasks.push({ p: mishPath, t: mishTitle, b: `type=menu\ntitle=${mishTitle}\ndigits=${partDigits}` });
                                                  for(let p=1; p<=partsCount; p++) {
                                                      const pPad = partsCount >= 10 ? 2 : 1;
                                                      tasks.push({ p: `${mishPath}/${String(p).padStart(pPad, '0')}`, t: `חלק ${toHebrew(p)}`, b: `type=${endType}\ntitle=חלק ${toHebrew(p)}` });
                                                  }
                                              } else {
                                                  tasks.push({ p: mishPath, t: mishTitle, b: `type=${endType}\ntitle=${mishTitle}` });
                                              }
                                          }
                                      }
                                  }
                              }
                              counter++;
                          });
                      }
                  
                      for (let i = 0; i < tasks.length; i++) {
                          if (isAborted) break;
                          const ok = await upload(token, tasks[i].p, tasks[i].b);
                          if(ok) log.innerHTML += `<div>✓ SUCCESS: ${tasks[i].p}</div>`;
                          else log.innerHTML += `<div style="color:red">✗ FAILED: ${tasks[i].p}</div>`;
                          let pct = Math.round(((i + 1) / tasks.length) * 100);
                          document.getElementById('progBar').style.width = pct + "%";
                          document.getElementById('progText').innerText = pct + "%";
                          document.getElementById('progCounts').innerText = `${i+1} / ${tasks.length}`;
                          log.scrollTop = log.scrollHeight;
                      }
                  
                      document.getElementById('startBtn').style.display = "block";
                      document.getElementById('cancelBtn').style.display = "none";
                  }
                  
                  async function upload(token, path, body) {
                      const fd = new FormData();
                      fd.append('token', token);
                      fd.append('path', `ivr2:${path}/ext.ini`);
                      fd.append('qqfile', new Blob([body], { type: 'text/plain;charset=utf-8' }), 'ext.ini');
                      try {
                          const r = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, { method: 'POST', body: fd });
                          const d = await r.json();
                          return d && (d.responseStatus === "OK" || d.status === "OK");
                      } catch(e) { return false; }
                  }
                  
                  loadLibrary('bavli');
                  

                  </script>

                  </body>
                  </html>'''

                  L תגובה 1 תגובה אחרונה תגובה ציטוט 0
                  • L מנותק
                    lavitoren הטי"ל @בעזרת השם
                    נערך לאחרונה על ידי

                    @בעזרת-השם סמן את כל הקוד ואז לחץ על קוד

                    תגובה 1 תגובה אחרונה תגובה ציטוט 0
                    • ב מנותק
                      בעזרת השם @lavitoren הטי"ל
                      נערך לאחרונה על ידי

                      @lavitoren-הטי-ל אני אנסה, משום מה אני לא מצליח לשלוח את זה כקוד, זה מתחלק לי לכמה חלקים

                      L 2 תגובות תגובה אחרונה תגובה ציטוט 0
                      • L מנותק
                        lavitoren הטי"ל @בעזרת השם
                        נערך לאחרונה על ידי

                        @בעזרת-השם אז למה לי כן עם הקוד שלך הצליח לי

                        ב תגובה 1 תגובה אחרונה תגובה ציטוט 0
                        • L מנותק
                          lavitoren הטי"ל @בעזרת השם
                          נערך לאחרונה על ידי lavitoren הטי"ל

                          @בעזרת-השם בכל אופן יש לך בינה מלאכותית??

                          תגובה 1 תגובה אחרונה תגובה ציטוט 0
                          • ב מנותק
                            בעזרת השם @lavitoren הטי"ל
                            נערך לאחרונה על ידי

                            @lavitoren-הטי-ל אני לא יודע, ניסתי לעשות לפי מה שאמרת,
                            בכל מקרה אני אנסה לעשות עם מה ששדרגת,וגם אני אנסה בלי נדר לעבוד על הTTS
                            אעדכן אותך אם הצלחתי

                            L תגובה 1 תגובה אחרונה תגובה ציטוט 0
                            • L מנותק
                              lavitoren הטי"ל @בעזרת השם
                              נערך לאחרונה על ידי

                              @בעזרת-השם תודה תודה תודה כבר נתתי היום 20 לייקים אז אינני יכול ליתן לך אבל קח ממני כאילו נתתיך אשריך

                              תגובה 1 תגובה אחרונה תגובה ציטוט 0

                              שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.

                              נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.

                              בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗

                              הרשמה התחברות
                              • פוסט ראשון
                                פוסט אחרון