4th Class Social Studies Unit 4.2 MCQs – Provinces & Historical Personalities | PAKMCQs

4th Class Social Studies – Pakistan Movement & Historical Personalities Full MCQs | PAKMCQs

Pakistan Movement MCQs | Provinces Contribution (پاکستان کی تشکیل)

PakMCQs presents the role of provinces and regions in the making of Pakistan with easy explanations. Learn about Pakistan Resolution, contributions of Sindh, Punjab, Khyber Pakhtunkhwa, Balochistan, Kashmir, and minorities. Explore lives and achievements of Quaid-e-Azam Muhammad Ali Jinnah, Allama Iqbal, and Fatima Jinnah for complete exam preparation. Studying with explanations will insha'Allah improve your preparation.

پی ڈی ایف میں ڈنلوڈ کرنے سےبہترہے، یہاں ویب سائیٹ سے وضاحت کے ساتھ پڑھیں۔ وضاحت کے ساتھ پڑھنے سے اپکی تیاری انشا اللہ اچھی ہو جائے گی۔

Provinces Role & Personalities | پاکستان کے قیام میں صوبوں کا کردار اور تاریخی شخصیات

Contribution of Provinces / Regions in the Making of Pakistan and Historical Personalities of Pakistan

Muslimon ne Indo-Pak subcontinent par kai sadiyon tak hukumat ki, lekin 1857 ki jang-e-azadi ke baad British ne qabza kar liya۔ Muslimon ne azadi ke liye lambi struggle ki۔ Aakhir kar 23 March 1940 ko Muslim League ke salana ijlas mein, jo Minto Park (ab Iqbal Park) Lahore mein hua, aik alag Muslim mulk ka mutalba kiya gaya۔ Is resolution ko unanimously pass kiya gaya۔ Isay Pakistan Resolution kehte hain۔ Tamam Musalman aik platform par jama ho gaye۔ Musalsal mehnat ke baad 14 August 1947 ko Pakistan bana۔

Think and Answer

1. Minto Park ka naya naam kya hai aur yahan kaunsa minar bana hai؟
2. Un rehnumaon ke naam likho jinhon ne Pakistan banane mein kirdar ada kiya؟

Role of Provinces / Regions in Creation of Pakistan

Pakistan aik federation hai jismein: Sindh, Punjab, Khyber Pakhtunkhwa, Balochistan, Kashmir, Gilgit Baltistan aur Islamabad shamil hain۔ Har region ne Pakistan Movement mein apna hissa dala۔

Role of Sindh

Muhammad Bin Qasim ne 712 A.D mein Sindh fatah kiya aur yahan se Islam phaila۔ Isi liye Sindh ko Bab-ul-Islam (Gateway of Islam) kehte hain۔ Sindh pehla province tha jis ne Muslim state ka resolution pass kiya. Yeh resolution Sir Abdul Majeed Sindhi ne diya.

Important leaders: Sibghatullah Shah Rashdi, Quaid-e-Azam (Sindh se talluq), Fatima Jinnah, Sir Abdullah Haroon, Ghulam Hussain Hidayatullah, Mir Bande Ali Talpur, Muhammad Ayub Khoro۔ Students ne bhi hissa liya: Noor Muhammad High School Hyderabad aur Sindh Madrassa-tul-Islam Karachi۔ 3 March 1943 ko Sindh Assembly ne Pakistan Resolution ke haq mein resolution pass kiya aur 26 June 1947 ko Pakistan join karne ka faisla kiya۔

Role of Punjab

Punjab abadi ke hisaab se sab se bara province hai۔ Important personalities: Allama Muhammad Iqbal, Sir Muhammad Shafi, Malik Barkat Ali, Begum Jehan Ara Shahnawaz۔ Allama Iqbal ne Pakistan ka concept diya aur apni poetry se Musalmanon ko jagaya۔ 23 March 1940 ko Lahore mein Pakistan Resolution pesh hui۔ Is ki yaad mein Minar-e-Pakistan banaya gaya jo azadi ki struggle ki nishani hai۔

Role of Khyber Pakhtunkhwa

Purana naam: North West Frontier Province (NWFP). Yeh region apni strategic location ki wajah se important hai۔ Khyber Pass trade aur military route tha۔ Important leaders: Sardar Abdul Rab Nishtar, Sardar Aurangzeb Khan, Sir Sahibzada Abdul Qayyum Khan۔ July 1947 mein referendum hua aur zyada logon ne Pakistan join karne ka faisla kiya۔

Role of Balochistan

Balochistan ke log azadi pasand thay۔ Important personalities: Ghazi Muhammad Isa, Mir Jaffar Khan Jamali, Fazal Ahmad Ghazi, Malik Abdullah Jan Kasi, Fateh Muhammad۔ June 1947 mein Shahi Jirga ne Pakistan join karne ka faisla kiya۔

Role of Kashmir and Gilgit Baltistan

Yahan ke Musalman bhi Pakistan join karna chahte thay۔ Ruler Maharaja Hari Singh ne Muslim majority hone ke bawajood Pakistan ke sath nahi milaya۔ Logon ne baghawat ki aur kuch ilaqay azad kar ke Pakistan ke sath mil gaye۔

Stop and Tell: Khyber Pakhtunkhwa apni location ki wajah se kyun important hai؟

Role of Minorities in Development of Pakistan

Sirf Musalman hi nahi balkay Christians, Parsis, Sikhs aur Hindus ne bhi Pakistan ke liye kaam kiya۔ Important names: SP Singha (Punjab Assembly Speaker), A.R. Cornelius, Bhagwan Das, Akshay Kumar Das, Kamran Michael, Kamini Kumar Dutta, Dr. Ramesh Kumar۔ Health sector: Dr. Ruth Pfau, Sister Ruth Louis۔ Defence: Major General Noel Khokhar, Cecil Chaudhry, Balwant Kumar Dass۔ Education & Sports: Bishop Anthony Lobo, Kanhaiya Lal Nagpal, Anthony D’Souza, Aneel Dalpat, Byram Avari۔

Historical Personalities of Pakistan

Quaid-e-Azam Muhammad Ali Jinnah

Quaid-e-Azam Pakistan ke founder thay۔ Paidaish: 25 December 1876, Karachi. 1913 mein Muslim League join ki۔ Unhon ne din raat mehnat ki aur Pakistan banaya۔ Pehle Governor General bane۔ Wafat: 11 September 1948. Golden Principles: Faith, Unity, Discipline.

Allama Muhammad Iqbal

