-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptlyglobalpreviewjs.js
More file actions
69 lines (48 loc) · 1.73 KB
/
optlyglobalpreviewjs.js
File metadata and controls
69 lines (48 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var project_id = "330576466";
var token = "2d8c31acef0031406f5d69ce29d99719:a6c7034b";
function OptlyAPI(project_id, token){
this.project_id = project_id;
this.token = token;
this.GET = function(url, callback, options){
xmlHttp = new XMLHttpRequest()
if(callback){
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
console.log("on ready state change, about to call call back");
callback(xmlHttp.responseText);
}
}
}
xmlHttp.open( "GET",
url,
false );
xmlHttp.setRequestHeader("Token" , this.token)
xmlHttp.send()
return xmlHttp.responseText
}
this.getProject = function(){
return JSON.parse(this.GET("https://www.optimizelyapis.com/experiment/v1/projects/" + this.project_id + "/"));
}
this.getExperiments = function(callback){
return JSON.parse(this.GET("https://www.optimizelyapis.com/experiment/v1/projects/" + this.project_id + "/experiments/", callback));
}
this.getVariation = function(variation_id){
return JSON.parse(this.GET("https://www.optimizelyapis.com/experiment/v1/variations/" + variation_id));
}
this.getVariationName = function(variation_id){
return this.getVariation(variation_id)["description"]
}
}
function templateMachine(){
this.insertExpModules = function(experiments){
console.log("starting insert exp modules");
experiments = JSON.parse(experiments)
}
}
optly = new OptlyAPI(project_id, token)
doms = new templateMachine()
experiments = optly.getExperiments(doms.insertExpModules)
// for every experiment, create an appropriate experimentModule
// optly.getVariation(experiments[0]["variation_ids"][0])
// // Get Name
// optly.getVariations(experiments[0]["variation_ids"][0])["description"]