SwarmPlayer is now detected; CIS-LB random load balancer created
[living-lab-site.git] / application / views / video / watch_view.php
index 9f7d091..4477f8f 100644 (file)
@@ -3,7 +3,7 @@
        siteUrl = '<?php echo site_url() ?>';
 </script>
 
-<div id="watch-main">
+<div id="main">
 <?php // Invalid name in URL ?>
 <?php if (isset($video['err'])):
        if ($video['err'] == 'INVALID_NAME'):
@@ -19,7 +19,7 @@
        
 <?php // Correct URL ?>
 <?php else: ?>
-       <h1><?php echo $video['title'] ?></h1>
+       <h1><a href="<?php echo site_url('catalog/category/'. $video['category_name']) ?>"><?php echo $video['category_title'] ?></a> &rsaquo; <?php echo $video['title'] ?></h1>
        
        <div id="video-widget-tabs">
                <ul>
                <div id="video-widget"></div>
        </div>
        
-       <div id="video-info" style="clear: both">
-       <div id="video-upload-info">
-               <?php echo $this->lang->line('ui_uploaded_by') ?>
-                       <span id="video-date"><?php echo $video['user_name'] ?></span>
-                       <?php echo $this->lang->line('ui_on_date') ?>
-                       <span id="video-date"><?php echo $video['date'] ?></span>
-       </div>
+       <div style="clear: both"></div>
        
-       <div id="video-popularity">
-               <div id="video-views">
-                       <?php echo $video['views'] . ' '
-                               . ($video['views'] == 1 ? 
-                                       $this->lang->line('ui_view') : 
-                                       $this->lang->line('ui_views') );
-                       ?>
+       <div id="video-footer">
+               <div id="video-info" style="clear: both">
+                       <div id="video-upload-info">
+                               <?php echo $this->lang->line('ui_uploaded_by') ?>
+                                       <span id="video-user"><a href="<?php echo site_url("user/profile/{$video['username']}") ?>"><?php echo $video['username'] ?></a></span>
+                                       <?php echo $this->lang->line('ui_on_date') ?>
+                                       <span id="video-date"><?php echo $video['date'] ?></span>
+                       </div>
+                       
+                       <div id="video-popularity">
+                               <div id="video-views">
+                                       <?php echo $video['views'] . ' '
+                                               . ($video['views'] == 1 ? 
+                                                       $this->lang->line('ui_view') : 
+                                                       $this->lang->line('ui_views') );
+                                       ?>
+                               </div>
+                               
+                               <div><a class="link-vote" data-action="like" href="#"><?php echo $this->lang->line('video_like') ?></a>
+                                       <a class="link-vote" data-action="dislike" href="#"><?php echo $this->lang->line('video_dislike') ?></a>
+                                       <span id="video-likes"><?php echo $video['likes'] ?></span> <?php
+                                               echo $this->lang->line('ui_likes') ?>,
+                                       <span id="video-dislikes"><?php echo $video['dislikes'] ?></span> <?php
+                                               echo $this->lang->line('ui_dislikes'); ?>
+                               </div>
+                       </div>
+                       
+                       <div id="video-shorted-description" class="video-description"><?php echo $video['shorted_description'] ?></div>
+                       
+                       <div id="video-info-details">
+                               <div id="video-description" class="video-description"><?php echo $video['description'] ?></div>
+
+                               <dl id="video-category">
+                                       <dt><?php echo ucwords($this->lang->line('ui_category'))
+                                               . ': ' ?></dt>
+                                       <dd><?php echo $video['category_title'] ?></dd>
+                               </dl>
+
+                               <dl id="video-tags">
+                                       <dt><?php echo ucwords($this->lang->line('ui_tags')). ': ' ?></dt>
+                                       <dd><?php if (isset($video['tags'])): 
+                                       foreach ($video['tags'] as $tag => $score): ?>
+                                       <a href="<?php echo site_url('catalog/search/'. $tag) ?>" class="video-tag">
+                                               <?php echo "$tag " // TODO print score in future ?>
+                                       </a>
+                                       <?php endforeach; endif ?></dd>
+                               </dl>
+
+                               <dl id="video-torrents">
+                                       <dt><?php echo $this->lang->line('ui_download_torrents') ?>: </dt>
+                                 <?php foreach ($video['assets'] as $asset): ?>
+                                       <dd><a href="<?php echo $asset['src'] ?>"><?php echo $asset['def'] ?></a></dd>
+                                 <?php endforeach ?>
+                               </dl>
+
+                               <dl id="video-license">
+                                       <dt><?php echo ucwords($this->lang->line('ui_license')).': ' ?></dt>
+                                       <dd><?php echo $video['license'] ?></dd>
+                               </dl>
+                       </div>
+                       
+                       <a id="a-show-info-details" data-val="more" href="#"><?php echo $this->lang->line('video_show_more') ?></a>
                </div>
-               
-               <div><span id="video-likes">
-                       <?php echo $video['likes'] . ' '
-                               . ($video['likes'] == 1 ? 
-                                       $this->lang->line('ui_like') : 
-                                       $this->lang->line('ui_likes') );
-                       ?></span>,
-               <span id="video-dislikes">
-                       <?php echo $video['dislikes'] . ' '
-                               . ($video['dislikes'] == 1 ? 
-                                       $this->lang->line('ui_dislike') : 
-                                       $this->lang->line('ui_dislikes') );
-                       ?>
-               </span></div>
-       </div>
        
