Spaces:
Running
Running
Download make.js from patrickleenyc/bufo-bench: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/spaces/patrickleenyc/bufo-bench/resolve/main/make.js
- Command line
-
hf download hf://spaces/patrickleenyc/bufo-bench/make.js
-
curl -L -o make.js https://huggingface.co/spaces/patrickleenyc/bufo-bench/resolve/main/make.js
2.41 kB
| const P=window.BUFO_PROMPTS; | |
| const el=id=>document.getElementById(id); | |
| for(const t of P.tasks){const option=document.createElement('option');option.value=t.id;option.textContent=t.title;el('prompt-task').append(option);} | |
| function selectTask(update=false){const t=P.tasks.find(t=>t.id===el('prompt-task').value)||P.tasks[0];el('benchmark-prompt').value=t.full_prompt;if(update){const url=new URL(location.href);url.searchParams.set('task',t.id);url.hash='benchmark-prompts';history.pushState({},'',url);}} | |
| function readLocation(){const id=new URL(location.href).searchParams.get('task');el('prompt-task').value=P.tasks.some(t=>t.id===id)?id:'02-morning-coffee';selectTask();} | |
| function custom(){const joke=el('joke').value.trim();el('custom-prompt').value=joke?P.recipe.replace('{{JOKE}}',()=>joke):'';return !!joke;} | |
| el('joke').value='Bufo offering you a slice of pizza instead of an apology.';custom(); | |
| el('build-custom').onclick=()=>{if(!custom()){el('copy-status').textContent='Describe his predicament first.';el('joke').focus();}else{el('custom-prompt').focus();el('copy-status').textContent='Prompt ready. Bring the original frog.';}}; | |
| el('joke').oninput=custom; | |
| async function copy(text,button,field){if(!text){el('copy-status').textContent='Describe his predicament first.';el('joke').focus();return;}try{await navigator.clipboard.writeText(text);button.textContent='Copied ✓';el('copy-status').textContent='Copied. Don’t forget to bring the frog.';}catch{field.hidden=false;field.focus();field.select();button.textContent='Select all + copy';el('copy-status').textContent='Clipboard unavailable. The text is selected; use your device’s Copy command.';}} | |
| for(const button of document.querySelectorAll('[data-copy]')){const original=button.textContent;button.onclick=async()=>{const field=el(button.dataset.copy);await copy(field.value,button,field);setTimeout(()=>button.textContent=original,2500);};} | |
| el('copy-task-link').onclick=async()=>{const url=new URL(location.href);url.search='';url.searchParams.set('task',el('prompt-task').value);url.hash='benchmark-prompts';el('link-fallback').value=String(url);el('link-fallback').hidden=true;await copy(String(url),el('copy-task-link'),el('link-fallback'));setTimeout(()=>el('copy-task-link').textContent='Copy link to this task',2500);}; | |
| el('prompt-task').onchange=()=>selectTask(true);window.addEventListener('popstate',readLocation);readLocation(); | |