forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshare_scratch_paper.js
More file actions
45 lines (38 loc) · 833 Bytes
/
share_scratch_paper.js
File metadata and controls
45 lines (38 loc) · 833 Bytes
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
'use strict';
const RSVP = require('rsvp');
const app = require('../app');
const postJSON = require('./ajax/post_json');
const {
setPath
} = require('./helpers');
module.exports = () => {
return new RSVP.Promise((resolve, reject) => {
const {
dataEditor,
codeEditor
} = app.getEditor();
const gist = {
'description': 'temp',
'public': true,
'files': {
'data.js': {
'content': dataEditor.getValue()
},
'code.js': {
'content': codeEditor.getValue()
}
}
};
postJSON('https://api.github.com/gists', gist).then(({
id
}) => {
app.setLoadedScratch(id);
setPath('scratch', id);
const {
href
} = location;
$('#algorithm').html('Shared');
resolve(href);
});
});
};