Changes between Version 3 and Version 4 of Development/Styles/JavaScript


Ignore:
Timestamp:
Sep 19, 2006 2:04:25 PM (12 years ago)
Author:
clynx
Comment:

add function hideSameTimestamps

Legend:

Unmodified
Added
Removed
Modified
  • Development/Styles/JavaScript

    v3 v4  
    11[[TracNav(Development)]] 
    22''This is part of the [wiki:Development Development Documentation Project], please help document Colloquy if you know anything that would be relevant here for other users to know about.'' 
     3 
     4= HOWTO = 
     5 
     6When you want to use homebrewed functions you need to create at least one HTML file. The genericTemplate.html will be used for every window. The only thing you have to do is to create the file and add your script into the <head> section. 
    37 
    48= !JavaScript Tips and Code Snippets = 
    59 
    610Got a cool !JavaScript tip or snippet? Post it! 
     11 
     12== Display only changed timestamps == 
     13 
     14This function allows you to hide elements by classnames which have the same value. This is the script which is used inside the Frugal Style. 
     15 
     16{{{ 
     17function hideSameTimestamps() { 
     18    function getElementsByClassName( className, tagName, rootNode ) { 
     19        rootNode = rootNode || document; 
     20        tagName = tagName || '*'; 
     21 
     22        var result = []; 
     23        var elements = rootNode.getElementsByTagName( tagName ); 
     24        for( var x = 0; x < elements.length; x++ ) { 
     25            if ( !elements[x].className || elements[x].className != className ) { continue; } 
     26            result.push( elements[x] ); 
     27        } 
     28        return result; 
     29    } 
     30 
     31    var elements = getElementsByClassName( 'envelope', 'div' ); 
     32    var parentTimestamp = getElementsByClassName( 'timestamp', 'span', elements[ elements.length - 2 ] )[0]; 
     33    var currentTimestamp = getElementsByClassName( 'timestamp', 'span', elements[ elements.length - 1 ] )[0]; 
     34 
     35    elements[ elements.length - 1 ].scrollIntoView( true ); 
     36 
     37    if ( parentTimestamp.innerHTML == currentTimestamp.innerHTML ) { 
     38        currentTimestamp.style.visibility = 'hidden'; 
     39    } 
     40} 
     41}}} 
    742 
    843== Orkut-style text fading ==