This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tvdb-views.js
73 lines (63 loc) · 2.44 KB
/
tvdb-views.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
/**
* A meteor library for communicating with thetvdb.com
*
* @author Robin Helgelin <[email protected]>
*/
(function() {
// Store session for easy access
var tvdbSession = Meteor.TVDBSession;
// Register our tvdbStatus helper
Handlebars.registerHelper(
"tvdbStatus",
function() {
return new Handlebars.SafeString(Template._tvdbStatus())
});
// --- Start tvdbStatus events and methods
Template._tvdbStatus.events({
"click .configure-button": function() {
tvdbSession.configure();
}
});
Template._tvdbStatus.configured = function() {
return Meteor.TVDB().isConfigured();
};
Template._tvdbStatus.hasWorkingQueue = function() {
return Meteor.TVDB().isWorking();
};
// --- End tvdbStatus
// --- Start tvdbConfigureDialog events and methods
Template._tvdbConfigureDialog.events({
"click .configure-login-service-dismiss-button": function() {
tvdbSession.set('configureDialogVisible', false);
},
'click #configure-login-service-dialog-save-configuration': function () {
if (tvdbSession.get('configureDialogVisible') &&
! tvdbSession.get('configureDialogSaveDisabled')) {
var configuration = {};
configuration.apikey = document.getElementById(
'configure-login-service-dialog-apikey').value
.replace(/^\s*|\s*$/g, ""); // trim;
// Configure
Meteor.call("tvdbConfigure", configuration, function(error) {
if (error) {
Meteor._debug("Error configurating tvdb server " + error.reason);
} else {
tvdbSession.set('configured', true);
tvdbSession.set('configureDialogVisible', false);
}
});
}
},
"input, keyup input": function() {
var empty = document.getElementById("configure-login-service-dialog-apikey").value === "";
tvdbSession.set('configureDialogSaveDisabled', empty);
}
});
Template._tvdbConfigureDialog.visible = function() {
return tvdbSession.get('configureDialogVisible');
};
Template._tvdbConfigureDialog.saveDisabled = function() {
return tvdbSession.get('configureDialogSaveDisabled');
};
// --- End tvdbConfigureDialog
})();