home.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. $(document).keydown(function(event){
  2. if(event.keyCode==13){
  3. var txt = $('.y_lplist_inp').val();
  4. if (txt != '') {
  5. window.location.href = '/video/home?name='+ txt;
  6. };
  7. }
  8. });
  9. // 获取 "video" 视频元素时长
  10. $(function(){
  11. function myFunction(cid){
  12. cid.each(function(){
  13. var _this=$(this)
  14. _this.find('video.video_list_main')[0].addEventListener("loadedmetadata", function(){
  15. var tol = this.duration;//获取总时长
  16. var time = parseInt(tol);
  17. var minutes = parseInt(time / 60);
  18. var seconds =( time - minutes * 60);
  19. _this.find('.time_b').html(Appendzero(minutes)+':'+Appendzero(seconds))
  20. })
  21. })
  22. }
  23. function Appendzero (obj) { //时间补零
  24. if (obj < 10) return "0" + obj; else return obj;
  25. }
  26. myFunction($('.m_video_box ul li'));
  27. });
  28. //获取url中的参数
  29. function getUrlParam(name){
  30. //构造一个含有目标参数的正则表达式对象
  31. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  32. //匹配目标参数
  33. var r = window.location.search.substr(1).match(reg);
  34. //alert(r);
  35. //返回参数值
  36. if (r!=null) return decodeURI(r[2]);
  37. return null;
  38. }
  39. var _name = getUrlParam('name');
  40. if(_name){
  41. $('.m_videohead_box').hide();
  42. }else{
  43. $('.m_videohead_box').show();
  44. }