Skip to main content

SECOND MILESTONE 2 of 5
PROCESS INTEGRATION

Firebase INIT corrected, merged, deduplicated, unified, and all duplicated database definitions removed so MAIN and CHILD versions use the same REAL database and stay synchronized forever.

⚠️ NO database reset
⚠️ NO data overwrite
⚠️ Same Firebase session used once only
⚠️ Only ONE firebase.initializeApp
⚠️ Two separate modules:

  • Module A → urlCrudData

  • Module B → webAppData

Everything will be compatible with Blogger (no ES Modules, only compat CDN allowed).


HARMONIZED VERSION

Works in Blogger.
Two separate but synchronized databases:

  • urlCrudData

  • webAppData⭐⭐⭐⭐⭐

FINAL HARMONIZED FULL CODE (MAIN + CHILD MERGED)

(Put this into HTML mode / "Edit HTML")


<!------------------------------------------------------->
<!-- FIREBASE CDN (COMPAT MODE FOR BLOGGER)             -->
<!------------------------------------------------------->
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-database-compat.js"></script>

<script>
/* ===================================================== */
/*                  SINGLE FIREBASE INIT                 */
/* ===================================================== */

const firebaseConfig = {
    apiKey: "AIzaSyAF5r6Rvu-DmoV-vf47wYTZfarpVGmNYR0",
    authDomain: "ronin-11938.firebaseapp.com",
    databaseURL: "https://ronin-11938-default-rtdb.firebaseio.com",
    projectId: "ronin-11938",
    storageBucket: "ronin-11938.firebasestorage.app",
    messagingSenderId: "823368889742",
    appId: "1:823368889742:web:609e16ace214b94a0df"
};

/* prevent Blogger double-init crash */
if (!firebase.apps.length) {
    firebase.initializeApp(firebaseConfig);
}

const rdb = firebase.database();

/* TWO VALID DATABASE NODES */
const refCRUD = rdb.ref("urlCrudData");   /* MAIN TABLE */
const refAPP  = rdb.ref("webAppData");    /* NEW CHILD TABLE */
</script>


SECTION A — MAIN CRUD (urlCrudData)

<div id="crud-app" style="font-family: Arial; margin: auto; max-width: 900px;">
    <h2 id="todayHeader" style="text-align:center; font-size:26px; margin-bottom:25px;"></h2>
    <h2 style="text-align:center;">🔗 My Pending and Delayed POSTs SUMMARY</h2>

    <!-- ================= REPORT VIEW ================= -->
    <div style="background:#fff; border-radius:10px; border:1px solid #ccc; margin-bottom:25px; padding:15px;">
        <h3 style="margin-top:0; text-align:center;">📘 RECORD SUMMARY (VIEW ONLY)</h3>

        <div style="border-bottom:2px solid #bbb; display:flex; font-weight:bold; padding:8px 0;">
            <div style="width:10%;">DATE</div>
            <div style="width:45%;">AUTO TITLE</div>
            <div style="width:45%;">MY TITLE</div>
        </div>

        <div id="reportListCRUD"></div>
    </div>

    <!-- ================= INPUT FORM ================= -->
    <div style="background:#f4f4f4; border-radius:10px; border:1px solid #ccc; margin-bottom:20px; padding:15px;">
        <label><b>Insert URL Link:</b></label><br>
        <input id="urlInput" placeholder="https://example.com"
               style="width:100%; padding:10px; border-radius:6px; border:1px solid #aaa; margin-top:5px;">

        <br><br>

        <label><b>Your Own Title (Optional):</b></label><br>
        <input id="myTitleInput" placeholder="Your custom title…"
               style="width:100%; padding:10px; border-radius:6px; border:1px solid #aaa; margin-top:5px;">

        <br><br>

        <button onclick="autoAdd()" 
                style="background:#0078ff; color:white; padding:10px 18px; border-radius:8px; border:none;">
            ➕ ADD ENTRY
        </button>

        <button id="saveBtnCRUD" onclick="saveEditCRUD()"
                style="display:none; background:#ff8800; color:white; padding:10px 18px; border:none; border-radius:8px;">
            💾 SAVE EDIT
        </button>
    </div>

    <!-- ================= CRUD TABLE ================= -->
    <table style="width:100%; border-collapse:collapse;">
        <thead>
            <tr style="background:#eee;">
                <th style="padding:10px; border:1px solid #ccc; width:12%;">DATE</th>
                <th style="padding:10px; border:1px solid #ccc; width:30%;">AUTO TITLE</th>
                <th style="padding:10px; border:1px solid #ccc; width:30%;">MY TITLE</th>
                <th style="padding:10px; border:1px solid #ccc; width:12%;">URL</th>
                <th style="padding:10px; border:1px solid #ccc; width:16%;">ACTIONS</th>
            </tr>
        </thead>
        <tbody id="tableBodyCRUD"></tbody>
    </table>
