moved static data one directory up

This commit is contained in:
Kevin Froman 2019-09-23 17:56:05 -05:00
parent e4df34ef29
commit 09f6735961
124 changed files with 27 additions and 54 deletions

View file

@ -0,0 +1,96 @@
/*
Onionr - Private P2P Communication
This file handles the UI for managing friends/contacts
This program 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.
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
friendListDisplay = document.getElementById('friendList')
addForm = document.getElementById('addFriend')
function removeFriend(pubkey){
post_to_url('/friends/remove/' + pubkey, {'token': webpass})
}
addForm.onsubmit = function(){
var friend = document.getElementsByName('addKey')[0]
var alias = document.getElementsByName('data')[0]
if (alias.value.toLowerCase().trim() == 'anonymous'){
PNotify.error({
text: "Anonymous is a reserved alias name"
})
return false
}
fetch('/friends/add/' + friend.value, {
method: 'POST',
headers: {
"token": webpass
}}).then(function(data) {
if (alias.value.trim().length > 0){
post_to_url('/friends/setinfo/' + friend.value + '/name', {'data': alias.value, 'token': webpass})
}
})
return false
}
fetch('/friends/list', {
headers: {
"token": webpass
}})
.then((resp) => resp.json()) // Transform the data into json
.then(function(resp) {
var keys = [];
for(var k in resp) keys.push(k);
console.log(keys)
if (keys.length == 0){
friendListDisplay.innerText = "None yet :("
}
for (var i = 0; i < keys.length; i++){
var peer = keys[i]
var name = resp[keys[i]]['name']
if (name === null || name === ''){
name = peer
}
var entry = document.createElement('div')
var nameText = document.createElement('input')
removeButton = document.createElement('button')
removeButton.classList.add('friendRemove')
removeButton.classList.add('button', 'is-danger')
entry.setAttribute('data-pubkey', peer)
removeButton.innerText = 'X'
nameText.value = name
nameText.readOnly = true
nameText.style.fontStyle = "italic"
entry.style.paddingTop = '8px'
entry.appendChild(removeButton)
entry.appendChild(nameText)
friendListDisplay.appendChild(entry)
}
// If friend delete buttons are pressed
var friendRemoveBtns = document.getElementsByClassName('friendRemove')
for (var x = 0; x < friendRemoveBtns.length; x++){
var friendKey = friendRemoveBtns[x].parentElement.getAttribute('data-pubkey')
friendRemoveBtns[x].onclick = function(){
removeFriend(friendKey)
}
}
})

View file

@ -0,0 +1,162 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<!--Mobile responsive-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
Friends
</title>
<link rel='shortcut icon' type='image/ico' href='/shared/images/favicon.ico'>
<link rel='stylesheet' href='/shared/main/PNotifyBrightTheme.css'>
<link rel='stylesheet' href='/shared/main/bulma.min.css'>
<link rel='stylesheet' href='/shared/main/styles-new.css'>
<link rel='stylesheet' href='/friends/style.css'>
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
<script defer src="/shared/navbar.js"></script>
<script defer src="/shared/misc.js"></script>
<script defer src="/friends/friends.js"></script>
</head>
<body>
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item idLink" href="/">
<img src="/shared/images/favicon.ico" class="navbarLogo"> Onionr
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item idLink" href="/">Home</a>
<a class="navbar-item idLink" href="/mail/">Mail</a>
<a class="navbar-item idLink" href="/friends/">Friends</a>
<a class="navbar-item idLink" href="/board/">Circles</a>
<a class="navbar-item idLink" href="/chat/">Chat</a>
</div>
</div>
</nav>
<!--Hero (Dark Section)-->
<section class="hero is-small is-dark">
<div class="hero-body">
<div class="container">
<div class="columns">
<div class="column">
<h1 class="title">
Friends
</h1>
<h2 class="subtitle">
Manage your friend list
</h2>
</div>
<div class="column is-7">
<div class="field">
<label class="label">Open Site</label>
<div class="field has-addons">
<p class="control">
<a class="button is-static">Identity</a>
</p>
<p class="control is-expanded">
<input id="myPub" class="input myPub" type="text" readonly>
</p>
<p class="control">
<a id="myPubCopy" class="button is-primary">Copy</a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<br>
<!--Start Content-->
<div class="container">
<div class="columns">
<!--Add Friend-->
<div class="column is-one-third">
<div class="card">
<header class="card-header">
<p class="card-header-title">
Add Friend
</p>
</header>
<div class="card-content">
<div class="content">
<form id='addFriend' action='/' method='POST'>
<div class="field">
<label class="label">Friend ID</label>
<p class="control is-expanded">
<input id="" class="input" type="text" name='addKey' placeholder='Public Key/ID'
minlength="52" maxlength="500" required>
</p>
</div>
<div class="field">
<label class="label">Alias</label>
<p class="control is-expanded">
<input id="" class="input" type="text" name='data' placeholder='Name' required>
</p>
</div>
</div>
</div>
<footer class="card-footer">
<a class="card-footer-item">
<button class="button is-success" type='submit'>Add Friend</button>
</a>
</footer>
</div>
</div>
<!--Friend List-->
<div class="column">
<div class="card">
<header class="card-header">
<p class="card-header-title">
Friend List
</p>
</header>
<div class="card-content">
<div class="content">
<div id='friendList'>
<!--Friend list is appended here-->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Template markup for friend list-->
<template id="friendTemplate">
<div class="box">
<div class="columns">
<div class="column is-narrow" id='friendName'>
Name
</div>
<div class="column" id='friendPubkey'>
Public Key
</div>
<div class="column is-narrow friendRemove" id='defriend'>
<a class="">Delete</a>
</div>
</div>
</div>
</template>
</body>
</html>

View file

@ -0,0 +1,4 @@
#friendList button{
display: inline;
margin-right: 10px;
}