feature: allow users to manage ssh keys

This commit is contained in:
Usman Nasir
2020-10-25 10:07:50 +05:00
parent b815d10600
commit a749f71395
120 changed files with 18507 additions and 5400 deletions

View File

@@ -1,13 +1,12 @@
/*global gettext, pgettext, get_format, quickElement, removeChildren, addEvent*/
/*global gettext, pgettext, get_format, quickElement, removeChildren*/
/*
calendar.js - Calendar functions by Adrian Holovaty
depends on core.js for utility functions like removeChildren or quickElement
*/
(function() {
'use strict';
'use strict';
{
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
var CalendarNamespace = {
const CalendarNamespace = {
monthsOfYear: [
gettext('January'),
gettext('February'),
@@ -36,7 +35,7 @@ depends on core.js for utility functions like removeChildren or quickElement
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));
},
getDaysInMonth: function(month, year) {
var days;
let days;
if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
days = 31;
}
@@ -52,11 +51,11 @@ depends on core.js for utility functions like removeChildren or quickElement
return days;
},
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
var today = new Date();
var todayDay = today.getDate();
var todayMonth = today.getMonth() + 1;
var todayYear = today.getFullYear();
var todayClass = '';
const today = new Date();
const todayDay = today.getDate();
const todayMonth = today.getMonth() + 1;
const todayYear = today.getFullYear();
let todayClass = '';
// Use UTC functions here because the date field does not contain time
// and using the UTC function variants prevent the local time offset
@@ -69,33 +68,33 @@ depends on core.js for utility functions like removeChildren or quickElement
//
// The day variable above will be 1 instead of 2 in, say, US Pacific time
// zone.
var isSelectedMonth = false;
let isSelectedMonth = false;
if (typeof selected !== 'undefined') {
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month);
}
month = parseInt(month);
year = parseInt(year);
var calDiv = document.getElementById(div_id);
const calDiv = document.getElementById(div_id);
removeChildren(calDiv);
var calTable = document.createElement('table');
const calTable = document.createElement('table');
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year);
var tableBody = quickElement('tbody', calTable);
const tableBody = quickElement('tbody', calTable);
// Draw days-of-week header
var tableRow = quickElement('tr', tableBody);
for (var i = 0; i < 7; i++) {
let tableRow = quickElement('tr', tableBody);
for (let i = 0; i < 7; i++) {
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
}
var startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
var days = CalendarNamespace.getDaysInMonth(month, year);
const startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
const days = CalendarNamespace.getDaysInMonth(month, year);
var nonDayCell;
let nonDayCell;
// Draw blanks before first of month
tableRow = quickElement('tr', tableBody);
for (i = 0; i < startingPos; i++) {
for (let i = 0; i < startingPos; i++) {
nonDayCell = quickElement('td', tableRow, ' ');
nonDayCell.className = "nonday";
}
@@ -103,14 +102,14 @@ depends on core.js for utility functions like removeChildren or quickElement
function calendarMonth(y, m) {
function onClick(e) {
e.preventDefault();
callback(y, m, django.jQuery(this).text());
callback(y, m, this.textContent);
}
return onClick;
}
// Draw days of month
var currentDay = 1;
for (i = startingPos; currentDay <= days; i++) {
let currentDay = 1;
for (let i = startingPos; currentDay <= days; i++) {
if (i % 7 === 0 && currentDay !== 1) {
tableRow = quickElement('tr', tableBody);
}
@@ -128,9 +127,9 @@ depends on core.js for utility functions like removeChildren or quickElement
todayClass += "selected";
}
var cell = quickElement('td', tableRow, '', 'class', todayClass);
var link = quickElement('a', cell, currentDay, 'href', '#');
addEvent(link, 'click', calendarMonth(year, month));
const cell = quickElement('td', tableRow, '', 'class', todayClass);
const link = quickElement('a', cell, currentDay, 'href', '#');
link.addEventListener('click', calendarMonth(year, month));
currentDay++;
}
@@ -205,4 +204,4 @@ depends on core.js for utility functions like removeChildren or quickElement
};
window.Calendar = Calendar;
window.CalendarNamespace = CalendarNamespace;
})();
}