-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
115 lines (100 loc) · 4.47 KB
/
bundle.js
File metadata and controls
115 lines (100 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/**
* This file is used at client side.
* It contains function which creates ajax POST request to the nodejs server.
* It also handles dynamic visibility of some HTML elememts
* Minified version oh this file is bundle.js
*
* Authers :
* Neha Bhoi (Neha.Bhoi@student.csulb.edu)
* Ashwini Ukarde (ashwiniganesh.ukarde@student.csulb.edu)
* Mandar Kuklarni (mandarvijay.kulkarni@student.csulb.edu)
* Mayank Pidiha (mayank.pidiha@student.csulb.edu)
*
**/
// function execute after index.html load in DOM
window.onload = function () {
// function to update file list on HTML Page
let picker = document.getElementById('picker');
let listing = document.getElementById('listing');
//add event listener on folder upload input element
picker.addEventListener('change', e => {
var fileList = [];
for (let file of Array.from(e.target.files)) {
let item = document.createElement('li');
item.textContent = file.webkitRelativePath;
var jsonObj = {
name: file.name,
relativePath: file.webkitRelativePath
}
fileList.push(jsonObj);
listing.appendChild(item);
};
});
// Function excutes after form submit action
var submitFunction1 = function () {
var form = $('form')[0];
var fd = new FormData(form);
let picker = document.getElementById('picker');
let picker1 = document.getElementById('picker1');
var group = $('input[name=x]:checked').val()
if (group == 'folder') {
var ins = picker.files.length;
fd.set('filetocheckin', {});
for (var x = 0; x < ins; x++) {
fd.append('filetocheckin', document.getElementById('picker').files[x]);
}
} else if (group == 'file') {
var ins = picker1.files.length;
fd.set('filetocheckin', {});
for (var x = 0; x < ins; x++) {
fd.append('filetocheckin', document.getElementById('picker1').files[x]);
}
}
$.ajax({
url: '/submit-Command-data',
data: fd,
type: 'POST',
contentType: false, // NEEDED, DON'T OMIT THIS (requires jQuery 1.6+)
processData: false, // NEEDED, DON'T OMIT THIS
success: function (msg) {
if(msg.list){
let snapshotList = document.getElementById('snapshotList');
let list_title = document.getElementById('list_title');
list_title.textContent = 'List of snapshot in '+ msg.list.reponame;
for (let itemList of msg.list.snapshotsList) {
let item = document.createElement('li');
item.textContent = itemList
snapshotList.appendChild(item);
}
console.log()
alert("list success!")
} else {
alert(msg)
location.reload();
}
}
});
}
// add submit function on form submit action
var form = document.getElementById("uploadForm");
form.addEventListener('submit', function (event) {
event.preventDefault();
submitFunction1();
});
// add radio button handler on the click of folder upload radio button
document.getElementById('checkFolder').onclick = function () {
if (this.checked) {
document.getElementById("picker1").style.visibility = "hidden";
document.getElementById("picker").style.visibility = "visible";
}
};
//add radio button handler on the click of file upload radio button
document.getElementById('checkFiles').onclick = function () {
if (this.checked) {
document.getElementById("picker").style.visibility = "hidden";
document.getElementById("picker1").style.visibility = "visible";
}
};
}
},{}]},{},[1]);