Added Account section
This commit is contained in:
27
account/creditcard/creditcard.css
Normal file
27
account/creditcard/creditcard.css
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
#creditcard {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
105
account/creditcard/creditcard.js
Normal file
105
account/creditcard/creditcard.js
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiGet, apiPost, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.ccCurrent = "cc-current";
|
||||
elements.ccNew = "cc-new";
|
||||
elements.expiryCurrent = "expiry-current";
|
||||
elements.expiryMonth = "expiry-month";
|
||||
elements.expiryYear = "expiry-year";
|
||||
elements.updateButton = "update-button";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.ccCurrent = {};
|
||||
ui.ccNew = {};
|
||||
ui.expiryCurrent = {};
|
||||
ui.expiryMonth = {};
|
||||
ui.expiryYear = {};
|
||||
ui.updateButton = {};
|
||||
|
||||
// Callback for account details API call
|
||||
var displayCC = function(response)
|
||||
{
|
||||
if (!response.credit_card)
|
||||
return;
|
||||
|
||||
ui.ccCurrent.innerHTML = response.credit_card.last_four;
|
||||
ui.expiryCurrent.innerHTML = response.credit_card.expiry;
|
||||
};
|
||||
|
||||
// Click handler for update button
|
||||
var handleUpdate = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"card_number": ui.ccNew.value,
|
||||
"expiry_month": parseInt(ui.expiryMonth.value),
|
||||
"expiry_year": parseInt(ui.expiryYear.value)
|
||||
};
|
||||
|
||||
apiPost("/account/credit-card", req, function(response)
|
||||
{
|
||||
location.href = "/account";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.ccCurrent = document.getElementById(elements.ccCurrent);
|
||||
ui.ccNew = document.getElementById(elements.ccNew);
|
||||
ui.expiryCurrent = document.getElementById(elements.expiryCurrent);
|
||||
ui.expiryMonth = document.getElementById(elements.expiryMonth);
|
||||
ui.expiryYear = document.getElementById(elements.expiryYear);
|
||||
ui.updateButton = document.getElementById(elements.updateButton);
|
||||
|
||||
// Populate expiry selectors
|
||||
var now = new Date();
|
||||
ui.expiryMonth.value = now.getMonth() + 1;
|
||||
for (var i = 0; i < 25; i++) {
|
||||
var year = document.createElement("option");
|
||||
year.value = now.getFullYear() + i;
|
||||
year.innerHTML = now.getFullYear() + i;
|
||||
ui.expiryYear.appendChild(year);
|
||||
}
|
||||
|
||||
// Register event handlers
|
||||
ui.updateButton.addEventListener("click", handleUpdate);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/account", displayCC, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
91
account/creditcard/index.shtml
Normal file
91
account/creditcard/index.shtml
Normal file
@ -0,0 +1,91 @@
|
||||
<!--
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - Account // Update Credit Card</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="creditcard.css" />
|
||||
<script src="creditcard.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/account_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="creditcard">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Update Credit Card</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Current Card</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Current Card</td>
|
||||
<td>xxxxxxxxxxxx<span id="cc-current"></span> Exp: <span id="expiry-current"></span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="lmc-tbody-head">
|
||||
<tr class="noshow">
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Update Card</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>New Card Number</td>
|
||||
<td><input id="cc-new" type="text" /></td>
|
||||
<td class="info">Linode accepts Visa, MasterCard, American Express, and Discover</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Expires</td>
|
||||
<td>
|
||||
<select id="expiry-month">
|
||||
<option value="1">01</option>
|
||||
<option value="2">02</option>
|
||||
<option value="3">03</option>
|
||||
<option value="4">04</option>
|
||||
<option value="5">05</option>
|
||||
<option value="6">06</option>
|
||||
<option value="7">07</option>
|
||||
<option value="8">08</option>
|
||||
<option value="9">09</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
</select>
|
||||
<select id="expiry-year"></select>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button id="update-button" type="button">Update Credit Card</button>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user