Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to override the BASE_PATH #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ Add this code to you to your page to enable Clippy.js.
<!-- Clippy.js -->
<script src="clippy.min.js"></script>

<!-- Init script -->
<!-- Init script (using //s3.amazonaws.com/clippy.js/Agents/ as an Agent host) -->
<script type="text/javascript">
clippy.load('Merlin', function(agent){
// do anything with the loaded agent
agent.show();
});
</script>

<!-- Of if you want to define an alternate agent path you can pass a JSON like this -->
<script type="text/javascript">
clippy.load({name:'Clippy', path:'/clippy/agents/'}, function(agent){
// do anything with the loaded agent
agent.show();
});
</script>

```

Usage: Actions
Expand Down
12 changes: 8 additions & 4 deletions build/clippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,14 @@ clippy.Balloon.prototype = {

};

clippy.BASE_PATH = '//s3.amazonaws.com/clippy.js/Agents/';

clippy.load = function (name, successCb, failCb) {
clippy.load = function (options, successCb, failCb) {
if(typeof options === 'string') {
var name = options;
clippy.BASE_PATH = '//s3.amazonaws.com/clippy.js/Agents/';
} else {
var name = options.hasOwnProperty('name') ? options.name : 'Clippy';
clippy.BASE_PATH = options.hasOwnProperty('path') ? options.path : '//s3.amazonaws.com/clippy.js/Agents/';
}
var path = clippy.BASE_PATH + name;

var mapDfd = clippy.load._loadMap(path);
Expand Down Expand Up @@ -1012,4 +1017,3 @@ clippy.Queue.prototype = {
this._progressQueue();
}
};

Loading