-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwork.html
409 lines (352 loc) · 10.5 KB
/
work.html
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<html>
<head>
<title>Quick task schedule!</title>
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
</link>
<script type="text/javascript" src="const.js" ></script>
<script type="text/javascript" src="libs/jquery-1.11.1.min.js" ></script>
<script type="text/javascript" src="libs/underscore-min.js" ></script>
<script type="text/javascript" src="libs/backbone-min.js" ></script>
<script src="libs/jquery-ui.js">
</script>
<script src="libs/pretty-json-min.js">
</script>
<script src="https://api.trello.com/1/client.js?key=83fbbffdca68e9e5655f409d9b204618">
</script>
<script src="https://apis.google.com/js/api.js">
</script>
<script src="rules.js">
</script>
<script src="google-common.js">
</script>
<script src="sheets.js">
</script>
<script src="calendar.js">
</script>
<script src="list.js">
</script>
<script src="trello.js">
</script>
<script src="card.js">
</script>
<script src="graph.js">
</script>
<script src="time.js">
</script>
<script src="scheduler.js">
</script>
</head>
<body>
<div id="airea"></div>
<a href="/">Home</a>
<a onclick="next()" href="#">Next</a>
<div id="error"></div>
<script type="text/javascript">
var addMessage = function(message){
document.getElementById('airea').innerHTML += message;
}
var addWarning = console.log;
var addError = function(message){
document.getElementById('error').innerHTML = document.getElementById('error').innerHTML + message + "<br\>";
}
var techDebt = true;
var done = function(){}
var base = function(time, string){
return function(){
document.getElementById('airea').innerHTML = `You have ${time} minutes? ${string}`;
}
}
var renderRow = function(card, buttonNames) {
var html = '';
html += '<tr style=\"outline: thin solid\">' + '<div align="left">';
html += card.name.substring(0, 45);
html += '</div><div align="right">';
for (var bs = 0; bs < buttonNames.length; bs ++ ){
var buttonName = buttonNames[bs];
html += '<button id="'+buttonName+card.id+'" style="display: inline;">'+buttonName+'</button>';
}
html += '</div></tr>';
return(html);
}
var tag = function(){
document.getElementById('airea').innerHTML = "";
var time = 5;
var untaggedList = scheduler.getUntagged();
if(untaggedList === undefined){
return null;
}
var listName = untaggedList.name;
untaggedList = untaggedList.cards;
var all_labels = Object.keys(scheduler.labelsNames).filter(labelIsAType);
return function(){
var table = '';
table +=('<table style=\"width:100%\">');
for (var i in untaggedList){
var card = untaggedList[i];
table += renderRow(card, all_labels);
}
table += '</table>';
addMessage(table);
for (var i in untaggedList){
var card = untaggedList[i];
for (var bs = 0; bs < all_labels.length; bs ++ ){
var buttonSize = all_labels[bs];
var btn = document.getElementById(buttonSize+card.id);
btn.setAttribute("onclick",
'processFunction("'+buttonSize+'", scheduler.lists["'+listName+'"], "'+card.id+'");');
}
}
}
}
var processFunction = function(size, list, cardID) {
console.log(size + " "+ list.name + " " + cardID);
var btn = document.getElementById(size+cardID);
if(size == "Skip"){
list.cards[cardID].setSkipped();
btn.style.borderStyle = 'inset';
return;
}
list.cards[cardID].setLabel(size, btn.style.borderStyle!=='inset');
btn.style.borderStyle = (btn.style.borderStyle!=='inset' ? 'inset' : 'outset');
btn.innerText = (btn.style.borderStyle!=='inset' ? size.toLowerCase() : size.toUpperCase());
};
var prioritise = function(){
document.getElementById('airea').innerHTML = "";
for (var l in scheduler.requiredLists) {
var name = scheduler.requiredLists[l];
var list = scheduler.lists[name];
scheduler.sort(list);
}
var time = 5;
var firstListNotPriod = scheduler.getFirstNotPrioList();
if(firstListNotPriod === null)
return null;
var buttonSizes = ["Big", "Medium", "Small", "Skip"];
var cardVarName = ["big", "medium", "small", "skip"];
return function(){
var table = '';
table +=('<table style=\"width:100%\">');
var customSort = function(a,b){
if(a.big && !b.big) {
return -1;
}
if(!a.big && b.big) {
return 1;
}
if(a.medium && !b.medium) {
return -1;
}
if(!a.medium && b.medium) {
return 1;
}
if(a.small && !b.small) {
return -1;
}
if(!a.small && b.small) {
return 1;
}
return a.pos - b.pos;
};
var ccards = firstListNotPriod.cards;
ccards = Object.keys(ccards).map(function(key) {
return ccards[key];
});
ccards.sort(customSort);
for (var i in ccards){
var card = ccards[i];
table += renderRow(card, buttonSizes);
}
table += '</table>';
var bigrem = 1 - firstListNotPriod.bigCount;
var medrem = 3 - firstListNotPriod.medCount;
var smallrem = 5 - firstListNotPriod.smallCount;
addMessage(`You need ${bigrem} big ${medrem} med ${smallrem} small`);
addMessage(table);
for (var i in ccards){
var card = ccards[i];
for (var bs = 0; bs < buttonSizes.length; bs ++ ){
var buttonSize = buttonSizes[bs];
var btn = document.getElementById(buttonSize+card.id);
btn.setAttribute("onclick",
'processFunction("'+buttonSize+'", scheduler.lists["'+firstListNotPriod.name+'"], "'+card.id+'");');
btn.style.borderStyle = card[cardVarName[bs]] ? 'inset' : 'outset';
btn.innerText = (btn.style.borderStyle!=='inset' ? buttonSize.toLowerCase() : buttonSize.toUpperCase());
}
}
}
}
var dateThemAllFunction = function (){
var undatedList = scheduler.lists.Today.getUndated();
for (var i in undatedList){
var card = undatedList[i];
card._network_reschedule();
}
}
var bigoCardo;
var allSupporting = false;
var skiplist = [];
var skipthisone = function () {
skiplist.push(bigoCardo);
schedulerInitEnded(scheduler);
}
var allSupTru = function() {
allSupporting = true;
schedulerInitEnded(scheduler);
}
var processSupporting = function(a,b){
console.log(a,b, bigoCardo);
bigoCardo.addSupporting(b);
}
var supportingValidate = function() {
// the same thing, but pick a big card and ask me if it's ok how it's supported.
return null;
}
var supporting = function () {
document.getElementById('airea').innerHTML = '<textarea rows="4" cols="50"></textarea><br/>' + '<a onclick="allSupTru()" href="#">Advanced</a> <a onclick="skipthisone()" href="#">Skip</a><br/><br/>';
var targetLists = ["Tomorrow", "Week", "Month"];
for (var l in targetLists) {
var listName = targetLists[l];
var list = scheduler.lists[listName];
var tcards = list.cards;
for (var i in tcards){
bigoCardo = tcards[i];
if(skiplist.indexOf(bigoCardo) >= 0){
continue;
}
if(bigoCardo.big && bigoCardo.supportingCards != undefined && bigoCardo.supportingCards.length === 0) {
return function(){
addMessage("Please support card <a href = \"" +bigoCardo.shortUrl + "\">" + bigoCardo.name + "</a><br/>");
addMessage("<br/>Options<br/>");
var plist = scheduler.lists[list.previous];
if(allSupporting){
plist = scheduler;
}
for (var i in plist.cards){
var pcard = plist.cards[i];
addMessage('<div align="left">'+ pcard.name + '</div> <div align="right"><button id='+pcard.id+'>Add</button></div>');
}
for (var i in plist.cards){
var pcard = plist.cards[i];
var btn = document.getElementById(pcard.id);
btn.setAttribute("onclick",
'processSupporting(scheduler.lists["'+list.name+'"], "'+pcard.id+'");');
}
};
}
}
}
return supportingValidate();
}
var date = function(){
document.getElementById('airea').innerHTML = "";
var undatedList = scheduler.lists.Today.getUndated();
if(undatedList.length === 0)
return null;
return function(){
document.getElementById('airea').innerHTML = '<button id="dateThemAll" style="display: inline;">dateThemAll</button>';
var btn = document.getElementById("dateThemAll");
btn.setAttribute("onclick",
'dateThemAllFunction();');
}
}
var once = false;
var projects = function(){
if(once) {
return null;
}
once = true;
return function(){
document.getElementById('airea').innerHTML = `You have 5 minutes? Review
<a href="https://docs.google.com/spreadsheets/d/1S20YvTFcT5kxSQgpWK9y691nIKYZktMFJnXgQq-YqN0/edit#gid=0">
projects</a>`;
}
}
function shuffle(array) {
let counter = array.length;
// While there are elements in the array
while (counter > 0) {
// Pick a random index
let index = Math.floor(Math.random() * counter);
// Decrease counter by 1
counter--;
// And swap the last element with it
let temp = array[counter];
array[counter] = array[index];
array[index] = temp;
}
return array;
}
var schedule = function() {
return null;
}
var stuffs = [
"tag",
"prioritise",
"projects",
"date",
//"supporting",
"schedule"
];
var g_supported = false;
//TODO: location? home
var schedulerInitEnded = function(scheduler){
if(!g_supported){
setTimeout(function() {
g_supported = true;
}, 600);
}
//TODO
var stuff;
stuffs = shuffle(stuffs);
console.log(stuffs);
if(stuffs[0] === "supporting" && !g_supported) {
setTimeout(function() {
schedulerInitEnded(scheduler);
}, 300);
return;
}
var sMapping = {
"tag" : tag(),
"prioritise":prioritise(),
"projects": projects(),
"date": date(),
"supporting": supporting(),
"schedule": schedule(),
};
stuff = sMapping[stuffs[0]];
while(stuff == null && stuffs.length != 0) {
stuffs.splice(0, 1);
stuff = sMapping[stuffs[0]];
}
if(stuffs.length === 0){
base(5, "Done!")();
return;
}
stuff();
}
var next = function() {
schedulerInitEnded(scheduler);
}
var scheduler = new Scheduler(schedulerInitEnded);
//else
/*
todo: prioritise these 5 tasks (choose only 3)
-- pick a list that is overbooked
-- choose 3 least interesting tasks in the list, and 2 most interesting tasks in inbox
-- the three tasks chosen move to the list, last 2 tasks drop to inbox
-- also allow me not to vote at this time
Create and or update the checklist for an MIT
Approve creating dummy tasks for me to reach the load values for a list (not today) that
match what I noticed over the last (other list)
ask me to approve splitting a week task to 5*8h tasks
ask me to approve converting a checklist to a list of tasks
-- condition: number of checklist tasks >= 2*task duration, in hours
ask me to approve moving a card from an overlap to a free location.
-- Don't move cards that I've tagged as unmovable.
-- Tag cards that I refuse to move as unmovable.
-- On weekly and daily marked as done, drop unmovable tag.
on overbooked lists: pick 3/5 tasks that would get pushed out.
*/
</script>
</body>
</html>