Skip to content

Instantly share code, notes, and snippets.

@Tehnix
Created August 18, 2012 19:59
Show Gist options
  • Save Tehnix/3389412 to your computer and use it in GitHub Desktop.
Save Tehnix/3389412 to your computer and use it in GitHub Desktop.
Example of usage of Terminal.js (https://github.com/Tehnix/Terminal.js)
$(document).ready(function() {
var githubDir = {
__name__: 'github',
Tehnix: {
__name__: 'Tehnix'
},
ZealDev: {
__name__: 'ZealDev'
}
};
// Fetch my repository information from github. The reason I call a local .php file instead of
// directly to the github API, is because AJAX calls are limited to your own domain. The php files basically just
// does a call to the API with curl...
$.get('/github-repos-Tehnix.php').done(function(data) {
data = $.parseJSON(data);
for (var i=0; i < data.length; i++) {
githubDir.Tehnix[data[i].name] = {
__name__: data[i].name,
link: {
__name__: 'link',
__type__: 'link',
__link__: data[i].html_url
},
'Description.txt': {
__name__: 'Description.txt',
__type__: 'file',
__text__: data[i].description
}
}
}
});
$.get('/github-repos-ZealDev.php').done(function(data) {
data = $.parseJSON(data);
for (var i=0; i < data.length; i++) {
githubDir.ZealDev[data[i].name] = {
__name__: data[i].name,
link: {
__name__: 'link',
__type__: 'link',
__link__: data[i].html_url
},
'Description.txt': {
__name__: 'Description.txt',
__type__: 'file',
__text__: data[i].description
}
}
}
});
// Instantiate the terminal plugin on the container with id terminal
$("#terminal").terminal({
domain: 'zealdev.dk',
startText: 'Welcome! Take a look around, who knows, maybe you\'ll find something interesting :) !...',
filesystem: {
root: {
__name__: '/',
home: {
__name__: 'home',
www: {
__name__: 'www',
github: githubDir,
'about.txt': {
__name__: 'about.txt',
__type__: 'file',
__text__: 'Hey there :) I see you\'ve manage to figure out how this operates. If you\'re interested in the plugin itself, it is hosted on github (or very soon will be) and you can check it out there...'
}
}
}
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment