mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
Resolves #181 share levels easily with gist IDs and jsonp
This commit is contained in:
parent
d01f1806b4
commit
507291a0c4
3 changed files with 69 additions and 11 deletions
|
@ -202,6 +202,30 @@ var initDemo = function(sandbox) {
|
|||
tryLocaleDetect();
|
||||
}
|
||||
|
||||
if (params.gist_level_id) {
|
||||
$.ajax({
|
||||
url: 'https://api.github.com/gists/' + params.gist_level_id,
|
||||
type: 'GET',
|
||||
dataType: 'jsonp',
|
||||
success: function(response) {
|
||||
var data = response.data || {};
|
||||
var files = data.files || {};
|
||||
if (!Object.keys(files).length) {
|
||||
console.warn('no files found');
|
||||
return;
|
||||
}
|
||||
var file = files[Object.keys(files)[0]];
|
||||
if (!file.content) {
|
||||
console.warn('file empty');
|
||||
}
|
||||
eventBaton.trigger(
|
||||
'commandSubmitted',
|
||||
'importLevelNow ' + escape(file.content) + '; clear'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (params.command) {
|
||||
var command = unescape(params.command);
|
||||
sandbox.mainVis.customEvents.on('gitEngineReady', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue