18 changed files with 263 additions and 21 deletions
Split View
Diff Options
-
12customize.dist/src/less2/include/colortheme.less
-
16customize.dist/src/less2/include/toolbar.less
-
1customize.dist/translations/messages.js
-
74pinned.js
-
118rpc.js
-
1server.js
-
2www/code/app-code.less
-
11www/common/sframe-app-framework.js
-
21www/common/toolbar3.js
-
1www/contacts/app-contacts.less
-
2www/drive/app-drive.less
-
2www/file/app-file.less
-
2www/pad/app-pad.less
-
2www/poll/app-poll.less
-
4www/settings/app-settings.less
-
2www/slide/app-slide.less
-
2www/whiteboard/app-whiteboard.less
-
11www/whiteboard/inner.js
@ -0,0 +1,74 @@ |
|||
/* jshint esversion: 6, node: true */ |
|||
const Fs = require('fs'); |
|||
const Semaphore = require('saferphore'); |
|||
const nThen = require('nthen'); |
|||
|
|||
const sema = Semaphore.create(20); |
|||
|
|||
let dirList; |
|||
const fileList = []; |
|||
const pinned = {}; |
|||
|
|||
const hashesFromPinFile = (pinFile, fileName) => { |
|||
var pins = {}; |
|||
pinFile.split('\n').filter((x)=>(x)).map((l) => JSON.parse(l)).forEach((l) => { |
|||
switch (l[0]) { |
|||
case 'RESET': { |
|||
pins = {}; |
|||
//jshint -W086
|
|||
// fallthrough
|
|||
} |
|||
case 'PIN': { |
|||
l[1].forEach((x) => { pins[x] = 1; }); |
|||
break; |
|||
} |
|||
case 'UNPIN': { |
|||
l[1].forEach((x) => { delete pins[x]; }); |
|||
break; |
|||
} |
|||
default: throw new Error(JSON.stringify(l) + ' ' + fileName); |
|||
} |
|||
}); |
|||
return Object.keys(pins); |
|||
}; |
|||
|
|||
module.exports.load = function (cb) { |
|||
nThen((waitFor) => { |
|||
Fs.readdir('./pins', waitFor((err, list) => { |
|||
if (err) { throw err; } |
|||
dirList = list; |
|||
})); |
|||
}).nThen((waitFor) => { |
|||
fileList.splice(0, fileList.length); |
|||
dirList.forEach((f) => { |
|||
sema.take((returnAfter) => { |
|||
Fs.readdir('./pins/' + f, waitFor(returnAfter((err, list2) => { |
|||
if (err) { throw err; } |
|||
list2.forEach((ff) => { fileList.push('./pins/' + f + '/' + ff); }); |
|||
}))); |
|||
}); |
|||
}); |
|||
}).nThen((waitFor) => { |
|||
fileList.forEach((f) => { |
|||
sema.take((returnAfter) => { |
|||
Fs.readFile(f, waitFor(returnAfter((err, content) => { |
|||
if (err) { throw err; } |
|||
const hashes = hashesFromPinFile(content.toString('utf8'), f); |
|||
hashes.forEach((x) => { |
|||
(pinned[x] = pinned[x] || {})[f.replace(/.*\/([^/]*).ndjson$/, (x, y)=>y)] = 1; |
|||
}); |
|||
}))); |
|||
}); |
|||
}); |
|||
}).nThen(() => { |
|||
cb(pinned); |
|||
}); |
|||
}; |
|||
|
|||
if (!module.parent) { |
|||
module.exports.load(function (data) { |
|||
Object.keys(data).forEach(function (x) { |
|||
console.log(x + ' ' + JSON.stringify(data[x])); |
|||
}); |
|||
}); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save