diff --git a/apps/factclock/ChangeLog b/apps/factclock/ChangeLog new file mode 100644 index 000000000..09953593e --- /dev/null +++ b/apps/factclock/ChangeLog @@ -0,0 +1 @@ +0.01: New Clock! diff --git a/apps/factclock/README.md b/apps/factclock/README.md new file mode 100644 index 000000000..83b590c0b --- /dev/null +++ b/apps/factclock/README.md @@ -0,0 +1,5 @@ +# Fact Clock + +A clock that displays a random fact alongside the time. + +This uses `text_facts` for the list of facts, but you can implement new apps that provide the `textsource` module (see the readme for the `text_facts` app) to make this clock display different information. \ No newline at end of file diff --git a/apps/factclock/app-icon.js b/apps/factclock/app-icon.js new file mode 100644 index 000000000..6eb4bb2a5 --- /dev/null +++ b/apps/factclock/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwcF23btoCV7QfBrYRM2kAhMkgEtCJegiwDBgBBLtAMCoA3BCwQRHoADCNIUCKxMDAYPAPgZcICIWwRwgRI6ARBwAREhYRIjYRBgVggEDCJOACIO07dsgETtsBCJcTsEGBIORCJRHCmwJB2LRHg0DGQIFC7ZKBNwnRkmSm0ACIsAgO2yRcCwIRDhgRILgWJCIMWgENR4fbhuBCINBMgMJCJNt2YLBoEtCIcGwEN2wRE3+kCI1C4DpDR4WdGoIRFpHYCIUBR4XtCJFYCIacBtgRIpKECCIdnpJZHpMhZIRcB7c7AwIRHkktEYNN23ZaYQRIwDhDrwRLyUCBoOXCoYRJpMgIgIIECJMkEAKwBCJ41OCMoFECJlpNaJZ0I/0BCKEACIsAn//AAX0yUQCIQAGFQ2QCJMACIuAlu2wASIAAkBJYPQBIsF0AHFhZgEARoA==")) \ No newline at end of file diff --git a/apps/factclock/app.js b/apps/factclock/app.js new file mode 100644 index 000000000..6ae457d4e --- /dev/null +++ b/apps/factclock/app.js @@ -0,0 +1,110 @@ +Graphics.prototype.setFontBebasNeue = function() { + // Actual height 31 (32 - 2) + // 1 BPP + return this.setFontCustom( + atob('AAAAAAAAAAAAAAAAAAAPgAAAAAD4AAAAAA+AAAAAAPgAAAAAD4AAAAAAAAAAAAAAgAAAAAA4AAAAAB+AAAAAD/gAAAAD/4AAAAH/4AAAAH/4AAAAP/wAAAAP/wAAAAf/gAAAAf/gAAAA//AAAAA/+AAAAAP+AAAAAD8AAAAAA8AAAAAAIAAAAAAAAAAAAAAAAAAAAAAf//8AAAf///wAAP///+AAH////wAD////+AA/////gAPgAAD4AD4AAA+AA+AAAPgAPgAAD4AD////+AAf////AAH////wAA////4AAH///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAADwAAAAAA8AAAAAAfAAAAAAHwAAAAAD////4AB////+AA/////gAP////4AD////+AA/////gAAAAAAAAAAAAAAAAAcAAHgAB/gA/4AA/4A/+AAf+Af/gAP/gP/4AD/wH/+AA+AD+PgAPgD+D4AD4B/A+AA+B/gPgAP//wD4AD//4A+AAf/8APgAD/8AD4AAf8AAeAAAAAAAAAAAAAAAAADgAfAAAH4AH8AAD+AB/wAB/gAf8AA/4AH/gAPwPgH4AD4D4A+AA+A+APgAPgPwD4AD8H+B+AA/////gAH////wAB//f/8AAP/j/+AAA/gf+AAAAAAAAAAAAAHgAAAAAP8AAAAAP/AAAAAP/wAAAAf/8AAAAf//AAAA//HwAAA/+B8AAA/+AfAAA/+AHwAAP////4AD////+AA/////gAP////4AD////+AAAAAHwAAAAAB8AAAAAAAAAAAAAAAAAAAAh4AAD//4fwAA//+H+AAP//h/wAD//4f+AA//+B/gAPgeAD4AD4PAA+AA+DwAPgAPh+AD4AD4f//+AA+D///gAPg///wAD4H//4AA8A//8AAAAAAAAAAAAAAAAAA///gAAB////AAA////4AAf////AAP////4AD////+AA+A8APgAPgfAD4AD4HwA+AA+B8APgAP8f//4AD/H//+AAfx///AAD8P//gAAfB//wAAAAB/AAAAAAAAAAAAAAAAAA8AAAAAAPgAAAAAD4AAACAA+AAAHgAPgAAf4AD4AA/+AA+AD//gAPgH//4AD4P//wAA+///gAAP//+AAAD//8AAAA//wAAAAP/AAAAAD+AAAAAAAAAAAAAAAAAAAAAH4D/gAAH/j/+AAD/9//wAB////8AA/////gAP9/4H4AD4D8A+AA+A+APgAPgPgD4AD4D8A+AA/////gAP////4AB////8AAP/3/+AAB/4f/AAAAAA+AAAAAAAAAAAAAAAAAAH/wHAAAH//B8AAH//4fwAB///H8AA///x/gAPwH8H4AD4AfA+AA+AHwPgAPgB4D4AD4A+B+AA/////gAH////wAB////8AAP///+AAA///+AAAAAAAAAAAAAAAAAAAAAAAAAAPgA+AAAD4APgAAA+AD4AAAPgA+AAAD4APgAAAAAAAAA'), + 46, + atob("CBIRDxEREhESERIRCA=="), + 44|65536 + ); +}; + +{ + // the font we're using + const factFont = "6x15"; + // swap every 10 minutes + const minsPerFact = 5; + // timeout used to update every minute + let drawTimeout; + // the fact we're going to display (pre-rendered with a border) + let factGfx; + // how long until the next fact? + let factCounter = minsPerFact; + // the gfx we use for the time so we can gat a shadow on it + let timeGfx = Graphics.createArrayBuffer(g.getWidth()>>1, 48, 2, {msb:true}); + timeGfx.transparent = 0; + timeGfx.palette = new Uint16Array([ + 0, g.toColor(g.theme.bg), 0, g.toColor(g.theme.fg) + ]); + + + let getNewFact = () => { + let fact = require("textsource").getRandomText(); + // wrap to fit the screen + let lines = g.setFont(factFont).wrapString(fact.txt, g.getWidth()-10); + let txt = lines.join("\n"); + // allocate a gfx for this + factGfx = Graphics.createArrayBuffer(g.getWidth(), g.stringMetrics(txt).height+4, 2, {msb:true}); + factGfx.transparent = 0; + factGfx.setFont(factFont).setFontAlign(0,-1).setColor(3).drawString(txt, factGfx.getWidth()/2, 2); + if (factGfx.filter) factGfx.filter([ // add shadow behind text + 0,1,1,1,0, + 1,1,1,1,1, + 1,1,1,1,1, + 1,1,1,1,1, + 0,1,1,1,0, + ], { w:5, h:5, div:1, max:1, filter:"max" }); + factGfx.palette = new Uint16Array([ + 0, g.toColor(g.theme.bg), 0, g.toColor(g.theme.fg) + ]); + }; + getNewFact(); + + // schedule a draw for the next minute + let queueDraw = function() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, 60000 - (Date.now() % 60000)); + }; + + let draw = function() { + // queue next draw in one minute + queueDraw(); + // new fact? + if (--factCounter < 0) { + factCounter = minsPerFact; + getNewFact(); + } + // Work out where to draw... + g.reset(); + require("clockbg").fillRect(Bangle.appRect); + // work out locale-friendly date/time + var date = new Date(); + var timeStr = require("locale").time(date,1); + var dateStr = require("locale").date(date,1); + // draw time to buffer + timeGfx.clear(1); + timeGfx.setFontAlign(0,-1).setFont("BebasNeue"); + timeGfx.drawString(timeStr,timeGfx.getWidth()/2,2); + timeGfx.setFontAlign(0,1).setFont("6x8"); + timeGfx.drawString(dateStr,timeGfx.getWidth()/2,timeGfx.getHeight()-2); + // add shadow to buffer and render + if (timeGfx.filter) timeGfx.filter([ // add shadow behind text + 0,1,1,1,0, + 1,1,1,1,1, + 1,1,1,1,1, + 1,1,1,1,1, + 0,1,1,1,0, + ], { w:5, h:5, div:1, max:1, filter:"max" }); + var y = (Bangle.appRect.y+g.getHeight()-(factGfx.getHeight()+timeGfx.getHeight()*2))>>1; + g.drawImage(timeGfx,0, y, {scale:2}); + // draw the fact + g.drawImage(factGfx,0, g.getHeight()-factGfx.getHeight()); + }; + + // Show launcher when middle button pressed + Bangle.setUI({mode:"clock", remove:function() { + // free any memory we allocated to allow fast loading + delete Graphics.prototype.setFontBebasNeue; + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + require('widget_utils').show(); // re-show widgets + }}); + // Load widgets + Bangle.loadWidgets(); + require("widget_utils").swipeOn(); + // draw immediately at first, queue update + draw(); +} \ No newline at end of file diff --git a/apps/factclock/icon.png b/apps/factclock/icon.png new file mode 100644 index 000000000..3186d0a96 Binary files /dev/null and b/apps/factclock/icon.png differ diff --git a/apps/factclock/metadata.json b/apps/factclock/metadata.json new file mode 100644 index 000000000..35b13f393 --- /dev/null +++ b/apps/factclock/metadata.json @@ -0,0 +1,17 @@ +{ "id": "factclock", + "name": "Fact Clock", + "shortName":"Facts", + "version":"0.01", + "description": "A clock that displays a random fact alongside the time", + "icon": "icon.png", + "screenshots": [{"url":"screenshot.png"}], + "type": "clock", + "tags": "clock", + "supports" : ["BANGLEJS2"], + "dependencies" : { "textsource":"module", "clockbg":"module" }, + "readme": "README.md", + "storage": [ + {"name":"factclock.app.js","url":"app.js"}, + {"name":"factclock.img","url":"app-icon.js","evaluate":true} + ] +} diff --git a/apps/factclock/screenshot.png b/apps/factclock/screenshot.png new file mode 100644 index 000000000..e52590491 Binary files /dev/null and b/apps/factclock/screenshot.png differ diff --git a/apps/textfacts/ChangeLog b/apps/textfacts/ChangeLog new file mode 100644 index 000000000..86394c2a3 --- /dev/null +++ b/apps/textfacts/ChangeLog @@ -0,0 +1 @@ +0.01: New Module! diff --git a/apps/textfacts/README.md b/apps/textfacts/README.md new file mode 100644 index 000000000..1b3444e1c --- /dev/null +++ b/apps/textfacts/README.md @@ -0,0 +1,30 @@ +# List of Facts + +A list of hundreds of 'facts' from Google Gemini. Provides a `textsource` module that apps can use to query a random fact. + +This is designed to be used by clocks that want to display interesting text (like `fact_clock`). + +## Usage + +In your app's metadata, add `"dependencies" : { "textsource":"module" }` + +```JS +require("textsource").getCount() // return how many lines we have +require("textsource").getText(n) // return a numbered line (0..getCount()-1) +require("textsource").getRandomText() +//={ "idx": 312, +// "txt": "The Sahara Desert is the largest hot desert in the world" +//} +``` + +## Adding new lists of facts + +Different lists of facts could be added to this module, but if you want to add something totally different (a list of Haiku) +it's best to just copy this app, replace the text (see below), but keep the provided filenames of `textsource` the same. + +Then users can just install whatever list they want from the app loader and the installed app will automatically +use whichever one is installed. + +## Adding new facts + +Add then to `facts.txt`, then re-run the code from inside the `getText` function in `lib.js`, paste the base64 code produced in an update the value in `getCount()` diff --git a/apps/textfacts/facts.txt b/apps/textfacts/facts.txt new file mode 100644 index 000000000..4cb2e6338 --- /dev/null +++ b/apps/textfacts/facts.txt @@ -0,0 +1,288 @@ +This list of facts was created by asking the Google Gemini AI +Animals are multicellular organisms that consume other organisms for food +Asteroids are rocky objects that orbit the Sun +Augmented reality is the overlay of digital information on a real-world environment +Bacteria are single-celled microorganisms +Biotechnology is the use of living organisms to create products or processes +Black holes are regions of spacetime where gravity is so strong that nothing can escape +Blockchain is a distributed database that is used to record transactions +Blood is a fluid that transports oxygen, nutrients, and waste products throughout the body +Blue whales are filter feeders that eat krill +Blue whales are the largest animals on Earth +Blue whales can weigh as much as 33 elephants +Cardiac muscle is found only in the heart +Cartilage is a soft, flexible tissue that is found in the joints +Cells are the basic building blocks of life +Climate change is the long-term warming of the Earth's climate +Comets are made of ice, dust, and rock +Cryptocurrency is a digital currency that uses cryptography for security +Cybersecurity is the protection of computer systems and networks from attack +Dark matter and dark energy are mysterious substances that make up most of the universe +Deep learning is a type of machine learning that uses artificial neural networks to learn from data +Deforestation is the clearing of forests +DNA is a double helix structure +DNA is made up of nucleotides, which contain adenine, guanine, cytosine, and thymine +DNA is the genetic material of all living organisms +DNA is the genetic material of all living things +E-commerce is the buying and selling of goods and services over the Internet +Exoplanets are planets that orbit stars other than our Sun +Fossil fuels are fuels formed from the remains of prehistoric plants and animals +Fungi are a kingdom of eukaryotic organisms +Genetic engineering is the modification of the genetic material of an organism +Global warming is the increase in average global temperatures +Greenhouse gases are gases that trap heat in the Earth's atmosphere +Hair and nails are made of keratin, a protein +Humans are primates that belong to the genus Homo +Hummingbirds are the only birds that can hover +Hummingbirds are the smallest birds in the world +Hummingbirds can flap their wings up to 80 times per second +Jupiter is the largest planet in our solar system +Koalas are exclusively found in Australia +Koalas are marsupials native to Australia +Koalas sleep for an average of 22 hours per day +Ligaments are tough bands of tissue that connect bones to other bones +Machine learning is a type of artificial intelligence that allows computers to learn from data +Mars is often called the "Red Planet. +Meteorites are meteors that reach Earth's surface +Meteors are objects that enter Earth's atmosphere and burn up +Mount Everest is located on the border between Nepal and Tibet +Mount Everest is named after Sir George Everest +Mount Everest is over 29,000 feet tall +Mount Everest is the highest mountain in the world +Mount Everest is the highest mountain in the world, reaching 8,848 meters +Mount Everest is the tallest mountain in the Himalayas +Mount Everest is the tallest mountain in the world +Mount Everest was first climbed in 1953 +Muscles are made of muscle tissue, which is a contractile tissue +Nanotechnology is the engineering of materials at the atomic and molecular scale +Nebulae are clouds of gas and dust in space +Neptune is the farthest planet from the Sun +Nerves are bundles of nerve cells that carry messages throughout the body +Neurons are nerve cells +Neurotransmitters are chemicals that help neurons communicate with each other +Octopuses are highly intelligent creatures +Octopuses are highly intelligent invertebrates +Octopuses have three hearts and nine brains +Overpopulation is the growth of a population beyond the carrying capacity of its environment +Peak oil is the point in time when global oil production reaches its maximum and begins to decline +Plants are multicellular organisms that produce their own food through photosynthesis +Platelets help to clot blood +Pluto was reclassified as a dwarf planet in 2006 +Pollution is the release of harmful substances into the environment +Quantum computing is a type of computing that uses quantum mechanics to perform calculations +Quantum entanglement is a phenomenon where two particles become linked, regardless of distance +Quasars are extremely bright objects that are powered by supermassive black holes +Red blood cells contain hemoglobin, which carries oxygen +Renewable energy is energy that is derived from sources that are replenished naturally +RNA is another type of nucleic acid that is involved in protein synthesis +Saturn is known for its rings +Skeletal muscles are attached to bones and allow us to move +Smooth muscles are found in the walls of organs and blood vessels +Social media are online platforms that allow people to create and share content +Supernovae are powerful explosions of dying stars +Synapses are the gaps between neurons +Synthetic biology is the design and construction of biological systems +Tendons are tough bands of tissue that connect muscles to bones +The alveoli are tiny air sacs in the lungs where gas exchange takes place +The Amazon Rainforest covers about 40% of South America +The Amazon Rainforest is home to a vast biodiversity +The Amazon Rainforest is home to more than 10 million species of plants and animals +The Amazon Rainforest is home to the Amazon River +The Amazon Rainforest is home to the Amazon River, the second-longest river in the world +The Amazon Rainforest is home to the largest number of animal species in the world +The Amazon Rainforest is home to the largest number of plant species in the world +The Amazon Rainforest is the largest rainforest in the world +The Amazon Rainforest produces more than 20% of the world's oxygen +The Andromeda Galaxy is the nearest large galaxy to the Milky Way +The anus is the opening at the end of the rectum +The arteries carry blood away from the heart +The Beatles are considered one of the most influential bands in music history. +The Beatles were a popular English rock band +The Beatles were formed in Liverpool, England +The Beatles were known for their innovative music and cultural impact +The Big Bang is the theory that the universe began as a singularity and has been expanding ever since +The bladder stores urine +The bones are made of bone tissue, which is a hard, mineralized tissue +The bones provide structure and support for the body +The brain is divided into the cerebrum, cerebellum, and brainstem +The brain is the most complex organ in the human body +The brainstem controls basic life functions such as breathing and heart rate +The bronchi are two tubes that branch off from the trachea and lead to the lungs +The bronchioles are smaller tubes that branch off from the bronchi +The capillaries are tiny blood vessels that connect arteries to veins +The cardiovascular system is another name for the circulatory system +The central nervous system includes the brain and spinal cord +The cerebellum is responsible for balance and coordination +The cerebrum is the largest part of the brain and is responsible for thought, feeling, and movement +The circulatory system transports blood throughout the body +The Cold War was a period of geopolitical tension between the United States and the Soviet Union +The Colosseum could hold up to 80,000 spectators +The Colosseum was built in the first century AD +The Colosseum was damaged by an earthquake in 847 AD +The Colosseum was once a stadium for gladiatorial contests +The Colosseum was used for public executions in the Middle Ages +The dermis is the middle layer of the skin +The digestive system breaks down food and absorbs nutrients +The Drake equation estimates the number of extraterrestrial civilizations in our galaxy +The ears allow us to hear +The Eiffel Tower is 330 meters tall +The Eiffel Tower is a wrought iron lattice tower +The Eiffel Tower is one of the most recognizable landmarks in the world +The Eiffel Tower is the tallest structure in Paris +The Eiffel Tower was built for the 1889 World's Fair +The Eiffel Tower was originally intended to be a temporary structure +The endocrine system includes the pituitary gland, thyroid gland, adrenal glands, pancreas, ovaries, and testes +The endocrine system regulates hormone production +The epidermis is the outermost layer of the skin +The eyes allow us to see +The Fermi Paradox is the question of why we haven't found evidence of extraterrestrial civilizations yet +The Forbidden City is now a museum +The Forbidden City was built in the 15th century +The Forbidden City was built to protect the emperor from his enemies +The Forbidden City was home to Chinese emperors until 1912 +The Forbidden City was the imperial palace of China for centuries +The gallbladder stores bile, which helps to break down fats +The Grand Canyon is a popular tourist destination +The Grand Canyon is a UNESCO World Heritage Site +The Grand Canyon is home to a variety of plant and animal life +The Grand Canyon is over 277 miles long +The Grand Canyon is over a mile deep in some places +The Grand Canyon was formed over millions of years by the Colorado River +The Great Barrier Reef is a UNESCO World Heritage Site +The Great Barrier Reef is facing threats from climate change +The Great Barrier Reef is home to a variety of marine life +The Great Barrier Reef is home to over 1,500 species of fish +The Great Barrier Reef is home to the largest number of coral species in the world +The Great Barrier Reef is made up of over 2,900 individual reefs +The Great Barrier Reef is the largest coral reef system in the world +The Great Barrier Reef is the largest living structure on Earth +The Great Wall of China is a UNESCO World Heritage Site +The Great Wall of China is made up of several walls that were built over centuries +The Great Wall of China is over 13,000 miles long +The Great Wall of China is visible from space +The Great Wall of China was built over a period of 2,000 years +The Great Wall of China was built to protect China from invaders +The Harry Potter series has been adapted into eight films +The Harry Potter series is based on the adventures of the young wizard Harry Potter +The Harry Potter series is based on the wizarding world created by J.K. Rowling +The Harry Potter series is popular among children and adults alike +The Harry Potter series was written by J.K. Rowling +The heart is a muscular organ that pumps blood throughout the body +The heart pumps blood throughout the body +The human brain contains approximately 100 billion neurons +The human brain is divided into the cerebrum, cerebellum, and brainstem +The human brain is more complex than any computer +The hypodermis is the innermost layer of the skin +The immune system protects the body from disease +The Industrial Revolution began in Great Britain +The Industrial Revolution led to the rise of urbanization and industrialization +The Industrial Revolution transformed societies with technological advancements +The integumentary system is the skin and its appendages +The intestines absorb nutrients from food +The kidneys are two bean-shaped organs that are located on either side of the spine +The kidneys filter waste products from the blood +The Large Hadron Collider is located at CERN, near Geneva, Switzerland +The Large Hadron Collider is the world's largest particle accelerator +The Large Hadron Collider was used to discover the Higgs boson +The large intestine is a shorter, wider tube that is located in the abdomen +The liver filters toxins from the blood +The liver is a large organ that is located in the upper right quadrant of the abdomen +The lungs are two large organs that are located on either side of the chest +The lungs help us breathe +The lymphatic system helps to fight infection +The lymphatic system is also known as the immune system +The Mariana Trench is home to the Challenger Deep +The Mariana Trench is home to unique deep-sea creatures +The Mariana Trench is the deepest point in the ocean +The Mariana Trench is the deepest point in the ocean, reaching over 10,000 meters +The Mayan civilization was highly advanced in astronomy and mathematics +The Mayan civilization was known for its advanced calendar system +The Milky Way is a spiral galaxy that contains our solar system +The Mona Lisa has no eyebrows +The Mona Lisa is a famous portrait painting +The Mona Lisa is a famous portrait painting of Lisa del Giocondo +The Mona Lisa is currently on display at the Louvre Museum in Paris +The Mona Lisa is housed in the Louvre Museum in Paris +The Mona Lisa is known for its enigmatic smile +The Mona Lisa was painted by Leonardo da Vinci +The Mongol Empire eventually fragmented into smaller khanates +The Mongol Empire was founded by Genghis Khan +The Mongol Empire was the largest contiguous land empire in history +The Moon is Earth's only natural satellite +The muscles allow us to move +The muscular system allows us to move +The nervous system controls our thoughts, feelings, and actions +The Nile River flows through 11 countries +The Nile River is the longest river in Africa +The Nile River is the longest river in the world +The Nile River is the main source of water for Egypt +The nose allows us to smell +The pancreas produces insulin and glucagon, which regulate blood sugar levels +The periodic table is arranged in rows called periods and columns called groups +The periodic table organizes the elements based on their atomic number and properties +The periodic table was created by Dmitri Mendeleev +The Pyramids of Giza are the largest ancient structures in the world +The Pyramids of Giza are the oldest of the Seven Wonders of the Ancient World +The Pyramids of Giza are the only one of the Seven Wonders of the Ancient World that still stands +The Pyramids of Giza were built by slave labor +The Pyramids of Giza were built over 4,500 years ago +The rectum is the last part of the large intestine +The Renaissance saw the rise of humanism and individualism +The Renaissance was a period of cultural and artistic rebirth in Europe +The Renaissance was influenced by classical Greek and Roman culture +The reproductive system allows us to reproduce +The respiratory system allows us to breathe +The Roman Empire at its peak stretched from Britain to North Africa +The Roman Empire was conquered by Germanic tribes +The Roman Empire was ruled by emperors for centuries +The Rubik's Cube has over 43 quintillion possible combinations +The Rubik's Cube has six sides, each with a different color +The Rubik's Cube is a popular puzzle game +The Rubik's Cube was invented by Ernő Rubik +The Rubik's Cube was invented in Hungary +The Sahara Desert is about the size of the United States +The Sahara Desert is home to the Tuareg people +The Sahara Desert is home to the world's largest sand dunes +The Sahara Desert is the driest place on Earth +The Sahara Desert is the largest desert in the world by area +The Sahara Desert is the largest hot desert in the world +The Sahara Desert was once a lush, green landscape +The skeletal system provides structure and support for the body +The skin is made of three layers: the epidermis, dermis, and hypodermis +The skin is the largest organ in the human body +The small intestine is a long, coiled tube that is located in the abdomen +The speed of light in a vacuum is approximately 300,000 kilometers per second +The speed of light is a constant in the universe +The speed of light is a fundamental constant of the universe +The Statue of Liberty is a symbol of freedom and democracy +The Statue of Liberty was a gift from France to the United States +The Statue of Liberty was dedicated in 1886 +The Statue of Liberty was designed by French sculptor Frédéric Auguste Bartholdi +The Statue of Liberty was designed to represent the goddess Libertas +The stomach breaks down food +The Sun is a giant ball of plasma +The Super Bowl is the championship game of the National Football League +The Super Bowl is typically held in a major U.S. city +The Super Bowl is typically held on the first Sunday of February +The Taj Mahal is considered one of the most beautiful buildings in the world +The Taj Mahal is made of white marble +The Taj Mahal was built as a mausoleum for Mumtaz Mahal +The Taj Mahal was built by Mughal Emperor Shah Jahan +The Taj Mahal was built to honor Mumtaz Mahal, the wife of Shah Jahan +The Titanic sank after hitting an iceberg +The Titanic sank after hitting an iceberg in the North Atlantic Ocean +The Titanic sank in the North Atlantic Ocean in 1912 +The Titanic was the largest ship in the world at the time of its sinking +The Titanic was the largest ship in the world when it was built +The tongue allows us to taste +The ureters are two tubes that carry urine from the kidneys to the bladder +The urethra is a tube that carries urine out of the body +The urinary system filters waste products from the blood +The veins carry blood back to the heart +The Venus flytrap is a carnivorous plant that traps and digests insects +The Venus flytrap is a native plant of North and South Carolina +The Venus flytrap is native to North and South Carolina +Uranus rotates on its side +Venus is the hottest planet in our solar system +Viruses are smaller than bacteria and can only replicate inside living cells +White blood cells help to fight infection diff --git a/apps/textfacts/icon.png b/apps/textfacts/icon.png new file mode 100644 index 000000000..2beaa3be1 Binary files /dev/null and b/apps/textfacts/icon.png differ diff --git a/apps/textfacts/lib.js b/apps/textfacts/lib.js new file mode 100644 index 000000000..a4040a0f4 --- /dev/null +++ b/apps/textfacts/lib.js @@ -0,0 +1,29 @@ +exports = {}; +exports.getCount = function() { + return 288; +}; +exports.getText = function(n) { + /*var s = require("Storage").read("textsource.txt"); + var idx = s.indexOf("\n"); + var lengths = [idx]; + while (idx>=0) { + var next = s.indexOf("\n",idx+1); + if (next>=0) { + var len = next-idx; + if (len>255) throw new Error("Line too long!"); + lengths.push(len); + } + idx = next; + } + print(`Count = ${lengths.length}`); + print(`var idxs = E.toUint8Array(atob("${btoa(lengths)}"));`);*/ + var idxs = E.toUint8Array(atob("PUovVCpNWElbLi0uKkEsPydJTVhkKSBVNDFNO1EsTz5ELjIvMTwyKiowRl8mMj4/MCczSjczKEFRLCxKGE4rLyxdY1YdMURdX1I5V0oePEJQMiZHQEo4NVQyWVNSPUNCMS1PLS5GZhlHNUI2TVFDRkU+O2Q8YTEwNTtAKzxYGiQxSDM1RXAyMRlpIzFFO0I8MjE/KDRJNz07PVNBRUA4UzIuP0E6VFBDNEMqO0gyMjExUFA4KlQxR0Y/TChWTBouODI4NVJIQkAeLEFENi8vPi5EKx0mQCouMTUcTlBWM0VOYi81MztIRC8sRDI1PzwqLSk5LzwvPTkzQEgwSk4xPTtCLFNFHSJINkFNJjg1RipGNUlAHks5OShIQDgbME0q")); + if (n<0 || n>=idxs.length) return; + var idx = n ? E.sum(new Uint8Array(idxs.buffer,0,n))+1 : 0; + var len = idxs[n]-1; + return require("Storage").read("textsource.txt").substring(idx, idx+len); +}; +exports.getRandomText = function() { + let n = Math.floor(Math.random()*exports.getCount()); + return { idx : n, txt : exports.getText(n) }; +}; \ No newline at end of file diff --git a/apps/textfacts/metadata.json b/apps/textfacts/metadata.json new file mode 100644 index 000000000..a8728185e --- /dev/null +++ b/apps/textfacts/metadata.json @@ -0,0 +1,16 @@ +{ "id": "textfacts", + "name": "List of Facts", + "shortName":"Facts", + "version":"0.01", + "description": "A list of hundreds of 'facts' from Google Gemini. Provides a `textsource` module that apps can use to query a random fact.", + "icon": "icon.png", + "type": "module", + "tags": "", + "provides_modules" : ["textsource"], + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"textsource.txt","url":"facts.txt"}, + {"name":"textsource","url":"lib.js"} + ] +}