Ebook

Book Cover
Book Title
Author Name
Category --
Price Free
Access Unlock
About this book
SECURE READER


Loading Document...

Login Required

You need to be logged in to access this content.

Create new account

cdsvs ddv<\/p>\n","cover":"https:\/\/examups.com\/wp-content\/uploads\/2024\/08\/Principles-of-Agronomy.png","file":"","category":"AAU (JORHAT)","price":1,"original_price":90,"is_paid":1,"link":"https:\/\/examups.com\/ebook\/","can_read":false,"can_download":false,"primary_action":"buy","sec_action":"none","btn_text":"Buy Now","btn_price":"\u20b91"},{"id":1,"title":"Agronomy","author":"Dr. R.K Sani","desc":"

Book is very good book<\/p>\n","cover":"https:\/\/examups.com\/wp-content\/uploads\/2024\/08\/Principles-of-Agronomy.png","file":"https:\/\/examups.com\/wp-content\/uploads\/2026\/01\/Secondary_Macronutrient_Essentials-1-1.pdf","category":"Free","price":1,"original_price":499,"is_paid":1,"link":"https:\/\/examups.com\/agronomy-2\/","can_read":true,"can_download":false,"primary_action":"read","sec_action":"buy_pdf","btn_text":"Read Now","btn_price":""}]; const ebUser = { id: null }; const ebRzpKey = "rzp_live_msZP27iCfeNQqT"; const ebDeepLink = 3; let ebState = { activeBook: null, filter: 'all' }; // --- 1. RENDER LIST --- function ebRender() { const list = document.getElementById('ebList'); const search = document.getElementById('ebSearch').value.toLowerCase(); list.innerHTML = ''; const filtered = ebData.filter(b => { const matchSearch = b.title.toLowerCase().includes(search) || b.author.toLowerCase().includes(search); const matchCat = (ebState.filter === 'all') || (b.category === ebState.filter); return matchSearch && matchCat; }); if(filtered.length === 0) { list.innerHTML = '

