File tree Expand file tree Collapse file tree 3 files changed +65
-10
lines changed
Expand file tree Collapse file tree 3 files changed +65
-10
lines changed Original file line number Diff line number Diff line change 2734327343 frameDoc: {},
2734427344 tableQuads: {},
2734527345 remoteDocURL: '',
27346+ remoteSideDocURL: '',
2734627347 parseError: '',
2734727348 inputTab: 'json-ld',
2734827349 outputTab: 'expanded',
@@ -27365,17 +27366,39 @@
2736527366 get hasTableQuads() {
2736627367 return Object.keys(this.tableQuads).length > 0;
2736727368 },
27369+ get sideDoc() {
27370+ if (this.outputTab === 'framed') {
27371+ return 'frameDoc';
27372+ } else {
27373+ return 'contextDoc';
27374+ }
27375+ },
27376+ get sideEditor() {
27377+ if (this.outputTab === 'framed') {
27378+ return this.frameEditor;
27379+ } else {
27380+ return this.contextEditor;
27381+ }
27382+ },
27383+ get sideEditorURLFieldPlaceholderText() {
27384+ if (this.outputTab === 'framed') {
27385+ return 'Frame URL';
27386+ } else {
27387+ return 'Context URL';
27388+ }
27389+ },
2736827390 // methods
27369- async retrieveDoc() {
27391+ async retrieveDoc(_editor, docVar, url ) {
2737027392 try {
27371- const rv = await fetch(this.remoteDocURL );
27393+ const rv = await fetch(url );
2737227394 if (!rv.ok) {
2737327395 throw new Error(`HTTP error status: ${rv.status}`);
2737427396 }
27375- this.doc = await rv.json();
27376- setEditorValue(this.mainEditor , this.doc );
27397+ this[docVar] = await rv.json();
27398+ setEditorValue(_editor , this[docVar] );
2737727399 // clear the remoteDocURL to avoid confusion around state
2737827400 this.remoteDocURL = '';
27401+ this.remoteSideDocURL = '';
2737927402 } catch (err) {
2738027403 this.parseError = err.message;
2738127404 }
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ window.app = createApp({
126126 frameDoc : { } ,
127127 tableQuads : { } ,
128128 remoteDocURL : '' ,
129+ remoteSideDocURL : '' ,
129130 parseError : '' ,
130131 inputTab : 'json-ld' ,
131132 outputTab : 'expanded' ,
@@ -148,17 +149,39 @@ window.app = createApp({
148149 get hasTableQuads ( ) {
149150 return Object . keys ( this . tableQuads ) . length > 0 ;
150151 } ,
152+ get sideDoc ( ) {
153+ if ( this . outputTab === 'framed' ) {
154+ return 'frameDoc' ;
155+ } else {
156+ return 'contextDoc' ;
157+ }
158+ } ,
159+ get sideEditor ( ) {
160+ if ( this . outputTab === 'framed' ) {
161+ return this . frameEditor ;
162+ } else {
163+ return this . contextEditor ;
164+ }
165+ } ,
166+ get sideEditorURLFieldPlaceholderText ( ) {
167+ if ( this . outputTab === 'framed' ) {
168+ return 'Frame URL' ;
169+ } else {
170+ return 'Context URL' ;
171+ }
172+ } ,
151173 // methods
152- async retrieveDoc ( ) {
174+ async retrieveDoc ( _editor , docVar , url ) {
153175 try {
154- const rv = await fetch ( this . remoteDocURL ) ;
176+ const rv = await fetch ( url ) ;
155177 if ( ! rv . ok ) {
156178 throw new Error ( `HTTP error status: ${ rv . status } ` ) ;
157179 }
158- this . doc = await rv . json ( ) ;
159- setEditorValue ( this . mainEditor , this . doc ) ;
180+ this [ docVar ] = await rv . json ( ) ;
181+ setEditorValue ( _editor , this [ docVar ] ) ;
160182 // clear the remoteDocURL to avoid confusion around state
161183 this . remoteDocURL = '' ;
184+ this . remoteSideDocURL = '' ;
162185 } catch ( err ) {
163186 this . parseError = err . message ;
164187 }
Original file line number Diff line number Diff line change @@ -103,8 +103,8 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
103103 < div class ="item ">
104104 < div class ="ui icon input ">
105105 < input type ="text " placeholder ="Document URL "
106- v-model ="remoteDocURL " @keyup.enter ="retrieveDoc() ">
107- < i class ="file link icon " @click ="retrieveDoc() "> </ i >
106+ v-model ="remoteDocURL " @keyup.enter ="retrieveDoc(mainEditor, 'doc', remoteDocURL ) ">
107+ < i class ="file link icon " @click ="retrieveDoc(mainEditor, 'doc', remoteDocURL ) "> </ i >
108108 </ div >
109109 </ div >
110110 </ div >
@@ -244,6 +244,15 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
244244 < span v-show ="outputTab == 'compacted' || outputTab == 'flattened' "> New JSON-LD Context</ span >
245245 < span v-show ="outputTab == 'framed' "> JSON-LD Frame</ span >
246246 </ div >
247+ < div class ="right menu ">
248+ < div class ="item ">
249+ < div class ="ui icon input ">
250+ < input type ="text " :placeholder ="sideEditorURLFieldPlaceholderText "
251+ v-model ="remoteSideDocURL " @keyup.enter ="retrieveDoc(sideEditor, sideDoc, remoteSideDocURL) ">
252+ < i class ="file link icon " @click ="retrieveDoc(sideEditor, sideDoc, remoteSideDocURL) "> </ i >
253+ </ div >
254+ </ div >
255+ </ div >
247256 </ div >
248257 < div class ="ui bottom attached fitted resizable scrolling segment ">
249258 < div id ="context-editor " v-effect ="docChanged('context', contextDoc, $el) "
You can’t perform that action at this time.
0 commit comments