cis notified web server of a job completion; upload form interface and validation...
[living-lab-site.git] / application / views / video / comments_view.php
1 <h4><?php echo $this->lang->line('video_title_comment') ?>: </h4>
2
3 <?php echo form_open("video/comment/$video_id") ?>
4         <textarea name="comment" id="comment" rows="4" cols="56"><?php 
5                 if (validation_errors()):
6                         echo set_value('comment', '');
7                 endif;
8         ?></textarea>
9         
10         <div><input type="button" id="button-post" value="<?php echo $this->lang->line('video_submit_post_comment') ?>" />
11                 <span id="comment-chars-left">512</span> <?php echo $this->lang->line('ui_chars_left') ?>
12         </div>
13         <div><?php echo form_error('comment') ?></div>
14 </form>
15
16 <?php if ($comments_count == 0): ?>
17
18 <h4><?php echo $this->lang->line('video_title_no_comments') ?></h4>
19
20 <?php else: ?>
21
22   <?php if ($hottest_comments): ?>
23         <h4><?php echo $this->lang->line('video_title_hottest_comments'). ": " ?></h4>
24
25         <?php foreach ($hottest_comments as $hottest_comment): ?>
26                 <div class="comment-info"><strong class="comment-user"><a href="<?php echo site_url("user/profile/{$hottest_comment['username']}") ?>"><?php echo $hottest_comment['username'] ?></a></strong>
27                         (<span class="comment-time"><?php echo $hottest_comment['local_time'] ?></span>)
28                 </div>
29                 
30                 <div class="comment-content"><?php echo $hottest_comment['content'] ?></div>
31                 
32                 <div class="comment-popularity"><a class="link-vote-video-comment" data-action="like" data-commentid="<?php echo $hottest_comment['id'] ?>" href="#"><?php echo $this->lang->line('video_like') ?></a>
33                         &nbsp;<a class="link-vote-video-comment" data-action="dislike" data-commentid="<?php echo $hottest_comment['id'] ?>" href="#"><?php echo $this->lang->line('video_dislike') ?></a>
34                         &nbsp;&nbsp;&nbsp;&nbsp;<span id="<?php echo "video-comment-{$hottest_comment['id']}-likes" ?>"><?php echo $hottest_comment['likes'] ?></span> <?php
35                                 echo $this->lang->line('ui_likes') ?>,
36                         <span id="<?php echo "video-comment-{$hottest_comment['id']}-dislikes" ?>"><?php echo $hottest_comment['dislikes'] ?></span> <?php
37                                 echo $this->lang->line('ui_dislikes'); ?>
38                 </div>
39         <?php endforeach ?>
40   <?php endif ?>
41
42 <h4><?php echo $this->lang->line('video_title_all_comments'). " ($comments_count): " ?></h4>
43
44 <?php foreach ($comments as $comment): ?>
45         <div class="comment-info"><strong class="comment-user"><a href="<?php echo site_url("user/profile/{$comment['username']}") ?>"><?php echo $comment['username'] ?></a></strong>
46                 (<span class="comment-time"><?php echo $comment['local_time'] ?></span>)
47         </div>
48         
49         <div class="comment-content"><?php echo $comment['content'] ?></div>
50         
51         <div class="comment-popularity"><a class="link-vote-video-comment" data-action="like" data-commentid="<?php echo $comment['id'] ?>" href="#"><?php echo $this->lang->line('video_like') ?></a>
52                 &nbsp;<a class="link-vote-video-comment" data-action="dislike" data-commentid="<?php echo $comment['id'] ?>" href="#"><?php echo $this->lang->line('video_dislike') ?></a>
53                 &nbsp;&nbsp;&nbsp;&nbsp;<span id="<?php echo "video-comment-{$comment['id']}-likes" ?>"><?php echo $comment['likes'] ?></span> <?php
54                         echo $this->lang->line('ui_likes') ?>,
55                 <span id="<?php echo "video-comment-{$comment['id']}-dislikes" ?>"><?php echo $comment['dislikes'] ?></span> <?php
56                         echo $this->lang->line('ui_dislikes'); ?>
57         </div>
58 <?php endforeach ?>
59
60 <?php echo $comments_pagination ?>
61 <?php endif ?>
62
63 <script type="text/javascript">
64         $(function() {
65                 $('#button-post')
66                         .click(function() {
67                                 $.post('<?php echo site_url("video/ajax_comment/$video_id") ?>',
68                                         {comment: $('#comment').val()},
69                                         function(data) {
70                                                 $('#video-comments').html(data);
71                                         });
72                         });
73                 
74                 $('.pagination')
75                         .ajaxLinksMaker({
76                                 linkSelectors: [
77                                         '.pg-first',
78                                         '.pg-prev',
79                                         '.pg-next',
80                                         '.pg-last',
81                                         '.pg-num'
82                                 ],
83                                 target: '#video-comments'
84                         });
85                         
86                 $('.link-vote-video-comment')
87                         .click(function(event) {
88                                 var user_id = "<?php echo $user_id ?>";
89                                 var action, idOutput, commentId;
90                                 commentId = $(this).data('commentid');
91                                 if ($(this).data('action') == 'like')
92                                 {
93                                         var action = 'like';
94                                         var idOutput = '#video-comment-' + commentId + '-likes';
95                                 }
96                                 else
97                                 {
98                                         var action = 'dislike';
99                                         var idOutput = '#video-comment-' + commentId + '-dislikes';
100                                 }
101                                 //alert(action + " " + user_id);
102                                 
103                                 event.preventDefault();
104                                 
105                                 if (user_id.length != 0)
106                                 {
107                                         $.ajax({
108                                                 type: "GET",
109                                                 url: "<?php echo site_url("video/ajax_vote_comment") ?>/"
110                                                         + action
111                                                         + "/" + commentId,
112                                                 data: {t: ""+Math.random()},
113                                                 dataType: "text",
114                                                 success: function(text) {
115                                                         if (text)
116                                                                 $(idOutput).html(text);
117                                                         else
118                                                                 alert('<?php echo $this->lang->line('ui_msg_repeated_action_restriction') ?>');
119                                                 }
120                                         });
121                                 }
122                                 else
123                                         alert('<?php echo $this->lang->line('ui_msg_login_restriction') ?>');
124                         });
125                 
126                 $('#comment')
127                         .bind('keyup paste drop change', function(event) {
128                                 $textarea = $(this);
129                                 
130                                 if ($textarea.val().length >= 513)
131                                         $textarea.val($textarea.val().substring(0, 512));
132
133                                 $('#comment-chars-left').html('' + (512 - $textarea.val().length));
134                         });
135         });
136 </script>