Paidaish: 9 November 1877, Sialkot. 1930 Allahabad Address mein Muslim state ka concept diya۔ Unki shayari ne Musalmanon mein azadi ka jazba paida kiya۔ Wafat: 21 April 1938.

Mohtarma Fatima Jinnah

Quaid-e-Azam ki chhoti behan theen۔ Paidaish: 31 July 1893. Profession: Dentist. 1938 mein Muslim League women wing ki leader banin. Unhon ne “Madrasat-ul-Banat-ul-Islam” (1949) ka aghaz kiya, Fatima Medical College ki bunyad rakhi aur “Khatun-e-Pakistan” school start kiya۔ Wafat: 9 July 1967.

I Have Learnt
  • Sindh, Punjab, KPK, Balochistan, Kashmir aur Gilgit Baltistan ne Pakistan banane mein hissa liya
  • Minorities ne bhi Pakistan ke liye kaam kiya
  • Quaid-e-Azam, Allama Iqbal aur Fatima Jinnah aham rehnuma thay

پاکستان کے قیام میں صوبوں/علاقوں کا کردار اور پاکستان کی تاریخی شخصیات

مسلمانوں نے برصغیر پر کئی صدیوں تک حکومت کی، لیکن 1857 کی جنگِ آزادی کے بعد برطانوی حکومت نے قبضہ کر لیا۔ مسلمانوں نے طویل جدوجہد کی۔ آخرکار 23 مارچ 1940 کو منٹو پارک لاہور میں ایک علیحدہ مسلم ریاست کا مطالبہ پیش کیا گیا۔ اس قرارداد کو قراردادِ پاکستان کہا جاتا ہے۔ مسلسل کوششوں کے بعد 14 اگست 1947 کو پاکستان قائم ہوا۔

سوچیں اور جواب دیں

1. منٹو پارک کا نیا نام کیا ہے اور وہاں کون سا مینار بنایا گیا ہے؟
2. ان رہنماؤں کے نام لکھیں جنہوں نے پاکستان بنانے میں کردار ادا کیا؟

پاکستان کے قیام میں صوبوں/علاقوں کا کردار

پاکستان ایک وفاق ہے جس میں سندھ، پنجاب، خیبر پختونخوا، بلوچستان، کشمیر، گلگت بلتستان اور اسلام آباد شامل ہیں۔ ہر علاقے نے تحریکِ پاکستان میں اہم کردار ادا کیا۔

سندھ کا کردار

محمد بن قاسم نے 712 عیسوی میں سندھ فتح کیا، اسی لیے سندھ کو باب الاسلام کہا جاتا ہے۔ سندھ پہلا صوبہ تھا جس نے مسلم ریاست کے حق میں قرارداد منظور کی، جو سر عبدالمجید سندھی نے پیش کی۔

اہم رہنما: صبغت اللہ شاہ راشدی، قائداعظم، محترمہ فاطمہ جناح، سر عبداللہ ہارون، غلام حسین ہدایت اللہ، میر بندے علی ٹالپور، محمد ایوب کھوڑو۔ طلبہ نے بھی حصہ لیا: نور محمد ہائی اسکول اور سندھ مدرسۃ الاسلام۔ 3 مارچ 1943 کو سندھ اسمبلی نے قرارداد منظور کی اور سندھ پہلا صوبہ بنا جو پاکستان میں شامل ہوا۔

پنجاب کا کردار

پنجاب آبادی کے لحاظ سے سب سے بڑا صوبہ ہے۔ اہم شخصیات: علامہ محمد اقبال، سر محمد شفیع، ملک برکت علی، بیگم جہاں آرا شاہنواز۔ علامہ اقبال نے پاکستان کا تصور پیش کیا۔ 23 مارچ 1940 کو لاہور میں قراردادِ پاکستان پیش کی گئی، جس کی یاد میں مینارِ پاکستان بنایا گیا۔

خیبر پختونخوا کا کردار

پرانا نام: NWFP. یہ علاقہ اپنی جغرافیائی اہمیت کی وجہ سے اہم تھا۔ خیبر پاس تجارت اور فوجی راستہ تھا۔ اہم رہنما: سردار عبدالرب نشتر، سردار اورنگزیب خان، سر صاحبزادہ عبدالقیم خان۔ جولائی 1947 میں ریفرنڈم ہوا اور لوگوں نے پاکستان میں شامل ہونے کا فیصلہ کیا۔

بلوچستان کا کردار

بلوچستان کے لوگ آزادی پسند تھے۔ اہم شخصیات: غازی محمد عیسیٰ، میر جعفر خان جمالی، فضل احمد غازی، ملک عبداللہ جان کاسی، فتح محمد۔ جون 1947 میں شاہی جرگہ نے پاکستان کے ساتھ شامل ہونے کا فیصلہ کیا۔

کشمیر اور گلگت بلتستان کا کردار

حکمران مہاراجہ ہری سنگھ نے مسلم اکثریت کے باوجود پاکستان کے ساتھ الحاق نہیں کیا۔ لوگوں نے بغاوت کی اور کچھ علاقوں کو آزاد کرا کر پاکستان کے ساتھ شامل کر لیا۔

سوال: خیبر پختونخوا اپنی جغرافیائی حیثیت کی وجہ سے کیوں اہم ہے؟

پاکستان کی ترقی میں اقلیتوں کا کردار

عیسائی، پارسی، سکھ اور ہندوؤں نے بھی خدمات انجام دیں: اہم نام: ایس پی سنگھا، اے آر کارنیلیس، بھگوان داس، اکشے کمار داس، کامران مائیکل، ڈاکٹر رمیش کمار۔ صحت: ڈاکٹر روتھ فاؤ۔ دفاع: میجر جنرل نویل کھوکھر، سیسل چوہدری۔ تعلیم و کھیل: بشپ انتھونی لوبو، کنہیا لال ناگپال، انتھونی ڈی سوزا، انیل دلپت، بیرم آواری۔

پاکستان کی تاریخی شخصیات

قائداعظم محمد علی جناح

بانیِ پاکستان۔ پیدائش: 25 دسمبر 1876۔ 1913 میں مسلم لیگ میں شامل ہوئے۔ پہلے گورنر جنرل بنے۔ وفات: 11 ستمبر 1948۔ سنہری اصول: ایمان، اتحاد، نظم و ضبط.

علامہ محمد اقبال

پیدائش: 9 نومبر 1877۔ 1930 کے خطبۂ الہ آباد میں مسلم ریاست کا تصور پیش کیا۔ ان کی شاعری نے مسلمانوں کو بیدار کیا۔ وفات: 21 اپریل 1938.

محترمہ فاطمہ جناح

