diff --git a/images/friendica-32px.png b/images/friendica-32px.png new file mode 100644 index 0000000..c3ee0f4 Binary files /dev/null and b/images/friendica-32px.png differ diff --git a/images/mastodon-32px.png b/images/mastodon-32px.png new file mode 100644 index 0000000..f7df2c4 Binary files /dev/null and b/images/mastodon-32px.png differ diff --git a/images/pleroma-32px.png b/images/pleroma-32px.png new file mode 100644 index 0000000..3699f75 Binary files /dev/null and b/images/pleroma-32px.png differ diff --git a/index.html b/index.html index a423009..c469ad9 100644 --- a/index.html +++ b/index.html @@ -81,6 +81,19 @@ Регистрация на lor.sh

+ + + + + + + + + + + + +
ПлатформаMastodon
РегистрацияПремодерируемая
diff --git a/js/functions.js b/js/functions.js index 7bfef72..fca7ea2 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1,14 +1,12 @@ /** - * Returns random key from the object. + * Returns random item from given array. * - * @param {object} obj - * @returns {string} + * @param {array} array + * @returns {object} */ -function getRandomKey(obj) { - let keys = Object.keys(obj); - - return keys[ keys.length * Math.random() << 0 ]; -}; +function getRandomItem(array) { + return array[array.length * Math.random() << 0]; +} /** * Randomly sorts an array. diff --git a/js/list-servers.js b/js/list-servers.js index 03d0d20..56a540a 100644 --- a/js/list-servers.js +++ b/js/list-servers.js @@ -1,19 +1,33 @@ // Should be included using 'defer' after servers.js and functions.js -let listGroup = document.getElementById('server-list'); +let tableBody = document.getElementById('table-servers-body'); -let shuffledServerNames = shuffleArray(Object.keys(instances)); -console.log('shuffled: ', shuffledServerNames); +let shuffledServers = shuffleArray(instances); +console.log('shuffled: ', shuffledServers); -for (serverName of shuffledServerNames) { - let url = instances[serverName]; +for (server of shuffledServers) { + let platform = platforms[server.platform]; + let regMode = registrationModes[server.registration]; - // Creating list item - let item = document.createElement('a'); - item.setAttribute('class', 'list-group-item'); - item.setAttribute('href', url); - item.innerText = serverName; + let tr = document.createElement('tr'); - listGroup.appendChild(item); + let tdName = document.createElement('td'); + let tdPlatform = document.createElement('td'); + let tdRegistration = document.createElement('td'); + tr.appendChild(tdName); + tr.appendChild(tdPlatform); + tr.appendChild(tdRegistration); + + serverLink = document.createElement('a'); + serverLink.setAttribute('href', server.url); + serverLink.innerText = server.name; + tdName.appendChild(serverLink); + platformIcon = document.createElement('img'); + platformIcon.setAttribute('src', platform.icon); + tdPlatform.appendChild(platformIcon); + tdPlatform.appendChild(document.createTextNode(' ' + platform.name)); + tdRegistration.innerText = regMode.name; + + // Adding to table + tableBody.appendChild(tr); } - diff --git a/js/random-server.js b/js/random-server.js index 8dc58a1..5d52657 100644 --- a/js/random-server.js +++ b/js/random-server.js @@ -1,10 +1,27 @@ // Should be included using 'defer' after servers.js and functions.js -let serverName = getRandomKey(instances); -let url = instances[serverName]; +let server = getRandomItem(instances); -console.log('Randomly selected: ', serverName, url); +console.log('Randomly selected: ', server); +// Server link let linkElement = document.getElementById('reg-link'); -linkElement.setAttribute('href', url); -linkElement.innerText = 'Регистрация на ' + serverName; +linkElement.setAttribute('href', server.url); +linkElement.innerText = 'Регистрация на ' + server.name; + +let platform = platforms[server.platform]; +let regMode = registrationModes[server.registration]; + +// Additional metadata elements +let platformElement = document.getElementById('node-platform'); +let registrationElement = document.getElementById('node-registration'); + +// Icon element +let platformIcon = document.createElement('img'); +platformIcon.setAttribute('src', platform.icon); + +platformElement.innerHTML = ''; +platformElement.appendChild(platformIcon); +platformElement.appendChild(document.createTextNode(' ' + platform.name)); + +registrationElement.innerText = regMode.name; \ No newline at end of file diff --git a/js/servers.js b/js/servers.js index c7bcb94..00748e2 100644 --- a/js/servers.js +++ b/js/servers.js @@ -1,10 +1,22 @@ // You can add your instances here using Pull Request on Github -var instances = { - 'lor.sh': 'https://lor.sh', - 'mastodon.ml': 'https://mastodon.ml', - 'Expired Mentality': 'https://expired.mentality.rip', - 'Клуб "Свобода"': 'https://soc.phreedom.club', - 'zHub.link': 'https://zhub.link', - 'Дорогу осилит идущий': 'https://aspirant.de', +var instances = [ + {name: 'lor.sh', url: 'https://lor.sh', platform: 'mastodon', registration: 'premoderated'}, + {name: 'mastodon.ml', url: 'https://mastodon.ml', platform: 'mastodon', registration: 'open'}, + {name: 'Expired Mentality', url: 'https://expired.mentality.rip', platform: 'pleroma', registration: 'open'}, + {name: 'Клуб "Свобода"', url: 'https://soc.phreedom.club', platform: 'pleroma', registration: 'open'}, + {name: 'zHub.link', url: 'https://zhub.link', platform: 'mastodon', registration: 'open'}, + {name: 'Дорогу осилит идущий', url: 'https://aspirant.de', platform: 'mastodon', registration: 'open'}, +]; + +var platforms = { + mastodon: {name: 'Mastodon', icon: 'images/mastodon-32px.png'}, + pleroma: {name: 'Pleroma', icon: 'images/pleroma-32px.png'}, + friendica: {name: 'Friendica', icon: 'images/friendica-32px.png'}, + //misskey: {name: 'Misskey', icon: 'images/misskey.png'}, +}; + +var registrationModes = { + open: {name: 'Открытая', description: 'Свободная регистрация'}, + premoderated: {name: 'Премодерируемая', description: 'После регистрации необходимо дождаться проверки модератора'}, }; diff --git a/servers.html b/servers.html index 2f17c9e..3a35472 100644 --- a/servers.html +++ b/servers.html @@ -72,9 +72,17 @@

Рекомендованные русскоязычные серверы

-
- -
+ + + + + + + + + + +
СерверПлатформаРегистрация