smjain commited on
Commit
a14a321
·
verified ·
1 Parent(s): ac62d55

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +281 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Selfishgene
3
- emoji: 🏆
4
- colorFrom: blue
5
- colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: selfishgene
3
+ emoji: 🐳
4
+ colorFrom: red
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,281 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>The Selfish Gene - Chapter Summaries</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .chapter-card {
11
+ transition: all 0.3s ease;
12
+ transform-origin: top;
13
+ }
14
+ .chapter-card:hover {
15
+ transform: scale(1.02);
16
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
17
+ }
18
+ .chapter-content {
19
+ max-height: 0;
20
+ overflow: hidden;
21
+ transition: max-height 0.5s ease;
22
+ }
23
+ .chapter-content.open {
24
+ max-height: 1000px;
25
+ }
26
+ .active-tab {
27
+ border-bottom: 3px solid #3b82f6;
28
+ color: #3b82f6;
29
+ }
30
+ .search-highlight {
31
+ background-color: #fef08a;
32
+ }
33
+ </style>
34
+ </head>
35
+ <body class="bg-gray-50 min-h-screen">
36
+ <div class="container mx-auto px-4 py-8">
37
+ <!-- Header -->
38
+ <header class="text-center mb-12">
39
+ <h1 class="text-4xl md:text-5xl font-bold text-gray-800 mb-4">The Selfish Gene</h1>
40
+ <p class="text-xl text-gray-600 mb-6">by Richard Dawkins</p>
41
+ <div class="relative max-w-2xl mx-auto">
42
+ <input type="text" id="searchInput" placeholder="Search chapters..."
43
+ class="w-full px-6 py-3 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 shadow-sm">
44
+ <i class="fas fa-search absolute right-6 top-3.5 text-gray-400"></i>
45
+ </div>
46
+ </header>
47
+
48
+ <!-- Tabs -->
49
+ <div class="flex overflow-x-auto mb-8 border-b border-gray-200">
50
+ <button class="tab-btn px-6 py-3 font-medium text-gray-600 whitespace-nowrap" data-tab="all">All Chapters</button>
51
+ <button class="tab-btn px-6 py-3 font-medium text-gray-600 whitespace-nowrap" data-tab="core">Core Ideas</button>
52
+ <button class="tab-btn px-6 py-3 font-medium text-gray-600 whitespace-nowrap" data-tab="examples">Examples</button>
53
+ </div>
54
+
55
+ <!-- Chapters Container -->
56
+ <div id="chaptersContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
57
+ <!-- Chapters will be inserted here by JavaScript -->
58
+ </div>
59
+
60
+ <!-- Back to Top Button -->
61
+ <button id="backToTop" class="fixed bottom-6 right-6 bg-blue-500 text-white p-3 rounded-full shadow-lg opacity-0 invisible transition-all duration-300">
62
+ <i class="fas fa-arrow-up"></i>
63
+ </button>
64
+ </div>
65
+
66
+ <script>
67
+ // Book data
68
+ const chapters = [
69
+ {
70
+ title: "Chapter 1: Why are people?",
71
+ coreIdea: "Life on earth evolved through natural selection. Dawkins argues against group or species-level explanations for behavior, insisting instead that genes drive evolution.",
72
+ explanation: "Animals behave selfishly because genes promoting their own survival reproduce better.",
73
+ example: "Blackheaded gulls eat neighbor's chicks secretly for easy food, a clear selfish behavior that helps their genes spread."
74
+ },
75
+ {
76
+ title: "Chapter 2: The replicators",
77
+ coreIdea: "Life started with molecules capable of copying themselves, called 'replicators.' These replicators evolved through natural selection by becoming stable, fast, and accurate at copying themselves.",
78
+ explanation: "Early replicators accidentally made copying mistakes (mutations), which sometimes produced improvements, kickstarting evolution.",
79
+ example: "Like a document copied many times by hand, occasional errors creep in. If an error makes the copy better at replicating, it spreads more widely."
80
+ },
81
+ {
82
+ title: "Chapter 3: Immortal coils",
83
+ coreIdea: "Genes, specifically DNA molecules, are modern replicators. Dawkins explains how these genes build complex survival machines (organisms) to preserve themselves.",
84
+ explanation: "DNA stores 'blueprints' for building organisms. Bodies are temporary structures created to protect and pass on genes.",
85
+ example: "Every cell in your body holds DNA instructions ('architectural plans') for building you, copied perfectly billions of times, passing your genes forward."
86
+ },
87
+ {
88
+ title: "Chapter 4: The gene machine",
89
+ coreIdea: "Organisms (survival machines) evolved to protect and spread genes, which indirectly control the bodies carrying them. Dawkins emphasizes that genes 'program' organisms for their own benefit.",
90
+ explanation: "Genes control bodies by creating proteins that build structures (eyes, limbs) and influence behavior to maximize their survival.",
91
+ example: "A bird's wings, controlled by genes, evolved because flight helps the genes spread, not because flight is good for the bird species."
92
+ },
93
+ {
94
+ title: "Chapter 5: Aggression: stability and the selfish machine",
95
+ coreIdea: "Aggressive behavior is explained through game theory and evolutionary stability. Genes evolve strategies that cannot easily be defeated by others, creating stable patterns in nature.",
96
+ explanation: "Animals use aggressive strategies that balance risks and benefits, evolving stable behaviors.",
97
+ example: "Animals often bluff or display aggression rather than fight directly because direct combat is risky, but threats are effective and stable strategies."
98
+ },
99
+ {
100
+ title: "Chapter 6: Genesmanship",
101
+ coreIdea: "Dawkins explores how genes influence behaviors beyond aggression, manipulating their environment—including other organisms—to spread themselves.",
102
+ explanation: "Genes evolve to manipulate not just bodies but interactions, producing cunning strategies to outwit rivals.",
103
+ example: "Parasites manipulate host behavior to spread themselves (like certain viruses that cause sneezing or coughing, effectively spreading genes)."
104
+ },
105
+ {
106
+ title: "Chapter 7: Family planning",
107
+ coreIdea: "Family relationships (parent-offspring) involve conflicts of genetic interest. Dawkins describes how genes promote certain familial strategies for their benefit.",
108
+ explanation: "Parents balance resource allocation among offspring to optimize gene survival. Offspring compete for parental resources.",
109
+ example: "Baby birds loudly demand food, manipulating parents to invest heavily in their survival, often more than the parents genetically 'prefer.'"
110
+ },
111
+ {
112
+ title: "Chapter 8: Battle of the generations",
113
+ coreIdea: "Conflict between generations arises from differing genetic interests, especially in reproduction and resource allocation.",
114
+ explanation: "Genes balance the resources given to current offspring against resources for future offspring, causing conflicts.",
115
+ example: "A fetus may chemically signal its mother's body to gain extra nutrition, causing pregnancy stress, reflecting a genetic tug-of-war."
116
+ },
117
+ {
118
+ title: "Chapter 9: Battle of the sexes",
119
+ coreIdea: "Sexual reproduction involves genetic conflict between males and females. Dawkins describes how genes exploit strategies to maximize reproductive success.",
120
+ explanation: "Males typically invest less in offspring, females more. Genes lead males to compete for mates, females to choose carefully.",
121
+ example: "Male birds develop bright feathers to attract females. Females choose the brightest male because brightness signals good genes."
122
+ },
123
+ {
124
+ title: "Chapter 10: You scratch my back, I'll ride on yours",
125
+ coreIdea: "Explains cooperation and mutual benefit through reciprocal altruism. Cooperation evolves when organisms benefit from exchanging favors.",
126
+ explanation: "Animals cooperate if both sides gain genetic advantages over time.",
127
+ example: "Vampire bats share blood meals with others who previously helped them, ensuring survival when food is scarce."
128
+ },
129
+ {
130
+ title: "Chapter 11: Memes: the new replicators",
131
+ coreIdea: "Dawkins introduces 'memes,' cultural units (ideas, behaviors, beliefs) that replicate similarly to genes, spreading culturally rather than biologically.",
132
+ explanation: "Cultural ideas spread because they replicate well, independently of biological advantage.",
133
+ example: "Songs, jokes, fashion trends spread rapidly by imitation, similar to how genes replicate biologically."
134
+ },
135
+ {
136
+ title: "Chapter 12: Nice guys finish first",
137
+ coreIdea: "'Nice' (cooperative) strategies often outperform selfish ones over time. Dawkins explains the evolution of cooperation using game theory, particularly the 'Tit-for-Tat' strategy.",
138
+ explanation: "'Tit-for-Tat'—cooperate first, then copy the other player—proves successful in long-term interactions.",
139
+ example: "Animals grooming each other cooperate by mutual benefit; those who cheat lose long-term help, making cooperation a stable strategy."
140
+ },
141
+ {
142
+ title: "Chapter 13: The long reach of the gene",
143
+ coreIdea: "Genes' influence extends far beyond individual bodies, shaping environments and interactions among organisms. Dawkins explains 'extended phenotypes.'",
144
+ explanation: "Genes indirectly control features outside their organism's body, shaping their environment to improve survival chances.",
145
+ example: "Beaver dams represent genes indirectly creating environmental conditions that enhance survival, illustrating the gene's far-reaching influence."
146
+ }
147
+ ];
148
+
149
+ // DOM Elements
150
+ const chaptersContainer = document.getElementById('chaptersContainer');
151
+ const searchInput = document.getElementById('searchInput');
152
+ const tabButtons = document.querySelectorAll('.tab-btn');
153
+ const backToTopBtn = document.getElementById('backToTop');
154
+
155
+ // Current filter state
156
+ let currentTab = 'all';
157
+ let currentSearchTerm = '';
158
+
159
+ // Initialize the app
160
+ function init() {
161
+ renderChapters();
162
+ setupEventListeners();
163
+ }
164
+
165
+ // Render chapters based on current filters
166
+ function renderChapters() {
167
+ chaptersContainer.innerHTML = '';
168
+
169
+ const filteredChapters = chapters.filter(chapter => {
170
+ // Filter by search term
171
+ const matchesSearch = currentSearchTerm === '' ||
172
+ chapter.title.toLowerCase().includes(currentSearchTerm) ||
173
+ chapter.coreIdea.toLowerCase().includes(currentSearchTerm) ||
174
+ chapter.explanation.toLowerCase().includes(currentSearchTerm) ||
175
+ chapter.example.toLowerCase().includes(currentSearchTerm);
176
+
177
+ return matchesSearch;
178
+ });
179
+
180
+ filteredChapters.forEach((chapter, index) => {
181
+ const chapterCard = document.createElement('div');
182
+ chapterCard.className = 'chapter-card bg-white rounded-xl shadow-md overflow-hidden border border-gray-100';
183
+ chapterCard.innerHTML = `
184
+ <div class="p-6 cursor-pointer" onclick="toggleChapterContent(${index})">
185
+ <div class="flex justify-between items-start">
186
+ <h3 class="text-xl font-bold text-gray-800 mb-2">${chapter.title}</h3>
187
+ <i class="fas fa-chevron-down text-gray-400 transition-transform duration-300" id="chevron-${index}"></i>
188
+ </div>
189
+ ${currentTab === 'all' || currentTab === 'core' ? `
190
+ <div class="mt-3">
191
+ <h4 class="font-semibold text-gray-700">Core Idea:</h4>
192
+ <p class="text-gray-600 mt-1">${highlightSearchTerms(chapter.coreIdea)}</p>
193
+ </div>
194
+ ` : ''}
195
+ </div>
196
+ <div class="chapter-content px-6 pb-6" id="content-${index}">
197
+ ${currentTab === 'all' || currentTab === 'core' ? `
198
+ <div class="mt-4">
199
+ <h4 class="font-semibold text-gray-700">Explanation:</h4>
200
+ <p class="text-gray-600 mt-1">${highlightSearchTerms(chapter.explanation)}</p>
201
+ </div>
202
+ ` : ''}
203
+ ${currentTab === 'all' || currentTab === 'examples' ? `
204
+ <div class="mt-4">
205
+ <h4 class="font-semibold text-gray-700">Example:</h4>
206
+ <p class="text-gray-600 mt-1">${highlightSearchTerms(chapter.example)}</p>
207
+ </div>
208
+ ` : ''}
209
+ </div>
210
+ `;
211
+ chaptersContainer.appendChild(chapterCard);
212
+ });
213
+ }
214
+
215
+ // Highlight search terms in text
216
+ function highlightSearchTerms(text) {
217
+ if (!currentSearchTerm) return text;
218
+
219
+ const regex = new RegExp(currentSearchTerm, 'gi');
220
+ return text.replace(regex, match =>
221
+ `<span class="search-highlight">${match}</span>`
222
+ );
223
+ }
224
+
225
+ // Toggle chapter content visibility
226
+ function toggleChapterContent(index) {
227
+ const content = document.getElementById(`content-${index}`);
228
+ const chevron = document.getElementById(`chevron-${index}`);
229
+
230
+ content.classList.toggle('open');
231
+ chevron.classList.toggle('rotate-180');
232
+ }
233
+
234
+ // Set up event listeners
235
+ function setupEventListeners() {
236
+ // Search input
237
+ searchInput.addEventListener('input', (e) => {
238
+ currentSearchTerm = e.target.value.toLowerCase().trim();
239
+ renderChapters();
240
+ });
241
+
242
+ // Tab buttons
243
+ tabButtons.forEach(button => {
244
+ button.addEventListener('click', () => {
245
+ currentTab = button.dataset.tab;
246
+ tabButtons.forEach(btn => btn.classList.remove('active-tab'));
247
+ button.classList.add('active-tab');
248
+ renderChapters();
249
+ });
250
+ });
251
+
252
+ // Set first tab as active by default
253
+ tabButtons[0].classList.add('active-tab');
254
+
255
+ // Back to top button
256
+ window.addEventListener('scroll', () => {
257
+ if (window.pageYOffset > 300) {
258
+ backToTopBtn.classList.remove('opacity-0', 'invisible');
259
+ backToTopBtn.classList.add('opacity-100', 'visible');
260
+ } else {
261
+ backToTopBtn.classList.remove('opacity-100', 'visible');
262
+ backToTopBtn.classList.add('opacity-0', 'invisible');
263
+ }
264
+ });
265
+
266
+ backToTopBtn.addEventListener('click', () => {
267
+ window.scrollTo({
268
+ top: 0,
269
+ behavior: 'smooth'
270
+ });
271
+ });
272
+ }
273
+
274
+ // Make toggle function available globally
275
+ window.toggleChapterContent = toggleChapterContent;
276
+
277
+ // Initialize the app
278
+ document.addEventListener('DOMContentLoaded', init);
279
+ </script>
280
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=smjain/selfishgene" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
281
+ </html>