قائداعظم کی چھوٹی بہن۔ پیدائش: 31 جولائی 1893۔ پیشہ: ڈینٹسٹ۔ خدمات: خواتین ونگ کی رہنما بنیں، مدرسۃ البنات الاسلام (1949) کا آغاز کیا، فاطمہ میڈیکل کالج کی بنیاد رکھی اور خاتونِ پاکستان اسکول شروع کیا۔ وفات: 9 جولائی 1967.

خلاصہ (I Have Learnt)
  • سندھ، پنجاب، خیبر پختونخوا، بلوچستان، کشمیر اور گلگت بلتستان نے پاکستان کے قیام میں کردار ادا کیا
  • اقلیتوں نے بھی پاکستان کی ترقی میں حصہ لیا
  • قائداعظم، علامہ اقبال اور فاطمہ جناح اہم رہنما تھے
Read More
چار آپشن میں سے کسی پر بھی کلک کرنے سے جواب سبز ہو جائے گا

Top 10 FAQs: Contribution of Provinces & Historical Personalities of Pakistan

What was the Pakistan Resolution of 1940? +

The Pakistan Resolution was passed on 23 March 1940 in Lahore, demanding a separate homeland for Muslims of the subcontinent. It later became the foundation for the creation of Pakistan.

When did Pakistan come into existence? +

Pakistan came into existence on 14 August 1947 after a long struggle by Muslims under the leadership of Quaid-e-Azam Muhammad Ali Jinnah.

What was the role of Sindh in the creation of Pakistan? +

Sindh played a leading role by being the first province to pass the Pakistan Resolution in its assembly in 1943 and later became the first province to join Pakistan.

What was the role of Punjab in the Pakistan Movement? +

Punjab played a major role through leaders like Allama Iqbal, who presented the idea of a separate Muslim state. Lahore was also the place where the Pakistan Resolution was passed.

What was the contribution of Khyber Pakhtunkhwa in Pakistan’s creation? +

Khyber Pakhtunkhwa contributed through its brave people and leaders. In 1947, a referendum was held, and the majority voted in favor of joining Pakistan.

What was the role of Balochistan in the Pakistan Movement? +

Balochistan joined the movement later, but its leaders worked to spread awareness. In June 1947, the Shahi Jirga decided to join Pakistan.

What was the role of Kashmir and Gilgit-Baltistan? +

The people of these regions wanted to join Pakistan. Some areas were liberated by locals and became part of Pakistan despite opposition from the ruler.

Did minorities contribute to the creation of Pakistan? +

Yes, minorities like Christians, Hindus, Parsis, and Sikhs also contributed in areas like politics, education, health, and defence.

Who was Quaid-e-Azam Muhammad Ali Jinnah? +

Quaid-e-Azam was the founder of Pakistan, a great leader and lawyer who led the Pakistan Movement and became the first Governor-General of Pakistan.

What were the contributions of Allama Iqbal and Fatima Jinnah? +

Allama Iqbal gave the idea of a separate Muslim state and inspired Muslims through his poetry. Fatima Jinnah supported Quaid-e-Azam and played an important role in mobilizing women in the Pakistan Movement.

Bookmark updated
🔐 Login Required

Save to Dashboard

Please log in to your account to bookmark this question and review it later from your dashboard.

اس سوال کو اپنے ڈیش بورڈ میں محفوظ کرنے کے لیے براہِ کرم لاگ ان کریں۔
یا

Frequently Asked Questions (FAQs)

