-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
213 lines (148 loc) · 5.54 KB
/
test.html
File metadata and controls
213 lines (148 loc) · 5.54 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<html>
<head>
<style type='text/css'>
#output{
position:absolute;
left:50%;
top:0;
height:80%;
overflow:scroll;
background-color:lightblue;
}
</style>
</head>
<body>
<div id='podcast-tools'>
<h2>Podcast Tools</h2>
<center>
<span id='podcastTime'></span> </center>
</div>
<div id="podcast">
<pre>
START
DATE: <input type="datetime" id="start_date"> TIME: h:<input type="datetime" id="start_time_h" maxlength="2" size="2"> m:<input type="datetime" id="start_time_m" maxlength="2" size="2"> s:<input type="datetime" id="start_time_s" maxlength="2" size="2">
END
DATE: <input type="datetime" id="end_date"> TIME h: <input type="datetime" id="end_time_h" maxlength="2" size="2"> m:<input type="datetime" id="end_time_m" maxlength="2" size="2"> s:<input type="datetime" id="end_time_s" maxlength="2" size="2">
<input id="showname" value="show name"><br/>
<button class='custom_button' id="go_podcast">create podcast file</button>
<button class='custom_button' id="go_podcast_ftp">create podcast file (ftp)</button>
<!--
CHANNEL ID:
<input id='channel_id' maxlength='3' size='3'>"
EPISODE TITLE: <input id='title' maxlength='255' size='80'>
EPISODE SUBTITLE: <input id='subtitle' maxlength='255' size='80'>
EPISODE SUMMARY:
<textarea id='summary' maxlength='4000' rows='20' cols='80'></textarea>
EPISODE URL: <input id='url' maxlength='255' size='75'>
<span class='custom_button' id="go_podcast_episode">add episode</span>
</pre>
-->
<div id="output"></div>
</pre>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script>
var podcaster_url = './create_audio_file_old.php';
var podcaster_url_ftp = './create_audio_file.php';
var podcast_audio_root = '';
var episode_endpoint = '';//'/episode.php';
var archive_tool_url = '';//'http://archive.citr.ca';
$('#start_date').datepicker({ dateFormat: "@" });
$('#end_date').datepicker({ dateFormat: "@" });
// TEST INIT
$('#start_time_h').val('13');
$('#end_time_h').val('14');
$('#start_time_m,#start_time_s,#end_time_m,#end_time_s,#start_time_h,#end_time_h').change(function(){
$('#prev_start').click(function(a){
a.preventDefault();
var start_unix = parse_start();
$('#prev_start').attr('data-audio',start_unix);
alert('dingus');
return false;
});
});
$('#start_time_m,#start_time_s,#end_time_m,#end_time_s').val('00');
$('#podcastStart').click(function(){
updatePodcast('start');
});
$('#podcastEnd').click(function(){
updatePodcast('end');
});
function updatePodcast(start_or_end){
$.ajax(archive_tool_url+'/time/',{
success:function(time){
var timestamp = new Date(time*1000);
var hours = timestamp.getHours();
var minutes = timestamp.getMinutes();
var seconds = timestamp.getSeconds();
var date = time - hours*60*60 - minutes*60 - seconds;
var target = '#'+start_or_end;
$(target+'_date').val(date);
$(target+'_time_h').val(hours);
$(target+'_time_m').val(minutes);
$(target+'_time_s').val(seconds);
}
});
if(start_or_end == 'start'){
}
}
function parse_start(){
var start_date = parseInt($('#start_date').val()) / 1000;
var start_hour = parseInt($('#start_time_h').val());
var start_minute = parseInt($('#start_time_m').val());
var start_second = parseInt($('#start_time_s').val());
return start_date + 60*60*start_hour + 60*start_minute + start_second;
}
function parse_end(){
var end_date = parseInt($('#end_date').val()) / 1000;
var end_hour = parseInt($('#end_time_h').val());
var end_minute = parseInt($('#end_time_m').val());
var end_second = parseInt($('#end_time_s').val());
return end_date + 60*60*end_hour + 60*end_minute + end_second;
}
var do_podcast = function(podcast_url){
var show_name = $('#showname').val();
var start_unix = parse_start();
var end_unix = parse_end();
$('#output').html('start unix:<br/>'+start_unix+'<br/>end unix:<br/> '+end_unix);
$('#output').append('<br/>requested duration: '+ Math.floor((end_unix-start_unix)/60/60)).append(' hours');
$('#output').append('<hr/>making audio...please wait...');
$.ajax(podcast_url,{
data:{start:start_unix, end:end_unix, show:show_name},
success:function(data){
var data = JSON.parse(data);
if(data.error){
$('#output').append('<p>error creating audio:<br/>'+data.error)
} else {
$('#output').append('<p>audio created successfully. audio should show up here soon:<hr/>'+
'<a href="http://playlist.citr.ca/podcasting/audio/2015/'+data.filename+'">'+data.filename+'</a>');
// $('#output').append('<hr/>did ajax request to '+podcaster_url+'. <hr/>result: '+data);
console.log(data);
var channel = $('#channel_id').val();
var title = $('#title').val();
var subtitle = $('#subtitle').val();
var summary = $('#summary').val();
$('#url').val(podcast_audio_root + data.filename);
var episode_url = podcast_audio_root+data.filename;
}
},
error:function(data){
console.info(data);
$('#output').append('Podcast API error: '+data.statusText);
},
complete:function(data){
// $('#output').append('<hr/>request complete');
}
});
}
$('#go_podcast_ftp').click(function() {
do_podcast(podcaster_url_ftp);
});
$('#go_podcast').click(function() {
do_podcast(podcaster_url);
});
</script>
</body>
</html>