~campmumbai/+junk/padmaApi

« back to all changes in this revision

Viewing changes to static/js/padmaList.js

  • Committer: Sanjay B
  • Date: 2009-06-14 14:51:10 UTC
  • Revision ID: b@pad.ma-20090614145110-x8hc9mrqak6r1doo
first commit - fetches all data from pad.ma

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
$(document).ready(function() {
 
2
  var apiUrl = "/list/videos?listId=" + listId;
 
3
  callPadma(apiUrl, initList);
 
4
  });
 
5
 
 
6
var padmaVideo = function(json, index) {
 
7
  this.id = json.id;
 
8
  this.index = index;
 
9
  this.title = json.title; 
 
10
  this.poster = "http://pad.ma/" + this.id + "/poster.jpg";
 
11
  this.wrapperHtml = this.getWrapperHtml()
 
12
  this.init();
 
13
  }
 
14
 
 
15
padmaVideo.prototype.getWrapperHtml = function() {
 
16
  var that = this;
 
17
  var videoElem = $('<div />');
 
18
  videoElem.attr('id', that.id);
 
19
  videoElem.addClass("videoWrapper");
 
20
  var html = '';
 
21
  html += "<div class='videoTitle'>";
 
22
  html += this.title;
 
23
  html += "</div>";
 
24
  html += "<div class='videoPoster'>";
 
25
  html += "<img src='" + this.poster + "' />";
 
26
  html += "</div>";
 
27
  html += "<div class='videoMeta'>";
 
28
  html += "Loading...";
 
29
  html += "</div>";
 
30
  videoElem.html(html);
 
31
  return videoElem;
 
32
  }
 
33
 
 
34
padmaVideo.prototype.init = function() {
 
35
  var that = this;
 
36
  $('#videos').append(that.wrapperHtml);
 
37
  this.loadData();
 
38
  }
 
39
 
 
40
padmaVideo.prototype.metaLoaded = function() {
 
41
  var that = this;
 
42
  $('#' + that.id + ' .videoMeta').html(that.meta.description_html);
 
43
  }
 
44
 
 
45
padmaVideo.prototype.layersLoaded = function() {
 
46
  return true;
 
47
  }
 
48
 
 
49
padmaVideo.prototype.loadData = function() {
 
50
  var that = this;
 
51
  var metaUrl = "http://pad.ma/" + that.id + "/video.js";
 
52
  $.getScript(metaUrl, function() {
 
53
    that.meta = video;
 
54
    that.metaLoaded();
 
55
    var layersUrl = "http://pad.ma/" + that.id + "/layers.js";
 
56
    $.getScript(layersUrl, function() {
 
57
      that.layers = layers;
 
58
      that.layersLoaded();
 
59
      });
 
60
    });
 
61
  }
 
62
 
 
63
var padmaVideos = [];
 
64
function initList(json) {
 
65
  var videos = json.videos;
 
66
  for (v in videos) {
 
67
    var thisVideo = new padmaVideo(videos[v], v);
 
68
    padmaVideos.push(thisVideo);
 
69
    }
 
70
  }