-
Notifications
You must be signed in to change notification settings - Fork 1
/
thinker.js
executable file
·94 lines (75 loc) · 3.01 KB
/
thinker.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(function (window, $) {
/*
$occurrences = inpho("/thinker/$id/occurrences.json?sep_filter=True");
$related = inpho("/thinker/$id/related.json?sep_filter=True");
$hyponyms = inpho("/thinker/$id/hyponyms.json?sep_filter=True");
$influenced = inpho("/thinker/$id/influenced.json?sep_filter=True");
*/
//global variables
var host = "https://inpho.cogs.indiana.edu";
var crossRef = angular.module("thinker", []);
crossRef.controller("ThinkerCtrl", function ($scope, $http, $q) {
$scope.currentThinkerID = "3345";
$scope.newThinkerID = "";
$scope.currentIdeaID = "2638";
$scope.newIdeaID = "";
$scope.currentIdea = [];
$scope.currentThinker = []; //initialize to an empty array.
$scope.showRelatedThinker = true; //Related Thinker toggle
$scope.showRelatedThinkerLabel = "Hide";
$scope.showStudent = true; //Student Toggle
$scope.showStudentLabel = "Hide";
$scope.toggle = function (what) {
$scope["show" + what] = !$scope["show" + what];
if ($scope["show" + what] == true) {
$scope["show" + what + "Label"] = "Hide";
}
else {
$scope["show" + what + "Label"] = "Show";
}
};
$scope.getCurrentThinker = function () {
getThinkerService($scope, $http, $q);
};
$scope.getThisThinker = function (thinkerID) {
$scope.currentThinkerID = thinkerID;
$scope.getCurrentThinker();
};
$scope.getThisIdea = function (ideaID) {
$scope.currentIdeaID = ideaID;
console.log(ideaID);
console.log(currentIdeaID);
$scope.getCurrentIdea();
};
$scope.getCurrentIdea = function() {
getIdeaService($scope, $http, $q);
};
$scope.getNewIdea = function (){
$scope.getThisIdea($scope.newIdeaID);
};
$scope.getNewThinker = function () {
$scope.getThisThinker($scope.newThinkerID);
};
setTimeout($scope.getCurrentThinker(), 500);
});
function getIdeaService(scope, http, $q){
console.log("does it arrive?");
http({ method: 'GET', url: host + "/idea/" + scope.currentIdeaID + ".json" }).
success(function (data, status, headers, config) {
scope.currentIdea = data;
console.log(scope.currentIdea);
}).
error(function (data, status, headers, config) {
alert("Error:" + status);
});
}
function getThinkerService(scope, http, $q) { //retrieve one thinker at a time using http service provided by AngularJS. Recommend to stick with AngularJS
http({ method: 'GET', url: host + "/thinker/" + scope.currentThinkerID + ".json" }).
success(function (data, status, headers, config) {
scope.currentThinker = data;
}).
error(function (data, status, headers, config) {
alert("Error:" + status);
});
}
})(window, jQuery);