/* * This file is part of Linode Manager Classic. * * Linode Manager Classic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Linode Manager Classic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Linode Manager Classic. If not, see . */ import { settings, elements, apiPost, parseParams, setupHeader } from "/global.js"; (function() { // Element names specific to this page elements.addButton = "add-button"; elements.key = "key"; elements.label = "label"; // Data received from API calls var data = {}; // Static references to UI elements var ui = {}; ui.addButton = {}; ui.key = {}; ui.label = {}; // Click handler for add button var handleAdd = function(event) { var req = { "label": ui.label.value, "ssh_key": ui.key.value }; apiPost("/profile/sshkeys", req, function(response) { location.href = "/profile/ssh"; }); }; // Initial setup var setup = function() { // Parse URL parameters data.params = parseParams(); setupHeader(); // Get element references ui.addButton = document.getElementById(elements.addButton); ui.key = document.getElementById(elements.key); ui.label = document.getElementById(elements.label); // Register event handlers ui.addButton.addEventListener("click", handleAdd); }; // Attach onload handler window.addEventListener("load", setup); })();