Skip to content

Commit

Permalink
Use mount point instead of remote path on JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
sh19910711 committed Aug 18, 2015
1 parent 703825e commit 24ffa5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/web_console/templates/_markup.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div id="console"
data-remote-path='<%= "#{@mount_point}/repl_sessions/#{@session.id}" %>'
data-mount-point='<%= @mount_point %>'
data-session-id='<%= @session.id %>'
data-prompt-label='>> '>
</div>
16 changes: 9 additions & 7 deletions lib/web_console/templates/console.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ function REPLConsole(config) {

this.commandStorage = new CommandStorage();
this.prompt = getConfig('promptLabel', ' >>');
this.remotePath = getConfig('remotePath');
this.mountPoint = getConfig('mountPoint');
this.sessionId = getConfig('sessionId');
}

REPLConsole.prototype.getUrl = function(path) {
REPLConsole.prototype.getSessionUrl = function(path) {
var parts = [ this.mountPoint, 'repl_sessions', this.sessionId ];
if (path) {
return this.remotePath + '/' + path;
} else {
return this.remotePath;
parts.push(path);
}
// Join and remove duplicate slashes.
return parts.join('/').replace(/([^:]\/)\/+/g, '$1');
};

REPLConsole.prototype.commandHandle = function(line, callback) {
Expand Down Expand Up @@ -96,7 +98,7 @@ REPLConsole.prototype.commandHandle = function(line, callback) {
}
}

putRequest(self.getUrl(), params, function(xhr) {
putRequest(self.getSessionUrl(), params, function(xhr) {
var response = parseJSON(xhr.responseText);
var result = isSuccess(xhr.status);
if (result) {
Expand Down Expand Up @@ -448,7 +450,7 @@ REPLConsole.prototype.scrollToBottom = function() {

// Change the binding of the console
REPLConsole.prototype.switchBindingTo = function(frameId, callback) {
var url = this.remotePath + "/trace";
var url = this.getSessionUrl('trace');
var params = "frame_id=" + encodeURIComponent(frameId);
postRequest(url, params, callback);
};
Expand Down

0 comments on commit 24ffa5e

Please sign in to comment.