-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.js
84 lines (70 loc) · 1.99 KB
/
java.js
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
//create userid
function makeId(strLength) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < strLength; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
};
var userId = makeId(32);
window.location.hash = userId;
$('body').append('<span class="abs-top-right">' + userId + '</span>');
//included for the purposes of reading information from Box
//part of initial dev work
var box = new BoxSdk();
var accessToken = "Ym67uwveS5EhhUrho1GstzlkunIo4B4x"; //expired
var boxClient = new box.BasicBoxClient({ accessToken: accessToken });
var folderId = '46199583831'; //loan applications
boxClient.folders.get({ id: folderId, params: {fields: "name,item_collection"} })
.then(function (folder) {
var rootFolder = folder;
var id = folder.id;
console.log(rootFolder);
})
.catch(function (err) {
console.log(err);
});
//uploader
var uploaderOptions = {
container: '.container',
size: 'small',
onClose: function(){
location.reload();
}
}
var uploader = new Box.ContentUploader();
uploader.on('complete', function(data){
//console.log('complete');
//console.log(data);
enablePreview(data[0].id);
attachMeta(data[0].id);
$(".preview-container").outerHeight(525);
});
uploader.show(folderId, accessToken, uploaderOptions);
//preview
var previewOptions = {
container: '.preview-container',
showDownload: true,
logoUrl: 'assets/preview.png'
}
var preview = new Box.Preview();
function enablePreview(fileId){
preview.show(fileId, accessToken, previewOptions);
$('ul.nav-tabs li:last').removeClass("hide");
//$('li a[href="#preview"]').attr("data-toggle", "tab");
//$.('.nav-tabs a[href="#preview"]').tab('show');
}
//meta
function attachMeta(fileId){
console.log("attachMeta");
var scope = "global";
boxClient.metadata.createFileMetadata({
fileId: fileId,
scope: scope,
body: {
userId: userId
},
templateKey: "properties"
});
console.log("attachMeta 2x");
}