Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('.ovc_descr_short').each(function(_, e) {
  2.   if (e.textContent.length > 30) $(e).text(e.textContent.slice(0,30) + '...')
  3. })
  4.  
  5. var playlists = $(".playlists");
  6.  
  7. var cid = playlists.attr('cid');
  8.  
  9. var course = $(".course_header")[0];
  10. var courseID = $(course.getElementsByClassName("coursename_header")[0].getElementsByTagName("a")[0]).attr('href').replace("/course/view.php?id=","");
  11. var mid = "XAOe";
  12.  
  13. playlists.children().each(function (index, value) {
  14.     var video = $(this).children();
  15.    
  16.     var playlistid = $(this).attr('id').replace("playlist","");
  17.    
  18.     video.each(function (video_index, video_value) {
  19.         var block = $(video_value);
  20.        
  21.         var element = $("<button></button>").text("הורד סרטון").attr('class','getvideo').attr('cid',cid).attr('playlistid',playlistid).attr('courseID',courseID).attr('mid',mid);
  22.        
  23.         var link = block.find("div.ovc_descr_short");
  24.         link.append(element);
  25.     });
  26. });
  27.  
  28. $(".getvideo").click(function(){
  29. var url = "http://opal.openu.ac.il/mod/ouilvideocollection/actions.php";
  30. var action = "getplaylist";
  31. var context = $(this).attr('cid');
  32. var playlistid = $(this).attr('playlistid');
  33. var courseID = $(this).attr('courseID');
  34. var mid = $(this).attr('mid');
  35.  
  36. jQuery.ajax({
  37.     type: "POST",
  38.     url: url,
  39.     data: {action: action, context: context, playlistid: playlistid, course: courseID, mid: mid},
  40.     success: function(data) {
  41.         var obj = jQuery.parseJSON(data);
  42.         var cdnid = obj.cdnid;
  43.        
  44.         var getURL = "http://opal.openu.ac.il/local/ouil_video/player.php?mediaid=" + cdnid + "&ie9=2"
  45.         $.get(getURL, function(data) {
  46.             var info = $(data.html)[2];
  47.             var href = $(info).find("source").attr('src');
  48.             window.open(href, '_blank');
  49.         });    
  50.     }
  51. });
  52.  
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement