summaryrefslogtreecommitdiff
path: root/src/static/js/jquery.meetingtools.js
blob: 2ce958d01e78796046f0f6859c5ff2bc6581a387 (plain)
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
/*
 * a jQuery plugin for listing tagged meetings from meetingtools
 *
 */

jQuery.fn.meetingtools = function(options) {
	
	var defaults = { 
		    onAdd:      function() {},
		    onUpdate:   function() {},
		    url:        'http://localhost:8000'
    }; 
	var options = $.extend({}, defaults, options); 
	
	this.each(function() {
		var tags = options.tags;
		var url = options.url;
		var url = options.url+'/room/+'+tags+'.json?callback=?';
		var div = $(this);
		$.getJSON(url,function(data) {
			div.html("<ul class=\"meeting-list\">");
			ul = div.find('ul.meeting-list');
			$.each(data,function(i,room) {
				var html = "<li class=\"meeting\"><h4>"+room['name']+"</h4><div class=\"meeting-info\">";
				if (room['description']) {
					html += "<div class=\"meeting-description\">";
					html += room['description'];
					html += "</div>";
				}
				html += "<div class=\"meeting-participants\">" 
				html += "There are currently " + room['user_count'] + " participant(s) and " + room['host_count'] + " host(s) in the room.";
				html += "</div>";
				html += "<div class=\"meeting-button\"><a target=\"_blank\" title=\"Enter "+room['name']+"\" href=\"" + room['url'] + "\">Enter " + room['name'] + "</a></div>";
				html += "<div class=\"meeting-url\">" + room['url'] + "</a></div>";
				html += "</div>";
				html += "</li>";
				ul.append(html);
				options.onAdd();
			});
			options.onUpdate();
		});
		
		
	});
}