Changeset 2240

Show
Ignore:
Timestamp:
01/17/05 00:32:43 (4 years ago)
Author:
timothy
Message:

Initial Find panel for transcripts added. Still needs work in areas.
* All criteria work except: buddy list rules and addressed to me rules.
* Found messages are centered in the display. There is no highlight, yet!
* A "find all" needs added also to allow browsing hidden messages (ones no longer in scrollback).
* Event message searching will be added later down the road when backend support is added.
* Retrieving messages was greatly optimized. Further optimizations can happen.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Colloquy.xcode/project.pbxproj

    r2206 r2240  
    1212                                GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 
    1313                                GCC_OPTIMIZATION_LEVEL = 0; 
    14                                 OTHER_CFLAGS = "\U0001-DDEBUG"; 
     14                                OTHER_CFLAGS = "\U0001-DDEBUG -falign-loops=16"; 
    1515                                PREBINDING = NO; 
    1616                                UNSTRIPPED_PRODUCT = YES; 
     
    457457                        targetProxy = 1C09DFF6052DFF6600D748CF; 
    458458                }; 
     459                1C0A4C980799BDAF0093B702 = { 
     460                        children = ( 
     461                                1C0A4C990799BDAF0093B702, 
     462                        ); 
     463                        isa = PBXVariantGroup; 
     464                        name = JVFind.nib; 
     465                        path = ""; 
     466                        refType = 4; 
     467                        sourceTree = "<group>"; 
     468                }; 
     469                1C0A4C990799BDAF0093B702 = { 
     470                        isa = PBXFileReference; 
     471                        lastKnownFileType = wrapper.nib; 
     472                        name = English; 
     473                        path = Languages/English.lproj/JVFind.nib; 
     474                        refType = 4; 
     475                        sourceTree = "<group>"; 
     476                }; 
     477                1C0A4C9A0799BDAF0093B702 = { 
     478                        children = ( 
     479                                1C0A4C9B0799BDB00093B702, 
     480                        ); 
     481                        isa = PBXVariantGroup; 
     482                        name = JVTranscriptCriterion.nib; 
     483                        path = ""; 
     484                        refType = 4; 
     485                        sourceTree = "<group>"; 
     486                }; 
     487                1C0A4C9B0799BDB00093B702 = { 
     488                        isa = PBXFileReference; 
     489                        lastKnownFileType = wrapper.nib; 
     490                        name = English; 
     491                        path = Languages/English.lproj/JVTranscriptCriterion.nib; 
     492                        refType = 4; 
     493                        sourceTree = "<group>"; 
     494                }; 
     495                1C0A4C9C0799BDB00093B702 = { 
     496                        fileRef = 1C0A4C980799BDAF0093B702; 
     497                        isa = PBXBuildFile; 
     498                        settings = { 
     499                        }; 
     500                }; 
     501                1C0A4C9D0799BDB00093B702 = { 
     502                        fileRef = 1C0A4C9A0799BDAF0093B702; 
     503                        isa = PBXBuildFile; 
     504                        settings = { 
     505                        }; 
     506                }; 
     507                1C0A4CA50799BDD00093B702 = { 
     508                        fileEncoding = 4; 
     509                        isa = PBXFileReference; 
     510                        lastKnownFileType = sourcecode.c.h; 
     511                        path = JVTabbedChatWindowController.h; 
     512                        refType = 4; 
     513                        sourceTree = "<group>"; 
     514                }; 
     515                1C0A4CA70799BDD00093B702 = { 
     516                        fileEncoding = 4; 
     517                        isa = PBXFileReference; 
     518                        lastKnownFileType = sourcecode.c.h; 
     519                        path = JVTranscriptCriterionController.h; 
     520                        refType = 4; 
     521                        sourceTree = "<group>"; 
     522                }; 
     523                1C0A4CA80799BDD00093B702 = { 
     524                        fileEncoding = 4; 
     525                        isa = PBXFileReference; 
     526                        lastKnownFileType = sourcecode.c.objc; 
     527                        path = JVTranscriptCriterionController.m; 
     528                        refType = 4; 
     529                        sourceTree = "<group>"; 
     530                }; 
     531                1C0A4CAC0799BDD00093B702 = { 
     532                        fileRef = 1C0A4CA80799BDD00093B702; 
     533                        isa = PBXBuildFile; 
     534                        settings = { 
     535                        }; 
     536                }; 
     537                1C0A4CB90799BE000093B702 = { 
     538                        fileEncoding = 4; 
     539                        isa = PBXFileReference; 
     540                        lastKnownFileType = sourcecode.c.objc; 
     541                        path = JVTabbedChatWindowController.m; 
     542                        refType = 4; 
     543                        sourceTree = "<group>"; 
     544                }; 
     545                1C0A4CBA0799BE000093B702 = { 
     546                        fileRef = 1C0A4CB90799BE000093B702; 
     547                        isa = PBXBuildFile; 
     548                        settings = { 
     549                        }; 
     550                }; 
     551                1C0A4CC50799BE110093B702 = { 
     552                        fileEncoding = 4; 
     553                        isa = PBXFileReference; 
     554                        lastKnownFileType = sourcecode.c.h; 
     555                        path = JVTranscriptFindWindowController.h; 
     556                        refType = 4; 
     557                        sourceTree = "<group>"; 
     558                }; 
     559                1C0A4CE40799BE660093B702 = { 
     560                        fileEncoding = 4; 
     561                        isa = PBXFileReference; 
     562                        lastKnownFileType = sourcecode.c.objc; 
     563                        path = JVTranscriptFindWindowController.m; 
     564                        refType = 4; 
     565                        sourceTree = "<group>"; 
     566                }; 
     567                1C0A4CE50799BE660093B702 = { 
     568                        fileRef = 1C0A4CE40799BE660093B702; 
     569                        isa = PBXBuildFile; 
     570                        settings = { 
     571                        }; 
     572                }; 
     573                1C0A4CF40799BEA70093B702 = { 
     574                        fileEncoding = 4; 
     575                        isa = PBXFileReference; 
     576                        lastKnownFileType = sourcecode.c.h; 
     577                        path = JVViewCell.h; 
     578                        refType = 4; 
     579                        sourceTree = "<group>"; 
     580                }; 
     581                1C0A4CF50799BEA70093B702 = { 
     582                        fileEncoding = 4; 
     583                        isa = PBXFileReference; 
     584                        lastKnownFileType = sourcecode.c.objc; 
     585                        path = JVViewCell.m; 
     586                        refType = 4; 
     587                        sourceTree = "<group>"; 
     588                }; 
     589                1C0A4CF70799BEA70093B702 = { 
     590                        fileRef = 1C0A4CF50799BEA70093B702; 
     591                        isa = PBXBuildFile; 
     592                        settings = { 
     593                        }; 
     594                }; 
    459595                1C16362607021F240020D94D = { 
    460596                        isa = PBXFileReference; 
     
    13571493                1C7EF5C306B346E50037F173 = { 
    13581494                        fileRef = 1C7EF5C106B346E50037F173; 
    1359                         isa = PBXBuildFile; 
    1360                         settings = { 
    1361                         }; 
    1362                 }; 
    1363                 1C889DEA0677AC7F00D98F3C = { 
    1364                         fileEncoding = 4; 
    1365                         isa = PBXFileReference; 
    1366                         lastKnownFileType = sourcecode.c.h; 
    1367                         path = JVTabbedChatWindowController.h; 
    1368                         refType = 4; 
    1369                         sourceTree = "<group>"; 
    1370                 }; 
    1371                 1C889DEB0677AC7F00D98F3C = { 
    1372                         fileEncoding = 4; 
    1373                         isa = PBXFileReference; 
    1374                         lastKnownFileType = sourcecode.c.objc; 
    1375                         path = JVTabbedChatWindowController.m; 
    1376                         refType = 4; 
    1377                         sourceTree = "<group>"; 
    1378                 }; 
    1379                 1C889DED0677AC7F00D98F3C = { 
    1380                         fileRef = 1C889DEB0677AC7F00D98F3C; 
    13811495                        isa = PBXBuildFile; 
    13821496                        settings = { 
     
    20692183                                1CF627CB07558F79005DFCFA, 
    20702184                                1CD4C099078249C10003620F, 
     2185                                1C0A4C9C0799BDB00093B702, 
     2186                                1C0A4C9D0799BDB00093B702, 
    20712187                        ); 
    20722188                        isa = PBXResourcesBuildPhase; 
     
    25362652                                1C0730D406777678008D8AD9, 
    25372653                                1C0730E50677A63B008D8AD9, 
    2538                                 1C889DED0677AC7F00D98F3C, 
    25392654                                1C2391AA0677E6B7000E89A7, 
    25402655                                1C96E93F06AADBBD0013B0A9, 
     
    25422657                                1C4671E606D7759100071DC6, 
    25432658                                1CF803F1070C948000C9B54C, 
     2659                                1C0A4CAC0799BDD00093B702, 
     2660                                1C0A4CBA0799BE000093B702, 
     2661                                1C0A4CE50799BE660093B702, 
     2662                                1C0A4CF70799BEA70093B702, 
    25442663                        ); 
    25452664                        isa = PBXSourcesBuildPhase; 
     
    44254544                                1CE2BC1E042F4AD300000102, 
    44264545                                1CE2BC1D042F4AD300000102, 
    4427                                 1C889DEB0677AC7F00D98F3C, 
    4428                                 1C889DEA0677AC7F00D98F3C, 
     4546                                1C0A4CB90799BE000093B702, 
     4547                                1C0A4CA50799BDD00093B702, 
     4548                                1C0A4CE40799BE660093B702, 
     4549                                1C0A4CC50799BE110093B702, 
     4550                                1C0A4CA80799BDD00093B702, 
     4551                                1C0A4CA70799BDD00093B702, 
    44294552                                F5C497750385713801000102, 
    44304553                                F5C497740385713801000102, 
     
    45934716                                1C06077A064A5DE8002438AF, 
    45944717                                1C060779064A5DE8002438AF, 
     4718                                1C0A4CF50799BEA70093B702, 
     4719                                1C0A4CF40799BEA70093B702, 
    45954720                                1CC6FD63054B70BC0075807C, 
    45964721                                1CC6FD62054B70BC0075807C, 
     
    46814806                                1CBECE3A0508D58F000001C8, 
    46824807                                1CBECE380508D58F000001C8, 
     4808                                1C0A4C980799BDAF0093B702, 
     4809                                1C0A4C9A0799BDAF0093B702, 
    46834810                                1C1AD009053487ED00F71D4E, 
    46844811                                1CB4DCA9053627C00080D36F, 
     
    48434970                                GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 
    48444971                                GCC_OPTIMIZATION_LEVEL = s; 
     4972                                OTHER_CFLAGS = "-falign-loops=16"; 
    48454973                                PREBINDING = YES; 
    48464974                                UNSTRIPPED_PRODUCT = YES; 
  • trunk/JVChatMessage.h

    r2166 r2240  
    1515        NSDate *_date; 
    1616        JVIgnoreMatchResult _ignoreStatus; 
     17        BOOL _senderIsLocalUser; 
    1718        BOOL _action; 
    1819        BOOL _highlighted; 
     
    2627- (NSDate *) date; 
    2728- (id) sender; 
     29- (BOOL) senderIsLocalUser; 
    2830 
    2931- (NSTextStorage *) body; 
  • trunk/JVChatMessage.m

    r2172 r2240  
    6161                        if( senderStr ) _sender = [NSString stringWithUTF8String:senderStr]; 
    6262                        xmlFree( senderStr ); 
     63 
     64                        xmlChar *selfStr = xmlGetProp( subNode, "self" ); 
     65                        if( selfStr && ! strcmp( selfStr, "yes" ) ) _senderIsLocalUser = YES; 
     66                        else _senderIsLocalUser = NO; 
     67                        xmlFree( selfStr ); 
    6368 
    6469/*                      if( _sender && [[self transcript] isKindOfClass:[JVChatRoom class]] ) { 
     
    8994                _action = NO; 
    9095                _highlighted = NO; 
     96                _senderIsLocalUser = NO; 
    9197                _ignoreStatus = JVNotIgnored; 
    9298        } 
     
    159165        [self load]; 
    160166        return _sender; 
     167} 
     168 
     169- (BOOL) senderIsLocalUser { 
     170        [self load]; 
     171        return _senderIsLocalUser; 
    161172} 
    162173 
  • trunk/JVChatTranscript.h

    r1832 r2240  
    5656 
    5757- (unsigned long) numberOfMessages; 
     58- (NSArray *) messages; 
    5859- (JVChatMessage *) messageAtIndex:(unsigned long) index; 
    5960- (NSArray *) messagesInRange:(NSRange) range; 
     61- (BOOL) messageIsInScrollback:(JVChatMessage *) message; 
     62 
     63- (void) jumpToMessage:(JVChatMessage *) message; 
    6064 
    6165- (IBAction) close:(id) sender; 
  • trunk/JVChatTranscript.m

    r2232 r2240  
    88 
    99#import "MVApplicationController.h" 
     10#import "JVTranscriptFindWindowController.h" 
    1011#import "JVChatController.h" 
    1112#import "JVStyle.h" 
     
    3334static NSString *JVToolbarChooseStyleItemIdentifier = @"JVToolbarChooseStyleItem"; 
    3435static NSString *JVToolbarEmoticonsItemIdentifier = @"JVToolbarEmoticonsItem"; 
     36static NSString *JVToolbarFindItemIdentifier = @"JVToolbarFindItem"; 
    3537 
    3638static unsigned long xmlChildElementCount( xmlNodePtr node ) { 
     
    8587- (BOOL) _usingSpecificStyle; 
    8688- (BOOL) _usingSpecificEmoticons; 
     89 
     90- (int) visibleMessageCount; 
     91- (int) locationOfMessage:(unsigned int) identifier; 
     92- (int) locationOfElementByIndex:(unsigned int) index; 
    8793@end 
    8894 
     
    502508 
    503509#pragma mark - 
    504 #pragma mark Message Numbering 
     510#pragma mark Message Level Access 
    505511 
    506512- (unsigned long) numberOfMessages { 
     
    520526 
    521527- (NSArray *) messages { 
    522         if( [_messages containsObject:[NSNull null]] || [_messages count] < [self numberOfMessages] ) 
    523                 [self messagesInRange:NSMakeRange( 0, [self numberOfMessages] )]; 
    524         return _messages; 
     528        return [self messagesInRange:NSMakeRange( 0, -1 )]; // will stop at the total number of messages 
    525529} 
    526530 
    527531- (JVChatMessage *) messageAtIndex:(unsigned long) index { 
     532        if( [_messages count] > index ) { 
     533                id obj = [_messages objectAtIndex:index]; 
     534                if( ! [obj isKindOfClass:[NSNull class]] ) return obj; 
     535        } 
     536 
    528537        NSArray *msgs = [self messagesInRange:NSMakeRange( index, 1 )]; 
    529538        if( [msgs count] ) return [msgs objectAtIndex:0]; 
     
    532541 
    533542- (NSArray *) messagesInRange:(NSRange) range { 
     543        if( ! range.length ) return [NSArray array]; 
     544 
     545        if( ( range.location + range.length ) > range.location && [_messages count] >= ( range.location + range.length ) ) { 
     546                NSArray *sub = [_messages subarrayWithRange:range]; 
     547                if( ! [sub containsObject:[NSNull null]] ) return sub; 
     548        } 
     549 
    534550        xmlXPathContextPtr ctx = xmlXPathNewContext( _xmlLog ); 
    535551        if( ! ctx ) return nil; 
    536          
     552 
    537553 /* We need to discover all messages which are children of envelope, within the specified range.  
    538554        We don't have a counter attribute to work with, and the Xpath position() doesn't help us - we need  
     
    540556        Note that the nodeset is unsorted by default. */ 
    541557 
    542         xmlXPathObjectPtr result = xmlXPathEval("/log/envelope/message", ctx ); 
    543         if( ! result || ! result -> nodesetval ) 
     558        xmlXPathObjectPtr result = xmlXPathEval( "/log/envelope/message", ctx ); 
     559        if( ! result || ! result -> nodesetval ) { 
     560                xmlXPathFreeContext( ctx ); 
    544561                return nil; 
    545  
    546         xmlXPathNodeSetSort( result -> nodesetval ); // now sort the resultant nodeset in document order 
     562        } 
    547563 
    548564        unsigned int i = 0; 
     565        unsigned int size = result -> nodesetval -> nodeNr; 
     566 
     567        if( [_messages count] == size && ! [_messages containsObject:[NSNull null]] ) { 
     568                xmlXPathFreeContext( ctx ); 
     569                xmlXPathFreeObject( result ); 
     570                return [NSArray arrayWithArray:_messages]; 
     571        } 
    549572 
    550573        if( [_messages count] < range.location ) 
     
    552575                        [_messages insertObject:[NSNull null] atIndex:i]; 
    553576 
     577        xmlXPathNodeSetSort( result -> nodesetval ); // now sort the resultant nodeset in document order 
     578 
     579        unsigned int stop = MIN( ( ( range.location + range.length ) < range.location ? (unsigned) -1 : ( range.location + range.length ) ), size ); 
     580        NSMutableArray *ret = [NSMutableArray arrayWithCapacity:( stop - range.location )]; 
     581        JVChatMessage *msg = nil; 
    554582        xmlNodePtr node = NULL; 
    555         unsigned int size = result -> nodesetval -> nodeNr; 
    556         NSMutableArray *ret = [NSMutableArray arrayWithCapacity:size]; 
    557         JVChatMessage *msg = nil; 
    558  
    559         for( i = range.location; i < ( range.location + range.length ); i++ ) { 
    560                 node = result -> nodesetval -> nodeTab[i]; 
    561                 if( ! node ) continue; 
    562                 if( [_messages count] > (i) && [[_messages objectAtIndex:(i)] isKindOfClass:[NSNull class]] ) { 
     583 
     584        // note: the range is allowed to be longer than the number of messages, we will stop at whatever comes sooner 
     585        for( i = range.location; i < stop; i++ ) { 
     586                if( ! ( node = result -> nodesetval -> nodeTab[i] ) ) continue; 
     587                if( [_messages count] > i && [[_messages objectAtIndex:i] isKindOfClass:[JVChatMessage class]] ) { 
     588                        msg = [_messages objectAtIndex:i]; 
     589                } else if( [_messages count] > i && [[_messages objectAtIndex:i] isKindOfClass:[NSNull class]] ) { 
    563590                        msg = [JVChatMessage messageWithNode:node messageIndex:i andTranscript:self]; 
    564                         [_messages replaceObjectAtIndex:(i) withObject:msg]; 
    565                 } else if( [_messages count] > (i) && [[_messages objectAtIndex:(i)] isKindOfClass:[JVChatMessage class]] ) { 
    566                         msg = [_messages objectAtIndex:(i)]; 
    567                 } else if( [_messages count] == (i) ) { 
     591                        [_messages replaceObjectAtIndex:i withObject:msg]; 
     592                } else if( [_messages count] == i ) { 
    568593                        msg = [JVChatMessage messageWithNode:node messageIndex:i andTranscript:self]; 
    569                         [_messages insertObject:msg atIndex:(i)]; 
     594                        [_messages insertObject:msg atIndex:i]; 
    570595                } else continue; 
    571596                if( msg ) [ret addObject:msg]; 
     
    574599        xmlXPathFreeContext( ctx ); 
    575600        xmlXPathFreeObject( result ); 
    576         return ret; 
     601        return [NSArray arrayWithArray:ret]; 
     602
     603 
     604- (BOOL) messageIsInScrollback:(JVChatMessage *) message { 
     605#ifdef WebKitVersion146 
     606        if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
     607                DOMElement *element = [[[display mainFrame] DOMDocument] getElementById:[NSString stringWithFormat:@"%u", [message envelopeNumber]]]; 
     608                return ( element ? YES : NO ); 
     609        } else 
     610#endif 
     611        // old JavaScript method 
     612        return (BOOL) [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"messageIsInScrollback( \"%u\" );", [message envelopeNumber]]] intValue]; 
    577613} 
    578614 
     
    593629        if( [identifier isEqualToString:JVToolbarToggleChatDrawerItemIdentifier] ) { 
    594630                toolbarItem = [_windowController toggleChatDrawerToolbarItem]; 
     631        } else if( [identifier isEqualToString:JVToolbarFindItemIdentifier] ) { 
     632                [toolbarItem setLabel:NSLocalizedString( @"Find", "find toolbar item label" )]; 
     633                [toolbarItem setPaletteLabel:NSLocalizedString( @"Find", "find toolbar item patlette label" )]; 
     634                [toolbarItem setToolTip:NSLocalizedString( @"Show Find Panel", "find toolbar item tooltip" )]; 
     635                [toolbarItem setImage:[NSImage imageNamed:@"reveal"]]; 
     636                [toolbarItem setTarget:[JVTranscriptFindWindowController sharedController]]; 
     637                [toolbarItem setAction:@selector( showWindow: )]; 
    595638        } else if( [identifier isEqualToString:JVToolbarChooseStyleItemIdentifier] && ! willBeInserted ) { 
    596639                [toolbarItem setLabel:NSLocalizedString( @"Style", "choose style toolbar item label" )]; 
     
    659702- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar { 
    660703        NSArray *list = [NSArray arrayWithObjects: JVToolbarToggleChatDrawerItemIdentifier,  
    661                 JVToolbarChooseStyleItemIdentifier, JVToolbarEmoticonsItemIdentifier, NSToolbarShowColorsItemIdentifier, 
     704                JVToolbarChooseStyleItemIdentifier, JVToolbarEmoticonsItemIdentifier, JVToolbarFindItemIdentifier, NSToolbarShowColorsItemIdentifier, 
    662705                NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,  
    663706                NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil]; 
     
    673716 
    674717#pragma mark - 
    675 #pragma mark Highlight Jumping 
     718#pragma mark Highlight/Message Jumping 
    676719 
    677720- (IBAction) jumpToPreviousHighlight:(id) sender { 
     
    685728        if( [scroller isMemberOfClass:[JVMarkedScroller class]] ) 
    686729                [scroller jumpToNextMark:sender]; 
     730} 
     731 
     732- (void) jumpToMessage:(JVChatMessage *) message { 
     733        unsigned int loc = [self locationOfMessage:[message envelopeNumber]]; 
     734        if( loc ) { 
     735                NSScroller *scroller = [[[[[display mainFrame] frameView] documentView] enclosingScrollView] verticalScroller]; 
     736                float scale = NSHeight( [scroller rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [scroller frame] ) / [scroller knobProportion] ); 
     737                float shift = ( ( NSHeight( [scroller rectForPart:NSScrollerKnobSlot] ) * [scroller knobProportion] ) / 2. ) / scale; 
     738                [[(NSScrollView *)[scroller superview] documentView] scrollPoint:NSMakePoint( 0., loc - shift )]; 
     739        } 
    687740} 
    688741 
     
    12691322        return [NSString stringWithFormat:shell, [self title], [self _chatEmoticonsCSSFileURL], [[_chatStyle mainStyleSheetLocation] absoluteString], [[_chatStyle variantStyleSheetLocationWithName:_chatStyleVariant] absoluteString], [[_chatStyle baseLocation] absoluteString], [_chatStyle contentsOfHeaderFile], html]; 
    12701323} 
     1324 
     1325#pragma mark - 
     1326 
     1327- (int) locationOfMessage:(unsigned int) identifier { 
     1328#ifdef WebKitVersion146 
     1329        if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
     1330                DOMElement *element = [[[display mainFrame] DOMDocument] getElementById:[NSString stringWithFormat:@"%d", identifier]]; 
     1331                return [[element valueForKey:@"offsetTop"] intValue]; 
     1332        } else 
     1333#endif 
     1334        // old JavaScript method 
     1335        return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfMessage( \"%d\" );", identifier]] intValue]; 
     1336} 
     1337 
     1338- (int) locationOfElementByIndex:(unsigned int) index { 
     1339#ifdef WebKitVersion146 
     1340        if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
     1341                DOMHTMLElement *body = [(DOMHTMLDocument *)[[display mainFrame] DOMDocument] body]; 
     1342                if( index < [[body children] length] ) return [[[[body children] item:index] valueForKey:@"offsetTop"] intValue]; 
     1343                else return 0; 
     1344        } else 
     1345#endif 
     1346        // old JavaScript method 
     1347        return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfElementByIndex( %d );", index]] intValue]; 
     1348} 
     1349 
     1350- (int) visibleMessageCount { 
     1351#ifdef WebKitVersion146 
     1352        if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
     1353                return [[[(DOMHTMLDocument *)[[display mainFrame] DOMDocument] body] children] length]; 
     1354        } else 
     1355#endif 
     1356        // old JavaScript method 
     1357        return [[display stringByEvaluatingJavaScriptFromString:@"scrollBackMessageCount();"] intValue]; 
     1358} 
    12711359@end 
    12721360 
  • trunk/JVDirectChat.m

    r2238 r2240  
    103103- (void) addEventMessageToLogAndDisplay:(NSString *) message withName:(NSString *) name andAttributes:(NSDictionary *) attributes entityEncodeAttributes:(BOOL) encode; 
    104104- (void) addMessageToLogAndDisplay:(NSData *) message fromUser:(MVChatUser *) user asAction:(BOOL) action; 
    105 - (int) visibleMessageCount; 
    106 - (int) locationOfMessage:(unsigned int) identifier; 
    107 - (int) locationOfElementByIndex:(unsigned int) index; 
    108105- (void) scrollToBottom; 
    109106- (void) appendMessage:(NSString *) html subsequent:(BOOL) subsequent; 
     
    130127- (void) _changeChatEmoticonsMenuSelection; 
    131128- (void) _switchingStyleEnded:(in NSString *) html; 
     129- (int) visibleMessageCount; 
     130- (int) locationOfMessage:(unsigned int) identifier; 
     131- (int) locationOfElementByIndex:(unsigned int) index; 
    132132@end 
    133133 
     
    15171517} 
    15181518 
    1519 - (int) locationOfMessage:(unsigned int) identifier { 
    1520 #ifdef WebKitVersion146 
    1521         if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
    1522                 DOMElement *element = [[[display mainFrame] DOMDocument] getElementById:[NSString stringWithFormat:@"%d", identifier]]; 
    1523                 return [[element valueForKey:@"offsetTop"] intValue]; 
    1524         } else 
    1525 #endif 
    1526         // old JavaScript method 
    1527         return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfMessage( \"%d\" );", identifier]] intValue]; 
    1528 } 
    1529  
    1530 - (int) locationOfElementByIndex:(unsigned int) index { 
    1531 #ifdef WebKitVersion146 
    1532         if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
    1533                 DOMHTMLElement *body = [(DOMHTMLDocument *)[[display mainFrame] DOMDocument] body]; 
    1534                 if( index < [[body children] length] ) return [[[[body children] item:index] valueForKey:@"offsetTop"] intValue]; 
    1535                 else return 0; 
    1536         } else 
    1537 #endif 
    1538         // old JavaScript method 
    1539         return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfElementByIndex( %d );", index]] intValue]; 
    1540 } 
    1541  
    1542 - (int) visibleMessageCount { 
    1543 #ifdef WebKitVersion146 
    1544         if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) { 
    1545                 return [[[(DOMHTMLDocument *)[[display mainFrame] DOMDocument] body] children] length]; 
    1546         } else 
    1547 #endif 
    1548         // old JavaScript method 
    1549         return [[display stringByEvaluatingJavaScriptFromString:@"scrollBackMessageCount();"] intValue]; 
    1550 } 
    1551  
    15521519- (void) scrollToBottom { 
    15531520#ifdef WebKitVersion146 
  • trunk/Resources/template.html

    r2108 r2240  
    7373                } 
    7474 
     75                function messageIsInScrollback( id ) { 
     76                        return ( document.getElementById( id ).id.length ? 1 : 0 ); 
     77                } 
     78 
    7579                function locationOfMessage( id ) { 
    7680                        element = document.getElementById( id );