-
Notifications
You must be signed in to change notification settings - Fork 1
/
controlpanel.js
108 lines (84 loc) · 2.5 KB
/
controlpanel.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
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
$projectsList = $('.projects');
$addProjectBtn = $('#add-project');
$addProjectForm = $('.create-project-form');
$createProjectBtn = $('.create-project.btn');
$importProjectBtn = $('#import-project');
var projectsArr = [];
var fileEntry;
chrome.storage.local.get("projects", function(data) {
console.log(data);
projectsArr = data.projects || [];
console.log(projectsArr);
console.log("projects");
if (!projectsArr.length) {
$projectsList.html("No projects...");
}
_.each(projectsArr, function(project) {
$projectsList.add('<li>' + project.name + '</li>');
});
});
console.log($addProjectBtn);
$addProjectBtn.click(function() {
$addProjectForm.fadeIn();
$addProjectBtn.hide();
});
function setEntry(anEntry, isWritable, name) {
fileEntry = anEntry;
gotWritable = isWritable;
if (fileEntry) {
//updateModeForBaseName(fileEntry.name);
} else if (name) {
//updateModeForBaseName(name);
}
//updatePath();
}
var directoryEntry = null;
function openFile() {
chrome.fileSystem.chooseEntry({type:"openDirectory"}, function (entry) {
console.log("entry");
directoryEntry = entry;
console.log()
// if (chrome.runtime.lastError) {
// showError(chrome.runtime.lastError.message);
// return;
// }
// clearError();
// setEntry(entry, false);
// replaceDocContentsFromFileEntry();
});
}
$importProjectBtn.click(openFile);
$createProjectBtn.click(function() {
chrome.fileSystem.chooseEntry({ type: "openDirectory" }, function (directoryEntry) {
console.log(directoryEntry);
var projectName = $addProjectForm.find('.name').val();
console.log(projectName);
directoryEntry.createWriter(function(writer) {
console.log("writer");
writer.onwriteend = function(e) {
console.log("file created");
};
writer.write(new Blob([document.getElementById("HTMLFile").value],
{type: 'text/plain'}));
});
});
// chrome.fileSystem.getWritableEntry('~/'+projectName+'-project', function(a) {
// console.log("hey");
// console.log(a);
// });
// fs.root.getDirectory('~/'+projectName+'-project', {create: true}, function(dirEntry) {
// console.log(dirEntry);
// projectsArr.push({
// "name" : name,
// "directory" : "/"
// });
// console.log("arr:" + projectsArr);
// chrome.storage.local.set({"projects" : projectsArr}, function(a) {
// console.log("set");
// console.log(a);
// });
// $addProjectForm.hide();
// $addProjectBtn.fadeIn();
// }, null);
// }, null);
});