@@ -10,7 +10,7 @@ const copied = ref(false);
1010
1111function runScript () {
1212 try {
13- output .value = JSON . stringify ( evaluate (code .value ), null , 2 );
13+ output .value = evaluate (code .value );
1414 } catch (error) {
1515 output .value = ' ' + error;
1616 }
@@ -45,17 +45,16 @@ onMounted(() => {
4545 const params = new URLSearchParams (window .location .search );
4646 if (params .has (' s' )) {
4747 code .value = decodeURIComponent (params .get (' s' ));
48+ } else {
49+ code .value = ' # Hello World!\n # This is a comment\n x = 1\n y = 2\n\n # return sum of x and y\n x + y\n\n # now hit run to view the solution' ;
4850 }
4951});
5052 </script >
5153
5254<template >
5355 <div class =" box" >
5456 <div >
55- <label for =" code" >Code</label >
56- <br />
57- <textarea ref =" input" v-model.trim =" code" @input =" reset" name =" code" id =" code" spellcheck =" false"
58- autocomplete =" off" ></textarea >
57+ <textarea ref =" input" v-model.trim =" code" @input =" reset" spellcheck =" false" autocomplete =" off" ></textarea >
5958 </div >
6059 <div >
6160 <button @click =" runScript" >Run</button >
@@ -68,9 +67,15 @@ onMounted(() => {
6867 <span @click =" copyURL" >{{ copied ? 'Copied' : 'Copy' }}</span >
6968 </div >
7069 </div >
71- <div v-show =" output.length" >
70+ <div v-show =" (typeof output !== 'string')" >
71+ <div v-if =" output.solution" >
72+ <b >Solution:</b >
73+ <div v-for =" n in output.solution" :key =" n" >= {{ n }}</div >
74+ </div >
75+ </div >
76+ <div v-show =" (typeof output !== 'string')" >
7277 <b >Output:</b >
73- <p >{{ output }}</p >
78+ <p >{{ JSON.stringify( output, null, 2) }}</p >
7479 </div >
7580 </div >
7681</template >
@@ -84,7 +89,7 @@ onMounted(() => {
8489}
8590
8691.box > div {
87- margin-bottom : 1 rem ;
92+ margin-bottom : 1.5 rem ;
8893}
8994
9095button {
0 commit comments