1. What was the Pakistan Resolution of 1940? ▼
The Pakistan Resolution was passed on 23 March 1940 in Lahore, demanding a separate homeland for Muslims of the subcontinent. It later became the foundation for the creation of Pakistan.
2. When did Pakistan come into existence? ▼
Pakistan came into existence on 14 August 1947 after a long struggle by Muslims under the leadership of Quaid-e-Azam Muhammad Ali Jinnah.
3. What was the role of Sindh in the creation of Pakistan? ▼
Sindh played a leading role by being the first province to pass the Pakistan Resolution in its assembly in 1943 and later became the first province to join Pakistan.
Go to Page:
// YAHAN AAP KA SPECIFIC BACKGROUND LINK LAGA DIYA HAI pdfBackgroundUrl: "https://media.licdn.com/dms/image/v2/D4D22AQEeipTaShU2pg/feedshare-shrink_800/B4DZr3lbg8J4Ag-/0/1765090376076?e=1766620800&v=beta&t=jhdnVgeSHW5QsvbAbK719ygBmv_7sP76YE5CybbpcgY", shareImage: { width: 1200, height: 630, backgroundGradient: ['#1e3c72', '#2a5298'], textColor: '#ffffff', optionTextColor: '#333333', correctAnswerColor: '#28a745', borderRadius: 20, padding: 40, questionFontSize: 36, urduFontSize: 32, optionFontSize: 28, noticeFontSize: 24, correctAnswerFontSize: 28, overlayOpacity: 0.7 } }; let answersShown = false; let selectedOptions = {}; let currentPage = 1; let speechSynthesis = window.speechSynthesis; let contentExpanded = false; let contentInUrdu = false; function getCurrentPageFromURL() { const urlParams = new URLSearchParams(window.location.search); const page = parseInt(urlParams.get('page')); return isNaN(page) || page < 1 ? 1 : Math.min(page, Math.ceil(questions.length / config.questionsPerPage)); } function updateURL(page) { const urlParams = new URLSearchParams(window.location.search); urlParams.set('page', page); const newUrl = window.location.pathname + '?' + urlParams.toString(); window.history.pushState({ path: newUrl }, '', newUrl); } function parseHighlightedText(text) { text = text.replace(/\[red\](.*?)\[\/red\]/g, '$1'); text = text.replace(/\[blue\](.*?)\[\/blue\]/g, '$1'); text = text.replace(/\[green\](.*?)\[\/green\]/g, '$1'); text = text.replace(/\[yellow\](.*?)\[\/yellow\]/g, '$1'); text = text.replace(/\[purple\](.*?)\[\/purple\]/g, '$1'); return text; } // ========================================================= // ============ TOC / SCROLL LOGIC START =================== // ========================================================= function generateTOC() { const tocContainer = document.getElementById('toc-container'); const tocList = document.getElementById('toc-list'); tocList.innerHTML = ''; let hasTopics = false; let topicCount = 0; // Added for counting headings questions.forEach((q, index) => { if (q.topicHeading) { hasTopics = true; topicCount++; const li = document.createElement('li'); li.className = 'toc-item'; li.textContent = q.topicHeading; li.onclick = () => scrollToTopic(index); // Hide headings after the 6th one if (topicCount > 6) { li.style.display = 'none'; li.classList.add('hidden-toc-item'); } tocList.appendChild(li); } }); // Remove existing button if any const existingBtn = document.getElementById('toc-see-more-btn-container'); if (existingBtn) existingBtn.remove(); // Add 'See More' button if there are more than 6 topics if (topicCount > 6) { const btnContainer = document.createElement('div'); btnContainer.id = 'toc-see-more-btn-container'; btnContainer.style.textAlign = 'center'; btnContainer.style.marginTop = '20px'; btnContainer.style.gridColumn = '1 / -1'; // To span full width if in grid const seeMoreBtn = document.createElement('button'); seeMoreBtn.className = 'btn btn-primary'; seeMoreBtn.textContent = 'See More Headings'; seeMoreBtn.onclick = function() { const hiddenItems = tocList.querySelectorAll('.hidden-toc-item'); hiddenItems.forEach(item => { item.style.display = 'flex'; // Restoring original flex display }); btnContainer.style.display = 'none'; // Hide button after clicking }; btnContainer.appendChild(seeMoreBtn); tocContainer.appendChild(btnContainer); } if (hasTopics) { tocContainer.style.display = 'block'; } } function scrollToTopic(questionIndex) { const targetPage = Math.floor(questionIndex / config.questionsPerPage) + 1; if (targetPage === currentPage) { executeScrollHighlight(questionIndex); } else { window.location.href = window.location.pathname + `?page=${targetPage}&scrollTo=${questionIndex}`; } } function executeScrollHighlight(index) { const element = document.getElementById(`q-card-${index}`); const headingElement = document.getElementById(`heading-for-${index}`); const targetElement = headingElement || element; if (targetElement) { targetElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); if(element) { element.classList.add('highlight-scroll'); setTimeout(() => { element.classList.remove('highlight-scroll'); }, 2500); } } } function checkScrollOnLoad() { const urlParams = new URLSearchParams(window.location.search); const scrollToIdx = urlParams.get('scrollTo'); if (scrollToIdx !== null) { setTimeout(() => { executeScrollHighlight(parseInt(scrollToIdx)); const newUrl = window.location.pathname + '?page=' + currentPage; window.history.replaceState({}, '', newUrl); }, 800); } } // ========================================================= // ============ TOC / SCROLL LOGIC END ===================== // ========================================================= function loadQuestions(page = 1) { currentPage = page; updateURL(page); const quizContainer = document.getElementById('quiz-container'); quizContainer.innerHTML = ''; const startIndex = (page - 1) * config.questionsPerPage; const endIndex = Math.min(startIndex + config.questionsPerPage, questions.length); for (let i = startIndex; i < endIndex; i++) { const q = questions[i]; // TOC: Add Topic Heading if exists if (q.topicHeading) { const headingDiv = document.createElement('div'); headingDiv.className = 'in-quiz-topic-heading'; headingDiv.id = `heading-for-${i}`; headingDiv.textContent = q.topicHeading; quizContainer.appendChild(headingDiv); } const questionElement = document.createElement('div'); questionElement.className = 'question-card'; questionElement.id = `q-card-${i}`; // TOC: Add ID for scrolling // CHECK FOR IMPORTANT QUESTION if (q.isImportant) { questionElement.classList.add('important-question'); // Add Badge with Star Icon const badge = document.createElement('div'); badge.className = 'important-badge'; // Star Icon URL (CDN) const starIconURL = "https://cdn-icons-png.flaticon.com/512/1828/1828884.png"; // Using Image tag instead of tag badge.innerHTML = ` Important`; questionElement.appendChild(badge); } const questionTextContainer = document.createElement('div'); questionTextContainer.onclick = function() { if (q.questionLink) { window.location.href = q.questionLink; } }; const questionNumber = i + 1; questionTextContainer.innerHTML = ` ${questionNumber}. ${q.question} ${q.urdu} `; questionElement.appendChild(questionTextContainer); if (q.ttsEnabled) { const ttsButton = document.createElement('button'); ttsButton.className = 'tts-btn'; ttsButton.innerHTML = `Listen Question`; ttsButton.onclick = (e) => { e.stopPropagation(); speakQuestion(q); }; questionElement.appendChild(ttsButton); } const optionsDiv = document.createElement('div'); optionsDiv.className = 'options'; optionsDiv.id = `options-${i}`; q.options.forEach((option, j) => { const optionDiv = document.createElement('div'); optionDiv.className = 'option'; optionDiv.onclick = (e) => { e.stopPropagation(); selectOption(optionDiv, String.fromCharCode(65 + j), i); }; optionDiv.innerHTML = `${String.fromCharCode(65 + j)}${option}`; optionsDiv.appendChild(optionDiv); }); questionElement.appendChild(optionsDiv); if (q.showSocialShare) { const shareButtons = document.createElement('div'); shareButtons.className = 'share-buttons'; const whatsappBtn = document.createElement('button'); whatsappBtn.className = 'share-btn whatsapp-btn'; whatsappBtn.innerHTML = `Share via WhatsApp`; whatsappBtn.onclick = () => shareQuestionWithImage(i, 'whatsapp'); shareButtons.appendChild(whatsappBtn); const copyLinkBtn = document.createElement('button'); copyLinkBtn.className = 'share-btn copy-link-btn'; copyLinkBtn.innerHTML = `Copy Link`; copyLinkBtn.onclick = () => { const link = q.questionLink || window.location.href; navigator.clipboard.writeText(link).then(() => { copyLinkBtn.innerHTML = `Copied!`; copyLinkBtn.classList.add('copied'); setTimeout(() => { copyLinkBtn.innerHTML = `Copy Link`; copyLinkBtn.classList.remove('copied'); }, 2000); }); }; shareButtons.appendChild(copyLinkBtn); questionElement.appendChild(shareButtons); } const explanationBtn = document.createElement('button'); explanationBtn.className = 'explanation-btn'; explanationBtn.onclick = (e) => { e.stopPropagation(); toggleExplanation(i); }; explanationBtn.innerHTML = 'اس سوال کو وضاحت کے ساتھ پڑھیں'; // START: *** NEW LAYOUT LOGIC *** // Create a container for the action buttons const actionsContainer = document.createElement('div'); actionsContainer.className = 'question-actions'; // Add the explanation button to the container actionsContainer.appendChild(explanationBtn); // Add the MODERN comment icon to the container if (q.questionLink) { const commentLink = document.createElement('a'); commentLink.href = q.questionLink; commentLink.target = '_blank'; commentLink.className = 'modern-comment-link'; const commentSVG = ``; commentLink.innerHTML = `(Comments) ${commentSVG}`; actionsContainer.appendChild(commentLink); } // Add the actions container to the main question element questionElement.appendChild(actionsContainer); // END: *** NEW LAYOUT LOGIC *** const explanationDiv = document.createElement('div'); explanationDiv.className = 'explanation'; explanationDiv.id = `explanation-${i}`; const translateBtn = document.createElement('button'); translateBtn.className = 'translate-btn'; translateBtn.innerHTML = 'Translate in Urdu'; translateBtn.onclick = (e) => { e.stopPropagation(); toggleExplanationTranslation(i); }; explanationDiv.appendChild(translateBtn); const explanationText = document.createElement('div'); explanationText.innerHTML = parseHighlightedText(q.explanation.replace(/\n/g, '
')); explanationDiv.appendChild(explanationText); const explanationUrduDiv = document.createElement('div'); explanationUrduDiv.className = 'explanation-urdu'; explanationUrduDiv.innerHTML = parseHighlightedText(q.explanationUrdu.replace(/\n/g, '
')); explanationDiv.appendChild(explanationUrduDiv); if (q.explanationImage) { const imgContainer = document.createElement('div'); imgContainer.style.textAlign = 'center'; const imgLink = document.createElement('a'); imgLink.href = q.explanationImageLink || '#'; imgLink.target = '_blank'; const img = document.createElement('img'); img.src = q.explanationImage; img.alt = q.explanationImageAlt || 'Explanation Image'; img.className = 'explanation-image'; imgLink.appendChild(img); imgContainer.appendChild(imgLink); if (q.explanationImageCaption) { const caption = document.createElement('div'); caption.className = 'question-image-caption'; caption.textContent = q.explanationImageCaption; imgContainer.appendChild(caption); } explanationDiv.appendChild(imgContainer); } questionElement.appendChild(explanationDiv); quizContainer.appendChild(questionElement); // Har 3 sawalat ke baad ad daalne ka logic if ((i + 1) % 3 === 0 && i < endIndex - 1) { const adContainer = document.createElement('div'); adContainer.className = 'ad-container'; adContainer.innerHTML = `

