Changeset 2240
- Timestamp:
- 01/17/05 00:32:43 (4 years ago)
- Files:
-
- trunk/Colloquy.xcode/project.pbxproj (modified) (10 diffs)
- trunk/JVChatMessage.h (modified) (2 diffs)
- trunk/JVChatMessage.m (modified) (3 diffs)
- trunk/JVChatTranscript.h (modified) (1 diff)
- trunk/JVChatTranscript.m (modified) (14 diffs)
- trunk/JVDirectChat.m (modified) (3 diffs)
- trunk/JVTranscriptCriterionController.h (added)
- trunk/JVTranscriptCriterionController.m (added)
- trunk/JVTranscriptFindWindowController.h (added)
- trunk/JVTranscriptFindWindowController.m (added)
- trunk/JVViewCell.h (added)
- trunk/JVViewCell.m (added)
- trunk/Languages/English.lproj/JVFind.nib (added)
- trunk/Languages/English.lproj/JVFind.nib/classes.nib (added)
- trunk/Languages/English.lproj/JVFind.nib/info.nib (added)
- trunk/Languages/English.lproj/JVFind.nib/keyedobjects.nib (added)
- trunk/Languages/English.lproj/JVTranscriptCriterion.nib (added)
- trunk/Languages/English.lproj/JVTranscriptCriterion.nib/classes.nib (added)
- trunk/Languages/English.lproj/JVTranscriptCriterion.nib/info.nib (added)
- trunk/Languages/English.lproj/JVTranscriptCriterion.nib/keyedobjects.nib (added)
- trunk/Resources/template.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Colloquy.xcode/project.pbxproj
r2206 r2240 12 12 GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 13 13 GCC_OPTIMIZATION_LEVEL = 0; 14 OTHER_CFLAGS = "\U0001-DDEBUG ";14 OTHER_CFLAGS = "\U0001-DDEBUG -falign-loops=16"; 15 15 PREBINDING = NO; 16 16 UNSTRIPPED_PRODUCT = YES; … … 457 457 targetProxy = 1C09DFF6052DFF6600D748CF; 458 458 }; 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 }; 459 595 1C16362607021F240020D94D = { 460 596 isa = PBXFileReference; … … 1357 1493 1C7EF5C306B346E50037F173 = { 1358 1494 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;1381 1495 isa = PBXBuildFile; 1382 1496 settings = { … … 2069 2183 1CF627CB07558F79005DFCFA, 2070 2184 1CD4C099078249C10003620F, 2185 1C0A4C9C0799BDB00093B702, 2186 1C0A4C9D0799BDB00093B702, 2071 2187 ); 2072 2188 isa = PBXResourcesBuildPhase; … … 2536 2652 1C0730D406777678008D8AD9, 2537 2653 1C0730E50677A63B008D8AD9, 2538 1C889DED0677AC7F00D98F3C,2539 2654 1C2391AA0677E6B7000E89A7, 2540 2655 1C96E93F06AADBBD0013B0A9, … … 2542 2657 1C4671E606D7759100071DC6, 2543 2658 1CF803F1070C948000C9B54C, 2659 1C0A4CAC0799BDD00093B702, 2660 1C0A4CBA0799BE000093B702, 2661 1C0A4CE50799BE660093B702, 2662 1C0A4CF70799BEA70093B702, 2544 2663 ); 2545 2664 isa = PBXSourcesBuildPhase; … … 4425 4544 1CE2BC1E042F4AD300000102, 4426 4545 1CE2BC1D042F4AD300000102, 4427 1C889DEB0677AC7F00D98F3C, 4428 1C889DEA0677AC7F00D98F3C, 4546 1C0A4CB90799BE000093B702, 4547 1C0A4CA50799BDD00093B702, 4548 1C0A4CE40799BE660093B702, 4549 1C0A4CC50799BE110093B702, 4550 1C0A4CA80799BDD00093B702, 4551 1C0A4CA70799BDD00093B702, 4429 4552 F5C497750385713801000102, 4430 4553 F5C497740385713801000102, … … 4593 4716 1C06077A064A5DE8002438AF, 4594 4717 1C060779064A5DE8002438AF, 4718 1C0A4CF50799BEA70093B702, 4719 1C0A4CF40799BEA70093B702, 4595 4720 1CC6FD63054B70BC0075807C, 4596 4721 1CC6FD62054B70BC0075807C, … … 4681 4806 1CBECE3A0508D58F000001C8, 4682 4807 1CBECE380508D58F000001C8, 4808 1C0A4C980799BDAF0093B702, 4809 1C0A4C9A0799BDAF0093B702, 4683 4810 1C1AD009053487ED00F71D4E, 4684 4811 1CB4DCA9053627C00080D36F, … … 4843 4970 GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 4844 4971 GCC_OPTIMIZATION_LEVEL = s; 4972 OTHER_CFLAGS = "-falign-loops=16"; 4845 4973 PREBINDING = YES; 4846 4974 UNSTRIPPED_PRODUCT = YES; trunk/JVChatMessage.h
r2166 r2240 15 15 NSDate *_date; 16 16 JVIgnoreMatchResult _ignoreStatus; 17 BOOL _senderIsLocalUser; 17 18 BOOL _action; 18 19 BOOL _highlighted; … … 26 27 - (NSDate *) date; 27 28 - (id) sender; 29 - (BOOL) senderIsLocalUser; 28 30 29 31 - (NSTextStorage *) body; trunk/JVChatMessage.m
r2172 r2240 61 61 if( senderStr ) _sender = [NSString stringWithUTF8String:senderStr]; 62 62 xmlFree( senderStr ); 63 64 xmlChar *selfStr = xmlGetProp( subNode, "self" ); 65 if( selfStr && ! strcmp( selfStr, "yes" ) ) _senderIsLocalUser = YES; 66 else _senderIsLocalUser = NO; 67 xmlFree( selfStr ); 63 68 64 69 /* if( _sender && [[self transcript] isKindOfClass:[JVChatRoom class]] ) { … … 89 94 _action = NO; 90 95 _highlighted = NO; 96 _senderIsLocalUser = NO; 91 97 _ignoreStatus = JVNotIgnored; 92 98 } … … 159 165 [self load]; 160 166 return _sender; 167 } 168 169 - (BOOL) senderIsLocalUser { 170 [self load]; 171 return _senderIsLocalUser; 161 172 } 162 173 trunk/JVChatTranscript.h
r1832 r2240 56 56 57 57 - (unsigned long) numberOfMessages; 58 - (NSArray *) messages; 58 59 - (JVChatMessage *) messageAtIndex:(unsigned long) index; 59 60 - (NSArray *) messagesInRange:(NSRange) range; 61 - (BOOL) messageIsInScrollback:(JVChatMessage *) message; 62 63 - (void) jumpToMessage:(JVChatMessage *) message; 60 64 61 65 - (IBAction) close:(id) sender; trunk/JVChatTranscript.m
r2232 r2240 8 8 9 9 #import "MVApplicationController.h" 10 #import "JVTranscriptFindWindowController.h" 10 11 #import "JVChatController.h" 11 12 #import "JVStyle.h" … … 33 34 static NSString *JVToolbarChooseStyleItemIdentifier = @"JVToolbarChooseStyleItem"; 34 35 static NSString *JVToolbarEmoticonsItemIdentifier = @"JVToolbarEmoticonsItem"; 36 static NSString *JVToolbarFindItemIdentifier = @"JVToolbarFindItem"; 35 37 36 38 static unsigned long xmlChildElementCount( xmlNodePtr node ) { … … 85 87 - (BOOL) _usingSpecificStyle; 86 88 - (BOOL) _usingSpecificEmoticons; 89 90 - (int) visibleMessageCount; 91 - (int) locationOfMessage:(unsigned int) identifier; 92 - (int) locationOfElementByIndex:(unsigned int) index; 87 93 @end 88 94 … … 502 508 503 509 #pragma mark - 504 #pragma mark Message Numbering510 #pragma mark Message Level Access 505 511 506 512 - (unsigned long) numberOfMessages { … … 520 526 521 527 - (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 525 529 } 526 530 527 531 - (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 528 537 NSArray *msgs = [self messagesInRange:NSMakeRange( index, 1 )]; 529 538 if( [msgs count] ) return [msgs objectAtIndex:0]; … … 532 541 533 542 - (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 534 550 xmlXPathContextPtr ctx = xmlXPathNewContext( _xmlLog ); 535 551 if( ! ctx ) return nil; 536 552 537 553 /* We need to discover all messages which are children of envelope, within the specified range. 538 554 We don't have a counter attribute to work with, and the Xpath position() doesn't help us - we need … … 540 556 Note that the nodeset is unsorted by default. */ 541 557 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 ); 544 561 return nil; 545 546 xmlXPathNodeSetSort( result -> nodesetval ); // now sort the resultant nodeset in document order 562 } 547 563 548 564 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 } 549 572 550 573 if( [_messages count] < range.location ) … … 552 575 [_messages insertObject:[NSNull null] atIndex:i]; 553 576 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; 554 582 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]] ) { 563 590 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 ) { 568 593 msg = [JVChatMessage messageWithNode:node messageIndex:i andTranscript:self]; 569 [_messages insertObject:msg atIndex: (i)];594 [_messages insertObject:msg atIndex:i]; 570 595 } else continue; 571 596 if( msg ) [ret addObject:msg]; … … 574 599 xmlXPathFreeContext( ctx ); 575 600 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]; 577 613 } 578 614 … … 593 629 if( [identifier isEqualToString:JVToolbarToggleChatDrawerItemIdentifier] ) { 594 630 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: )]; 595 638 } else if( [identifier isEqualToString:JVToolbarChooseStyleItemIdentifier] && ! willBeInserted ) { 596 639 [toolbarItem setLabel:NSLocalizedString( @"Style", "choose style toolbar item label" )]; … … 659 702 - (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar { 660 703 NSArray *list = [NSArray arrayWithObjects: JVToolbarToggleChatDrawerItemIdentifier, 661 JVToolbarChooseStyleItemIdentifier, JVToolbarEmoticonsItemIdentifier, NSToolbarShowColorsItemIdentifier,704 JVToolbarChooseStyleItemIdentifier, JVToolbarEmoticonsItemIdentifier, JVToolbarFindItemIdentifier, NSToolbarShowColorsItemIdentifier, 662 705 NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier, 663 706 NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil]; … … 673 716 674 717 #pragma mark - 675 #pragma mark Highlight Jumping718 #pragma mark Highlight/Message Jumping 676 719 677 720 - (IBAction) jumpToPreviousHighlight:(id) sender { … … 685 728 if( [scroller isMemberOfClass:[JVMarkedScroller class]] ) 686 729 [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 } 687 740 } 688 741 … … 1269 1322 return [NSString stringWithFormat:shell, [self title], [self _chatEmoticonsCSSFileURL], [[_chatStyle mainStyleSheetLocation] absoluteString], [[_chatStyle variantStyleSheetLocationWithName:_chatStyleVariant] absoluteString], [[_chatStyle baseLocation] absoluteString], [_chatStyle contentsOfHeaderFile], html]; 1270 1323 } 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 } 1271 1359 @end 1272 1360 trunk/JVDirectChat.m
r2238 r2240 103 103 - (void) addEventMessageToLogAndDisplay:(NSString *) message withName:(NSString *) name andAttributes:(NSDictionary *) attributes entityEncodeAttributes:(BOOL) encode; 104 104 - (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;108 105 - (void) scrollToBottom; 109 106 - (void) appendMessage:(NSString *) html subsequent:(BOOL) subsequent; … … 130 127 - (void) _changeChatEmoticonsMenuSelection; 131 128 - (void) _switchingStyleEnded:(in NSString *) html; 129 - (int) visibleMessageCount; 130 - (int) locationOfMessage:(unsigned int) identifier; 131 - (int) locationOfElementByIndex:(unsigned int) index; 132 132 @end 133 133 … … 1517 1517 } 1518 1518 1519 - (int) locationOfMessage:(unsigned int) identifier {1520 #ifdef WebKitVersion1461521 if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) {1522 DOMElement *element = [[[display mainFrame] DOMDocument] getElementById:[NSString stringWithFormat:@"%d", identifier]];1523 return [[element valueForKey:@"offsetTop"] intValue];1524 } else1525 #endif1526 // old JavaScript method1527 return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfMessage( \"%d\" );", identifier]] intValue];1528 }1529 1530 - (int) locationOfElementByIndex:(unsigned int) index {1531 #ifdef WebKitVersion1461532 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 } else1537 #endif1538 // old JavaScript method1539 return [[display stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"locationOfElementByIndex( %d );", index]] intValue];1540 }1541 1542 - (int) visibleMessageCount {1543 #ifdef WebKitVersion1461544 if( [[display mainFrame] respondsToSelector:@selector( DOMDocument )] ) {1545 return [[[(DOMHTMLDocument *)[[display mainFrame] DOMDocument] body] children] length];1546 } else1547 #endif1548 // old JavaScript method1549 return [[display stringByEvaluatingJavaScriptFromString:@"scrollBackMessageCount();"] intValue];1550 }1551 1552 1519 - (void) scrollToBottom { 1553 1520 #ifdef WebKitVersion146 trunk/Resources/template.html
r2108 r2240 73 73 } 74 74 75 function messageIsInScrollback( id ) { 76 return ( document.getElementById( id ).id.length ? 1 : 0 ); 77 } 78 75 79 function locationOfMessage( id ) { 76 80 element = document.getElementById( id );
