Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 35: Riga 35:


<!-- 📦 Box: Accesso File Server -->
<!-- 📦 Box: Accesso File Server -->
<div id="server-files" style="display:none; padding:1rem; border:1px solid #ccc; border-radius:8px; background:#f9f9f9; margin-bottom:1rem;">
<div style="margin-top: 2rem; padding: 1rem; border: 1px solid #ccc; background: #f9f9f9; border-radius: 8px;">
   <strong>File Server:</strong> Accesso ai file CSS, JS, configurazioni.<br><br>
   <h3 style="margin-top: 0;">📂 Accesso File Server</h3>
  <select id="fileSelect" style="margin-bottom:0.5rem;">
  <p>Inserisci il nome completo del file MediaWiki che desideri leggere, ad esempio: <code>MediaWiki:Common.css</code></p>
    <option value="common.css">common.css</option>
 
    <option value="common.js">common.js</option>
   <input id="readFileName" type="text" style="width: 100%; padding: 8px; font-family: monospace; font-size: 14px;" placeholder="MediaWiki:CommonDashboard.js">
    <option value="LocalSettings.php">LocalSettings.php</option>
 
  </select><br>
   <button id="readFileBtn" class="mw-ui-button" style="margin-top: 10px;">📂 Leggi file</button>
   <textarea id="fileContent" rows="10" style="width:100%; display:none;"></textarea><br>
   <button onclick="saveMockFile()" style="display:none;" id="saveBtn">📀 Salva</button>
</div>


<div id="admin-file-box" style="display:none;">
  <div id="readFileResult" style="margin-top: 1rem; border: 1px solid #ddd; padding: 1rem; background: #fff; font-family: monospace; font-size: 14px; white-space: pre-wrap; max-height: 400px; overflow: auto;">
  <select id="file-select">
     <em>📄 Il contenuto del file verrà mostrato qui...</em>
     <option value="common.css">common.css</option>
   </div>
    <option value="common.js">common.js</option>
    <option value="LocalSettings.php">LocalSettings.php</option>
    <option value="CommonTranslate.js">CommonTranslate.js</option>
   </select>
  <button onclick="loadRealFileContent()">📂 Carica file</button>
  <button onclick="saveRealFileContent()">💾 Salva file</button><br><br>
  <textarea id="file-preview" style="width:100%;height:300px;"></textarea>
</div>
</div>


<script>
<script>
   const currentUser = mw.config.get("wgUserName") || "";
document.querySelector('#readFileBtn')?.addEventListener('click', async () => {
   if (currentUser === "GianniFrisardi") {
  const filenameInput = document.querySelector('#readFileName');
     document.getElementById("admin-file-box").style.display = "block";
  const fileContentDiv = document.querySelector('#readFileResult');
   const filename = filenameInput.value.trim();
 
   if (!filename) {
     fileContentDiv.innerHTML = '<span style="color:red;">⚠️ Inserisci un nome di file.</span>';
    return;
   }
   }
</script>


<div style="margin-top:20px;">
  try {
  <button id="readFileBtn" class="mw-ui-button">📂 Accesso File Server</button><br><br>
    const response = await fetch('/wiki/dashboard/api/read_file.php?filename=' + encodeURIComponent(filename));
    const data = await response.json();


  <label for="readFileName">Inserisci nome file MediaWiki (es: <code>MediaWiki:Common.css</code>)</label><br>
    if (data.status === 'success') {
  <input id="readFileName" type="text" style="width:100%;padding:5px;margin:5px 0;" placeholder="MediaWiki:CommonTranslate.js">
      fileContentDiv.innerHTML = `<pre style="background:#f4f4f4;border:1px solid #ccc;padding:8px;max-height:400px;overflow:auto;font-size:14px;">${data.content}</pre>`;
 
    } else {
  <div id="readFileResult" style="margin-top:10px;"></div>
      fileContentDiv.innerHTML = `<span style="color:red;">❌ Errore: ${data.message}</span>`;
</div>
    }
 
  } catch (error) {
<!-- 🔧 Accesso File Server – Sezione interattiva -->
    fileContentDiv.innerHTML = `<span style="color:red;">❌ Errore di connessione.</span>`;
<div style="margin-top:1rem; padding:1rem; border:1px solid #ccc; background:#f9f9f9; border-radius:8px;">
    console.error('Errore JS:', error);
  <label for="readFileName"><strong>Inserisci nome file MediaWiki</strong> (es: <code>MediaWiki:Common.css</code>)</label><br>
   }
  <input id="readFileName" type="text" style="width:100%; margin-top:5px;" placeholder="MediaWiki:CommonDashboard.js">
});
 
</script>
   <button id="readFileBtn" style="margin-top:8px; padding:6px 12px;">📂 Leggi file</button>


  <div id="readFileResult" style="margin-top:1rem; border:1px solid #ddd; padding:1rem; background:#fff; font-family:monospace; font-size:14px; white-space:pre-wrap; max-height:400px; overflow:auto;">
    <em>📄 Il contenuto del file verrà mostrato qui...</em>
  </div>
</div>





Versione delle 18:51, 31 lug 2025

🔧 Dashboard Operativa – Masticationpedia

Centro di comando per progetti, API, file e backup

📂 Accesso File Server

Inserisci il nome completo del file MediaWiki che desideri leggere, ad esempio: MediaWiki:Common.css

📄 Il contenuto del file verrà mostrato qui...
📜 Registro attività:
Registro avviato...