MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / parseContent

Function parseContent

ui/media/js/dnd.js:756–783  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

754}
755
756async function parseContent(text) {
757 text = text.trim()
758 if (text.startsWith("{") && text.endsWith("}")) {
759 try {
760 const task = JSON.parse(text)
761 if (!("reqBody" in task)) {
762 // support the format saved to the disk, by the UI
763 task.reqBody = Object.assign({}, task)
764 }
765 restoreTaskToUI(task)
766 return true
767 } catch (e) {
768 console.warn(`JSON text content couldn't be parsed.`, e)
769 }
770 return false
771 }
772 // Normal txt file.
773 const task = parseTaskFromText(text)
774 if (text.toLowerCase().includes("seed:") && task) {
775 // only parse valid task content
776 restoreTaskToUI(task)
777 return true
778 } else {
779 console.warn(`Raw text content couldn't be parsed.`)
780 promptField.value = text
781 return false
782 }
783}
784
785async function readFile(file, i) {
786 console.log(`Event %o reading file[${i}]:${file.name}...`)

Callers 4

readFileFunction · 0.85
dnd.jsFile · 0.85
main.jsFile · 0.85

Calls 3

restoreTaskToUIFunction · 0.85
parseTaskFromTextFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected