ki 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ki/orm.rb +4 -2
- data/lib/ki/version.rb +1 -1
- data/spec/examples/json.northpole.ro/config/deploy.rb +1 -1
- data/spec/examples/json.northpole.ro/public/images/js.png +0 -0
- data/spec/examples/json.northpole.ro/public/javascripts/app.coffee +24 -90
- data/spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee +49 -32
- data/spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js +251 -0
- data/spec/examples/json.northpole.ro/public/stylesheets/app.sass +24 -0
- data/spec/examples/json.northpole.ro/views/awsum.haml +108 -0
- data/spec/examples/json.northpole.ro/views/examples.haml +24 -6
- data/spec/examples/json.northpole.ro/views/faq.haml +25 -19
- data/spec/examples/json.northpole.ro/views/java.haml +1 -0
- data/spec/examples/json.northpole.ro/views/javascript.haml +7 -0
- data/spec/examples/json.northpole.ro/views/layout.haml +2 -0
- data/spec/examples/json.northpole.ro/views/playground.haml +9 -8
- data/spec/examples/json.northpole.ro/views/{foo.haml → seed.haml} +0 -1
- data/spec/lib/ki/orm_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -4
- metadata +12 -12
- data/spec/examples/json.northpole.ro/public/javascripts/util.coffee +0 -31
- data/spec/examples/json.northpole.ro/public/stylesheets/application.sass +0 -222
- data/spec/examples/json.northpole.ro/public/stylesheets/cover.css +0 -154
- data/spec/examples/json.northpole.ro/views/signup.haml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e570dca285d0879a444188fe3f855404b7eea148
|
4
|
+
data.tar.gz: bd7f3d50f1e5c475b8e04e263c498a1878d76408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69ae313e5b0596c6d064ca51a4b805ae7b3dd5785450e6987982d454ac27a56cfd61b15201ef4aa1511a888892f4b500d2ab47eeed850525db5d83a959a59ce7
|
7
|
+
data.tar.gz: 5de90c09ce1b696cefa724cf8a3a1569fe39843617c0465d717ea8c1ef467da94d64911fd80dca983eb50195a0aad986726d2f7b7f738521eed8805b8bae04ff
|
data/Gemfile.lock
CHANGED
data/lib/ki/orm.rb
CHANGED
@@ -154,8 +154,10 @@ module Ki
|
|
154
154
|
#
|
155
155
|
def delete(name, hash)
|
156
156
|
hash = nourish_hash_id hash
|
157
|
-
@db[name].remove hash
|
158
|
-
{
|
157
|
+
r = @db[name].remove hash
|
158
|
+
{
|
159
|
+
deleted_item_count: r["n"] || 0
|
160
|
+
}
|
159
161
|
end
|
160
162
|
|
161
163
|
# Count the number of hashes found in a specified collection, filtered
|
data/lib/ki/version.rb
CHANGED
Binary file
|
@@ -1,91 +1,13 @@
|
|
1
|
-
userCreated = () ->
|
2
|
-
notify("user created", "label label-success")
|
3
|
-
$("#user").attr('disabled','disabled')
|
4
|
-
$("#pass").attr('disabled','disabled')
|
5
|
-
$("#signup")
|
6
|
-
.blur()
|
7
|
-
.fadeOut()
|
8
|
-
$("#extra-info").fadeIn()
|
9
|
-
|
10
|
-
userNotCreated = (jqXHR) ->
|
11
|
-
result = JSON.parse(jqXHR.responseText)
|
12
|
-
notify(result['error'], "label label-important")
|
13
|
-
|
14
1
|
reqSuccess = (data) ->
|
15
2
|
str = JSON.stringify(data, `undefined`, 2)
|
16
3
|
output = $('#parsedJson')
|
17
4
|
if (output.length > 0)
|
18
5
|
output[0].innerHTML = syntaxHighlight(str)
|
19
6
|
|
20
|
-
storageNotCreated = (jqXHR) ->
|
21
|
-
$('#parsedJson')[0].innerHTML = syntaxHighlight("{}")
|
22
|
-
|
23
|
-
signupPage = () ->
|
24
|
-
$("#user").focus()
|
25
|
-
notify("press enter to submit", "label label-info")
|
26
|
-
|
27
|
-
$("#pass").keypress (event) ->
|
28
|
-
if event.which is 13
|
29
|
-
event.preventDefault()
|
30
|
-
user = $('#user').val()
|
31
|
-
pass = $('#pass').val()
|
32
|
-
jNorthPole.createUser(user, pass, userCreated, userNotCreated)
|
33
|
-
|
34
|
-
addTryRow = (keyVal, valVal) ->
|
35
|
-
clone = $('.templateTr').clone().removeClass('templateTr')
|
36
|
-
clone.find('.templateKey').val(keyVal)
|
37
|
-
clone.find('.templateValue').val(valVal)
|
38
|
-
clearButton = clone.find('.clearButton')
|
39
|
-
clearButton.show()
|
40
|
-
clearButton.click () ->
|
41
|
-
$(this).parent().parent().remove()
|
42
|
-
$('#tryNowTable tr:last').after(clone)
|
43
|
-
$('#tryNowTable tr:last input:first').focus()
|
44
|
-
|
45
|
-
tryNowPage = () ->
|
46
|
-
npSecret = $('#tryNowTable').data('npsecret')
|
47
|
-
npGuestSecret = $('#tryNowTable').data('npguestsecret')
|
48
|
-
|
49
|
-
addTryRow(npSecret, npGuestSecret)
|
50
|
-
addTryRow('color', 'green')
|
51
|
-
|
52
|
-
$("#addTableRow").click ->
|
53
|
-
addTryRow('', '')
|
54
|
-
|
55
|
-
$("#postButton").click ->
|
56
|
-
data = getDataFromTable()
|
57
|
-
jNorthPole.createStorage(data, reqSuccess)
|
58
|
-
|
59
|
-
$("#getButton").click ->
|
60
|
-
data = getDataFromTable()
|
61
|
-
jNorthPole.getStorage(data, reqSuccess)
|
62
|
-
|
63
|
-
$("#putButton").click ->
|
64
|
-
data = getDataFromTable()
|
65
|
-
jNorthPole.putStorage(data, reqSuccess)
|
66
|
-
|
67
|
-
$("#deleteButton").click ->
|
68
|
-
data = getDataFromTable()
|
69
|
-
jNorthPole.deleteStorage(data, reqSuccess)
|
70
|
-
|
71
7
|
if typeof String::endsWith isnt "function"
|
72
8
|
String::endsWith = (suffix) ->
|
73
9
|
@indexOf(suffix, @length - suffix.length) isnt -1
|
74
10
|
|
75
|
-
window.syntaxHighlight = (json) ->
|
76
|
-
json = json.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
77
|
-
json.replace /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, (match) ->
|
78
|
-
cls = "number"
|
79
|
-
if /^"/.test(match)
|
80
|
-
if /:$/.test(match)
|
81
|
-
cls = "key"
|
82
|
-
else
|
83
|
-
cls = "string"
|
84
|
-
else if /true|false/.test(match)
|
85
|
-
cls = "boolean"
|
86
|
-
else cls = "null" if /null/.test(match)
|
87
|
-
"<span class=\"" + cls + "\">" + match + "</span>"
|
88
|
-
|
89
11
|
setActiveMenuClass = () ->
|
90
12
|
checkFor = (s) ->
|
91
13
|
if document.URL.endsWith(s)
|
@@ -93,11 +15,26 @@ setActiveMenuClass = () ->
|
|
93
15
|
|
94
16
|
checkFor 'playground'
|
95
17
|
checkFor 'examples'
|
18
|
+
checkFor 'faq'
|
96
19
|
|
97
20
|
randomlyFlipBear = () ->
|
98
21
|
if Math.random() > 0.5
|
99
22
|
$(".bear").toggleClass('flipit')
|
100
23
|
|
24
|
+
window.syntaxHighlight = (json) ->
|
25
|
+
json = json.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
26
|
+
json.replace /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, (match) ->
|
27
|
+
cls = "number value"
|
28
|
+
if /^"/.test(match)
|
29
|
+
if /:$/.test(match)
|
30
|
+
cls = "key"
|
31
|
+
else
|
32
|
+
cls = "string value"
|
33
|
+
else if /true|false/.test(match)
|
34
|
+
cls = "boolean value"
|
35
|
+
else cls = "null value" if /null/.test(match)
|
36
|
+
"<span class=\"" + cls + "\">" + match + "</span>"
|
37
|
+
|
101
38
|
$(document).ready ->
|
102
39
|
setActiveMenuClass()
|
103
40
|
setInterval(randomlyFlipBear, 1000)
|
@@ -111,23 +48,20 @@ $(document).ready ->
|
|
111
48
|
$('#myTab a').click (e) ->
|
112
49
|
e.preventDefault()
|
113
50
|
$(this).tab('show')
|
51
|
+
window.location.hash = $(this)[0].hash
|
52
|
+
|
53
|
+
if window.location.hash?
|
54
|
+
$("#myTab a[href='#{window.location.hash}']").tab('show')
|
114
55
|
|
115
56
|
$('#npAction').click () ->
|
116
57
|
verb = $('#verb').text();
|
117
|
-
if verb == 'GET'
|
118
|
-
|
58
|
+
verb = 'SEARCH' if verb == 'GET'
|
59
|
+
|
119
60
|
resource = $('#resource').text()
|
120
61
|
try
|
121
62
|
jsonObj = JSON.parse(($('#playground').val()))
|
122
63
|
catch err
|
123
|
-
reqSuccess(JSON.parse('{}'))
|
124
|
-
return
|
64
|
+
reqSuccess(JSON.parse('{"error": "invalid json input"}'))
|
65
|
+
return
|
125
66
|
|
126
|
-
|
127
|
-
type: verb
|
128
|
-
url: "/" + resource + ".json"
|
129
|
-
data: JSON.stringify(jsonObj)
|
130
|
-
success: (data, textStatus, jqXHR) ->
|
131
|
-
reqSuccess(data)
|
132
|
-
error: (jqXHR, textstatus, errorthrown) ->
|
133
|
-
reqSuccess(JSON.parse(jqXHR.responseText))
|
67
|
+
jNorthPole.genericRequest(jsonObj, verb, resource, reqSuccess)
|
@@ -1,34 +1,51 @@
|
|
1
1
|
window.jNorthPole =
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
|
3
|
+
BASE_URL: '/'
|
4
|
+
|
5
|
+
help: """
|
6
|
+
NorthPole JS wrapper example usage:
|
7
|
+
|
8
|
+
responseHandler = function (data) {
|
9
|
+
console.log(data);
|
10
|
+
};
|
11
|
+
|
12
|
+
jNorthPole.BASE_URL = '/';
|
13
|
+
jNorthPole.getStorage(json, responseHandler);
|
14
|
+
"""
|
15
|
+
|
16
|
+
genericRequest: (jsonObj, method, endPoint, responseHandler, errorHandler=responseHandler) ->
|
17
|
+
throw 'responseHandler function missing' unless responseHandler?
|
18
|
+
|
19
|
+
r = new XMLHttpRequest
|
20
|
+
r.open method, "#{@BASE_URL}#{endPoint}.json", true
|
21
|
+
|
22
|
+
r.onreadystatechange = ->
|
23
|
+
return if r.readyState != 4
|
24
|
+
if status == 200
|
25
|
+
responseHandler(JSON.parse(r.responseText), r.status)
|
26
|
+
else
|
27
|
+
errorHandler(JSON.parse(r.responseText), r.status)
|
28
|
+
return
|
29
|
+
r.send JSON.stringify(jsonObj)
|
30
|
+
return
|
31
|
+
|
32
|
+
createUser: (api_key, secret, success, failure) ->
|
6
33
|
jsonObj = {'api_key': api_key, 'secret': secret}
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
createStorage: (jsonObj, responseHandler) ->
|
26
|
-
this.genericRequest(jsonObj, 'POST', responseHandler)
|
27
|
-
putStorage: (jsonObj, responseHandler) ->
|
28
|
-
this.genericRequest(jsonObj, 'PUT', responseHandler)
|
29
|
-
getStorage: (jsonObj, responseHandler) ->
|
30
|
-
this.genericRequest(jsonObj, 'SEARCH', responseHandler)
|
31
|
-
deleteStorage: (jsonObj, responseHandler) ->
|
32
|
-
this.genericRequest(jsonObj, 'DELETE', responseHandler)
|
33
|
-
getUrl: (id) ->
|
34
|
-
"http://localhost:9292/storage.json?id=" + id
|
34
|
+
@genericRequest(jsonObj, 'POST', 'user', success, failure)
|
35
|
+
return
|
36
|
+
|
37
|
+
createStorage: (jsonObj, responseHandler, errorHandler) ->
|
38
|
+
@genericRequest(jsonObj, 'POST', 'storage', responseHandler, errorHandler)
|
39
|
+
return
|
40
|
+
|
41
|
+
putStorage: (jsonObj, responseHandler, errorHandler) ->
|
42
|
+
@genericRequest(jsonObj, 'PUT', 'storage', responseHandler, errorHandler)
|
43
|
+
return
|
44
|
+
|
45
|
+
getStorage: (jsonObj, responseHandler, errorHandler) ->
|
46
|
+
@genericRequest(jsonObj, 'SEARCH', 'storage', responseHandler, errorHandler)
|
47
|
+
return
|
48
|
+
|
49
|
+
deleteStorage: (jsonObj, responseHandler, errorHandler) ->
|
50
|
+
@genericRequest(jsonObj, 'DELETE', 'storage', responseHandler, errorHandler)
|
51
|
+
return
|
@@ -0,0 +1,251 @@
|
|
1
|
+
if (!angular && require){
|
2
|
+
var angular = require('angular');
|
3
|
+
}
|
4
|
+
|
5
|
+
/* global YT */
|
6
|
+
angular.module('youtube-embed', ['ng'])
|
7
|
+
.service ('youtubeEmbedUtils', ['$window', '$rootScope', function ($window, $rootScope) {
|
8
|
+
var Service = {}
|
9
|
+
|
10
|
+
// adapted from http://stackoverflow.com/a/5831191/1614967
|
11
|
+
var youtubeRegexp = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
|
12
|
+
var timeRegexp = /t=(\d+)[ms]?(\d+)?s?/;
|
13
|
+
|
14
|
+
function contains(str, substr) {
|
15
|
+
return (str.indexOf(substr) > -1);
|
16
|
+
}
|
17
|
+
|
18
|
+
Service.getIdFromURL = function getIdFromURL(url) {
|
19
|
+
var id = url.replace(youtubeRegexp, '$1');
|
20
|
+
|
21
|
+
if (contains(id, ';')) {
|
22
|
+
var pieces = id.split(';');
|
23
|
+
|
24
|
+
if (contains(pieces[1], '%')) {
|
25
|
+
// links like this:
|
26
|
+
// "http://www.youtube.com/attribution_link?a=pxa6goHqzaA&u=%2Fwatch%3Fv%3DdPdgx30w9sU%26feature%3Dshare"
|
27
|
+
// have the real query string URI encoded behind a ';'.
|
28
|
+
// at this point, `id is 'pxa6goHqzaA;u=%2Fwatch%3Fv%3DdPdgx30w9sU%26feature%3Dshare'
|
29
|
+
var uriComponent = decodeURIComponent(id.split(';')[1]);
|
30
|
+
id = ('http://youtube.com' + uriComponent)
|
31
|
+
.replace(youtubeRegexp, '$1');
|
32
|
+
} else {
|
33
|
+
// https://www.youtube.com/watch?v=VbNF9X1waSc&feature=youtu.be
|
34
|
+
// `id` looks like 'VbNF9X1waSc;feature=youtu.be' currently.
|
35
|
+
// strip the ';feature=youtu.be'
|
36
|
+
id = pieces[0];
|
37
|
+
}
|
38
|
+
} else if (contains(id, '#')) {
|
39
|
+
// id might look like '93LvTKF_jW0#t=1'
|
40
|
+
// and we want '93LvTKF_jW0'
|
41
|
+
id = id.split('#')[0];
|
42
|
+
}
|
43
|
+
|
44
|
+
return id;
|
45
|
+
};
|
46
|
+
|
47
|
+
Service.getTimeFromURL = function getTimeFromURL(url) {
|
48
|
+
url = url || '';
|
49
|
+
|
50
|
+
// t=4m20s
|
51
|
+
// returns ['t=4m20s', '4', '20']
|
52
|
+
// t=46s
|
53
|
+
// returns ['t=46s', '46']
|
54
|
+
// t=46
|
55
|
+
// returns ['t=46', '46']
|
56
|
+
var times = url.match(timeRegexp);
|
57
|
+
|
58
|
+
if (!times) {
|
59
|
+
// zero seconds
|
60
|
+
return 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
// assume the first
|
64
|
+
var full = times[0],
|
65
|
+
minutes = times[1],
|
66
|
+
seconds = times[2];
|
67
|
+
|
68
|
+
// t=4m20s
|
69
|
+
if (typeof seconds !== 'undefined') {
|
70
|
+
seconds = parseInt(seconds, 10);
|
71
|
+
minutes = parseInt(minutes, 10);
|
72
|
+
|
73
|
+
// t=4m
|
74
|
+
} else if (contains(full, 'm')) {
|
75
|
+
minutes = parseInt(minutes, 10);
|
76
|
+
seconds = 0;
|
77
|
+
|
78
|
+
// t=4s
|
79
|
+
// t=4
|
80
|
+
} else {
|
81
|
+
seconds = parseInt(minutes, 10);
|
82
|
+
minutes = 0;
|
83
|
+
}
|
84
|
+
|
85
|
+
// in seconds
|
86
|
+
return seconds + (minutes * 60);
|
87
|
+
};
|
88
|
+
|
89
|
+
Service.ready = false;
|
90
|
+
|
91
|
+
function applyServiceIsReady() {
|
92
|
+
$rootScope.$apply(function () {
|
93
|
+
Service.ready = true;
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
// If the library isn't here at all,
|
98
|
+
if (typeof YT === "undefined") {
|
99
|
+
// ...grab on to global callback, in case it's eventually loaded
|
100
|
+
$window.onYouTubeIframeAPIReady = applyServiceIsReady;
|
101
|
+
} else if (YT.loaded) {
|
102
|
+
Service.ready = true;
|
103
|
+
} else {
|
104
|
+
YT.ready(applyServiceIsReady);
|
105
|
+
}
|
106
|
+
|
107
|
+
return Service;
|
108
|
+
}])
|
109
|
+
.directive('youtubeVideo', ['youtubeEmbedUtils', function (youtubeEmbedUtils) {
|
110
|
+
var uniqId = 1;
|
111
|
+
|
112
|
+
// from YT.PlayerState
|
113
|
+
var stateNames = {
|
114
|
+
'-1': 'unstarted',
|
115
|
+
0: 'ended',
|
116
|
+
1: 'playing',
|
117
|
+
2: 'paused',
|
118
|
+
3: 'buffering',
|
119
|
+
5: 'queued'
|
120
|
+
};
|
121
|
+
|
122
|
+
var eventPrefix = 'youtube.player.';
|
123
|
+
|
124
|
+
return {
|
125
|
+
restrict: 'EA',
|
126
|
+
scope: {
|
127
|
+
videoId: '=?',
|
128
|
+
videoUrl: '=?',
|
129
|
+
player: '=?',
|
130
|
+
playerVars: '=?',
|
131
|
+
playerHeight: '=?',
|
132
|
+
playerWidth: '=?'
|
133
|
+
},
|
134
|
+
link: function (scope, element, attrs) {
|
135
|
+
// allows us to $watch `ready`
|
136
|
+
scope.utils = youtubeEmbedUtils;
|
137
|
+
|
138
|
+
// player-id attr > id attr > directive-generated ID
|
139
|
+
var playerId = attrs.playerId || element[0].id || 'unique-youtube-embed-id-' + uniqId++;
|
140
|
+
element[0].id = playerId;
|
141
|
+
|
142
|
+
// Attach to element
|
143
|
+
scope.playerHeight = scope.playerHeight || 390;
|
144
|
+
scope.playerWidth = scope.playerWidth || 640;
|
145
|
+
scope.playerVars = scope.playerVars || {};
|
146
|
+
|
147
|
+
// YT calls callbacks outside of digest cycle
|
148
|
+
function applyBroadcast () {
|
149
|
+
var args = Array.prototype.slice.call(arguments);
|
150
|
+
scope.$apply(function () {
|
151
|
+
scope.$emit.apply(scope, args);
|
152
|
+
});
|
153
|
+
}
|
154
|
+
|
155
|
+
function onPlayerStateChange (event) {
|
156
|
+
var state = stateNames[event.data];
|
157
|
+
if (typeof state !== 'undefined') {
|
158
|
+
applyBroadcast(eventPrefix + state, scope.player, event);
|
159
|
+
}
|
160
|
+
scope.$apply(function () {
|
161
|
+
scope.player.currentState = state;
|
162
|
+
});
|
163
|
+
}
|
164
|
+
|
165
|
+
function onPlayerReady (event) {
|
166
|
+
applyBroadcast(eventPrefix + 'ready', scope.player, event);
|
167
|
+
}
|
168
|
+
|
169
|
+
function onPlayerError (event) {
|
170
|
+
applyBroadcast(eventPrefix + 'error', scope.player, event);
|
171
|
+
}
|
172
|
+
|
173
|
+
function createPlayer () {
|
174
|
+
var playerVars = angular.copy(scope.playerVars);
|
175
|
+
playerVars.start = playerVars.start || scope.urlStartTime;
|
176
|
+
var player = new YT.Player(playerId, {
|
177
|
+
height: scope.playerHeight,
|
178
|
+
width: scope.playerWidth,
|
179
|
+
videoId: scope.videoId,
|
180
|
+
playerVars: playerVars,
|
181
|
+
events: {
|
182
|
+
onReady: onPlayerReady,
|
183
|
+
onStateChange: onPlayerStateChange,
|
184
|
+
onError: onPlayerError
|
185
|
+
}
|
186
|
+
});
|
187
|
+
|
188
|
+
player.id = playerId;
|
189
|
+
return player;
|
190
|
+
}
|
191
|
+
|
192
|
+
function loadPlayer () {
|
193
|
+
if (scope.videoId || scope.playerVars.list) {
|
194
|
+
if (scope.player && typeof scope.player.destroy === 'function') {
|
195
|
+
scope.player.destroy();
|
196
|
+
}
|
197
|
+
|
198
|
+
scope.player = createPlayer();
|
199
|
+
}
|
200
|
+
};
|
201
|
+
|
202
|
+
var stopWatchingReady = scope.$watch(
|
203
|
+
function () {
|
204
|
+
return scope.utils.ready
|
205
|
+
// Wait until one of them is defined...
|
206
|
+
&& (typeof scope.videoUrl !== 'undefined'
|
207
|
+
|| typeof scope.videoId !== 'undefined'
|
208
|
+
|| typeof scope.playerVars.list !== 'undefined');
|
209
|
+
},
|
210
|
+
function (ready) {
|
211
|
+
if (ready) {
|
212
|
+
stopWatchingReady();
|
213
|
+
|
214
|
+
// URL takes first priority
|
215
|
+
if (typeof scope.videoUrl !== 'undefined') {
|
216
|
+
scope.$watch('videoUrl', function (url) {
|
217
|
+
scope.videoId = scope.utils.getIdFromURL(url);
|
218
|
+
scope.urlStartTime = scope.utils.getTimeFromURL(url);
|
219
|
+
|
220
|
+
loadPlayer();
|
221
|
+
});
|
222
|
+
|
223
|
+
// then, a video ID
|
224
|
+
} else if (typeof scope.videoId !== 'undefined') {
|
225
|
+
scope.$watch('videoId', function () {
|
226
|
+
scope.urlStartTime = null;
|
227
|
+
loadPlayer();
|
228
|
+
});
|
229
|
+
|
230
|
+
// finally, a list
|
231
|
+
} else {
|
232
|
+
scope.$watch('playerVars.list', function () {
|
233
|
+
scope.urlStartTime = null;
|
234
|
+
loadPlayer();
|
235
|
+
});
|
236
|
+
}
|
237
|
+
}
|
238
|
+
});
|
239
|
+
|
240
|
+
scope.$watchCollection(['playerHeight', 'playerWidth'], function() {
|
241
|
+
if (scope.player) {
|
242
|
+
scope.player.setSize(scope.playerWidth, scope.playerHeight);
|
243
|
+
}
|
244
|
+
});
|
245
|
+
|
246
|
+
scope.$on('$destroy', function () {
|
247
|
+
scope.player && scope.player.destroy();
|
248
|
+
});
|
249
|
+
}
|
250
|
+
};
|
251
|
+
}]);
|