aboutsummaryrefslogtreecommitdiff
path: root/web/scripts3.js
blob: bf3da76f6b85bf243d946555e3216a1853cc256f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function inlinevideo(mid) {
    var flashvars={
        file:'http://i.juick.com/video/'+mid+'.mp4',
        image:'http://i.juick.com/thumbs/'+mid+'.jpg',
        skin:'http://static.juick.com/glow.zip'
    };
    var params={
        allowfullscreen:'true'
    };
    swfobject.embedSWF('http://static.juick.com/player.swf','video-'+mid,'640','390','9.0.115','false',flashvars,params,null);
}

function postformListener(formEl,ev) {
    if(ev.ctrlKey && (ev.keyCode==10 || ev.keyCode==13)) formEl.submit();
}

function showMoreReplies(id) {
    $('#'+id+' .msg-comments').hide();

    var replies=$('#replies>li');
    var flagshow=0;
    for(var i=0; i<replies.length; i++) {
        if(flagshow==1) {
            if(replies[i].style.display=="none") {
                replies[i].style.display="block";
            } else {
                break;
            }
        }
        if(replies[i].id==id) {
            flagshow=1;
        }
    }
    return false;
}

function showCommentForm(mid,rid) {
    if($('#replies #'+rid+' textarea').length==0) {
        var c=$('#replies #'+rid+' .msg-comment');
        c.wrap('<form action="/post" method="POST" enctype="multipart/form-data"/>');
        c.before('<input type="hidden" name="mid" value="'+mid+'"/><input type="hidden" name="rid" value="'+rid+'"/>');
        c.append('<textarea name="body" rows="1" class="reply" placeholder="Add a comment..." onkeypress="postformListener(this.form,event)"></textarea><input type="submit" value="OK"/>');
    }
    //    $('#replies #'+rid+' .msg-links').hide();
    $('#replies #'+rid+' .msg-comment').show();
    $('#replies #'+rid+' textarea')[0].focus();
    $('#replies #'+rid+' textarea').autoResize({
        extraSpace: 0,
        minHeight: 1
    });
    return false;
}

function unfoldReply() {
    if((0+window.location.hash.substring(1))>0) {
        var el=$(window.location.hash);
        while(el.is(":hidden")) {
            el=el.prev();
        }
        showMoreReplies(el.attr('id'));
        window.location.replace(window.location.hash);
    }
}

$(document).ready(function() {
    $('textarea.reply').autoResize({
        extraSpace: 0,
        minHeight: 1
    });
});