Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<style>
@font-face {
  font-family: "IRANSans";
  src: url("/download/attachments/85042597/IRANSansXVF.woff2") format("woff2");
}

@font-face {
  font-family: "Vazir";
  src: url("/download/attachments/85042597/Vazir-Regular.woff2") format("woff2");
}

:root {
  --brand: #bd2b76;
  --brand-soft: #fff5fb;
  --brand-border: #f5c7e2;
}

body {
  background: #f4f5f8;
  font-family: Vazir, IRANSans, Tahoma;
}

#public-resolutions-app {
  direction: rtl;
  max-width: 1150px;
  margin: 30px auto;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  font-family: Vazir, IRANSans, Tahoma;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-betweencenter;
  gap: 12px;
  margin-bottom: 18px;
}

.public-title {
  color: var(--brand);
  font-size: 20px;
  font-weight: 900;
  margin: 0;
}

.public-actionsfilters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.public-btn {
  border: none;
  background:background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: #fff;
  border-radius: 9px14px;
  padding: 8px 14px;
  cursordisplay: pointerflex;
  font-familygap: inherit12px;
  flex-wrap: wrap;
  fontmargin-sizebottom: 13px16px;
}

.public-btn:hoverfield {
  opacityflex: 0.9 1 1 180px;
}

.public-filtersfield label {
  backgrounddisplay: var(--brand-soft)block;
  borderfont-weight: 1px solid var(--brand-border)800;
  borderfont-radiussize: 14px13px;
  paddingmargin-bottom: 14px5px;
}

.public-field  display: flex;input,
.public-field select {
  gapwidth: 12px100%;
  flexbox-wrapsizing: wrapborder-box;
  margin-bottom: 16px;
}

.public-field {border: 1px solid #d1d5db;
  flexborder-radius: 1 1 180px;
}

.public-field label {
  display: block9px;
  padding: 8px 10px;
  font-weightfamily: 800inherit;
  font-size: 13px;
  margin-bottombackground: 5px#fff;
}

.public-field input:focus,
.public-field select:focus {
  widthoutline: 100%none;
  boxborder-sizingcolor: border-boxvar(--brand);
  borderbox-shadow: 0 1px0 solid #d1d5db;
  border-radius: 9px;
  padding: 8px 10px5px rgba(189,43,118,0.25);
}

.public-table-wrap {
  width: 100%;
  fontoverflow-familyx: inheritauto;
  fontborder-sizeradius: 13px14px;
  backgroundborder: #fff1px solid #e5e7eb;
}

.public-field input:focus,
.public-field select:focus {
  outline: none#publicTable {
  width: 100%;
  min-width: 850px;
  border-colorcollapse: var(--brand)collapse;
  box-shadowbackground: 0#fff;
 0 5px rgba(189,43,118,0.25)font-size: 13px;
}

.public-table-wrap#publicTable th {
  widthbackground: 100%#f5f6fb;
  overflow-x: autocolor: #1f2933;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
}

#publicTable {
  widthpadding: 100%10px;
  mintext-widthalign: 900px;
  border-collapse: collapsecenter;
  background: #fff;
  font-sizeweight: 13px900;
}

#publicTable thtd {
  background: #f5f6fb;
  color: #1f2933;
  border: 1px solid #e5e7eb;
  padding: 9px 10px;
  text-align: center;
  fontvertical-weightalign: 900middle;
}

#publicTable td {
  border: 1px solid #e5e7eb;
  padding: 9px 10px;
  text-align: center;
  vertical-align: middle;
}

#publicTable td..title-cell {
  text-align: right;
  line-height: 2;
  white-space: pre-wrap;
}

#publicTable tbody tr:nth-child(even) {
  background: #fafafa;
}

.public-empty,
.public-loading,
.public-error,
.public-success {
  text-align: center;
  padding: 18px;
  border-radius: 12px;
  margin-top: 14px;
  font-weight: 800;
}

.public-loading {
  background: #f8fafc;
  color: #334155;
}

.public-empty {
  background: #fff7ed;
  color: #9a3412;
}

.public-error {
  background: #fef2f2;
  color: #b91c1c;
}

.public-success {</style>

<div id="public-resolutions-app">
  background: #f0fdf4;
  color: #166534;
}

