Reading Progress 0%
0 of 0 articles read
PDF Source: Summary Mode
{ id: "twtw-politics-20261107", issue: DEFAULT_ISSUE_NAME, category: "The world this week", kicker: "Politics", pdfPageStart: 4, pdfPageEnd: 8, title: "Madam Governor!! — Democrats win a midterm landslide", standfirst: "A sweeping blue wave gives Democrats both houses of Congress as war in Iran, inflation and corruption sink Republican incumbents.", date: "Nov 5th 2026", // ... existing code ... { id: "twtw-business-20261107", issue: DEFAULT_ISSUE_NAME, category: "The world this week", kicker: "Business", pdfPageStart: 9, pdfPageEnd: 12, title: "Stocks edge higher on divided government while oil drops and Binance loses $6.3bn", standfirst: "Anthropic commits $895bn to AI compute ahead of its IPO, euro-zone inflation hits 4%, and South Korean chip exports surge.", date: "Nov 5th 2026", // ... existing code ... { id: "twtw-cartoon-20261107", issue: DEFAULT_ISSUE_NAME, category: "The world this week", kicker: "Cartoon", pdfPageStart: 13, pdfPageEnd: 13, title: "Cartoon: The results of the midterms", standfirst: "A lighter take on the news: a King Kong-sized Donald Trump clings to the Capitol dome as Democratic biplanes swarm overhead.", date: "Nov 5th 2026", // ... existing code ... { id: "leaders-cover-20261107", issue: DEFAULT_ISSUE_NAME, category: "Leaders", kicker: "Our cover", pdfPageStart: 15, pdfPageEnd: 20, title: "Donald Trump’s humiliation offers America an opportunity", standfirst: "Voters demand a new way of doing things in Washington. Let them have it", date: "Nov 5th 2026", // ... existing code ... { id: "leaders-haiti-20261107", issue: DEFAULT_ISSUE_NAME, category: "Leaders", kicker: "Cool dictator, hellish hotspot", pdfPageStart: 21, pdfPageEnd: 23, title: "El Salvador’s gangbuster tries his luck in Haiti", standfirst: "The status quo is so dire Nayib Bukele might improve it. But the risks are huge", date: "Nov 5th 2026", // ... existing code ... { id: "leaders-cyber-20261107", issue: DEFAULT_ISSUE_NAME, category: "Leaders", kicker: "Give the good guys guns", pdfPageStart: 24, pdfPageEnd: 27, title: "The world must act to stop a cyber-disaster", standfirst: "Governments should make sure defenders have better models than attackers do", date: "Nov 5th 2026", // ... existing code ... { id: "leaders-medicine-20261107", issue: DEFAULT_ISSUE_NAME, category: "Leaders", kicker: "Markets maketh medicine", pdfPageStart: 28, pdfPageEnd: 30, title: "Patients are acting more like consumers. Good", standfirst: "Health care cannot be an ordinary market. But it could be much more like one", date: "Nov 5th 2026", // ... existing code ... { id: "leaders-porn-20261107", issue: DEFAULT_ISSUE_NAME, category: "Leaders", kicker: "Repeal the porn laws", pdfPageStart: 31, pdfPageEnd: 33, title: "England’s new ban on kinky porn will misfire", standfirst: "Bans make moralists feel good, but will not work as planned", date: "Nov 5th 2026", // ... existing code ... { id: "letters-palaeontology-20261107", issue: DEFAULT_ISSUE_NAME, category: "Letters", kicker: "A selection of correspondence", pdfPageStart: 35, pdfPageEnd: 39, title: "LLMs v palaeontology", standfirst: "Also this week: predatory journals, film critics, preparing for emergencies, London traditions, and AI accounting.", date: "Nov 5th 2026", // ... existing code ... { id: "by-invitation-philipson-20261107", issue: DEFAULT_ISSUE_NAME, category: "By Invitation", kicker: "Vote, splurge", pdfPageStart: 41, pdfPageEnd: 44, title: "Divided government in America will mean more spending, not less", standfirst: "But Democrats will struggle to unwind the president's agenda, writes Tomas Philipson", date: "Nov 5th 2026", // ... existing code ... { id: "by-invitation-kurum-20261107", issue: DEFAULT_ISSUE_NAME, category: "By Invitation", kicker: "Charge!", pdfPageStart: 45, pdfPageEnd: 48, title: "Markets are pushing electrification. Governments must push harder", standfirst: "The transformation can't be left to market forces alone, writes Murat Kurum, president of COP31", date: "Nov 5th 2026", // ... existing code ... { id: "briefing-lame-duck-20261107", issue: DEFAULT_ISSUE_NAME, category: "Briefing", kicker: "After the midterms", pdfPageStart: 50, pdfPageEnd: 61, title: "What will a lame-duck Donald Trump get up to overseas?", standfirst: "Embattled at home, the president will look abroad. That is worrying for the world, but it is not clear what he can achieve for good or ill", date: "Nov 5th 2026", // ... existing code ... { id: "asia-japan-disaster-20261107", issue: DEFAULT_ISSUE_NAME, category: "Asia", kicker: "The next big one", pdfPageStart: 63, pdfPageEnd: 67, title: "Japan prepares for its next natural disaster", standfirst: "Its new agency has plenty to do before a catastrophe strikes", date: "Nov 5th 2026", // ... existing code ... { id: "asia-starlink-myanmar-20261107", issue: DEFAULT_ISSUE_NAME, category: "Asia", kicker: "Weak signal", pdfPageStart: 68, pdfPageEnd: 72, title: "Dead Starlink terminals in Myanmar are getting people killed", standfirst: "Has Elon Musk taken another war zone offline?", date: "Nov 5th 2026", // ... existing code ... { id: "asia-australia-right-20261107", issue: DEFAULT_ISSUE_NAME, category: "Asia", kicker: "Hanson v Hastie", pdfPageStart: 73, pdfPageEnd: 78, title: "The fight for the soul of the Australian right", standfirst: "Can a special-forces veteran stop the rise of Pauline Hanson?", date: "Nov 5th 2026", // ... existing code ... { id: "asia-india-data-20261107", issue: DEFAULT_ISSUE_NAME, category: "Asia", kicker: "Ashoka", pdfPageStart: 79, pdfPageEnd: 81, title: "Cheap data is great for Indians but not for India’s reputation", standfirst: "The internet brings out the worst in everyone", date: "Nov 5th 2026", // ... existing code ... { id: "china-ai-labs-20261107", issue: DEFAULT_ISSUE_NAME, category: "China", kicker: "No hands on deck", pdfPageStart: 83, pdfPageEnd: 87, title: "With an eye on America, China is beefing up its AI-controlled labs", standfirst: "By automating scientific research it hopes to strengthen its industrial muscle", date: "Nov 5th 2026", // ... existing code ... { id: "china-sun-yat-sen-20261107", issue: DEFAULT_ISSUE_NAME, category: "China", kicker: "Solar cooling", pdfPageStart: 88, pdfPageEnd: 89, title: "China and Taiwan are fighting over Sun Yat-sen", standfirst: "The 160th birthday of the nationalist revolutionary will be unusually fraught", date: "Nov 5th 2026", // ... existing code ... { id: "china-podcasts-20261107", issue: DEFAULT_ISSUE_NAME, category: "China", kicker: "Youth culture", pdfPageStart: 90, pdfPageEnd: 93, title: "Hit podcasts reveal the angst of China’s youth", standfirst: "The government is getting twitchy about their growing popularity", date: "Nov 5th 2026", // ... existing code ... { id: "china-chaguan-20261107", issue: DEFAULT_ISSUE_NAME, category: "China", kicker: "Chaguan", pdfPageStart: 94, pdfPageEnd: 97, title: "A new path to political power in China runs through state firms", standfirst: "China Inc has become a breeding ground for up-and-coming officials", date: "Nov 5th 2026", // ... existing code ... { id: "us-democrats-power-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "Subpoena season", pdfPageStart: 99, pdfPageEnd: 103, title: "How the Democrats will wield their power", standfirst: "The party has control of Congress, at last. Now it must govern", date: "Nov 5th 2026", // ... existing code ... { id: "us-landslide-numbers-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "By the numbers", pdfPageStart: 104, pdfPageEnd: 112, title: "The Democrats have won the biggest congressional landslide in 50 years", standfirst: "Black, Hispanic and young voters helped power the party’s victory", date: "Nov 5th 2026", // ... existing code ... { id: "us-texas-revolution-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "Lone Star politics", pdfPageStart: 113, pdfPageEnd: 116, title: "A political revolution in Texas", standfirst: "What will Democrats do with control of America’s most iconic red state?", date: "Nov 5th 2026", // ... existing code ... { id: "us-prairie-fire-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "Plains-speaking", pdfPageStart: 117, pdfPageEnd: 119, title: "The prairie fire behind the Democrats’ big win", standfirst: "Wins in Iowa and Kansas revived the left’s rural populism", date: "Nov 5th 2026", // ... existing code ... { id: "us-el-sayed-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "Moderates v Progressives", pdfPageStart: 120, pdfPageEnd: 122, title: "Hero or liability? The debate over Abdul El-Sayed", standfirst: "Michigan’s pugnacious populist wants to shake up the Democratic Party", date: "Nov 5th 2026", // ... existing code ... { id: "us-lexington-20261107", issue: DEFAULT_ISSUE_NAME, category: "United States", kicker: "Lexington", pdfPageStart: 123, pdfPageEnd: 126, title: "Republicans are in for a brutal presidential contest", standfirst: "And Democrats suddenly have a unifying agenda", date: "Nov 5th 2026", // ... existing code ... { id: "americas-haiti-bukele-20261107", issue: DEFAULT_ISSUE_NAME, category: "The Americas", kicker: "Gangbusters", pdfPageStart: 128, pdfPageEnd: 132, title: "El Salvador’s president thinks he can eliminate Haiti’s gangs", standfirst: "Nayib Bukele has dispatched 2,000 troops to the island", date: "Nov 5th 2026", // ... existing code ... { id: "americas-brazil-janones-20261107", issue: DEFAULT_ISSUE_NAME, category: "The Americas", kicker: "Brazil’s election", pdfPageStart: 133, pdfPageEnd: 135, title: "André ‘Mad Dog’ Janones is a hero of the Brazilian left", standfirst: "Can politicians elsewhere in the world replicate his online campaigns?", date: "Nov 5th 2026", // ... existing code ... { id: "americas-pope-tour-20261107", issue: DEFAULT_ISSUE_NAME, category: "The Americas", kicker: "Long time no see", pdfPageStart: 136, pdfPageEnd: 140, title: "Can the pope’s tour of Latin America win back disenchanted youth?", standfirst: "Feminism and mysticism are providing reasons to question the faith", date: "Nov 5th 2026", // ... existing code ... { id: "americas-paraguay-ueno-20261107", issue: DEFAULT_ISSUE_NAME, category: "The Americas", kicker: "Ueno no more", pdfPageStart: 141, pdfPageEnd: 144, title: "Paraguay’s swaggering digital bank has fallen", standfirst: "The president could be next (Editor's note: Santiago Peña resigned shortly after publication)", date: "Nov 5th 2026", // ... existing code ... { id: "mea-ebola-20261107", issue: DEFAULT_ISSUE_NAME, category: "Middle East & Africa", kicker: "Viral loads", pdfPageStart: 146, pdfPageEnd: 150, title: "The latest Ebola outbreak could be the worst ever", standfirst: "New cases in Kenya and Nigeria show that the outbreak is unchecked", date: "Nov 5th 2026", // ... existing code ... { id: "mea-digital-identities-20261107", issue: DEFAULT_ISSUE_NAME, category: "Middle East & Africa", kicker: "Digital ghosts", pdfPageStart: 151, pdfPageEnd: 154, title: "Hackers are exploiting Africa’s digital identities", standfirst: "Governments are embracing new databases. So are criminals", date: "Nov 5th 2026", // ... existing code ... { id: "mea-iran-allies-20261107", issue: DEFAULT_ISSUE_NAME, category: "Middle East & Africa", kicker: "Nervous neighbours", pdfPageStart: 155, pdfPageEnd: 157, title: "America’s allies oppose more war in Iran. They may not get a say", standfirst: "Economies are shrinking and a deal remains elusive", date: "Nov 5th 2026", // ... existing code ... { id: "mea-gulf-defences-20261107", issue: DEFAULT_ISSUE_NAME, category: "Middle East & Africa", kicker: "Out of rounds", pdfPageStart: 158, pdfPageEnd: 161, title: "Gulf states brace for war with Iran—again", standfirst: "Their air defences are dangerously depleted", date: "Nov 5th 2026", // ... existing code ... { id: "mea-houthis-20261107", issue: DEFAULT_ISSUE_NAME, category: "Middle East & Africa", kicker: "Extreme DIY", pdfPageStart: 162, pdfPageEnd: 166, title: "How the Houthis built their war machine", standfirst: "The rebels in Yemen are outgrowing their dependence on their patron", date: "Nov 5th 2026", // ... existing code ... { id: "europe-ukraine-demography-20261107", issue: DEFAULT_ISSUE_NAME, category: "Europe", kicker: "No babies, boom", pdfPageStart: 168, pdfPageEnd: 174, title: "War-battered Ukraine risks a demographic collapse", standfirst: "Birth rates are plunging and Russia is celebrating", date: "Nov 5th 2026", // ... existing code ... { id: "europe-berlin-apartments-20261107", issue: DEFAULT_ISSUE_NAME, category: "Europe", kicker: "The means of habitation", pdfPageStart: 175, pdfPageEnd: 178, title: "The leftists who want to seize Berlin’s apartments", standfirst: "Die Linke’s radicalism makes it hard for it to form a coalition", date: "Nov 5th 2026", // ... existing code ... { id: "europe-poland-courts-20261107", issue: DEFAULT_ISSUE_NAME, category: "Europe", kicker: "Quagmire", pdfPageStart: 179, pdfPageEnd: 182, title: "Will Poland’s war over the rule of law ever end?", standfirst: "Liberals and populists are locked in an eternal struggle over the courts", date: "Nov 5th 2026", // ... existing code ... { id: "europe-france-countryside-20261107", issue: DEFAULT_ISSUE_NAME, category: "Europe", kicker: "Fermenting discontent", pdfPageStart: 183, pdfPageEnd: 187, title: "France’s unhappy countryside turns to the populist right", standfirst: "In long-suffering villages, Marine Le Pen has come to stand for hope", date: "Nov 5th 2026", // ... existing code ... { id: "britain-burnham-foreign-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Politics", pdfPageStart: 189, pdfPageEnd: 193, title: "Andy Burnham promises three foreign-policy overhauls", standfirst: "He speaks to The Economist. In Antigua, of all places", date: "Nov 5th 2026", // ... existing code ... { id: "britain-king-charles-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "To bleat or not to bleat?", pdfPageStart: 194, pdfPageEnd: 198, title: "How is King Charles III doing?", standfirst: "Quite well. Not least because he has stopped complaining", date: "Nov 5th 2026", // ... existing code ... { id: "britain-porn-evidence-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Sexual behaviour", pdfPageStart: 199, pdfPageEnd: 201, title: "Britain’s ban on some pornography is based on flimsy evidence", standfirst: "Once again, correlation and causation are not the same", date: "Nov 5th 2026", // ... existing code ... { id: "britain-immigration-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Immigration policy", pdfPageStart: 202, pdfPageEnd: 206, title: "Britain makes the path to permanent residence more arduous", standfirst: "It is unlikely to save the 'billions' that the government claims", date: "Nov 5th 2026", // ... existing code ... { id: "britain-seabirds-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Seabirds", pdfPageStart: 207, pdfPageEnd: 208, title: "Spare a thought for the European shag", standfirst: "But other seabirds off Britain’s coast are showing signs of resilience", date: "Nov 5th 2026", // ... existing code ... { id: "britain-vc-adonis-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Venture capital", pdfPageStart: 209, pdfPageEnd: 213, title: "Investor seeks AI Adonis", standfirst: "British venture capital resembles a cruel dating game", date: "Nov 5th 2026", // ... existing code ... { id: "britain-bagehot-20261107", issue: DEFAULT_ISSUE_NAME, category: "Britain", kicker: "Bagehot", pdfPageStart: 214, pdfPageEnd: 217, title: "Britain’s landlords deserve some love", standfirst: "Who will speak for the HMO Hero?", date: "Nov 5th 2026", // ... existing code ... { id: "intl-islam-digital-20261107", issue: DEFAULT_ISSUE_NAME, category: "International", kicker: "Virtual virtue", pdfPageStart: 219, pdfPageEnd: 225, title: "The digital world is making Islam more diverse", standfirst: "Muslims are young, online and playing by their own rules", date: "Nov 5th 2026", // ... existing code ... { id: "intl-europe-nationalism-20261107", issue: DEFAULT_ISSUE_NAME, category: "International", kicker: "The Telegram", pdfPageStart: 226, pdfPageEnd: 229, title: "Fear united Europe. Nationalism may tear it apart", standfirst: "Donald Trump and Vladimir Putin made Europe serious about its own defences. That may not last", date: "Nov 5th 2026", // ... existing code ... { id: "biz-ai-cyber-threats-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Hack to the future", pdfPageStart: 231, pdfPageEnd: 237, title: "Firms are racing to protect themselves from AI cyber threats", standfirst: "Hackers have unleashed a devastating wave of attacks. More may follow", date: "Nov 5th 2026", // ... existing code ... { id: "biz-ai-makers-cash-in-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Protection money", pdfPageStart: 238, pdfPageEnd: 240, title: "As hackers run riot with AI, its makers want to cash in", standfirst: "OpenAI and Anthropic spy a big opportunity in cyber-security", date: "Nov 5th 2026", // ... existing code ... { id: "biz-aramco-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Barrelling along", pdfPageStart: 241, pdfPageEnd: 244, title: "Besieged by war, Saudi Aramco continues to gush profits", standfirst: "Higher oil prices comfortably make up for bombed facilities", date: "Nov 5th 2026", // ... existing code ... { id: "biz-doordash-instacart-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Shopping spree", pdfPageStart: 245, pdfPageEnd: 247, title: "Can a DoorDash-Instacart fusion stand up to Amazon and Walmart?", standfirst: "The proposed merger shows the danger that delivery startups face", date: "Nov 5th 2026", // ... existing code ... { id: "biz-bartleby-curiosity-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Bartleby", pdfPageStart: 248, pdfPageEnd: 251, title: "Is curiosity all it’s cooked up to be?", standfirst: "A quality that everyone lauds has its complexities", date: "Nov 5th 2026", // ... existing code ... { id: "biz-freeport-copper-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Scratching the surface", pdfPageStart: 252, pdfPageEnd: 257, title: "America’s copper giant has big dreams—but cautious plans", standfirst: "Freeport-McMoRan’s strategy hints at doubts that prices will continue to rise", date: "Nov 5th 2026", // ... existing code ... { id: "biz-cvs-breakup-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Careworn", pdfPageStart: 258, pdfPageEnd: 261, title: "The break-up of CVS marks a turning point in American health care", standfirst: "The trend towards vertical integration may soon reverse", date: "Nov 5th 2026", // ... existing code ... { id: "biz-immortality-20261107", issue: DEFAULT_ISSUE_NAME, category: "Business", kicker: "Forever bound", pdfPageStart: 262, pdfPageEnd: 268, title: "The quest for immortality has become serious business", standfirst: "As entrepreneurs peddle scans and supplements, biotechs are probing the mysteries of ageing", date: "Nov 5th 2026", // ... existing code ... { id: "fin-ai-free-trade-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Globalisation strikes back", pdfPageStart: 270, pdfPageEnd: 276, title: "AI is turning protectionists into free traders", standfirst: "Barriers to commerce are rising—except in technology", date: "Nov 5th 2026", // ... existing code ... { id: "fin-intensive-parenting-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Tiger mothers of the world, unite", pdfPageStart: 277, pdfPageEnd: 282, title: "Intensive parenting is no longer the preserve of the rich", standfirst: "But wealthy families still come out on top", date: "Nov 5th 2026", // ... existing code ... { id: "fin-us-renters-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Past due", pdfPageStart: 283, pdfPageEnd: 288, title: "America’s renters are in serious trouble", standfirst: "Several gauges of their financial health are flashing red", date: "Nov 5th 2026", // ... existing code ... { id: "fin-markets-midterms-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Waves and ripples", pdfPageStart: 289, pdfPageEnd: 293, title: "What markets make of the midterms", standfirst: "Democrats triumph. Investors yawn", date: "Nov 5th 2026", // ... existing code ... { id: "fin-china-tycoons-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Collateral damage", pdfPageStart: 294, pdfPageEnd: 296, title: "Indebted tycoons haunt China’s banking system", standfirst: "Lenders are feeling the hangover from years of Wild East capitalism", date: "Nov 5th 2026", // ... existing code ... { id: "fin-buttonwood-china-ai-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Buttonwood", pdfPageStart: 297, pdfPageEnd: 299, title: "China’s AI stock-market struggles are a warning", standfirst: "What happens when the supply of new tech catches up with demand?", date: "Nov 5th 2026", // ... existing code ... { id: "fin-free-exchange-nordhaus-20261107", issue: DEFAULT_ISSUE_NAME, category: "Finance & economics", kicker: "Free Exchange", pdfPageStart: 300, pdfPageEnd: 303, title: "William Nordhaus, favourite economist of the right and the left", standfirst: "The Nobel-prizewinner was fascinated by what happens when markets fail", date: "Nov 5th 2026", // ... existing code ... { id: "sci-little-red-dots-20261107", issue: DEFAULT_ISSUE_NAME, category: "Science & technology", kicker: "Connecting the dots", pdfPageStart: 305, pdfPageEnd: 310, title: "Astronomers are mystified by little red dots in the sky", standfirst: "They could be the universe’s first supermassive black holes", date: "Nov 5th 2026", // ... existing code ... { id: "sci-ai-tinker-brains-20261107", issue: DEFAULT_ISSUE_NAME, category: "Science & technology", kicker: "Weights and measures", pdfPageStart: 311, pdfPageEnd: 312, title: "AI models can tinker with one another’s brains", standfirst: "For now, the tweaks are relatively small-scale", date: "Nov 5th 2026", // ... existing code ... { id: "sci-drones-sigint-20261107", issue: DEFAULT_ISSUE_NAME, category: "Science & technology", kicker: "Ears in the sky", pdfPageStart: 313, pdfPageEnd: 315, title: "Drones don’t just blow up the enemy", standfirst: "They can also pick up on radio transmissions to identify future targets", date: "Nov 5th 2026", // ... existing code ... { id: "sci-openai-maths-20261107", issue: DEFAULT_ISSUE_NAME, category: "Science & technology", kicker: "Show your working", pdfPageStart: 316, pdfPageEnd: 318, title: "OpenAI’s approach to mathematics does not add up", standfirst: "Two months after the firm’s initial advances, its lack of transparency is still causing problems", date: "Nov 5th 2026", // ... existing code ... { id: "sci-brown-rice-20261107", issue: DEFAULT_ISSUE_NAME, category: "Science & technology", kicker: "Well Informed", pdfPageStart: 319, pdfPageEnd: 321, title: "Is brown rice really healthier than white rice?", standfirst: "The scientific evidence goes against the grain", date: "Nov 5th 2026", // ... existing code ... { id: "culture-childlessness-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "(Don’t) be my baby", pdfPageStart: 323, pdfPageEnd: 327, title: "Is childlessness contagious?", standfirst: "A new book offers some surprising reasons people aren’t having children", date: "Nov 5th 2026", // ... existing code ... { id: "culture-newborn-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "Born wild", pdfPageStart: 328, pdfPageEnd: 330, title: "What is it like to be a newborn?", standfirst: "Nobody can quite say. But a new book tries to figure it out", date: "Nov 5th 2026", // ... existing code ... { id: "culture-claridges-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "Fit for a king", pdfPageStart: 331, pdfPageEnd: 333, title: "What goes on behind the doors of Claridge’s?", standfirst: "A new book gives readers a key card to the storied hotel’s past", date: "Nov 5th 2026", // ... existing code ... { id: "culture-remote-work-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "In praise of watercoolers", pdfPageStart: 334, pdfPageEnd: 336, title: "Is it time to end the era of remote work?", standfirst: "A new book makes a case for getting out of your tracksuit and into your officewear", date: "Nov 5th 2026", // ... existing code ... { id: "culture-china-africa-tech-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "Bigger brother", pdfPageStart: 337, pdfPageEnd: 339, title: "Chinese tech helps repressive African governments crush dissent", standfirst: "A fascinating new book investigates the cause and effects of China’s investment in Africa", date: "Nov 5th 2026", // ... existing code ... { id: "culture-max-richter-20261107", issue: DEFAULT_ISSUE_NAME, category: "Culture", kicker: "A sonic sweet spot", pdfPageStart: 340, pdfPageEnd: 343, title: "Explaining the popularity of Max Richter’s compositions", standfirst: "The classical composer manages to spin even serious subjects into gold", date: "Nov 5th 2026", // ... existing code ... { id: "indicators-20261107", issue: DEFAULT_ISSUE_NAME, category: "Economic & financial indicators", kicker: "Indicators", pdfPageStart: 345, pdfPageEnd: 349, title: "Economic data, commodities and markets", standfirst: "Output, prices and jobs; trade, exchange rates, budget balances and interest rates; The Economist commodity-price index; and global equity markets.", date: "Nov 5th 2026", // ... existing code ... { id: "obituary-huerta-20261107", issue: DEFAULT_ISSUE_NAME, category: "Obituary", kicker: "Truth and power", pdfPageStart: 351, pdfPageEnd: 354, title: "Dolores Huerta fought for farm-workers’ rights—and kept devastating secrets", standfirst: "The labour activist died on October 28th, aged 96", date: "Nov 5th 2026", // ... existing code ... let appState = { articles: [...INITIAL_ARTICLES], readIds: [], bookmarkedIds: [], notes: {}, // { [articleId]: "user note text" } customImages: {}, // { [articleId]: [{ dataUrl, caption }] } selectedIssue: DEFAULT_ISSUE_NAME, selectedSection: "ALL", queueFilter: "all", // 'all' | 'unread' | 'bookmarked' searchQuery: "", activeArticleId: null, isEditingArticle: false, showInlinePdfPages: false, splitPdfOpen: false, splitPdfPage: 1, splitPdfScale: 1.15, fontSize: "M" // 'S' | 'M' | 'L' | 'XL' }; // ========================================================================= // CLIENT-SIDE PDF.JS & INDEXEDDB ENGINE (100% LOCAL IN BROWSER) // ========================================================================= if (window.pdfjsLib) { window.pdfjsLib.GlobalWorkerOptions.workerSrc = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js"; } const PDF_DB_NAME = "EconomistWeeklyPDFStore_v1"; const PDF_STORE_NAME = "issuePdfs"; let activePdfDoc = null; let activePdfIssue = null; let activePdfFileName = ""; function openPdfIndexedDB() { return new Promise((resolve, reject) => { const req = indexedDB.open(PDF_DB_NAME, 1); req.onupgradeneeded = () => { const db = req.result; if (!db.objectStoreNames.contains(PDF_STORE_NAME)) { db.createObjectStore(PDF_STORE_NAME, { keyPath: "issue" }); } }; req.onsuccess = () => resolve(req.result); req.onerror = () => reject(req.error); }); } async function savePdfBinaryToIndexedDB(issue, fileName, arrayBuffer) { try { const db = await openPdfIndexedDB(); return await new Promise((resolve, reject) => { const tx = db.transaction(PDF_STORE_NAME, "readwrite"); tx.objectStore(PDF_STORE_NAME).put({ issue, fileName, data: arrayBuffer, savedAt: Date.now() }); tx.oncomplete = () => resolve(true); tx.onerror = () => reject(tx.error); }); } catch (e) { console.warn("IndexedDB save warning:", e); return false; } } async function loadPdfBinaryFromIndexedDB(issue) { try { const db = await openPdfIndexedDB(); return await new Promise((resolve, reject) => { const tx = db.transaction(PDF_STORE_NAME, "readonly"); const req = tx.objectStore(PDF_STORE_NAME).get(issue); req.onsuccess = () => resolve(req.result || null); req.onerror = () => reject(req.error); }); } catch (e) { return null; } } async function hydratePdfForSelectedIssue() { const targetIssue = appState.selectedIssue === "ALL" ? DEFAULT_ISSUE_NAME : appState.selectedIssue; if (activePdfDoc && activePdfIssue === targetIssue) { updatePdfStatusUI(); return; } const record = await loadPdfBinaryFromIndexedDB(targetIssue); if (record && record.data && window.pdfjsLib) { try { const loadingTask = window.pdfjsLib.getDocument({ data: record.data.slice(0) }); activePdfDoc = await loadingTask.promise; activePdfIssue = targetIssue; activePdfFileName = record.fileName || "Weekly Edition.pdf"; } catch (err) { activePdfDoc = null; activePdfIssue = null; } } else { activePdfDoc = null; activePdfIssue = null; activePdfFileName = ""; } updatePdfStatusUI(); if (appState.activeArticleId) { openReader(appState.activeArticleId); } } function updatePdfStatusUI() { const badge = document.getElementById("pdf-status-badge"); const btnLabel = document.getElementById("load-pdf-btn-label"); const scoped = getIssueScopedArticles(); const fullTextCount = scoped.filter(a => a.hasFullPdfText).length; if (activePdfDoc) { if (badge) { badge.textContent = `PDF Ready (${activePdfDoc.numPages}p)`; badge.className = "font-bold text-emerald-900 bg-emerald-100 px-2 py-0.5 rounded-full"; } if (btnLabel) btnLabel.textContent = "PDF Loaded ✓"; } else if (fullTextCount > 0) { if (badge) { badge.textContent = `Full Text (${fullTextCount}/${scoped.length})`; badge.className = "font-bold text-emerald-900 bg-emerald-100 px-2 py-0.5 rounded-full"; } if (btnLabel) btnLabel.textContent = "Load Issue PDF"; } else { if (badge) { badge.textContent = "Summary Mode"; badge.className = "font-bold text-amber-800 bg-amber-100 px-2 py-0.5 rounded-full"; } if (btnLabel) btnLabel.textContent = "Load Issue PDF"; } } function normalizeTextForMatch(str) { return String(str || "") .toLowerCase() .replace(/[’‘'“”"—–\-:?!.,;()\[\]]/g, " ") .replace(/\s+/g, " ") .trim(); } function cleanExtractedPageParagraphs(rawPageStrings) { const joined = rawPageStrings.join("\n"); const lines = joined .split(/\n+/) .map(l => l.trim()) .filter(l => { if (!l) return false; if (/^This article was downloaded by zlibrary/i.test(l)) return false; if (/^https?:\/\/www\.economist\.com/i.test(l)) return false; if (/^https?:\/\/t\.me\//i.test(l)) return false; if (/^\[Page \d+\]$/i.test(l)) return false; return true; }); const paragraphs = []; let current = ""; for (const line of lines) { if (!current) { current = line; } else if (/[.!?。”’"■]$/.test(current) && /^[A-Z“"‘'0-9]/.test(line) && current.length > 140) { paragraphs.push(current.trim()); current = line; } else if (current.endsWith("-")) { current = current.slice(0, -1) + line; } else { current += " " + line; } } if (current.trim()) paragraphs.push(current.trim()); return paragraphs.filter(p => p.length > 25); } async function processUploadedIssuePdf(file) { if (!file) return; if (!window.pdfjsLib) { notify("PDF.js library is still loading. Please try again in a second."); return; } const modal = document.getElementById("pdf-progress-modal"); const bar = document.getElementById("pdf-progress-bar"); const pagesLbl = document.getElementById("pdf-progress-pages"); const pctLbl = document.getElementById("pdf-progress-pct"); const detailLbl = document.getElementById("pdf-progress-detail"); modal.classList.remove("hidden"); modal.classList.add("flex"); try { const arrayBuffer = await file.arrayBuffer(); const pdf = await window.pdfjsLib.getDocument({ data: arrayBuffer.slice(0) }).promise; const numPages = pdf.numPages; const pageTexts = new Array(numPages + 1).fill(""); for (let p = 1; p <= numPages; p++) { const page = await pdf.getPage(p); const content = await page.getTextContent(); let lastY = null; let pageStr = ""; for (const item of content.items) { const y = item.transform ? item.transform[5] : null; if (lastY !== null && y !== null && Math.abs(y - lastY) > 6) { pageStr += "\n"; } else if (pageStr && !pageStr.endsWith(" ") && !pageStr.endsWith("\n")) { pageStr += " "; } pageStr += item.str; lastY = y; } pageTexts[p] = pageStr; if (p % 8 === 0 || p === numPages) { const pct = Math.round((p / numPages) * 100); bar.style.width = `${pct}%`; pagesLbl.textContent = `Page ${p} / ${numPages}`; pctLbl.textContent = `${pct}%`; } } detailLbl.textContent = "Mapping all 19 Page-2 sections and extracting full article bodies..."; // Detect Issue Date from Page 1 const p1Clean = pageTexts[1].replace(/\s+/g, " ").trim(); const issueDateMatch = p1Clean.match(/([A-Z]+\s+\d+(?:ST|ND|RD|TH)?\s*[-–]\s*\d+(?:ST|ND|RD|TH)?\s+\d{4})/i); let detectedIssue = DEFAULT_ISSUE_NAME; if (issueDateMatch) { const rawIss = issueDateMatch[1]; // Check if matches default Nov 7th-13th 2026 if (/NOVEMBER\s+7TH\s*[-–]\s*13TH\s+2026/i.test(rawIss)) { detectedIssue = DEFAULT_ISSUE_NAME; } else { detectedIssue = rawIss.replace(/\b\w+/g, w => w[0].toUpperCase() + w.slice(1).toLowerCase()); } } // Save PDF binary to IndexedDB under detectedIssue await savePdfBinaryToIndexedDB(detectedIssue, file.name, arrayBuffer); activePdfDoc = pdf; activePdfIssue = detectedIssue; activePdfFileName = file.name; // Parse section divider pages and article start pages across the PDF const sectionDividerPages = {}; for (let p = 3; p <= numPages; p++) { const lines = pageTexts[p].split("\n").map(s => s.trim()).filter(Boolean); if (lines.length >= 2 && lines.length <= 16) { const matchedSec = PAGE_2_SECTIONS.find(sec => normalizeTextForMatch(lines[0]) === normalizeTextForMatch(sec)); if (matchedSec && !sectionDividerPages[matchedSec]) { sectionDividerPages[matchedSec] = p; } } } // Match existing articles in this issue or discover new articles dynamically const existingForIssue = appState.articles.filter(a => a.issue === detectedIssue); if (existingForIssue.length > 0) { // Match each pre-mapped article to its exact page range in the PDF const sortedArticles = [...existingForIssue].sort((a, b) => (a.pdfPageStart || 999) - (b.pdfPageStart || 999)); for (let i = 0; i < sortedArticles.length; i++) { const art = sortedArticles[i]; let startP = art.pdfPageStart || 4; const normTitle = normalizeTextForMatch(art.title).slice(0, 36); // Refine start page by searching nearby pages for (let p = Math.max(3, startP - 3); p <= Math.min(numPages, startP + 5); p++) { if (normTitle.length > 10 && normalizeTextForMatch(pageTexts[p]).includes(normTitle)) { startP = p; break; } } let endP = art.pdfPageEnd || startP; if (i + 1 < sortedArticles.length && sortedArticles[i + 1].pdfPageStart) { endP = Math.max(startP, sortedArticles[i + 1].pdfPageStart - 1); } // Also stop before any next section divider page for (let p = startP + 1; p <= Math.min(numPages, endP + 2); p++) { const firstLine = (pageTexts[p].split("\n").map(s => s.trim()).filter(Boolean)[0]) || ""; if (PAGE_2_SECTIONS.some(sec => normalizeTextForMatch(firstLine) === normalizeTextForMatch(sec))) { endP = p - 1; break; } } const slicePages = []; for (let p = startP; p <= Math.min(numPages, endP); p++) { slicePages.push(pageTexts[p]); } const extractedParas = cleanExtractedPageParagraphs(slicePages); // Strip leading rubric/title/date header lines from first paragraph if duplicated if (extractedParas.length > 0) { art.pdfPageStart = startP; art.pdfPageEnd = endP; art.body = extractedParas; art.hasFullPdfText = true; } } } else { // New weekly issue PDF: auto-extract all sections and articles from Page 3..numPages const extractedArticles = []; let currentSec = PAGE_2_SECTIONS[0]; let currentArt = null; for (let p = 3; p <= numPages; p++) { const lines = pageTexts[p].split("\n").map(s => s.trim()).filter(Boolean); if (lines.length === 0) continue; // Check if this page is a Section Table of Contents divider const divSec = PAGE_2_SECTIONS.find(sec => normalizeTextForMatch(lines[0]) === normalizeTextForMatch(sec)); if (divSec && lines.length <= 16) { if (currentArt) { currentArt.pdfPageEnd = p - 1; extractedArticles.push(currentArt); currentArt = null; } currentSec = divSec; continue; } // Check if a new article starts on this page ("Section | Rubric" or "Section") const headerLine = lines[0]; const secPrefix = PAGE_2_SECTIONS.find(sec => normalizeTextForMatch(headerLine).startsWith(normalizeTextForMatch(sec)) && headerLine.length < sec.length + 45 ); if (secPrefix && lines.length >= 3) { if (currentArt) { currentArt.pdfPageEnd = p - 1; extractedArticles.push(currentArt); } currentSec = secPrefix; const parts = headerLine.split("|").map(s => s.trim()); const kicker = parts[1] || currentSec; const title = lines[1] || `${currentSec} Article (p. ${p})`; const standfirst = lines[2] && !/^[A-Z][a-z]{2}\s+\d+/.test(lines[2]) ? lines[2] : ""; const dateLine = lines.find(l => /^[A-Z][a-z]{2}\s+\d+(?:st|nd|rd|th)?\s+20\d{2}/.test(l)) || detectedIssue; currentArt = { id: `pdf-${detectedIssue.replace(/\W+/g, "")}-p${p}`, issue: detectedIssue, category: currentSec, kicker, pdfPageStart: p, pdfPageEnd: p, title, standfirst, date: dateLine, rawPages: [pageTexts[p]], hasFullPdfText: true }; } else if (currentArt) { currentArt.pdfPageEnd = p; currentArt.rawPages.push(pageTexts[p]); } } if (currentArt) extractedArticles.push(currentArt); extractedArticles.forEach(a => { a.body = cleanExtractedPageParagraphs(a.rawPages || []); delete a.rawPages; if (a.body.length === 0) a.body = ["View original PDF pages above for full layout and charts."]; appState.articles.unshift(a); }); } appState.selectedIssue = detectedIssue; persistAppState(); renderIssueDropdowns(); renderSidebar(); updatePdfStatusUI(); if (appState.activeArticleId) { openReader(appState.activeArticleId); } else { renderFeed(); } modal.classList.add("hidden"); modal.classList.remove("flex"); notify(`Loaded "${file.name}" (${numPages} pages) — Full text & PDF pages unlocked!`); } catch (err) { console.error("PDF parse error:", err); modal.classList.add("hidden"); modal.classList.remove("flex"); notify("Could not read PDF file. Please ensure it is a valid PDF."); } } async function renderPdfPageToCanvas(pageNum, canvas, desiredWidth) { if (!activePdfDoc || !canvas) return; const safePage = Math.max(1, Math.min(activePdfDoc.numPages, pageNum)); const page = await activePdfDoc.getPage(safePage); const unscaledViewport = page.getViewport({ scale: 1 }); const scale = desiredWidth ? (desiredWidth / unscaledViewport.width) : 1.25; const dpr = Math.min(window.devicePixelRatio || 1, 2); const viewport = page.getViewport({ scale: scale * dpr }); canvas.width = Math.floor(viewport.width); canvas.height = Math.floor(viewport.height); canvas.style.width = `${Math.floor(viewport.width / dpr)}px`; canvas.style.height = `${Math.floor(viewport.height / dpr)}px`; const ctx = canvas.getContext("2d"); await page.render({ canvasContext: ctx, viewport }).promise; } async function renderInlinePdfPagesForArticle(article) { const container = document.getElementById("inline-pdf-pages-container"); const listEl = document.getElementById("inline-pdf-pages-canvas-list"); const heading = document.getElementById("inline-pdf-pages-heading"); if (!appState.showInlinePdfPages || !article) { container.classList.add("hidden"); return; } container.classList.remove("hidden"); const startP = article.pdfPageStart || 1; const endP = article.pdfPageEnd || startP; heading.textContent = `Original PDF Pages ${startP}–${endP}`; if (!activePdfDoc) { listEl.innerHTML = `

Load your local weekly PDF file (The Economist (Web Edition)_0711.pdf) once to view pages ${startP}–${endP} in high resolution right inside this article.

`; return; } listEl.innerHTML = ""; const maxPagesToRender = Math.min(endP, startP + 9); // Render up to 10 pages per article inline const targetWidth = Math.min(680, listEl.clientWidth || 640); for (let p = startP; p <= maxPagesToRender; p++) { const wrapper = document.createElement("div"); wrapper.className = "bg-white border border-econ-rule rounded-lg p-2 shadow-2xs space-y-1.5"; const topBar = document.createElement("div"); topBar.className = "flex items-center justify-between px-2 py-1 text-[11px] font-semibold text-econ-muted"; topBar.innerHTML = `PDF Page ${p}`; const capBtn = document.createElement("button"); capBtn.type = "button"; capBtn.className = "text-econ-red hover:underline font-semibold"; capBtn.textContent = "+ Pin Page Image to Article"; capBtn.onclick = () => capturePdfPageIntoArticle(p, article.id); topBar.appendChild(capBtn); const canvas = document.createElement("canvas"); canvas.className = "w-full h-auto block rounded-xs"; wrapper.appendChild(topBar); wrapper.appendChild(canvas); listEl.appendChild(wrapper); await renderPdfPageToCanvas(p, canvas, targetWidth); } } async function capturePdfPageIntoArticle(pageNum, articleId) { if (!activePdfDoc || !articleId) return; const tempCanvas = document.createElement("canvas"); await renderPdfPageToCanvas(pageNum, tempCanvas, 900); const dataUrl = tempCanvas.toDataURL("image/jpeg", 0.86); if (!appState.customImages[articleId]) appState.customImages[articleId] = []; appState.customImages[articleId].push({ dataUrl, caption: `Original Edition — PDF Page ${pageNum}` }); persistAppState(); openReader(articleId); notify(`Captured PDF Page ${pageNum} into article!`); } async function renderSplitPdfViewer() { const wrapper = document.getElementById("reader-wrapper"); const grid = document.getElementById("reader-split-grid"); const pane = document.getElementById("split-pdf-pane"); const btn = document.getElementById("reader-split-pdf-btn"); const emptyBox = document.getElementById("split-pdf-empty"); const canvas = document.getElementById("split-pdf-canvas"); if (!appState.splitPdfOpen) { pane.classList.add("hidden"); grid.classList.remove("lg:grid-cols-2"); wrapper.classList.remove("max-w-none"); if (btn) { btn.classList.remove("bg-econ-red", "text-white", "border-econ-red"); btn.classList.add("bg-econ-paper", "text-econ-ink"); } return; } pane.classList.remove("hidden"); grid.classList.add("lg:grid-cols-2"); wrapper.classList.add("max-w-none"); if (btn) { btn.classList.add("bg-econ-red", "text-white", "border-econ-red"); btn.classList.remove("bg-econ-paper", "text-econ-ink"); } if (!activePdfDoc) { emptyBox.classList.remove("hidden"); canvas.classList.add("hidden"); return; } emptyBox.classList.add("hidden"); canvas.classList.remove("hidden"); const total = activePdfDoc.numPages; appState.splitPdfPage = Math.max(1, Math.min(total, appState.splitPdfPage || 1)); document.getElementById("split-pdf-total").textContent = total; document.getElementById("split-pdf-page-input").value = appState.splitPdfPage; document.getElementById("split-pdf-page-input").max = total; document.getElementById("split-pdf-zoom-label").textContent = `${Math.round(appState.splitPdfScale * 100)}%`; const baseWidth = Math.max(320, (document.getElementById("split-pdf-canvas-wrapper").clientWidth - 32) * appState.splitPdfScale); await renderPdfPageToCanvas(appState.splitPdfPage, canvas, baseWidth); } // ========================================================================= // RENDERING: FEED VIEW // ========================================================================= function renderFeed() { document.getElementById("feed-view").classList.remove("hidden"); document.getElementById("reader-wrapper").classList.add("hidden"); const visible = getVisibleArticles(); const cards = items.map(article => { const isRead = appState.readIds.includes(article.id); const isSaved = appState.bookmarkedIds.includes(article.id); const hasNote = Boolean((appState.notes[article.id] || "").trim()); const hasCharts = Array.isArray(article.charts) && article.charts.length > 0; const pageTag = article.pdfPageStart ? (article.pdfPageEnd && article.pdfPageEnd > article.pdfPageStart ? `p. ${article.pdfPageStart}–${article.pdfPageEnd}` : `p. ${article.pdfPageStart}`) : ""; return `
${esc(article.kicker || article.category)} ${pageTag ? `${pageTag}` : ""} ${article.hasFullPdfText ? `FULL TEXT` : ""} ${hasCharts ? `CHART` : ""} ${isRead ? `READ` : ""} ${hasNote ? `NOTE` : ""}
// ========================================================================= // RENDERING: ARTICLE READER VIEW // ========================================================================= function openReader(articleId) { const article = appState.articles.find(a => a.id === articleId); if (!article) return; const switchedArticle = appState.activeArticleId !== articleId; appState.activeArticleId = articleId; if (switchedArticle) { appState.isEditingArticle = false; if (article.pdfPageStart) { appState.splitPdfPage = article.pdfPageStart; } } if (!appState.readIds.includes(articleId)) { appState.readIds.push(articleId); persistAppState(); renderSidebar(); } document.getElementById("feed-view").classList.add("hidden"); document.getElementById("reader-wrapper").classList.remove("hidden"); document.getElementById("reader-section").textContent = article.category; document.getElementById("reader-rubric").textContent = article.kicker || article.category; document.getElementById("reader-headline").textContent = article.title; document.getElementById("reader-deck").textContent = article.standfirst || ""; document.getElementById("reader-date").textContent = article.date || ""; document.getElementById("reader-issue").textContent = article.issue || DEFAULT_ISSUE_NAME; document.getElementById("reader-readtime").textContent = calcReadTime(article.body); const pageBadge = document.getElementById("reader-page-badge"); const inlineBtnLabel = document.getElementById("inline-pdf-btn-label"); if (article.pdfPageStart) { const rangeStr = article.pdfPageEnd && article.pdfPageEnd > article.pdfPageStart ? `p. ${article.pdfPageStart}–${article.pdfPageEnd}` : `p. ${article.pdfPageStart}`; pageBadge.textContent = `PDF ${rangeStr}`; pageBadge.classList.remove("hidden"); inlineBtnLabel.textContent = appState.showInlinePdfPages ? `Hide PDF Pages (${rangeStr})` : `Original PDF Pages (${rangeStr})`; } else { pageBadge.classList.add("hidden"); inlineBtnLabel.textContent = "Original PDF Pages"; } const sourceBadge = document.getElementById("reader-text-source-badge"); if (article.hasFullPdfText) { sourceBadge.textContent = "Full Extracted PDF Text"; sourceBadge.className = "px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-900 font-semibold"; } else { sourceBadge.textContent = "Editorial Summary (Load PDF for Full Text)"; sourceBadge.className = "px-2 py-0.5 rounded-full bg-econ-tint text-econ-muted font-semibold"; } renderInlinePdfPagesForArticle(article); renderSplitPdfViewer(); // ========================================================================= // INITIALIZE EVENTS // ========================================================================= document.addEventListener("DOMContentLoaded", () => { loadAppState(); renderIssueDropdowns(); renderSidebar(); renderFeed(); hydratePdfForSelectedIssue(); // Load Issue PDF file input & drag-and-drop handlers document.getElementById("load-issue-pdf-input").addEventListener("change", (e) => { const file = e.target.files[0]; if (file) processUploadedIssuePdf(file); e.target.value = ""; }); const dropOverlay = document.getElementById("pdf-drop-overlay"); let dragCounter = 0; window.addEventListener("dragenter", (e) => { if (e.dataTransfer && Array.from(e.dataTransfer.types).includes("Files")) { dragCounter++; dropOverlay.classList.remove("hidden"); dropOverlay.classList.add("flex"); } }); window.addEventListener("dragleave", () => { dragCounter = Math.max(0, dragCounter - 1); if (dragCounter === 0) { dropOverlay.classList.add("hidden"); dropOverlay.classList.remove("flex"); } }); window.addEventListener("dragover", (e) => e.preventDefault()); window.addEventListener("drop", (e) => { e.preventDefault(); dragCounter = 0; dropOverlay.classList.add("hidden"); dropOverlay.classList.remove("flex"); const file = e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files[0]; if (file && (file.type === "application/pdf" || file.name.toLowerCase().endsWith(".pdf"))) { processUploadedIssuePdf(file); } }); // Inline PDF pages & Split PDF Viewer controls document.getElementById("toggle-inline-pdf-pages-btn").addEventListener("click", () => { appState.showInlinePdfPages = !appState.showInlinePdfPages; if (appState.activeArticleId) openReader(appState.activeArticleId); }); document.getElementById("close-inline-pdf-pages-btn").addEventListener("click", () => { appState.showInlinePdfPages = false; if (appState.activeArticleId) openReader(appState.activeArticleId); }); document.getElementById("reader-split-pdf-btn").addEventListener("click", () => { appState.splitPdfOpen = !appState.splitPdfOpen; renderSplitPdfViewer(); }); document.getElementById("split-pdf-close-btn").addEventListener("click", () => { appState.splitPdfOpen = false; renderSplitPdfViewer(); }); document.getElementById("split-pdf-prev").addEventListener("click", () => { appState.splitPdfPage = Math.max(1, appState.splitPdfPage - 1); renderSplitPdfViewer(); }); document.getElementById("split-pdf-next").addEventListener("click", () => { if (!activePdfDoc) return; appState.splitPdfPage = Math.min(activePdfDoc.numPages, appState.splitPdfPage + 1); renderSplitPdfViewer(); }); document.getElementById("split-pdf-page-input").addEventListener("change", (e) => { appState.splitPdfPage = Number(e.target.value) || 1; renderSplitPdfViewer(); }); document.getElementById("split-pdf-zoom-in").addEventListener("click", () => { appState.splitPdfScale = Math.min(2.2, Number((appState.splitPdfScale + 0.15).toFixed(2))); renderSplitPdfViewer(); }); document.getElementById("split-pdf-zoom-out").addEventListener("click", () => { appState.splitPdfScale = Math.max(0.6, Number((appState.splitPdfScale - 0.15).toFixed(2))); renderSplitPdfViewer(); }); document.getElementById("split-pdf-capture-btn").addEventListener("click", () => { if (appState.activeArticleId && activePdfDoc) { capturePdfPageIntoArticle(appState.splitPdfPage, appState.activeArticleId); } }); // Search // Issue selectors const onIssueChange = (e) => { appState.selectedIssue = e.target.value; appState.activeArticleId = null; persistAppState(); renderIssueDropdowns(); renderSidebar(); renderFeed(); hydratePdfForSelectedIssue(); }; document.getElementById("desktop-issue-select").addEventListener("change", onIssueChange);