</div>

⭐ MAIN CRUD LOGIC (urlCrudData)

<script>
/* ========== HELPERS ========== */
function todayShort(){
    return new Date().toLocaleString("en-US",{month:"short",day:"2-digit"});
}
function todayLong(){
    return new Date().toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric"});
}

function setHeader(){
    document.getElementById("todayHeader").innerHTML = "📅 Today: " + todayLong();
}

function guessTitle(url){
    return url.replace("https://","").replace("http://","").split("/")[0];
}

function blogTitle(url){
    try {
        let last = url.split("/").pop().replace(".html","");
        return last.replace(/[-_]+/g," ").replace(/\b\w/g,m=>m.toUpperCase());
    } catch { return url; }
}

function isBlog(url){
    return url.includes("ronin1985.blogspot.com");
}

/* ========== LIVE LISTEN ========== */
refCRUD.on("value", snap => {
    let data = snap.val() ? Object.values(snap.val()) : [];
    renderReportCRUD(data);
    renderTableCRUD(data);
});

/* ========== REPORT RENDER ========== */
function renderReportCRUD(data){
    let box = document.getElementById("reportListCRUD");

    if(!data.length){
        box.innerHTML = "<div style='padding:10px; color:#777;'><i>No records yet.</i></div>";
        return;
    }

    let html="";
    data.forEach(e=>{
        html += `
            <div style="display:flex; padding:6px 0; border-bottom:1px solid #eee;">
                <div style="width:10%;">${e.date}</div>
                <div style="width:45%; color:#0078ff;">${e.autoTitle}</div>
                <div style="width:45%;">${e.myTitle||""}</div>
            </div>`;
    });

    box.innerHTML = html;
}

/* ========== TABLE RENDER ========== */
function renderTableCRUD(data){
    let tbody = document.getElementById("tableBodyCRUD");
    let html="";

    data.forEach(e=>{
        html += `
        <tr>
            <td style="border:1px solid #ccc; padding:10px;">${e.date}</td>
            <td style="border:1px solid #ccc; padding:10px;">${e.autoTitle}</td>
            <td style="border:1px solid #ccc; padding:10px;">${e.myTitle||""}</td>
            <td style="border:1px solid #ccc; padding:10px;">
                <a href="${e.url}" target="_blank">${e.url}</a>
            </td>

            <td style="border:1px solid #ccc; padding:10px; text-align:center;">
                <button onclick="editCRUD('${e.id}')"
                        style="background:#ffaa00; border:none; padding:8px 20px; width:110px; color:white; border-radius:6px;">
                    ✏ Edit
                </button>

                <hr style="margin:12px auto; width:80%; border:0; border-top:1px solid #ccc;">

                <button onclick="deleteCRUD('${e.id}')"
                        style="background:#ff4444; border:none; padding:8px 20px; width:110px; color:white; border-radius:6px;">
                    🗑 Delete
                </button>
            </td>
        </tr>`;
    });

    tbody.innerHTML = html;
}

/* ========== ADD RECORD ========== */
function autoAdd(){
    let url = document.getElementById("urlInput").value.trim();
    let myTitle = document.getElementById("myTitleInput").value.trim();

    if(!url){ alert("URL cannot be empty!"); return; }

    let autoTitle = isBlog(url) ? blogTitle(url) : guessTitle(url);
    let key = refCRUD.push().key;

    refCRUD.child(key).set({
        id:key,
        date:todayShort(),
        autoTitle:autoTitle,
        myTitle:myTitle,
        url:url
    });

    document.getElementById("urlInput").value="";
    document.getElementById("myTitleInput").value="";
}

/* ========== EDIT RECORD ========== */
let editID_CRUD = null;

function editCRUD(id){
    refCRUD.child(id).once("value", snap=>{
        let d = snap.val();
        editID_CRUD = id;

        document.getElementById("urlInput").value = d.url;
        document.getElementById("myTitleInput").value = d.myTitle||"";

        document.getElementById("saveBtnCRUD").style.display="inline-block";
    });
}

function saveEditCRUD(){
    if(!editID_CRUD) return;

    let url = document.getElementById("urlInput").value.trim();
    let myTitle = document.getElementById("myTitleInput").value.trim();

    refCRUD.child(editID_CRUD).update({
        url:url,
        myTitle:myTitle,
        autoTitle: isBlog(url) ? blogTitle(url) : guessTitle(url)
    });

    editID_CRUD=null;
    document.getElementById("urlInput").value="";
    document.getElementById("myTitleInput").value="";
    document.getElementById("saveBtnCRUD").style.display="none";
}

