Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cstefanache committed Nov 12, 2024
1 parent 66fce96 commit 13ef763
Show file tree
Hide file tree
Showing 32 changed files with 580 additions and 421 deletions.
7 changes: 7 additions & 0 deletions cache/osbase_fullscreen_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"crc": 701226730,
"compiled_instruction": "\nYou are a code generator that produces JavaScript code exclusively using vanilla JavaScript that will execute in a browser window. When responding to queries, provide only valid and complete JavaScript code without any additional explanations or comments. Do not include any frameworks or libraries such as jQuery, React, or others. Follow best practices for vanilla JavaScript and ensure compatibility with modern browsers. Do not write node or server-side code.\n\nCreate a new function `toggleFullScreen` that toggles the fullscreen mode of the browser\nadd a span position fixed bottom centered z-index 999999 with a text that says '\u231e \u231d' that when clicked calls the `toggleFullScreen` function\n",
"result": "```javascript\nfunction toggleFullScreen() {\n if (!document.fullscreenElement) {\n document.documentElement.requestFullscreen();\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n }\n }\n}\n\nconst span = document.createElement('span');\nspan.textContent = '\u231e \u231d';\nspan.style.position = 'fixed';\nspan.style.bottom = '20px';\nspan.style.left = '50%';\nspan.style.transform = 'translateX(-50%)';\nspan.style.zIndex = '999999';\nspan.style.cursor = 'pointer';\nspan.onclick = toggleFullScreen;\n\ndocument.body.appendChild(span);\n```",
"output": "function toggleFullScreen() {\n if (!document.fullscreenElement) {\n document.documentElement.requestFullscreen();\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n }\n }\n}\n\nconst span = document.createElement('span');\nspan.textContent = '\u231e \u231d';\nspan.style.position = 'fixed';\nspan.style.bottom = '20px';\nspan.style.left = '50%';\nspan.style.transform = 'translateX(-50%)';\nspan.style.zIndex = '999999';\nspan.style.cursor = 'pointer';\nspan.onclick = toggleFullScreen;\n\ndocument.body.appendChild(span);\n",
"library": "function toggleFullScreen() { ... }\n"
}
10 changes: 5 additions & 5 deletions cache/presenter_presenter-logic_0.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"crc": 3036573701,
"compiled_instruction": "\nYou are a code generator that produces JavaScript code exclusively using vanilla JavaScript that will execute in a browser window. When responding to queries, provide only valid and complete JavaScript code without any additional explanations or comments. Do not include any frameworks or libraries such as jQuery, React, or others. Follow best practices for vanilla JavaScript and ensure compatibility with modern browsers. Do not write node or server-side code.\n\nGiven the following implemented functions:\n /**\n * Saves the filesystem object to local storage.\n * @function\n */\nwindow.os.fs.sync = function() { ... }\n /**\n * Processes and returns a path, handling `..`, `//`, and `/`.\n * @param {string} path - The path to process.\n * @returns {string|null} - The processed path or null if invalid.\n */\nwindow.os.fs.getPath = function(path) { ... }\n /**\n * Checks if the path is valid.\n * @param {string} path - The path to check.\n * @returns {boolean} - True if valid, false otherwise.\n */\nwindow.os.fs.isValidPath = function(path) { ... }\n /**\n * Returns a list of entries in the filesystem object at the given path.\n * @param {string} path - The path to list entries from.\n * @returns {Array} - An array of entries.\n */\nwindow.os.fs.ls = function(path) { ... }\n /**\n * Creates an empty object at the given path.\n * @param {string} path - The path to create the directory.\n */\nwindow.os.fs.mkdir = function(path) { ... }\n /**\n * Removes the object at the given path.\n * @param {string} path - The path to remove the object from.\n */\nwindow.os.fs.rm = function(path) { ... }\n /**\n * Writes the content to an entry in the filesystem object at the given path.\n * @param {string} path - The path to write to.\n * @param {string} content - The content to write.\n */\nwindow.os.fs.write = function(path, content) { ... }\n /**\n * Reads an entry split by `\\n` in the filesystem object at the given path.\n * @param {string} path - The path to read from.\n * @returns {string|null} - The content of the file or null if not found.\n */\nwindow.os.fs.read = function(path) { ... }\n\n/**\n * Registers a new application with the specified title, emoji, callback, dimensions, and optional extensions.\n * @param {string} title - The title of the application.\n * @param {string} emoji - The emoji to display for the application.\n * @param {function} callback - The function to call when the application is executed.\n * @param {number} [width=400] - The width of the application window.\n * @param {number} [height=400] - The height of the application window.\n * @param {Array} [extensions] - An optional array of extensions to register with the application.\n */\nwindow.os.registerApplication = function(title, emoji, callback, width = 400, height = 400, extensions) { ... }\n\n\n\ndefine a function called getSlideDOMElement that takes an array of strings as an argument\niterate the array and for each item:\n split item by `\\n`\n iterate the split result and for each line:\n if the line starts with a dot and a string append the class of the slide to the string\n create a slide div element with class slide\n generate html dom elements corresponding to the markdown syntax with headers, text, image and backtick as pre support and append them to the slide element\n append the slide element to the result array\nreturn the result array\n",
"result": "```javascript\nfunction getSlideDOMElement(slides) {\n const result = [];\n \n slides.forEach(item => {\n const lines = item.split('\\n');\n const slideElement = document.createElement('div');\n slideElement.className = 'slide';\n\n lines.forEach(line => {\n if (line.startsWith('.')) {\n slideElement.classList.add(line.substring(1).trim());\n } else {\n let element;\n if (line.startsWith('# ')) {\n element = document.createElement('h1');\n element.textContent = line.substring(2).trim();\n } else if (line.startsWith('## ')) {\n element = document.createElement('h2');\n element.textContent = line.substring(3).trim();\n } else if (line.startsWith('### ')) {\n element = document.createElement('h3');\n element.textContent = line.substring(4).trim();\n } else if (line.startsWith('![')) {\n const altText = line.substring(line.indexOf('[') + 1, line.indexOf(']'));\n const src = line.substring(line.indexOf('(') + 1, line.indexOf(')'));\n element = document.createElement('img');\n element.src = src;\n element.alt = altText;\n } else if (line.startsWith('`')) {\n element = document.createElement('pre');\n element.textContent = line.substring(1, line.lastIndexOf('`')).trim();\n } else {\n element = document.createElement('p');\n element.textContent = line.trim();\n }\n slideElement.appendChild(element);\n }\n });\n\n result.push(slideElement);\n });\n\n return result;\n}\n```",
"output": "function getSlideDOMElement(slides) {\n const result = [];\n \n slides.forEach(item => {\n const lines = item.split('\\n');\n const slideElement = document.createElement('div');\n slideElement.className = 'slide';\n\n lines.forEach(line => {\n if (line.startsWith('.')) {\n slideElement.classList.add(line.substring(1).trim());\n } else {\n let element;\n if (line.startsWith('# ')) {\n element = document.createElement('h1');\n element.textContent = line.substring(2).trim();\n } else if (line.startsWith('## ')) {\n element = document.createElement('h2');\n element.textContent = line.substring(3).trim();\n } else if (line.startsWith('### ')) {\n element = document.createElement('h3');\n element.textContent = line.substring(4).trim();\n } else if (line.startsWith('![')) {\n const altText = line.substring(line.indexOf('[') + 1, line.indexOf(']'));\n const src = line.substring(line.indexOf('(') + 1, line.indexOf(')'));\n element = document.createElement('img');\n element.src = src;\n element.alt = altText;\n } else if (line.startsWith('`')) {\n element = document.createElement('pre');\n element.textContent = line.substring(1, line.lastIndexOf('`')).trim();\n } else {\n element = document.createElement('p');\n element.textContent = line.trim();\n }\n slideElement.appendChild(element);\n }\n });\n\n result.push(slideElement);\n });\n\n return result;\n}\n",
"library": "function getSlideDOMElement(slides) { ... }\n"
"crc": 2855302671,
"compiled_instruction": "\nYou are a code generator that produces JavaScript code exclusively using vanilla JavaScript that will execute in a browser window. When responding to queries, provide only valid and complete JavaScript code without any additional explanations or comments. Do not include any frameworks or libraries such as jQuery, React, or others. Follow best practices for vanilla JavaScript and ensure compatibility with modern browsers. Do not write node or server-side code.\n\nGiven the following implemented functions:\n /**\n * Saves the filesystem object to local storage.\n * @function\n */\nwindow.os.fs.sync = function() { ... }\n /**\n * Processes and returns a path, handling `..`, `//`, and `/`.\n * @param {string} path - The path to process.\n * @returns {string|null} - The processed path or null if invalid.\n */\nwindow.os.fs.getPath = function(path) { ... }\n /**\n * Checks if the path is valid.\n * @param {string} path - The path to check.\n * @returns {boolean} - True if valid, false otherwise.\n */\nwindow.os.fs.isValidPath = function(path) { ... }\n /**\n * Returns a list of entries in the filesystem object at the given path.\n * @param {string} path - The path to list entries from.\n * @returns {Array} - An array of entries.\n */\nwindow.os.fs.ls = function(path) { ... }\n /**\n * Creates an empty object at the given path.\n * @param {string} path - The path to create the directory.\n */\nwindow.os.fs.mkdir = function(path) { ... }\n /**\n * Removes the object at the given path.\n * @param {string} path - The path to remove the object from.\n */\nwindow.os.fs.rm = function(path) { ... }\n /**\n * Writes the content to an entry in the filesystem object at the given path.\n * @param {string} path - The path to write to.\n * @param {string} content - The content to write.\n */\nwindow.os.fs.write = function(path, content) { ... }\n /**\n * Reads an entry split by `\\n` in the filesystem object at the given path.\n * @param {string} path - The path to read from.\n * @returns {string|null} - The content of the file or null if not found.\n */\nwindow.os.fs.read = function(path) { ... }\n\n/**\n * Registers a new application in the OS with a title, emoji, and a callback function.\n * The callback function should return a DOM element that will be displayed in the body.\n * A close button will be added to allow removal of the application from the body.\n * \n * @param {string} title - The title of the application.\n * @param {string} emoji - The emoji representing the application.\n * @param {function} callback - A function that returns a DOM element to be displayed.\n */\nwindow.os.registerApplication = function(title, emoji, callback) { ... }\n\n\n\ndefine a function called getSlideDOMElement that takes an array of strings as an argument\niterate the array and for each item:\n split item by `\\n`\n iterate the split result and for each line:\n if the line starts with a dot and a string append the class of the slide to the string\n create a slide div element with class slide\n generate html dom elements corresponding to the markdown syntax with headers, text, image and backtick as pre support and append them to the slide element\n append the slide element to the result array\nreturn the result array\n",
"result": "```javascript\nfunction getSlideDOMElement(slides) {\n const result = [];\n slides.forEach(item => {\n const lines = item.split('\\n');\n const slideElement = document.createElement('div');\n slideElement.className = 'slide';\n\n lines.forEach(line => {\n if (line.startsWith('.')) {\n slideElement.classList.add(line.substring(1).trim());\n } else {\n let element;\n if (line.startsWith('# ')) {\n element = document.createElement('h1');\n element.textContent = line.substring(2).trim();\n } else if (line.startsWith('## ')) {\n element = document.createElement('h2');\n element.textContent = line.substring(3).trim();\n } else if (line.startsWith('### ')) {\n element = document.createElement('h3');\n element.textContent = line.substring(4).trim();\n } else if (line.startsWith('![')) {\n const altText = line.match(/!\\[(.*?)\\]/)[1];\n const src = line.match(/\\((.*?)\\)/)[1];\n element = document.createElement('img');\n element.src = src;\n element.alt = altText;\n } else if (line.startsWith('`')) {\n element = document.createElement('pre');\n element.textContent = line.substring(1, line.length - 1).trim();\n } else {\n element = document.createElement('p');\n element.textContent = line.trim();\n }\n slideElement.appendChild(element);\n }\n });\n\n result.push(slideElement);\n });\n return result;\n}\n```",
"output": "function getSlideDOMElement(slides) {\n const result = [];\n slides.forEach(item => {\n const lines = item.split('\\n');\n const slideElement = document.createElement('div');\n slideElement.className = 'slide';\n\n lines.forEach(line => {\n if (line.startsWith('.')) {\n slideElement.classList.add(line.substring(1).trim());\n } else {\n let element;\n if (line.startsWith('# ')) {\n element = document.createElement('h1');\n element.textContent = line.substring(2).trim();\n } else if (line.startsWith('## ')) {\n element = document.createElement('h2');\n element.textContent = line.substring(3).trim();\n } else if (line.startsWith('### ')) {\n element = document.createElement('h3');\n element.textContent = line.substring(4).trim();\n } else if (line.startsWith('![')) {\n const altText = line.match(/!\\[(.*?)\\]/)[1];\n const src = line.match(/\\((.*?)\\)/)[1];\n element = document.createElement('img');\n element.src = src;\n element.alt = altText;\n } else if (line.startsWith('`')) {\n element = document.createElement('pre');\n element.textContent = line.substring(1, line.length - 1).trim();\n } else {\n element = document.createElement('p');\n element.textContent = line.trim();\n }\n slideElement.appendChild(element);\n }\n });\n\n result.push(slideElement);\n });\n return result;\n}\n",
"library": "function getSlideDOMElement(slides) { ... }\n const altText = line.match(/!\\[(.*?)\\]/)[1];\n const src = line.match(/\\((.*?)\\)/)[1];\n"
}
Loading

0 comments on commit 13ef763

Please sign in to comment.