.public-link {<div class="public-header">
  color: #2563eb;
 <h1 font-weight: 800;
  text-decoration: none;
}

.public-link:hover {
  text-decoration: underline;
}
</style>

<div id="public-resolutions-app">
  class="public-title">📌 مصوبات عمومی</h1>
  </div>

  <div class="public-filters">
    <div class="public-headerfield">
    <h1 class="public-title">📌 مصوبات عمومی</h1>

    <div class="public-actions"> <label>جستجو در عنوان مصوبه</label>
      <button<input type="buttontext" classid="public-btnsearchText" idplaceholder="refreshPublicBtn">🔄 بروزرسانی</button>
مثلاً بخشی از عنوان مصوبه">
    </div>

   <button type="button"<div class="public-btnfield">
      <label>کمیته</label>
      <select id="cleanPublicBtn">🧹 پاکسازی رکوردهای حذف‌شده</button>
committeeFilter">
        <option value="">همه کمیته‌ها</option>
      </div>select>
    </div>

  <div class="public-filters">
    <div class="public-field">
      <label>جستجو در عنوان مصوبه<<label>تاریخ جلسه</label>
      <input type="text" id="searchTextdateFilter" placeholder="مثلاً بخشی از عنوان مصوبه">1405/03/24">
    </div>
    </div>

  <div id="publicStatus" <div class="public-fieldloading">
>در حال بارگذاری    <label>کمیته</label>مصوبات عمومی...</div>

  <div    <selectclass="public-table-wrap" style="display:none;" id="committeeFilterpublicTableWrap">
        <option value<table id="publicTable">همه کمیته‌ها</option>>
      </select><thead>
    </div>

    <tr>
          <div<th classstyle="public-field">
width:5%;">ردیف</th>
          <label>تاریخ جلسه</label><th style="width:18%;">کمیته</th>
      <input type="text" id="dateFilter" placeholder="مثلاً 1405/03/24">    <th style="width:12%;">تاریخ جلسه</th>
    </div>
  </div>

   <div id="publicStatus" class="public-loading">در حال بارگذاری مصوبات عمومی...</div>

  <div class="public-table-wrap" style="display:none;" id="publicTableWrap">
    <table id="publicTable"><th style="width:35%;">عنوان مصوبه</th>
          <th style="width:12%;">مسئول پیگیری</th>
      <thead>
        <tr>
          <th <th style="width:5%12%;">ردیف<>مسئول اجرا</th>
          <th style="width:16%10%;">کمیته<>مهلت مقرر</th>
        </tr>
    <th style="width:11%;">تاریخ جلسه</th> </thead>
          <th style="width:32%;">عنوان مصوبه</th><tbody id="publicBody"></tbody>
          <th style="width:12%;">مسئول پیگیری</th>
          <th style="width:12%;">مسئول اجرا</th></table>
  </div>
</div>

