Changeset 505
- Timestamp:
- 10/17/07 02:42:47 (6 years ago)
- Files:
-
- 1 modified
-
lang/javascript/userscripts/syobocalplus.user.js (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/syobocalplus.user.js
r504 r505 133 133 if (!tobj) 134 134 { 135 tobj = {count: 0, name: name };135 tobj = {count: 0, name: name, tid: tid, box_class: "tid-"+tid}; 136 136 this.namedMap[tid] = tobj; 137 137 … … 143 143 144 144 tobj.count++; 145 this.count++; 146 147 return tobj; 145 148 }, 146 149 … … 158 161 searchTitle: function(kw) { 159 162 var matchedTitles = []; 160 163 var count = 0; 164 161 165 for(var s = 0;;) 162 166 { … … 168 172 var t = this.namedMap[ this.idxDB.charCodeAt(idx) ]; 169 173 if (t) 174 { 170 175 matchedTitles.push(t); 176 count += t.count; 177 } 171 178 } 172 179 … … 174 181 return null; 175 182 176 return matchedTitles; 183 return {count_all: count, titles: matchedTitles}; 184 }, 185 186 map: function(proc) { 187 for (var t in this.namedMap) 188 proc(this.namedMap[t], t); 189 }, 190 191 commitTitleFilterStyles: function() { 192 var rules = []; 193 this.map(function(t) { 194 rules.push(".plus-unvail-t"+t.tid+" .v3box."+t.box_class+"{-moz-opacity:1;}"); 195 }); 196 GM_addStyle(rules.join(' ')); 197 } 198 } 199 // ----------------------------------- 200 var FilterBox = function() { 201 var x = document.evaluate("//div[@class='main']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 202 if (x.snapshotLength < 1) 203 throw "div.main not found"; 204 205 this.element = x.snapshotItem(0); 206 this.originalClass = this.element.className; 207 } 208 209 FilterBox.prototype = { 210 clear: function() { 211 this.element.className = this.originalClass; 212 }, 213 214 setFilterClasses: function(c) { 215 this.element.className = this.originalClass+" "+c; 177 216 } 178 217 } … … 223 262 // ----------------------------------- 224 263 225 var ChannelSelector = function(chman ) {264 var ChannelSelector = function(chman, tman, fbox) { 226 265 this.chManager = chman; 266 this.titleManager = tman; 267 this.titleFilterBox = fbox; 227 268 228 269 var _this = this; … … 231 272 var ul = document.createElement("ul"); 232 273 document.body.appendChild(ul); 233 ul.innerHTML = "\u5168\u3066"; 274 275 276 ul.innerHTML = "\uff80\uff72\uff84\uff99\u691c\u7d22<input type=\"text\"><span> </span> \u5c40 \u5168\u3066"; 277 278 // search box 279 var txtbox = ul.childNodes[1]; 280 var resarea = ul.childNodes[2]; 281 var sbox = new SearchBox(txtbox, resarea); 282 sbox.search = function(k){return _this.searchTitle(k);} 234 283 235 284 var btnAllHide = document.createElement("button"); … … 251 300 252 301 ChannelSelector.prototype = { 302 searchTitle: function(key) { 303 if (!key.match(/[^\s]/) || key == "") 304 { 305 this.titleFilterBox.clear(); 306 removeClass(document.body, "plus-filtered"); 307 return {message: ""}; 308 } 309 var sres = this.titleManager.searchTitle(key); 310 311 addClass(document.body, "plus-filtered"); 312 313 if (!sres) 314 return {message: "(0)"}; 315 316 var len = sres.titles.length; 317 var unvail_classes = [] 318 for (var i = 0;i < len;i++) 319 unvail_classes.push("plus-unvail-t"+sres.titles[i].tid); 320 this.titleFilterBox.setFilterClasses(unvail_classes.join(" ")); 321 322 return {message: '('+sres.count_all+')'}; 323 }, 324 253 325 addChannel: function(chname, chobj) { 254 326 var li = document.createElement("li"); … … 314 386 applyChannelClass: function(chobj) { 315 387 this.box.className += " "+chobj.chclass; 388 } 389 } 390 // ----------------------------------- 391 var SearchBox = function(elem, msgbdy) { 392 this.textBox = elem; 393 elem.className = "plus-searchbox"; 394 this.messageBox = msgbdy; 395 396 var _this = this; 397 this.oldValue = elem.value; 398 elem.addEventListener("keyup", function(e){_this.onKey(e)}, false); 399 } 400 401 SearchBox.prototype = { 402 onKey: function(e) { 403 var v = this.textBox.value; 404 if (this.oldValue != v) 405 { 406 if (this.search) 407 { 408 var res = this.search(v); 409 if (res && res.message != undefined) 410 this.outMessage(res.message); 411 } 412 this.oldValue = v; 413 } 414 }, 415 416 outMessage: function(msg) { 417 this.messageBox.innerHTML = msg; 316 418 } 317 419 } … … 340 442 finish: function() { 341 443 this.chManager.commitChannelFilterStyles(); 444 this.titleManager.commitTitleFilterStyles(); 342 445 }, 343 446 … … 373 476 As[i].href.match(/tid\/([0-9]+)/); 374 477 var tid = RegExp["$1"] - 0; 375 this.titleManager.put(tid, title); 478 var tobj = this.titleManager.put(tid, title); 479 box.className += " "+tobj.box_class; 376 480 } 377 481 } … … 386 490 } 387 491 // ----------------------------------- 388 GM_addStyle(".chselector{z-index: 100; font-size: 80%; width: 100%; position: fixed; bottom: 0; margin: 0; padding: 2px; background: #eee; border-top: 1px solid #ddd;} .chselector li{display: inline; margin: 0 2px 0 2px;}"); 492 493 GM_addStyle(".chselector{z-index: 100; font-size: 80%; width: 100%; position: fixed; bottom: 0; margin: 0; padding: 2px 2px 2px 4px; background: ThreeDFace; border-top: 1px solid #ThreeDShadow;} .chselector li{display: inline; margin: 0 2px 0 2px;} .plus-filtered .v3box{-moz-opacity:"+HiddenAlpha+"}"); 389 494 390 495 document.body.style.paddingBottom = "2em"; 391 496 var divs = document.evaluate("//div[@class='v3box']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 497 var filter = new FilterBox(); 392 498 393 499 var chman = new ChannelManager(); 394 500 var tman = new TitleManager(); 395 new ChannelSelector(chman );501 new ChannelSelector(chman, tman, filter); 396 502 397 503 for (var fx in FixedChannels)
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)