()
| 223 | }; |
| 224 | |
| 225 | bind() { |
| 226 | |
| 227 | window.addEventListener("beforeunload", this.handleBeforeUnload) |
| 228 | |
| 229 | document.addEventListener("submit", (event) => { |
| 230 | // Disable unsaved changes warning when submitting the editor form |
| 231 | if (event.target.id === "editor") { |
| 232 | window.removeEventListener("beforeunload", this.handleBeforeUnload); |
| 233 | } |
| 234 | }) |
| 235 | |
| 236 | document.querySelectorAll('.query_favorite_toggle').forEach(function(element) { |
| 237 | element.addEventListener('click', toggleFavorite); |
| 238 | }); |
| 239 | |
| 240 | document.getElementById('show_schema_button')?.addEventListener('click', this.showSchema.bind(this)); |
| 241 | document.getElementById('hide_schema_button')?.addEventListener('click', this.hideSchema.bind(this)); |
| 242 | |
| 243 | |
| 244 | $("#format_button").click(function(e) { |
| 245 | e.preventDefault(); |
| 246 | this.formatSql(); |
| 247 | }.bind(this)); |
| 248 | |
| 249 | $("#rows").keyup(function() { |
| 250 | var curUrl = $("#fullscreen").attr("href"); |
| 251 | var newUrl = curUrl.replace(/rows=\d+/, "rows=" + $("#rows").val()); |
| 252 | $("#fullscreen").attr("href", newUrl); |
| 253 | }.bind(this)); |
| 254 | |
| 255 | $("#save_button").click(function() { |
| 256 | var params = this.getParams(this); |
| 257 | if(params) { |
| 258 | this.$form.attr("action", "../" + this.queryId + "/?params=" + this.serializeParams(params)); |
| 259 | } |
| 260 | this.$snapshotField.hide(); |
| 261 | this.$form.append(this.$snapshotField); |
| 262 | }.bind(this)); |
| 263 | |
| 264 | $("#save_only_button").click(function() { |
| 265 | var params = this.getParams(this); |
| 266 | if(params) { |
| 267 | this.$form.attr('action', '../' + this.queryId + '/?show=0¶ms=' + this.serializeParams(params)); |
| 268 | } else { |
| 269 | this.$form.attr('action', '../' + this.queryId + '/?show=0'); |
| 270 | } |
| 271 | this.$snapshotField.hide(); |
| 272 | this.$form.append(this.$snapshotField); |
| 273 | }.bind(this)); |
| 274 | |
| 275 | $("#refresh_button").click(function(e) { |
| 276 | e.preventDefault(); |
| 277 | var params = this.getParams(); |
| 278 | if(params) { |
| 279 | window.location.href = "../" + this.queryId + "/?params=" + this.serializeParams(params); |
| 280 | } else { |
| 281 | window.location.href = "../" + this.queryId + "/"; |
| 282 | } |
no test coverage detected