Advertisement Space

`; quizContainer.appendChild(adContainer); } if (q.ProTips) { const tipsElement = document.createElement('div'); tipsElement.className = 'tips-section'; tipsElement.innerHTML = q.ProTips; quizContainer.appendChild(tipsElement); } if (q.imageAfter) { const imageContainer = document.createElement('div'); imageContainer.className = 'question-image'; const imageLink = document.createElement('a'); imageLink.href = q.imageAfter.link; imageLink.target = '_blank'; const image = document.createElement('img'); image.src = q.imageAfter.url; image.alt = q.imageAfter.alt || 'Question related image'; imageLink.appendChild(image); imageContainer.appendChild(imageLink); if (q.imageAfter.caption) { const caption = document.createElement('div'); caption.className = 'question-image-caption'; caption.textContent = q.imageAfter.caption; imageContainer.appendChild(caption); } quizContainer.appendChild(imageContainer); } if (i < endIndex - 1) { const isAdNext = ((i + 1) % 3 === 0 && i < questions.length - 1); if (!isAdNext) { const divider = document.createElement('div'); divider.className = 'divider'; quizContainer.appendChild(divider); } } } if (answersShown) { showAllAnswers(); } else { hideAllAnswers(); } updatePagination(); // YEH LINE ADD KI GAYI HAI: Sawalat load hone ke baad ads ko load karein applyAds(); } function toggleExplanationTranslation(questionIndex) { const explanationDiv = document.getElementById(`explanation-${questionIndex}`); const englishExplanation = explanationDiv.querySelector('div:not(.explanation-urdu)'); const urduExplanation = explanationDiv.querySelector('.explanation-urdu'); if (englishExplanation.style.display !== 'none') { englishExplanation.style.display = 'none'; urduExplanation.style.display = 'block'; } else { englishExplanation.style.display = 'block'; urduExplanation.style.display = 'none'; } } function speakQuestion(question) { if (speechSynthesis.speaking) { speechSynthesis.cancel(); } const questionUtterance = new SpeechSynthesisUtterance(`Question: ${question.question.replace('?', '.')}`); questionUtterance.lang = 'en-US'; questionUtterance.rate = 0.7; questionUtterance.pitch = 0.8; let optionsText = 'Options: '; question.options.forEach((option, index) => { optionsText += `${String.fromCharCode(65 + index)}... ${option}. `; }); const optionsUtterance = new SpeechSynthesisUtterance(optionsText); optionsUtterance.lang = 'en-US'; optionsUtterance.rate = 0.7; optionsUtterance.pitch = 0.8; speechSynthesis.speak(questionUtterance); questionUtterance.onend = function() { speechSynthesis.speak(optionsUtterance); }; } function updatePagination() { const pagination = document.getElementById('pagination'); pagination.innerHTML = ''; const totalPages = Math.ceil(questions.length / config.questionsPerPage); if (totalPages <= 1) return; const firstBtn = document.createElement('button'); firstBtn.className = 'page-nav'; firstBtn.innerHTML = '« First'; firstBtn.onclick = () => { window.location.href = window.location.pathname + '?page=1'; }; if (currentPage === 1) firstBtn.classList.add('disabled-nav'); pagination.appendChild(firstBtn); const prevBtn = document.createElement('button'); prevBtn.className = 'page-nav'; prevBtn.innerHTML = '‹'; prevBtn.onclick = () => { window.location.href = window.location.pathname + '?page=' + (currentPage - 1); }; if (currentPage === 1) prevBtn.classList.add('disabled-nav'); pagination.appendChild(prevBtn); if (currentPage > 2) { const firstPageBtn = document.createElement('button'); firstPageBtn.className = 'page-btn'; firstPageBtn.textContent = '1'; if (1 === currentPage) firstPageBtn.classList.add('active'); firstPageBtn.onclick = () => { window.location.href = window.location.pathname + '?page=1'; }; pagination.appendChild(firstPageBtn); if (currentPage > 3) { const ellipsis1 = document.createElement('span'); ellipsis1.className = 'page-ellipsis'; ellipsis1.textContent = '...'; pagination.appendChild(ellipsis1); } } const startPage = Math.max(2, currentPage - 1); const endPage = Math.min(totalPages - 1, currentPage + 1); for (let i = startPage; i <= endPage; i++) { const pageBtn = document.createElement('button'); pageBtn.className = 'page-btn'; pageBtn.textContent = i; if (i === currentPage) pageBtn.classList.add('active'); pageBtn.onclick = () => { window.location.href = window.location.pathname + '?page=' + i; }; pagination.appendChild(pageBtn); } if (currentPage < totalPages - 1) { if (currentPage < totalPages - 2) { const ellipsis2 = document.createElement('span'); ellipsis2.className = 'page-ellipsis'; ellipsis2.textContent = '...'; pagination.appendChild(ellipsis2); } const lastPageBtn = document.createElement('button'); lastPageBtn.className = 'page-btn'; lastPageBtn.textContent = totalPages; if (totalPages === currentPage) lastPageBtn.classList.add('active'); lastPageBtn.onclick = () => { window.location.href = window.location.pathname + '?page=' + totalPages; }; pagination.appendChild(lastPageBtn); } const nextBtn = document.createElement('button'); nextBtn.className = 'page-nav'; nextBtn.innerHTML = '›'; nextBtn.onclick = () => { window.location.href = window.location.pathname + '?page=' + (currentPage + 1); }; if (currentPage === totalPages) nextBtn.classList.add('disabled-nav'); pagination.appendChild(nextBtn); const lastBtn = document.createElement('button'); lastBtn.className = 'page-nav'; lastBtn.innerHTML = 'Last »'; lastBtn.onclick = () => { window.location.href = window.location.pathname + '?page=' + totalPages; }; if (currentPage === totalPages) lastBtn.classList.add('disabled-nav'); pagination.appendChild(lastBtn); const searchDiv = document.createElement('div'); searchDiv.className = 'page-search'; searchDiv.innerHTML = ` `; pagination.appendChild(searchDiv); } function goToPageWithReload() { const pageInput = document.getElementById('pageInput'); const pageNum = parseInt(pageInput.value); const totalPages = Math.ceil(questions.length / config.questionsPerPage); if (pageNum >= 1 && pageNum <= totalPages) { window.location.href = window.location.pathname + '?page=' + pageNum; } else { alert(`Please enter a page number between 1 and ${totalPages}`); } } function selectOption(optionElement, selectedAnswer, questionIndex) { const question = questions[questionIndex]; const options = document.querySelectorAll(`#options-${questionIndex} .option`); options.forEach(opt => { opt.style.pointerEvents = 'none'; }); selectedOptions[questionIndex] = selectedAnswer; const correctOptionIndex = question.correctAnswer.charCodeAt(0) - 65; options[correctOptionIndex].classList.add('correct'); if (selectedAnswer !== question.correctAnswer) { const selectedIndex = selectedAnswer.charCodeAt(0) - 65; options[selectedIndex].classList.add('incorrect'); } } function toggleExplanation(questionIndex) { const explanationElement = document.getElementById(`explanation-${questionIndex}`); explanationElement.style.display = explanationElement.style.display === 'block' ? 'none' : 'block'; } function toggleFAQ(faqQuestion) { faqQuestion.classList.toggle('active'); const answer = faqQuestion.nextElementSibling; answer.style.display = answer.style.display === 'block' ? 'none' : 'block'; const toggleIcon = faqQuestion.querySelector('.faq-toggle'); toggleIcon.classList.toggle('rotated'); } function toggleAllAnswers() { answersShown = !answersShown; const btn = document.getElementById('toggleAnswersBtn'); if (answersShown) { btn.textContent = 'Hide All Answers'; showAllAnswers(); } else { btn.textContent = 'Show All Answers'; hideAllAnswers(); } } function showAllAnswers() { const startIndex = (currentPage - 1) * config.questionsPerPage; const endIndex = Math.min(startIndex + config.questionsPerPage, questions.length); for (let i = startIndex; i < endIndex; i++) { const q = questions[i]; const options = document.querySelectorAll(`#options-${i} .option`); if (options.length > 0) { const correctOptionIndex = q.correctAnswer.charCodeAt(0) - 65; options[correctOptionIndex].classList.add('correct'); if (selectedOptions.hasOwnProperty(i) && selectedOptions[i] !== q.correctAnswer) { const selectedIndex = selectedOptions[i].charCodeAt(0) - 65; options[selectedIndex].classList.add('incorrect'); } options.forEach(opt => { opt.style.pointerEvents = 'none'; }); } } } function hideAllAnswers() { const startIndex = (currentPage - 1) * config.questionsPerPage; const endIndex = Math.min(startIndex + config.questionsPerPage, questions.length); for (let i = startIndex; i < endIndex; i++) { const options = document.querySelectorAll(`#options-${i} .option`); options.forEach(option => { option.classList.remove('correct', 'incorrect'); }); options.forEach(opt => { opt.style.pointerEvents = 'auto'; }); } selectedOptions = {}; } function resetQuiz() { selectedOptions = {}; answersShown = false; document.getElementById('toggleAnswersBtn').textContent = 'Show All Answers'; loadQuestions(currentPage); } function changeHeaderImage(imageUrl) { document.getElementById('headerImage').src = imageUrl; } function toggleContentExpansion() { const contentPreview = document.getElementById('contentPreview'); const readMoreBtn = document.getElementById('readMoreBtn'); contentExpanded = !contentExpanded; if (contentExpanded) { contentPreview.classList.add('expanded'); readMoreBtn.textContent = 'Read Less'; } else { contentPreview.classList.remove('expanded'); readMoreBtn.textContent = 'Read More'; } } function toggleContentLanguage() { const englishContent = document.querySelector('.english-content'); const urduContent = document.querySelector('.urdu-content'); const translateBtn = document.getElementById('contentTranslateBtn'); contentInUrdu = !contentInUrdu; if (contentInUrdu) { englishContent.style.display = 'none'; urduContent.style.display = 'block'; translateBtn.textContent = 'Translate to English'; } else { englishContent.style.display = 'block'; urduContent.style.display = 'none'; translateBtn.textContent = 'Translate to Urdu'; } } async function createShareImage(questionIndex) { return new Promise((resolve) => { const q = questions[questionIndex]; const canvas = document.getElementById('shareCanvas'); const ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, canvas.width, canvas.height); if (q.backgroundImage) { const img = new Image(); img.crossOrigin = "Anonymous"; img.onload = function() { ctx.drawImage(img, 0, 0, canvas.width, canvas.height); ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'; ctx.fillRect(0, 0, canvas.width, canvas.height); drawQuestionContent(ctx, canvas, q, questionIndex); convertCanvasToImage(canvas, resolve); }; img.onerror = function() { console.log("Background image failed to load, using gradient fallback"); drawGradientBackground(ctx, canvas); drawQuestionContent(ctx, canvas, q, questionIndex); convertCanvasToImage(canvas, resolve); }; img.src = q.backgroundImage + (q.backgroundImage.includes('?') ? '&' : '?') + 't=' + Date.now(); } else { drawGradientBackground(ctx, canvas); drawQuestionContent(ctx, canvas, q, questionIndex); convertCanvasToImage(canvas, resolve); } }); } function drawGradientBackground(ctx, canvas) { const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height); gradient.addColorStop(0, '#1e3c72'); gradient.addColorStop(1, '#2a5298'); ctx.fillStyle = gradient; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = 'rgba(255, 255, 255, 0.05)'; for (let i = 0; i < 5; i++) { ctx.beginPath(); ctx.arc(Math.random() * canvas.width, Math.random() * canvas.height, Math.random() * 300 + 100, 0, Math.PI * 2); ctx.fill(); } } function drawQuestionContent(ctx, canvas, q, questionIndex) { const questionNumber = questionIndex + 1; const questionText = `${questionNumber}. ${q.question}`; const urduText = `${q.urdu.replace('؟', '').replace('?', '')}`; ctx.save(); ctx.beginPath(); ctx.roundRect(40, 40, canvas.width - 80, canvas.height - 80, 20); ctx.clip(); ctx.fillStyle = 'rgba(255, 255, 255, 0.15)'; ctx.fillRect(40, 40, canvas.width - 80, canvas.height - 80); ctx.strokeStyle = 'rgba(255, 255, 255, 0.3)'; ctx.lineWidth = 2; ctx.stroke(); ctx.restore(); ctx.fillStyle = '#ffffff'; ctx.textAlign = 'left'; ctx.font = 'bold 36px Roboto, sans-serif'; const questionLines = wrapText(ctx, questionText, canvas.width - 160, 36); let yPos = 80 + 36; questionLines.forEach(line => { ctx.fillText(line, 80, yPos); yPos += 36 + 10; }); ctx.font = '32px "Noto Nastaliq Urdu", serif'; ctx.textAlign = 'right'; const urduLines = wrapText(ctx, urduText, canvas.width - 160, 32); urduLines.forEach(line => { ctx.fillText(line, canvas.width - 80, yPos); yPos += 32 + 10; }); ctx.textAlign = 'left'; yPos += 20; ctx.font = 'italic 24px "Noto Nastaliq Urdu", serif'; ctx.fillStyle = 'rgba(255, 255, 255, 0.8)'; ctx.textAlign = 'right'; ctx.fillText("چار آپشن میں سے کسی پر بھی کلک کرنے سے جواب سبز ہو جائے گا", canvas.width - 80, yPos); yPos += 24 + 30; ctx.textAlign = 'left'; ctx.font = '28px Roboto, sans-serif'; ctx.textAlign = 'left'; q.options.forEach((option, index) => { const optionLetter = String.fromCharCode(65 + index); const isCorrect = optionLetter === q.correctAnswer; ctx.save(); ctx.beginPath(); ctx.roundRect(80, yPos - 10, canvas.width - 160, 28 + 20, 10); ctx.fillStyle = isCorrect ? 'rgba(40, 167, 69, 0.2)' : 'rgba(255, 255, 255, 0.15)'; ctx.fill(); ctx.strokeStyle = isCorrect ? '#28a745' : 'rgba(255, 255, 255, 0.3)'; ctx.lineWidth = 1; ctx.stroke(); ctx.restore(); ctx.beginPath(); ctx.arc(80 + 25, yPos + 28 / 2, 28 * 0.8, 0, Math.PI * 2); ctx.fillStyle = isCorrect ? '#28a745' : '#3498db'; ctx.fill(); ctx.fillStyle = '#ffffff'; ctx.textAlign = 'center'; ctx.fillText(optionLetter, 80 + 25, yPos + 28 / 2 + 28 * 0.3); ctx.fillStyle = isCorrect ? '#28a745' : '#ffffff'; ctx.textAlign = 'left'; ctx.fillText(`${optionLetter}) ${option}`, 80 + 60, yPos + 28 * 0.8); yPos += 28 + 30; }); ctx.fillStyle = 'rgba(255, 255, 255, 0.7)'; ctx.font = 'italic 20px Roboto, sans-serif'; ctx.textAlign = 'center'; ctx.fillText("Study For More PAKMCQs.ORG", canvas.width / 2, canvas.height - 40); } function convertCanvasToImage(canvas, resolve) { canvas.toBlob((blob) => { const imageUrl = URL.createObjectURL(blob); resolve(imageUrl); }, 'image/png', 1.0); } function wrapText(context, text, maxWidth, fontSize) { const words = text.split(' '); const lines = []; let currentLine = words[0]; for (let i = 1; i < words.length; i++) { const word = words[i]; const width = context.measureText(currentLine + ' ' + word).width; if (width < maxWidth) { currentLine += ' ' + word; } else { lines.push(currentLine); currentLine = word; } } lines.push(currentLine); return lines; } async function shareQuestionWithImage(questionIndex, platform) { try { const imageUrl = await createShareImage(questionIndex); const q = questions[questionIndex]; const shareUrl = q.questionLink || window.location.href; const shareText = `${questionIndex + 1}. ${q.question}\n\n${q.urdu.replace(/#&\d+/g, '')}\n\nStudy more at: ${shareUrl}`; if (navigator.share) { const response = await fetch(imageUrl); const blob = await response.blob(); const file = new File([blob], 'question.png', { type: 'image/png' }); await navigator.share({ title: q.question, text: shareText, files: [file], url: shareUrl }); } else { if (platform === 'facebook') { window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`, '_blank'); } else if (platform === 'twitter') { const mockImageUrl = imageUrl; window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}&url=${encodeURIComponent(mockImageUrl)}`, '_blank'); } else if (platform === 'whatsapp') { const link = document.createElement('a'); link.href = `whatsapp://send?text=${encodeURIComponent(shareText)}`; link.click(); } } } catch (err) { console.error('Error sharing:', err); alert('Sharing failed. Please try again or copy the link manually.'); } } /* ========================================================= */ /* ============ DYNAMIC PDF GENERATION LOGIC =============== */ /* ========================================================= */ async function generateDynamicPDF() { // Check if jsPDF is loaded if (!window.jspdf) { alert("PDF library is loading. Please wait a moment and try again."); return; } // --- UI: START LOADING & SHOW PROGRESS BAR --- const btn = document.getElementById('generatePdfBtn'); const btnText = btn.querySelector('.btn-text'); const btnProgress = btn.querySelector('.progress-bar-fill'); const originalText = "Click here for Download PDF"; btn.disabled = true; // Disable double clicks btnText.textContent = "Initializing..."; btnProgress.style.width = "10%"; // Start progress const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'mm', 'a4'); // Portrait, Millimeters, A4 // 1. Settings & Dimensions const pageWidth = 210; const pageHeight = 297; const marginTop = 30; const marginBottom = 05; const marginLeft = 15; const marginRight = 15; const contentWidth = pageWidth - marginLeft - marginRight; let cursorY = marginTop; // 2. Filter Questions (pdf = true) const pdfQuestions = questions.filter(q => q.pdf === true || (q.getAttribute && q.getAttribute('data-pdf') === "true") ); if (pdfQuestions.length === 0) { alert("No questions marked for PDF found."); // Reset Button btn.disabled = false; btnText.textContent = originalText; btnProgress.style.width = "0%"; return; } // --- UI: UPDATE STATUS --- btnText.textContent = "Downloading Image..."; btnProgress.style.width = "30%"; // 3. Load Background Image const bgUrl = config.pdfBackgroundUrl; let bgImage = null; try { bgImage = await loadImageAsBase64(bgUrl); // Image Loaded Success btnProgress.style.width = "50%"; } catch (e) { console.warn("Background image failed to load, generating PDF without it."); } // --- UI: UPDATE STATUS --- btnText.textContent = "Generating Pages..."; // Helper to Add a new page with background const addNewPage = () => { doc.addPage(); if (bgImage) { doc.addImage(bgImage, 'JPEG', 0, 0, pageWidth, pageHeight); } cursorY = marginTop; // Reset cursor to top margin }; // Add background to the first page if (bgImage) { doc.addImage(bgImage, 'JPEG', 0, 0, pageWidth, pageHeight); } // 4. Iterate and Print Questions pdfQuestions.forEach((q, index) => { // --- A. CALCULATE HEIGHT REQUIRED --- // Question Text Height doc.setFontSize(12); doc.setFont("helvetica", "bold"); const qTitle = `Q${index + 1}: ${q.question}`; const qTitleLines = doc.splitTextToSize(qTitle, contentWidth); const qTitleHeight = qTitleLines.length * 6; // Approx line height 6mm // Options Height doc.setFont("helvetica", "normal"); doc.setFontSize(10); let optionsHeight = 0; const processedOptions = []; q.options.forEach((opt, idx) => { const letter = String.fromCharCode(65 + idx); const optText = `${letter}) ${opt}`; const optLines = doc.splitTextToSize(optText, contentWidth - 5); // Indent slightly const h = optLines.length * 5; // Approx line height 5mm optionsHeight += h + 2; // +2mm padding between options processedOptions.push({ lines: optLines, height: h }); }); const totalQuestionHeight = qTitleHeight + optionsHeight + 8; // +8mm padding after question // --- B. CHECK SPACE & PAGE BREAK --- if (cursorY + totalQuestionHeight > pageHeight - marginBottom) { addNewPage(); } // --- C. RENDER CONTENT --- // Render Question Title doc.setFontSize(12); doc.setTextColor(0, 0, 0); doc.setFont("helvetica", "bold"); doc.text(qTitleLines, marginLeft, cursorY); cursorY += qTitleHeight + 2; // Render Options doc.setFontSize(10); doc.setFont("helvetica", "normal"); processedOptions.forEach((pOpt, idx) => { // Check if this is the correct answer to highlight (Optional visual cue) const letter = String.fromCharCode(65 + idx); if (letter === q.correctAnswer) { doc.setFont("helvetica", "bold"); doc.setTextColor(0, 100, 0); // Green } else { doc.setFont("helvetica", "normal"); doc.setTextColor(0, 0, 0); // Black } doc.text(pOpt.lines, marginLeft + 5, cursorY); cursorY += pOpt.height + 2; }); // Reset color/font and add bottom padding doc.setTextColor(0, 0, 0); cursorY += 6; }); // --- UI: FINALIZING --- btnText.textContent = "Saving PDF..."; btnProgress.style.width = "90%"; // 5. Save File doc.save('PAKMCQs_Questions.pdf'); // --- UI: COMPLETE & RESET --- btnText.textContent = "Downloaded!"; btnProgress.style.width = "100%"; setTimeout(() => { btn.disabled = false; btnText.textContent = originalText; btnProgress.style.width = "0%"; }, 3000); // Reset after 3 seconds } // Helper to load image with CORS handling for Blogger Images function loadImageAsBase64(url) { return new Promise((resolve, reject) => { const img = new Image(); // Ye line zaroori hai taake Google block na kare img.crossOrigin = 'Anonymous'; // URL ke aage time lagaya hai taake browser cache use na kare (Cache breaker) if (url.startsWith('http')) { img.src = url + (url.includes('?') ? '&' : '?') + 't=' + new Date().getTime(); } else { img.src = url; } img.onload = () => { const canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); try { const dataURL = canvas.toDataURL('image/jpeg', 0.8); // High Quality JPG resolve(dataURL); } catch (e) { console.error("CORS Error: Image load hui lekin export nahi ho saki.", e); // Agar phir bhi fail ho jaye to bina image ke continue karega reject(e); } }; img.onerror = (e) => { console.error("Image Failed to Load from URL:", url); reject(e); }; }); } /* ========================================================= */ document.addEventListener('DOMContentLoaded', function () { generateTOC(); // TOC Generate karna currentPage = getCurrentPageFromURL(); changeHeaderImage(config.headerImageUrl); loadQuestions(currentPage); checkScrollOnLoad(); // Scroll Check karna if redirected from another page document.getElementById('toggleAnswersBtn').addEventListener('click', toggleAllAnswers); document.getElementById('resetQuizBtn').addEventListener('click', resetQuiz); document.getElementById('readMoreBtn').addEventListener('click', toggleContentExpansion); document.getElementById('contentTranslateBtn').addEventListener('click', toggleContentLanguage); // === ATTACH PDF GENERATION EVENT === const pdfBtn = document.getElementById('generatePdfBtn'); if (pdfBtn) { pdfBtn.addEventListener('click', function(e) { e.preventDefault(); // Stop any default link behavior generateDynamicPDF(); }); } // =================================== const seeMoreFaqBtn = document.getElementById('seeMoreFaqBtn'); if (seeMoreFaqBtn) { seeMoreFaqBtn.addEventListener('click', function() { const hiddenFaqs = document.querySelectorAll('.hidden-faq'); hiddenFaqs.forEach(faq => { faq.style.display = 'block'; }); seeMoreFaqBtn.style.display = 'none'; }); } }); window.goToPageWithReload = goToPageWithReload;

Related Questions & Quizzes

Recommended for you

PAK MCQs

Prepare Smart

Dark Theme