<script>
(function () {
  const PUBLIC_RESOLUTIONS_PAGE_ID = 120520717;
  const PUBLIC_RESOLUTIONS_FILE = "public_resolutions.json";

  const BASE = (() => {
    try {
     <th style="width:10%;">مهلت مقرر</th>
          <th style="width:8%;">صورتجلسه</th> if (window.AJS && typeof AJS.contextPath === "function") return AJS.contextPath();
    } catch   </tr>
      </thead>(e) {}

    const  <tbodym id="publicBody"></tbody>
    </table>
  </div>
</div>

<script>
(function () {
  const PUBLIC_RESOLUTIONS_PAGE_ID = 120520717;
  const PUBLIC_RESOLUTIONS_FILE = "public_resolutions.json" location.pathname.match(/^(.+?)\/pages\//);
    return m ? m[1] : "";
  })();

  const BASEbaseUrl = (() => {
    try {
      if (window.AJS && typeof window.AJS.contextPath === "function") return AJS.contextPath();params && (window.AJS.params.baseURL || window.AJS.params.baseUrl)) ||
    } catch (e) {}(location.origin + BASE);

  let  const mallRows = location.pathname.match(/^(.+?)\/pages\//)[];

  const  return m ? m[1] : "";
  })();

  const baseUrl =
    (window.AJS && window.AJS.params && (window.AJS.params.baseURL || window.AJS.params.baseUrl)) ||
    (location.origin + BASE);

  let allRows = [];

  const statusBox = document.getElementById("publicStatusstatusBox = document.getElementById("publicStatus");
  const tableWrap = document.getElementById("publicTableWrap");
  const tbody = document.getElementById("publicBody");
  const searchText = document.getElementById("searchText");
  const committeeFilter = document.getElementById("committeeFilter");
  const dateFilter = document.getElementById("dateFilter");

  function safeText(v) {
    v = String(v || "");
    var amp = String.fromCharCode(38);

    v = v.replace(/&/g, amp + "amp;");
  const  tableWrapv = documentv.getElementById("publicTableWrapreplace(/</g, amp + "lt;");
  const  tbodyv = documentv.getElementById("publicBodyreplace(/>/g, amp + "gt;");
   const searchTextv = documentv.getElementByIdreplace("searchText");
  const committeeFilter = document.getElementById("committeeFilter/"/g, amp + "quot;");
  const  dateFilterv = documentv.getElementById("dateFilterreplace(/'/g, amp + "#39;");

  const refreshBtn = document.getElementById("refreshPublicBtn")return v;
  const cleanBtn = document.getElementById("cleanPublicBtn");}

  function safeTextnormalize(v) {
    v =return String(v || "");
    var amp = String.fromCharCode(38);
 .replace(/\u200c/g, "")
    v = v.replace(/&\s+/g, amp + "amp;" ");
    v = v.replace(/</g, amp + "lt;");trim();
  }

  function toPersianDigits(v) {
    return String(v = v|| "").replace(/>\d/g, ampfunction + "gt;");(d) {
    v = v.replace(/"/g, amp + "quot;") return "۰۱۲۳۴۵۶۷۸۹"[d];
    v = v.replace(/'/g, amp + "#39;"});

    return v;
  }

  async function normalize(vloadJSON(pageId, filename) {
    return String(v || "")
try {
      const  .replace(/\u200c/g, "")
directUrl =
        .replace(/\s+/g, " ")
      .trim();
  }

  function toPersianDigits(v) `${BASE}/download/attachments/${pageId}/${encodeURIComponent(filename)}?api=v2&cb=${Date.now()}`;

      const r1 = await fetch(directUrl, {
    return   String(v || credentials: "").replace(/\d/g, function (d) {
include",
        headers: { returnAccept: "۰۱۲۳۴۵۶۷۸۹"[d];
application/json,text/plain,*/*" }
      });

  }

   async functionif loadJSON(pageId, filename) (r1.ok) {
     try {
  const txt =  const directUrl =
await r1.text();
        if (txt  `${BASE}/download/attachments/${pageId}/${encodeURIComponent(filename)}?api=v2&cb=${Date.now()}`;

&& txt.trim()) return JSON.parse(txt);
      }
  const r1 =} awaitcatch fetch(directUrl,e1) {
        credentials: "include",
        headers: { Accept: "application/json,text/plain,*/*" }console.warn("direct loadJSON failed:", e1);
      });

      if (r1.ok)try {
        const txtmetaUrl = await r1.text();
        if (txt && txt.trim()) return JSON.parse(txt);
`${BASE}/rest/api/content/${pageId}/child/attachment?filename=${encodeURIComponent(filename)}&expand=version`;

      }
const r2 = await } catch (e1)fetch(metaUrl, {
      console.warn("⚠️ direct loadJSON failed:credentials: "include", e1);
    }

    tryheaders: {
 Accept: "application/json" }
   const  metaUrl =});

        `${BASE}/rest/api/content/${pageId}/child/attachment?filename=${encodeURIComponent(filename)}&expand=version`if (!r2.ok) return [];

      const r2meta = await fetch(metaUrl, {r2.json();
      const att credentials: "include",
        headers: { Accept: "application/json" }= meta && meta.results && meta.results[0] ? meta.results[0] : null;

      });

      if (!r2.okif (!att || !att._links || !att._links.download) return [];

      constlet metadl = await r2.json()att._links.download;
      constlet attdownloadUrl = meta && meta.results && meta.results[0] ? meta.results[0] : null;

dl.indexOf("http") === 0 ? dl : (baseUrl + dl);
      downloadUrl if+= (!att || !att._links || !att._links.download) return []downloadUrl.indexOf("?") >= 0 ? "&" : "?") + "cb=" + Date.now();

      letconst dlr3 = att._links.download; await fetch(downloadUrl, {
      let downloadUrl = dl.indexOf("http") === 0 ? dl : (baseUrl + dl);
      downloadUrl += (downloadUrl.indexOf("?") >= 0 ? "&" : "?") + "cb=" + Date.now()credentials: "include",
        headers: { Accept: "application/json,text/plain,*/*" }
      });

      if (!r3.ok) return [];

      const r3txt = await fetch(downloadUrl, {r3.text();
      if  credentials: "include",(!txt || !txt.trim()) return [];

      return  headers: { Accept: "application/json,text/plain,*/*" }JSON.parse(txt);
    } catch (e2) {
      } console.error("loadJSON error:", e2);

      if (!r3.ok) return [];

    }
  const}

 txt =async awaitfunction r3.textpageExists(pageId); {
    pageId = if String(!txtpageId || !txt"").trim()) return [];

    if (!pageId) return JSON.parse(txt)false;

    } catch (e2) try {
      console.error("❌ loadJSON error:", e2);
      return [];
const res = await fetch(`${baseUrl}/rest/api/content/${encodeURIComponent(pageId)}`, {
     }
  }

  async function pageExists(pageId) {
credentials: "include",
       pageId = String(pageId || "").trim();

headers: { Accept: "application/json" }
     if (!pageId) return false});

    try {
 return res.ok;
    const} rescatch = await fetch(`${baseUrl}/rest/api/content/${encodeURIComponent(pageId)}`,(e) {
        credentials: "include",return false;
    }
  }

  headers:async { Accept: "application/json" }function getAttachmentByName(pageId, filename) {
    try  });
{
      return res.ok;
    } catch (e) {
      return false;
    }
  }

  async function getAttachmentByName(pageId, filename) {
    try {
      const url const url =
        `${BASE}/rest/api/content/${pageId}/child/attachment?filename=${encodeURIComponent(filename)}&expand=version`;

      const r = await fetch(url, {
        credentials: "include",
        headers: { Accept: "application/json" }
      });

      if (!r.ok) return null;

      const j = await r.json();
      return j.results && j.results[0] ? j.results[0] : null;
    } catch (e) {
      console.error("getAttachmentByName error:", e);
      return null;
    }
  }

  async function updateData(pageId, attachmentId, file, filename) {
    const fd = new FormData();
    fd.append("file", file, filename);

    const r = await fetch(`${BASE}/rest/api/content/${pageId}/child/attachment/${attachmentId}/data`, {
      method: "POST",
      credentials: "include",
      headers: {
        "X-Atlassian-Token": "no-check",
        Accept: "application/json"
      },
      body: fd
    });

    if (!r.ok) {
      throw new Error(await r.text());
    }
  }

  async function uploadNew(pageId, file, filename) {
    const fd = new FormData();
    fd.append("file", file, filename);

    const r = await fetch(`${BASE}/rest/api/content/${pageId}/child/attachment`, {
      method: "POST",
      credentials: "include",
      headers: {
        "X-Atlassian-Token": "no-check",
        Accept: "application/json"
      },
      body: fd
    });

    if (!r.ok) {
      throw new Error(await r.text());
    }
  }

  async function savePublicRows(rows) {
    const blob = new Blob([JSON.stringify(rows, null, 2)], {
      type: "application/json"
    });

    const existing = await getAttachmentByName(PUBLIC_RESOLUTIONS_PAGE_ID, PUBLIC_RESOLUTIONS_FILE);

    if (existing) {
      await updateData(PUBLIC_RESOLUTIONS_PAGE_ID, existing.id, blob, PUBLIC_RESOLUTIONS_FILE);
    } else {
      await uploadNew(PUBLIC_RESOLUTIONS_PAGE_ID, blob, PUBLIC_RESOLUTIONS_FILE);
    }
  }

  async function removeDeletedMeetingRows(rows) {
    const validRows = [];

    for (const r of rows) /data`, {
      method: "POST",
      credentials: "include",
      headers: {
      if (!r || !String(r.title || "").trim()) continue;
 "X-Atlassian-Token": "no-check",
      const pageId = String(r.pageId || "").trim();
Accept: "application/json"
      if (!pageId) continue;

},
      body: fd
 const exists = await pageExists(pageId});

      if (exists!r.ok) {
      throw new validRows.push(r);Error(await r.text());
    }
  }

  async function uploadNew(pageId,  }file, filename) {
    }

const fd =  return validRowsnew FormData();
   }

  function fillCommitteeFilter(rows) { fd.append("file", file, filename);

    const oldValuer = committeeFilter.value || "";

await fetch(`${BASE}/rest/api/content/${pageId}/child/attachment`, {
    const committees = Array.from(new Set(method: "POST",
      rows.map(r => normalize(r.committee)).filter(Boolean)credentials: "include",
    )).sort();

  headers:  committeeFilter.innerHTML =
{
       `<option value="">همه کمیته‌ها</option>` +X-Atlassian-Token": "no-check",
      committees.map(c => `<optionAccept: value="${safeText(c)}">${safeText(c)}</option>`).join("");

"application/json"
    committeeFilter.value = oldValue;},
  }

   function getFilteredRows() {
    const q = normalize(searchText.value);body: fd
    });

    if (!r.ok) {
    const  cthrow =new normalizeError(committeeFilter.valueawait r.text());
    const d = normalize(dateFilter.value);

    return allRows.filter(function (r)}
  }

  async function savePublicRows(rows) {
    const blob = new Blob([JSON.stringify(rows, null, 2)], {
      type: "application/json"
 const title = normalize(r.title});

      const committeeexisting = normalize(r.committeeawait getAttachmentByName(PUBLIC_RESOLUTIONS_PAGE_ID, PUBLIC_RESOLUTIONS_FILE);

      const meetingDate = normalize(r.meetingDate);

if (existing) {
      ifawait (q && !title.includes(q)) return false;
      if (c && committee !== c) return falseupdateData(PUBLIC_RESOLUTIONS_PAGE_ID, existing.id, blob, PUBLIC_RESOLUTIONS_FILE);
    } else {
      await uploadNew(PUBLIC_RESOLUTIONS_PAGE_ID, blob, PUBLIC_RESOLUTIONS_FILE);
    }
  if (d && !meetingDate.includes(d)) return false;

      return true;
    });
  }

  function render() {
    const rows = getFilteredRows()}

  async function removeDeletedMeetingRows(rows) {
    const validRows = [];

    for (const r of rows) {
      if (!r || !String(r.title || "").trim()) continue;

    tbody.innerHTML =  const pageId = String(r.pageId || "").trim();

      if (!rows.lengthpageId) {continue;

      const tableWrap.style.displayexists = "none";await pageExists(pageId);

      statusBox.style.display = "block";if (exists) {
      statusBox.className = "public-empty" validRows.push(r);
      statusBox.textContent}
 = "موردی برای نمایش وجود ندارد."; }

    return  returnvalidRows;
    }

    rows.forEach(function fillCommitteeFilter(r, indexrows) {
      const pageIdoldValue = String(rcommitteeFilter.pageIdvalue || "").trim();

      const pageLinkcommittees = pageIdArray.from(new Set(
      rows.map(r  ? `${baseUrl}/pages/viewpage.action?pageId=${encodeURIComponent(pageId)}`=> normalize(r.committee)).filter(Boolean)
        : "")).sort();

      constcommitteeFilter.innerHTML tr = document.createElement("tr");

      tr.innerHTML`<option value= `
"">همه کمیته‌ها</option>` +
      committees.map(c =>  <td>${toPersianDigits(index + 1`<option value="${safeText(c)}">${safeText(c)}</td>
        <td>${safeText(r.committee || "")}</td>option>`).join("");

    committeeFilter.value = oldValue;
  }

  function getFilteredRows() {
    const q =  <td>${safeText(toPersianDigits(r.meetingDate || ""))}</td>normalize(searchText.value);
    const c   <td class="title-cell">${safeText(r.title || "")}</td>= normalize(committeeFilter.value);
    const d =  <td>${safeText(r.followup || "")}</td>normalize(dateFilter.value);

    return    <td>${safeTextallRows.filter(function (r.executor || "")}</td>
) {
      const title = <td>${safeTextnormalize(toPersianDigits(r.deadline || ""))}</td>
        <td>r.title);
      const committee   ${= normalize(r.committee);
      const meetingDate = normalize(r.meetingDate);

   pageLink
   if (q && !title.includes(q)) return false;
      ?if `<a class="public-link" href="${pageLink}" target="_self">مشاهده</a>`
     (c && committee !== c) return false;
      if (d  : ""&& !meetingDate.includes(d)) return false;

      return true;
    });
  }

  function render() {
  </td>
  const rows =  `getFilteredRows();

      tbody.appendChild(tr);
    })innerHTML = "";

     statusBox.style.display = "none";
if (!rows.length) {
      tableWrap.style.display = "blocknone";
  }

  async function loadPublicResolutions(cleanMode) {
    statusBox.style.display = "block";
      statusBox.className = "public-loadingempty";
      statusBox.textContent = cleanMode
"موردی برای نمایش وجود ندارد.";
  ? "در حال پاکسازی رکوردهایreturn;
 مربوط به صورتجلسات حذف‌شده..." }

      : "در حال بارگذاری مصوبات عمومی...";

    tableWrap.style.display = "none";

rows.forEach(function (r, index) {
      const tr = document.createElement("tr");

     try {
tr.innerHTML = `
    const data = await loadJSON(PUBLIC_RESOLUTIONS_PAGE_ID, PUBLIC_RESOLUTIONS_FILE);
      const rows = Array.isArray(data) ? data : [];

<td>${toPersianDigits(index + 1)}</td>
        <td>${safeText(r.committee || "")}</td>
      const validRows = await removeDeletedMeetingRows(rows);

 <td>${safeText(toPersianDigits(r.meetingDate || ""))}</td>
        allRows<td class= validRows;

"title-cell">${safeText(r.title || "")}</td>
       if <td>${safeText(validRowsr.length !== rows.length) {
followup || "")}</td>
         try {<td>${safeText(r.executor || "")}</td>
        <td>${safeText(toPersianDigits(r.deadline  await savePublicRows(validRows);|| ""))}</td>
        } catch (saveErr) {`;

      tbody.appendChild(tr);
    console.error("❌ خطا در ذخیره فایل پاکسازی‌شده:", saveErr)});

    statusBox.style.display = "none";
    tableWrap.style.display = "block";
  }

  async function loadPublicResolutions()  }{

    statusBox.style.display  fillCommitteeFilter(allRows)= "block";
    statusBox.className  render()= "public-loading";

    statusBox.textContent = if (cleanMode) {
  "در حال بارگذاری مصوبات عمومی...";
      statusBoxtableWrap.style.display = "blocknone";

    try {
      const statusBox.classNamedata = "public-success";
await loadJSON(PUBLIC_RESOLUTIONS_PAGE_ID, PUBLIC_RESOLUTIONS_FILE);
      const rows = Array.isArray(data) ? data statusBox.textContent =: [];

      const validRows =  `پاکسازی انجام شد. ${toPersianDigits(rows.length - validRows.length)} رکورد حذف‌شده از لیست پاک شد.`await removeDeletedMeetingRows(rows);

      allRows = validRows;

      if  setTimeout(function ((validRows.length !== rows.length) {
        await  rendersavePublicRows(validRows);
      }

     }, 1800fillCommitteeFilter(allRows);
      }render();

    } catch (e) {
      console.error(e);
      statusBox.style.display = "block";
      statusBox.className = "public-error";
      statusBox.textContent = "خطا در بارگذاری یا پاکسازی مصوبات عمومی.";
      tableWrap.style.display = "none";
    }
  }

  searchText.addEventListener("input", render);
  committeeFilter.addEventListener("change", render);
  dateFilter.addEventListener("input", render);

  refreshBtn.addEventListener("click", function () {
    loadPublicResolutions(false);
  });

  cleanBtn.addEventListener("click", function () {
    loadPublicResolutions(true);
  });

  loadPublicResolutions(false);
})();
</script>