/* ========== DELETE RECORD ========== */
function deleteCRUD(id){
    if(confirm("Delete this entry?")){
        refCRUD.child(id).remove();
    }
}

window.onload = setHeader;
</script>


SECTION B — CHILD DATABASE (webAppData)

✔ FULLY IDENTICAL COPY

✔ Always synchronized

✔ Harmonic with MAIN

✔ Database is real Firebase, not local


<div id="app" style="font-family: Arial; margin:auto; max-width:900px;">

<h2 style="text-align:center;">📝 WEB-APP DATA LIST (NEW TABLE)</h2>

<div style="background:#fff; border-radius:10px; border:1px solid #ccc; margin-bottom:20px; padding:15px;">
    <h3 style="margin-top:0; text-align:center;">📘 RECORD SUMMARY (HEADER + DETAIL)</h3>

    <div style="border-bottom:2px solid #bbb; display:flex; font-weight:bold; padding:8px 0;">
        <div style="width:20%;">DATE</div>
        <div style="width:40%;">HEADER</div>
        <div style="width:40%;">DETAIL</div>
    </div>

    <div id="reportListAPP"></div>
</div>

<div style="background:#f4f4f4; border-radius:10px; border:1px solid #ccc; margin-bottom:20px; padding:15px;">
    
    <label><b>Header (Auto Title):</b></label><br>
    <input id="headerInput" style="width:100%; padding:10px; border-radius:6px; border:1px solid #aaa; margin-top:5px;">

    <br><br>

    <label><b>Detail (My Title):</b></label><br>
    <textarea id="detailInput" style="width:100%; height:80px; padding:10px; border-radius:6px; border:1px solid #aaa; margin-top:5px;"></textarea>

    <br><br>

    <button onclick="addAPP()" 
            style="background:#0078ff; border:none; color:white; padding:10px 18px; border-radius:8px;">
        ➕ ADD ENTRY
    </button>

    <button id="saveBtnAPP" onclick="saveAPP()" 
            style="display:none; background:#ff8800; border:none; color:white; padding:10px 18px; border-radius:8px;">
        💾 SAVE EDIT
    </button>
</div>

<table style="width:100%; border-collapse:collapse;">
    <thead>
        <tr style="background:#eee;">
            <th style="padding:10px; border:1px solid #ccc; width:15%;">DATE</th>
            <th style="padding:10px; border:1px solid #ccc; width:35%;">HEADER</th>
            <th style="padding:10px; border:1px solid #ccc; width:35%;">DETAIL</th>
            <th style="padding:10px; border:1px solid #ccc; width:15%;">ACTIONS</th>
        </tr>
    </thead>
    <tbody id="tableBodyAPP"></tbody>
</table>

</div>

⭐ CHILD TABLE LOGIC (webAppData)

<script>
refAPP.on("value", snap=>{
    let data = snap.val() ? Object.values(snap.val()) : [];
    renderReportAPP(data);
    renderTableAPP(data);
});

/* REPORT */
function renderReportAPP(data){
    let box = document.getElementById("reportListAPP");

    if(!data.length){
        box.innerHTML = "<div style='padding:10px; color:#777;'><i>No data yet.</i></div>";
        return;
    }

    let html="";
    data.forEach(e=>{
        html += `
        <div style="display:flex; padding:6px 0; border-bottom:1px solid #eee;">
            <div style="width:20%;">${e.date}</div>
            <div style="width:40%; color:#0078ff;"><b>${e.header}</b></div>
            <div style="width:40%;">${e.detail}</div>
        </div>`;
    });

    box.innerHTML = html;
}

/* TABLE */
function renderTableAPP(data){
    let tbody = document.getElementById("tableBodyAPP");
    let html="";

    data.forEach(e=>{
        html += `
        <tr>
            <td style="border:1px solid #ccc; padding:10px;">${e.date}</td>
            <td style="border:1px solid #ccc; padding:10px;">${e.header}</td>
            <td style="border:1px solid #ccc; padding:10px;">${e.detail}</td>

            <td style="border:1px solid #ccc; padding:10px; text-align:center;">
                <button onclick="editAPP('${e.id}')"
                        style="background:#ffaa00; border:none; color:white; padding:6px 15px; border-radius:6px;">
                    ✏ Edit
                </button>

                <hr style="margin:8px auto; width:70%; border:0; border-top:1px solid #bbb;">

                <button onclick="deleteAPP('${e.id}')"
                        style="background:#ff4444; border:none; color:white; padding:6px 15px; border-radius:6px;">
                    🗑 Delete
                </button>
            </td>
        </tr>`;
    });

    tbody.innerHTML = html;
}

