~tsarev/+junk/power_juick

« back to all changes in this revision

Viewing changes to super_juick.user.js

  • Committer: Oleg Tsarev
  • Date: 2011-10-23 23:00:47 UTC
  • Revision ID: oleg.tsarev@percona.com-20111023230047-sceygliy27t9a5y4
add comments folding

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ==UserScript==
2
 
// @name Super Juick
 
2
// @name Power Juick
3
3
// @include http://juick.com/*
4
4
// @description Some tweaks for Juick.com
5
 
// @version 1.0.9
 
5
// @version 1.0.10
6
6
// ==/UserScript==
7
7
 
8
8
(function() {
94
94
            get_parentId : function(item) {
95
95
                return String(this.get_oo(item).innerHTML).substring(1);
96
96
            },
97
 
            get_reply : function(id) {
98
 
                return document.getElementById(id);
99
 
            }, 
100
97
            get_parent : function(item) {
101
 
                return this.get_reply(this.get_parentId(item));
 
98
                return document.getElementById(this.get_parentId(item));
102
99
            },
103
100
            reply_rewrite : function(item) {
104
101
                item.style.marginTop =     "1.25em";
108
105
                this.reply_rewrite_children(item);
109
106
            },
110
107
            reply_rewrite_children : function(reply) {
 
108
                var id= reply.getAttribute('id');
111
109
                var children= reply.reply_children;
112
110
                if (children.length > 0) {
113
111
                    var root= document.createElement('ul');
114
112
                    for(var i= 0; i < children.length; i++) {
115
 
                        var child= this.get_reply(children[i]);
 
113
                        var child= document.getElementById(children[i]);
116
114
                        this.reply_rewrite(child);
117
115
                        root.appendChild(child);
118
116
                    }
119
 
                    reply.appendChild(root);
 
117
 
 
118
                    var button= document.createElement('a');
 
119
                    button.setAttribute("style", "TEXT-DECORATION: NONE");
 
120
                    button.href= "javascript: window.reply_action('" + id + "');";
 
121
                    button.hide= function () {
 
122
                        reply.removeChild(root);
 
123
                        button.innerHTML= '+';
 
124
                        button.action= button.show;
 
125
                    };
 
126
                    button.show= function() {
 
127
                        reply.appendChild(root);
 
128
                        button.innerHTML= '-';
 
129
                        button.action= button.hide;
 
130
                    };
 
131
                    reply.appendChild(button);
 
132
                    button.show();
 
133
                    unsafeWindow.reply_cache[id]= button;
120
134
                }
121
135
            },
122
136
            reply_link : function(root, item) {
130
144
            run : function() {
131
145
                var ul= document.getElementById('replies');
132
146
                if (ul) {
 
147
                    unsafeWindow.reply_cache= {};
 
148
                    unsafeWindow.reply_action= function(id) {
 
149
                        unsafeWindow.reply_cache[id].action();
 
150
                    };
133
151
                    var root= ul.parentNode;
134
152
                    root.reply_children= [];
135
153
                    var replies= ul.getElementsByTagName('LI');