-       <div id="video-description"><?php echo $video['description'] ?></div>
-       
-       <dl id="video-category">
-               <dt><?php echo ucwords($this->lang->line('ui_category'))
-                       . ': ' ?></dt>
-               <dd><?php echo $video['category_title'] ?></dd>
-       </dl>
-       
-       <dl id="video-tags">
-               <dt><?php echo ucwords($this->lang->line('ui_tags')). ': ' ?></dt>
-               <dd><?php if (isset($video['tags'])): 
-               foreach ($video['tags'] as $tag => $score): ?>
-               <a href="<?php echo site_url('catalog/search/'. $tag) ?>" class="video-tag">
-                       <?php echo "$tag " // TODO print score in future ?>
-               </a>
-               <?php endforeach; endif ?></dd>
-       </dl>
-       
-       <dl id="video-license">
-               <dt><?php echo ucwords($this->lang->line('ui_license')).': ' ?></dt>
-               <dd><?php echo $video['license'] ?></dd>
-       </dl>
+               <div id="video-comments"><?php echo $comments ?></div>
        </div>
-       
 
 <?php endif // if (isset($video['err'])): ?>
 </div>
                                type: "<?php echo $plugin_type ?>",
                                src: <?php echo json_encode($video['assets']) ?>,
 
-                                               
-                               width: 427,
-                               height: 240,
                                showState: false,
-
                                
-                               //minWidth: 640,
-                               //maxWidth: 1024,
+                               minWidth: 640,
+                               maxWidth: 1024,
                                initialDuration: "<?php echo $video['duration'] ?>",
                                
                                resize: function() {
                                                .css('width', $('#video-widget').css('width'));
                                }
                        });
+               
+               $('.link-vote')
+                       .click(function(event) {
+                               var user_id = "<?php echo $user_id ?>";
+                               var action, idOutput;
+                               if ($(this).data('action') == 'like')
+                               {
+                                       var action = 'like';
+                                       var idOutput = '#video-likes';
+                               }
+                               else
+                               {
+                                       var action = 'dislike';
+                                       var idOutput = '#video-dislikes';
+                               }
+                               //alert(action + " " + user_id);
+                               
+                               event.preventDefault();
+                               
+                               if (user_id.length != 0)
+                               {
+                                       $.ajax({
+                                               type: "GET",
+                                               url: "<?php echo site_url("video/ajax_vote") ?>/"
+                                                       + action
+                                                       + "<?php echo "/{$video['id']}" ?>",
+                                               data: {t: ""+Math.random()},
+                                               dataType: "text",
+                                               success: function(text) {
+                                                       if (text)
+                                                               $(idOutput).html(text);
+                                                       else
+                                                               alert('<?php echo $this->lang->line('ui_msg_repeated_action_restriction') ?>');
+                                               }
+                                       });
+                               }
+                               else
+                                       alert('<?php echo $this->lang->line('ui_msg_login_restriction') ?>');
+                       })
+                       .button();
+               
+               $('#link-like')
+                       .click(function() {
+                               user_id = "<?php echo $user_id ?>";
+                               
+                               if (user_id)
+                               {
+                                       $.ajax({
+                                               type: "GET",
+                                               url: "<?php echo site_url("video/ajax_vote/like/{$video['id']}") ?>",
+                                               dataType: "text",
+                                               success: function(text) {
+                                                       if (text)
+                                                               $('#video-likes').html(text);
+                                                       else
+                                                               alert('<?php echo $this->lang->line('ui_msg_repeated_action_restriction') ?>');
+                                               }
+                                       });
+                               }
+                               else
+                                       alert('<?php echo $this->lang->line('ui_msg_login_restriction') ?>');
+                       })
+                       .button();
+               $('#link-dislike')
+                       .click(function() {
+                               user_id = "<?php echo $user_id ?>";
+                               
+                               if (user_id)
+                               {
+                                       $.ajax({
+                                               type: "GET",
+                                               url: "<?php echo site_url("video/ajax_vote/dislike/{$video['id']}/$user_id") ?>",
+                                               data: {t: ""+Math.random()},
+                                               dataType: "text",
+                                               success: function(text) {
+                                                       $('#video-dislikes').html(text);
+                                               }
+                                       });
+                               }
+                               else
+                                       alert('<?php echo $this->lang->line('ui_msg_login_restriction') ?>');
+                       })
+                       .button();
+                       
+               $('#video-info-details').hide();
+               
+               $('#a-show-info-details')
+//                     .button({
+//                             icons: {
+//                                     primary: 'ui-icon-triangle-1-s'
+//                             },
+//                             text: false
+//                     })
+                       .click(function(event) {
+                               event.preventDefault(true);
+                               $('#video-shorted-description').toggle();
+                               $('#video-info-details').fadeToggle();
+                               
+                               //console.log($(this).button('option', 'icons'));
+                               if ($(this).data('val') == 'more')
+                               {
+                                       $(this).data('val', 'less');
+                                       $(this).html('<?php echo $this->lang->line('video_show_less') ?>');
+                               }
+                               else
+                               {
+                                       $(this).data('val', 'more');
+                                       $(this).html('<?php echo $this->lang->line('video_show_more') ?>');
+                               }
+                       });
        });
 </script>
\ No newline at end of file