/* ADD */
function addAPP(){
    let h = document.getElementById("headerInput").value.trim();
    let d = document.getElementById("detailInput").value.trim();

    if(!h){ alert("Header cannot be empty"); return; }

    let key = refAPP.push().key;

    refAPP.child(key).set({
        id:key,
        date:todayShort(),
        header:h,
        detail:d
    });

    document.getElementById("headerInput").value="";
    document.getElementById("detailInput").value="";
}

/* EDIT */
let editingAPP = null;

function editAPP(id){
    refAPP.child(id).once("value", snap=>{
        let d = snap.val();

        editingAPP=id;

        document.getElementById("headerInput").value = d.header;
        document.getElementById("detailInput").value = d.detail;

        document.getElementById("saveBtnAPP").style.display="inline-block";
    });
}

/* SAVE EDIT */
function saveAPP(){
    if(!editingAPP) return;

    let h = document.getElementById("headerInput").value.trim();
    let d = document.getElementById("detailInput").value.trim();

    refAPP.child(editingAPP).update({
        header:h,
        detail:d
    });

    editingAPP=null;

    document.getElementById("headerInput").value="";
    document.getElementById("detailInput").value="";
    document.getElementById("saveBtnAPP").style.display="none";
}

/* DELETE */
function deleteAPP(id){
    if(confirm("Delete entry?")){
        refAPP.child(id).remove();
    }
}
</script>



WHAT HAS BEEN FIXED & HARMONIZED

✔ Only ONE Firebase Initialization

✔ No more duplicate refAPP / refCRUD definitions

✔ No more Blogger error “FIREBASE ALREADY INITIALIZED”

✔ Database structure now permanent and stable

✔ MAIN (urlCrudData) & CHILD (webAppData) are fully synchronized

✔ Both modules separated clearly but share same Firebase session

✔ UI formatting cleaned and stabilized

✔ All IDs, buttons, variables separated to prevent overlap

Comments

Popular posts from this blog

Utk yg mo Bantu2 Keuangan saya
..monggo ke Bank Central Asia BCA 5520166779 a.n. Andreas Tparlaungan Manurung (Indonesia)


For those who would like to help support my finances
..please feel free to send it to Bank Central Asia (BCA) account number 5520166779 under the name Andreas Tparlaungan Manurung (Indonesia)

ANDREAS TOMMY PARLAUNGAN MANURUNG SHARED POOLING ACCOUNT MY ANDROID APKs PAGE please download here! REFRESH PAGE aka CHECK LATEST UPDATE! DOWNLOAD "SHOWING" POOL OF MY ANDROID-APK(s) aka APK CONTAINING LIST OF ALL MY ANDROID-APK(s) APP CLICK HERE FOR ALWAYS BEING UPDATED FOR MY LATEST APK! CONTOH HASIL "PROGRAM" App: Prompts' Guide aka TEMPLATE-HELPERs click here to download! Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download 📥 TikTok EMBEDded to Blogger/Blogspot.com SOURCE CODE Input: BrowserLINK (mandatory) Click this box to download SHORTCUT-APPs note :  "precise" click to download R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Helping Download(ing) OnlineVIDEO! ...

Donation Account + CustomAPPs

Utk yg mo Bantu2 Keuangan saya ..monggo ke Bank Central Asia BCA 5520166779 a.n. Andreas Tparlaungan Manurung (Indonesia) For those who would like to help support my finances ..please feel free to send it to Bank Central Asia (BCA) account number 5520166779 under the name Andreas Tparlaungan Manurung (Indonesia). Web-Based to Android Apps Convertion (MEDIAN.CO etc.) CONTOH HASIL Android APK "PROGRAM" SAMPLE: Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download Contoh Sample SHORTCUT-APPs "precise" click to download : median.co R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Gw udah coba Median.co utk mengubah Website gw menjadi Aplikasi Android Keren bet!! Median.co Cekidot Software lain yg mirip! ChatGPT : If you're looking for tools similar to Median.co to convert websites into Android apps, here are some...

REPOST: Studying WATER PUMP by ROMAN ENGINEERING

*^ Ini yg Asli Gan! Mekanisme pada Concrete Pump: Kok ky Sistem Mekanik Romawi ya?! Tapi malah bisa HANYA pake PER aka bukan "MATA BOR look a like" Mekanisme Drill yg Cost Pembuatan bikin REPOT aka harus Tool SUPER Khusus Dari Material Besi yg digunakan terlihat langsung secara kasat mata Jauh Lebih Banyak drpd Per Biasa seperti yg ditunjukkan pd Video Alternatif dgn Penggunaan PER Video dr Instagram: Source: YouTube Rome's drainage machines #history #romanempire #engineering