Skip to content

Commit a451e55

Browse files
committed
Added link to the graphql endpoint
1 parent 98224eb commit a451e55

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

docs/demos/leaflet-graphql/index.html

+45-6
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,41 @@
6464
button:hover {
6565
background: #0056b3;
6666
}
67+
68+
#endpointLink {
69+
text-decoration: none;
70+
font-weight: bold;
71+
color: #007bff;
72+
background-color: #f8f9fa;
73+
padding: 8px 12px;
74+
border-radius: 4px;
75+
border: 1px solid #007bff;
76+
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
77+
}
78+
79+
#endpointLink:hover {
80+
background-color: #007bff;
81+
color: white;
82+
border-color: #0056b3;
83+
}
84+
85+
#endpointLink:active {
86+
background-color: #0056b3;
87+
border-color: #004085;
88+
}
6789
</style>
6890
</head>
6991

7092
<body>
7193
<div id="sidebar">
7294
<h3>Edit GraphQL Query</h3>
7395
<textarea id="graphqlQuery"></textarea>
74-
<button id="updateMap">Update Map</button>
75-
<button id="loadSimpleExample">Load Simple Example</button>
76-
<button id="loadComplexExample">Load Complex Example</button>
96+
<div style="display: flex; align-items: center; gap: 10px;">
97+
<button id="updateMap">Update Map</button>
98+
<button id="loadSimpleExample">Load Simple Example</button>
99+
<button id="loadComplexExample">Load Complex Example</button>
100+
<a id="endpointLink" href="" target="_blank">View JSON on Endpoint</a>
101+
</div>
77102
</div>
78103
<div id="map"></div>
79104

@@ -236,7 +261,12 @@ <h3>Edit GraphQL Query</h3>
236261
});
237262
}
238263

239-
document.getElementById('graphqlQuery').value = initialQuery;
264+
function setQuery(newContent) {
265+
const textarea = document.getElementById('graphqlQuery');
266+
textarea.value = newContent;
267+
268+
textarea.dispatchEvent(new Event('input'));
269+
}
240270

241271
// Event listener for the "Update Map" button
242272
document.getElementById('updateMap').addEventListener('click', () => {
@@ -245,16 +275,25 @@ <h3>Edit GraphQL Query</h3>
245275

246276

247277
document.getElementById('loadSimpleExample').addEventListener('click', () => {
248-
document.getElementById('graphqlQuery').value = simpleQuery;
278+
setQuery(simpleQuery);
249279
addDataToMap();
250280
});
251281

252282
document.getElementById('loadComplexExample').addEventListener('click', () => {
253-
document.getElementById('graphqlQuery').value = complexQuery;
283+
setQuery(complexQuery);
254284
addDataToMap();
255285
});
256286

287+
document.getElementById('graphqlQuery').addEventListener('input', function () {
288+
const editorContent = document.getElementById('graphqlQuery').value;
289+
const params = new URLSearchParams({ qtxt: editorContent });
290+
const fullUrl = `${GRAPHQL_URL}?${params.toString()}`;
291+
document.getElementById('endpointLink').href = fullUrl;
292+
});
293+
294+
document.getElementById('endpointLink').href = GRAPHQL_URL;
257295

296+
setQuery(initialQuery);
258297

259298
// Load the map data
260299
addDataToMap(initialQuery);

0 commit comments

Comments
 (0)