No books found.
'; return; } filtered.forEach(b => { const card = document.createElement('div'); card.className = 'eb-book-card'; card.className = 'eb-book-card'; // Navigation Logic card.onclick = () => { if(b.link && b.link !== '') { window.location.href = b.link; } else { ebOpenDetail(b.id); } }; const coverImg = b.cover ? `` : ''; const badge = b.is_paid ? 'Premium' : 'Free'; card.innerHTML = `
${coverImg} ${badge}
${b.title}
${b.author}
`; list.appendChild(card); }); } function ebFilter(cat, btn) { ebState.filter = cat; document.querySelectorAll('.eb-chip').forEach(c => c.classList.remove('active')); btn.classList.add('active'); ebRender(); } // --- 2. DETAILS LOGIC (ENHANCED) --- function ebOpenDetail(id) { const book = ebData.find(b => b.id === id); if(!book) return; ebState.activeBook = book; // 1. Cover & Blur const posterEl = document.getElementById('detPoster'); const blurEl = document.getElementById('detBlur'); if(book.cover) { posterEl.src = book.cover; blurEl.style.backgroundImage = `url(${book.cover})`; posterEl.style.display = 'block'; } else { posterEl.style.display = 'none'; blurEl.style.background = '#1f2937'; } // 2. Text & Meta document.getElementById('detTitle').innerText = book.title; document.getElementById('detAuthor').innerText = "By " + book.author; document.getElementById('detDesc').innerHTML = book.desc; document.getElementById('detCat').innerText = book.category; // Price let priceHtml = 'Free'; if(book.is_paid) { if(book.original_price) { priceHtml = `₹${book.original_price} ₹${book.price}`; } else { priceHtml = '₹' + book.price; } } document.getElementById('detPriceDisplay').innerHTML = priceHtml; // Access Badge const accessEl = document.getElementById('detAccess'); if(book.can_read) { accessEl.innerText = "Available"; accessEl.style.color = "#10b981"; } else { accessEl.innerText = "Locked"; accessEl.style.color = "#f59e0b"; } // --- BUTTONS LOGIC --- const btnLabel = document.getElementById('btnLabel'); const btnPrice = document.getElementById('btnPriceTag'); const btnSec = document.getElementById('detSecBtn'); const secLabel = document.getElementById('secBtnLabel'); // PRIMARY ACTION btnLabel.innerText = book.btn_text; btnPrice.innerText = book.btn_price; // SECONDARY ACTION (Download or Buy PDF) btnSec.classList.remove('locked-dl'); if(book.sec_action === 'download') { btnSec.style.display = 'flex'; secLabel.innerHTML = ' Download PDF'; } else if(book.sec_action === 'buy_pdf') { btnSec.style.display = 'flex'; btnSec.classList.add('locked-dl'); secLabel.innerHTML = ` Buy PDF (₹${book.price})`; } else { btnSec.style.display = 'none'; } document.getElementById('view-detail').classList.add('active'); } function ebCloseDetail() { document.getElementById('view-detail').classList.remove('active'); ebState.activeBook = null; } // --- 3. ACTIONS HANDLER --- // PRIMARY (Main Button) function ebHandlePrimary() { const book = ebState.activeBook; if(!book) return; if(ebUser.id === null) { document.getElementById('ebModal').style.display = 'flex'; return; } if(book.primary_action === 'read') { ebOpenReader(book); } else { ebStartPayment(book); } } // SECONDARY (Small Button) function ebHandleSecondary() { const book = ebState.activeBook; if(!book) return; if(ebUser.id === null) { document.getElementById('ebModal').style.display = 'flex'; return; } if(book.sec_action === 'download') { if(book.file) { window.open(book.file, '_blank'); } else { alert('No PDF file available.'); } } else if(book.sec_action === 'buy_pdf') { ebStartPayment(book); } } // --- 4. READER & PDF (SMART DOWNLOAD BUTTON) --- function ebOpenReader(book) { if(!book.file) { alert('Book file missing.'); return; } document.getElementById('view-reader').classList.add('active'); // --- SMART DOWNLOAD BUTTON IN READER --- const dlBtn = document.getElementById('readerDlBtn'); const newBtn = dlBtn.cloneNode(true); // Clear listeners dlBtn.parentNode.replaceChild(newBtn, dlBtn); if(book.can_download) { newBtn.style.display = 'flex'; newBtn.href = book.file; newBtn.target = '_blank'; newBtn.innerHTML = ' Download'; newBtn.title = "Download PDF"; } else if (book.sec_action === 'buy_pdf') { // SHOW LOCKED DOWNLOAD BUTTON WITH TEXT newBtn.style.display = 'flex'; newBtn.href = '#'; newBtn.removeAttribute('target'); // UPDATED: Shows icon + "Download (Price)" newBtn.innerHTML = ` Download (₹${book.price})`; newBtn.title = `Pay ₹${book.price} to Download`; // Trigger Payment on Click newBtn.addEventListener('click', (e) => { e.preventDefault(); if(confirm(`To download this PDF, you need to purchase the Premium version for ₹${book.price}. Proceed to payment?`)) { ebStartPayment(book); } }); } else { newBtn.style.display = 'none'; } ebRenderPDF(book.file); } async function ebRenderPDF(url) { const container = document.getElementById('eb-canvas-container'); const loader = document.getElementById('eb-loading-msg'); container.innerHTML = ''; container.appendChild(loader); loader.style.display = 'block'; try { const loadingTask = pdfjsLib.getDocument(url); const pdf = await loadingTask.promise; loader.style.display = 'none'; for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) { const page = await pdf.getPage(pageNum); const scale = 1.5; const viewport = page.getViewport({ scale: scale }); const canvas = document.createElement('canvas'); const context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width; canvas.style.width = '95%'; canvas.style.height = 'auto'; canvas.style.maxWidth = viewport.width + 'px'; container.appendChild(canvas); const renderContext = { canvasContext: context, viewport: viewport }; await page.render(renderContext).promise; } } catch (error) { console.error(error); loader.innerHTML = 'Error loading document.'; } } function ebToggleFullScreen() { const elem = document.getElementById('view-reader'); if (!document.fullscreenElement) { if (elem.requestFullscreen) elem.requestFullscreen(); else if (elem.webkitRequestFullscreen) elem.webkitRequestFullscreen(); else if (elem.msRequestFullscreen) elem.msRequestFullscreen(); } else { if (document.exitFullscreen) document.exitFullscreen(); else if (document.webkitExitFullscreen) document.webkitExitFullscreen(); else if (document.msExitFullscreen) document.msExitFullscreen(); } } function ebCloseReader() { if (document.fullscreenElement) { if (document.exitFullscreen) document.exitFullscreen(); } document.getElementById('view-reader').classList.remove('active'); document.getElementById('eb-canvas-container').innerHTML = '


Loading Document...
'; } // --- 5. PAYMENT & AUTH --- function ebStartPayment(book) { jQuery.post(agri_ajax.url, { action: 'agri_create_order', ebook_id: book.id }, (res) => { if(res.success) { const options = { "key": ebRzpKey, "amount": res.data.amount, "currency": "INR", "name": "AgriMaster", "description": "Unlock " + book.title, "order_id": res.data.order_id, "handler": function (response){ jQuery.post(agri_ajax.url, { action: 'agri_verify_payment', razorpay_payment_id: response.razorpay_payment_id, razorpay_order_id: response.razorpay_order_id, razorpay_signature: response.razorpay_signature, ebook_id: book.id }, (vRes) => { if(vRes.success) { alert('Payment Successful!'); location.reload(); } else { alert('Verification Failed'); } }); }, "theme": { "color": "#4f46e5" } }; const rzp = new Razorpay(options); rzp.open(); } else { alert('Error: ' + (res.data || 'Could not start payment.')); } }); } function ebLogin() { const u = document.getElementById('eb_user').value; const p = document.getElementById('eb_pass').value; if(!u || !p) return; jQuery.post(agri_ajax.url, { action: 'agri_ajax_login', user: u, pass: p }, (res) => { if(res.success) location.reload(); else alert(res.data); }); } function ebSignup() { const e = document.getElementById('eb_reg_email').value; const u = document.getElementById('eb_reg_user').value; jQuery.post(agri_ajax.url, { action: 'agri_ajax_signup', email: e, user: u }, (res) => { if(res.success) { alert('Account created! Please check your email.'); ebToggleAuth('login'); } else alert(res.data); }); } function ebToggleAuth(mode) { if(mode === 'signup') { document.getElementById('eb-login-form').style.display = 'none'; document.getElementById('eb-signup-form').style.display = 'block'; } else { document.getElementById('eb-login-form').style.display = 'block'; document.getElementById('eb-signup-form').style.display = 'none'; } } document.addEventListener('DOMContentLoaded', function() { ebRender(); if(ebDeepLink > 0) { setTimeout(() => { const b = ebData.find(x => x.id === ebDeepLink); if(b) { if(b.can_read) ebOpenReader(b); else ebOpenDetail(ebDeepLink); } }, 500); } });

Related Post

IBPS Recruitment 2021 Officer Government Jobs in Across India B.Sc, LLB, CA, MBA/PGDM Apply Before 2021-06-28IBPS Recruitment 2021 Officer Government Jobs in Across India B.Sc, LLB, CA, MBA/PGDM Apply Before 2021-06-28

IBPS Recruitment 2021 Officer Government Jobs in Across India B.Sc, LLB, CA, MBA/PGDM Location: Across India, India, Industry: Bank Salary: INR / Responsibilities: – Qualifications: B.Sc,LLB,CA,MBA/PGDM Start Date of Application