You are here

function kaltura_prepare_js_code in Kaltura 5

Same name and namespace in other branches
  1. 6.2 plugins/kaltura_playlist/kaltura_playlist.module \kaltura_prepare_js_code()
  2. 6 plugins/kaltura_playlist/kaltura_playlist.module \kaltura_prepare_js_code()
1 call to kaltura_prepare_js_code()
theme_kaltura_playlist_view in plugins/kaltura_playlist/kaltura_playlist.module

File

plugins/kaltura_playlist/kaltura_playlist.module, line 351

Code

function kaltura_prepare_js_code($div_id, $first_entry, $autonext, $node_count) {
  $javascript = '<script type="text/javascript">
  var timeoutId = 0;
  var mykdp = new KalturaPlayerController(\'kaltura_playlist_module\');
  mykdp.currentEntryId = "' . $first_entry->node_kaltura_kaltura_entryId . '";
  $("#' . $first_entry->node_kaltura_kaltura_entryId . '").addClass("playing");

  var myplaylist = Array();
  function test() { alert("test"); }
  function fill_playlist(div_id) {
    myplaylist = $("div.clips").children(".playlist-item");
  }
  fill_playlist("' . $div_id . '");
  ';
  if ($node_count >= 4) {
    $javascript .= '
    $("div#' . $div_id . '").scrollable({
      items:\'div.clips\',
      vertical:true,
      size:4,
      next:\'a.down\',
      prev:\'a.up\'
    });
    ';
  }
  $javascript .= '
  $("div.clips").height($("div.clips").height()+2);

  function replace_media(entry_id){
    $("#"+mykdp.currentEntryId).removeClass("playing");
    mykdp.insertEntry(entry_id, true);
    $("#"+mykdp.currentEntryId).addClass("playing");
  }
  ';
  if ($autonext == 1) {
    $javascript .= 'function auto_scroll_playlist() {
      current_entry = mykdp.currentEntryId;
      next_entries = $("#"+current_entry).next();
      if (next_entries.length) {
        next_id = $(next_entries[0]).attr("id");
      } else {
        next_id = $(myplaylist[0]).attr("id");
      }
      $("#"+next_id).click();
    }';
  }
  $javascript .= '</script>';
  return $javascript;
}