Skip to content

Parameter to allow to enforce JSON #11

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

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions opencpu-0.5.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ if(!window.jQuery) {


//new Session()
function Session(loc, key, txt){
function Session(loc, key, txt, force){
this.loc = loc;
this.key = key;
this.txt = txt;
this.force = force;
this.output = txt.split(/\r\n|\r|\n/g);

this.getKey = function(){
return key;
};

this.getLoc = function(){
return loc;
};
Expand Down Expand Up @@ -67,6 +68,9 @@ if(!window.jQuery) {
}

var url = this.getLoc() + "R/" + name + "/json";
if(this.force) {
url = url + "?force=true";
}
return $.get(url, data, success);
};

Expand Down Expand Up @@ -154,7 +158,7 @@ if(!window.jQuery) {
if(r_cors && loc.match("^/[^/]")){
loc = r_path.protocol + "//" + r_path.host + loc;
}
handler(new Session(loc, key, txt));
handler(new Session(loc, key, txt, ocpu.settings.force));
}).fail(function(){
console.log("OpenCPU error HTTP " + jqxhr.status + "\n" + jqxhr.responseText);
});
Expand Down Expand Up @@ -439,6 +443,9 @@ if(!window.jQuery) {
ocpu.call = r_fun_call;
ocpu.rpc = rpc;
ocpu.seturl = seturl;
ocpu.settings = {
force: false
}

//exported constructors
ocpu.Snippet = Snippet;
Expand Down