Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
moved javascript to own file instead in html. Javascript code is messy.
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorholk committed Oct 12, 2020
1 parent be59b89 commit 0ec34c6
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 119 deletions.
116 changes: 116 additions & 0 deletions pcs/static/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@

function changefolder(i) {
y = document.getElementById('change_folder')
y.value = i
y.click()
}

function folderpopup(){
i = document.getElementById('popupfolder');
y = document.getElementById('popupfile');
yy = document.getElementById('popupfolders');
if (getComputedStyle(y, null).display == 'none' || getComputedStyle(yy, null).display == 'none'){
display = getComputedStyle(i, null).display;
if (display == 'none'){
i.style.display = 'block';
} else {
i.style.display = 'none';
}
}else{
i.style.display = 'block';
y.style.display = 'none';
yy.style.display = 'none';
}
}
// Get the input field
var input = document.getElementById("newfoldername");

// Execute a function when the user releases a key on the keyboard
input.addEventListener("keyup", function(event) {
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("submitfolder").click();
}
});

function filepopup(){
i = document.getElementById('popupfile');
ii = document.getElementById('popupfolders');
y = document.getElementById('popupfolder');
if (getComputedStyle(y, null).display == 'none'){
display = getComputedStyle(i, null).display;
if (display == 'none'){
i.style.display = 'block';
ii.style.display = 'block';
} else {
i.style.display = 'none';
ii.style.display = 'none';
}
} else{
i.style.display = 'block';
ii.style.display = 'block';
y.style.display = 'none';
}
}
function fileuploaded(){
document.getElementById('submitfile').click()
}
function foldersuploaded(){
document.getElementById('submitfolders').click()
}

function deleteItem(i){
let y = document.getElementById('delete_button')
console.log(y)
y.value = i;
let x = confirm('Delete ' + i + " ?")
if (x == true){
y.click()
}
}
function editItem(i){
let y = document.getElementById('edit_button')
console.log(y)
let x = prompt('Assign a new name for ' + i)

if (!x == null || !x == ''){
y.value = String(i + "," + x)
y.click();
}
}
function download_folder(i){
let y = document.getElementById('zip_folder');
console.log(y);
y.value = i;
y.click();
console.log(y.value);
}


function deleteItem(i){
let y = document.getElementById('delete_button')
console.log(y)
y.value = i;
let x = confirm('Delete ' + i + " ?")
if (x == true){
y.click()
}
}

function editItem(i){
let y = document.getElementById('edit_button')
console.log(y)
let x = prompt('Assign a new name for ' + i)

if (!x == null || !x == ''){
y.value = String(i + "," + x)
y.click();
}
}

function fileuploaded(){
document.getElementById('submitfile').click()
}
4 changes: 3 additions & 1 deletion pcs/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

<link href="https://fonts.googleapis.com/css?family=Raleway:400,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Caveat&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Caveat&display=swap" rel="stylesheet">

<script src="../static/main.js"></script>

</head>
<body id="backgrounder">
Expand Down
92 changes: 0 additions & 92 deletions pcs/templates/main/cloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,97 +160,5 @@ <h6 style="font-weight: bold;">{{ user_cloud.get_storage() }} / {{ user_cloud.g
</form>
</div>
</div>
<script>

function changefolder(i) {
y = document.getElementById('change_folder')
y.value = i
y.click()
}

function folderpopup(){
i = document.getElementById('popupfolder');
y = document.getElementById('popupfile');
yy = document.getElementById('popupfolders');
if (getComputedStyle(y, null).display == 'none' || getComputedStyle(yy, null).display == 'none'){
display = getComputedStyle(i, null).display;
if (display == 'none'){
i.style.display = 'block';
} else {
i.style.display = 'none';
}
}else{
i.style.display = 'block';
y.style.display = 'none';
yy.style.display = 'none';
}
}
// Get the input field
var input = document.getElementById("newfoldername");

// Execute a function when the user releases a key on the keyboard
input.addEventListener("keyup", function(event) {
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("submitfolder").click();
}
});

function filepopup(){
i = document.getElementById('popupfile');
ii = document.getElementById('popupfolders');
y = document.getElementById('popupfolder');
if (getComputedStyle(y, null).display == 'none'){
display = getComputedStyle(i, null).display;
if (display == 'none'){
i.style.display = 'block';
ii.style.display = 'block';
} else {
i.style.display = 'none';
ii.style.display = 'none';
}
} else{
i.style.display = 'block';
ii.style.display = 'block';
y.style.display = 'none';
}
}
function fileuploaded(){
document.getElementById('submitfile').click()
}
function foldersuploaded(){
document.getElementById('submitfolders').click()
}

function deleteItem(i){
let y = document.getElementById('delete_button')
console.log(y)
y.value = i;
let x = confirm('Delete ' + i + " ?")
if (x == true){
y.click()
}
}
function editItem(i){
let y = document.getElementById('edit_button')
console.log(y)
let x = prompt('Assign a new name for ' + i)

if (!x == null || !x == ''){
y.value = String(i + "," + x)
y.click();
}
}
function download_folder(i){
let y = document.getElementById('zip_folder');
console.log(y);
y.value = i;
y.click();
console.log(y.value);
}

</script>
{% endblock %}
26 changes: 0 additions & 26 deletions pcs/templates/main/uploads.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,4 @@ <h6 style="font-weight: bold;">{{ obj.count_files() }} Files</h6>

</div>

<script>
function deleteItem(i){
let y = document.getElementById('delete_button')
console.log(y)
y.value = i;
let x = confirm('Delete ' + i + " ?")
if (x == true){
y.click()
}
}

function editItem(i){
let y = document.getElementById('edit_button')
console.log(y)
let x = prompt('Assign a new name for ' + i)

if (!x == null || !x == ''){
y.value = String(i + "," + x)
y.click();
}
}

function fileuploaded(){
document.getElementById('submitfile').click()
}
</script>
{% endblock %}

0 comments on commit 0ec34c6

Please sign in to comment.