OSDN Git Service

タブ保存ファイルの挙動の修正と、IDをクリックしてレスアンカーを出すように修正
authorh677 <h677>
Wed, 10 Nov 2004 14:28:49 +0000 (14:28 +0000)
committerh677 <h677>
Wed, 10 Nov 2004 14:28:49 +0000 (14:28 +0000)
Giko.dfm
Giko.pas
GikoSystem.pas

index 1835e53..805ebbb 100644 (file)
--- a/Giko.dfm
+++ b/Giko.dfm
@@ -569,6 +569,7 @@ object GikoForm: TGikoForm
               Align = alClient
               TabOrder = 0
               OnEnter = BrowserEnter
+              OnExit = BrowserExit
               OnStatusTextChange = BrowserStatusTextChange
               OnBeforeNavigate2 = BrowserBeforeNavigate2
               OnNewWindow2 = BrowserNewWindow2
index be28f43..a7d50bf 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -915,8 +915,6 @@ type
     procedure LogFolderOpenActionUpdate(Sender: TObject);
                procedure TabsSaveActionExecute(Sender: TObject);
                procedure TabsOpenActionExecute(Sender: TObject);
-               procedure TabsSaveToFileActionExecute(Sender: TObject);
-    procedure TabsOpenFromFileActionExecute(Sender: TObject);
     procedure OnlyAHundredResActionExecute(Sender: TObject);
     procedure OnlyKokoResActionExecute(Sender: TObject);
     procedure OnlyNewResActionExecute(Sender: TObject);
@@ -955,6 +953,7 @@ type
     procedure SortActiveColumnActionExecute(Sender: TObject);
     procedure SortNextColumnActionExecute(Sender: TObject);
     procedure SortPrevColumnActionExecute(Sender: TObject);
+    procedure BrowserExit(Sender: TObject);
        private
                { Private \90é\8c¾ }
         //RoundList : TRoundList;
@@ -1194,6 +1193,8 @@ type
                procedure IndividualAbonID(Atype : Integer);
                //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
                procedure IndividualAbon(Atag, Atype : Integer);
+               //ID\83A\83\93\83J\81[\92Ç\89Á
+               procedure IDAnchorPopup(Abody :string);
        published
                property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
        end;
@@ -3961,6 +3962,7 @@ begin
 
                                Thread.Browser.OnStatusTextChange := nil;
                                doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
+
                                GikoSys.CreateHTML2(doc, ThreadItem, sTitle);
                                Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
                                PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( Thread.Browser ), 0 );
@@ -6365,7 +6367,6 @@ var
        idx: Integer;
        wkIntSt: Integer;
        wkIntTo: Integer;
-       firstElement: IHTMLElement;
        document: IHTMLDocument2;
 begin
 
@@ -6394,12 +6395,7 @@ begin
 
                                if wkIntSt <> 0 then begin
                                        document := FActiveContent.Browser.Document as IHTMLDocument2;
-                                       if Assigned(document) then
-                                               firstElement := document.all.item('idSearch', 0) as IHTMLElement;
-                                               if Assigned(firstElement) then
-                                                       if firstElement.style.visibility <> 'hidden' then
-                                                               firstElement.style.visibility := 'hidden';
-
+                    IDAnchorPopup('');
                                        BrowserMovement(IntToStr(wkIntSt));
                                end;
 
@@ -7694,7 +7690,6 @@ begin
                if ThreadItem = nil then begin
                        ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
                end;
-
                if ThreadItem = nil then begin
                        //shift -> \90Ý\92è\83u\83\89\83E\83U\81i\96³\82¯\82ê\82ÎIE\81j
                        //ctrl  -> IE
@@ -8062,6 +8057,7 @@ var
        ThreadItem: TThreadItem;
 begin
        Result := False;
+    IDAnchorPopup('');
        Doc := FactiveContent.FBrowser.Document as IHtmlDocument2;
        if Assigned(Doc) then begin
                Range := Doc.selection.createRange as IHTMLTxtRange;
@@ -9241,7 +9237,7 @@ end;
 
 procedure TGikoForm.AllResActionUpdate(Sender: TObject);
 begin
-       AllResAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
+//     AllResAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
 end;
 
 procedure TGikoForm.ReloadClick(Sender: TObject);
@@ -10733,15 +10729,54 @@ end;
 
 procedure TGikoForm.ResRangeActionUpdate(Sender: TObject);
 begin
-       ResRangeAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
+//     ResRangeAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
 end;
 
 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
+var
+       p : TPoint;
+       doc : Variant;
+       e: IHTMLElement;
+       AID: string;
+       stlist : TStringList;
+       i : Integer;
+       body : String;
 begin
   result := true;
   try
        if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
-               FActiveContent.FBrowser.SetFocus;
+               FActiveContent.Browser.SetFocus;
+               try
+                       GetCursorPos(p);
+                       p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
+                       p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
+                       e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
+                       if (Assigned(e)) then begin
+                               if (e.className = 'date') or (e.id = 'date') then begin
+                                       AID := e.innerText;
+                                       if AnsiPos('id', AnsiLowerCase(AID)) > 0 then
+                                               AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11)
+                                       else begin
+                                               stlist := TStringList.Create;
+                                               try
+                                                       stList.DelimitedText := AID;
+                                                       for i := 0 to stList.Count - 1 do
+                                                               if Length(WideString(stList[i])) = 8 then begin
+                                                                       if GikoSys.NotDateorTimeString(stList[i]) then begin
+                                                                               AID := stList[i];
+                                                                               break;
+                                                                       end;
+                                                               end;
+                                               finally
+                                                       stList.Free;
+                                               end;
+                                       end;
+                                       body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread);
+                                       IDAnchorPopup(body);
+                               end;
+                       end;
+               except
+               end;
   except
   end;
 end;
@@ -11096,7 +11131,9 @@ begin
 
        if not SaveTabURLs then begin
                if TabsSaveAction.Tag = 0 then
-                       ShowMessage('\95Û\91\82·\82é\83^\83u\82ª\82 \82è\82Ü\82¹\82ñ');
+                       ShowMessage('\95Û\91\82·\82é\83^\83u\82ª\82 \82è\82Ü\82¹\82ñ')
+               else if TabsSaveAction.Tag = 1 then
+                       GikoForm.TabsOpenAction.Tag := -1;
        end;
 end;
 
@@ -11107,18 +11144,18 @@ const
 var
        SaveStringList: TStringList;
 begin
-    Result := false;
-       if FileExists( GikoSys.GetAppDir + Filename) then begin
-               if FileExists( GikoSys.GetAppDir + bFilename) then
-                       DeleteFile(GikoSys.GetAppDir + bFilename);
-
-               //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
-               RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
-   end;
+       Result := false;
 
        SaveStringList := TStringList.Create;
        try
                if GetTabURLs(SaveStringList) then begin
+                       if FileExists( GikoSys.GetAppDir + Filename) then begin
+                               if FileExists( GikoSys.GetAppDir + bFilename) then
+                                       DeleteFile(GikoSys.GetAppDir + bFilename);
+
+                               //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
+                               RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
+                       end;
                        SaveStringList.SaveToFile(GikoSys.GetAppDir + Filename);
                        Result := true;
                end;
@@ -11129,9 +11166,11 @@ end;
 
 procedure TGikoForm.TabsOpenActionExecute(Sender: TObject);
 begin
-       if not LoadTabURLs then begin
-               if TabsOpenAction.Tag = 0 then
-                       ShowMessage('\95\\8e¦\82·\82é\83^\83u\82ª\82 \82è\82Ü\82¹\82ñ\81B');
+       if TabsOpenAction.Tag <> -1 then begin
+               if not LoadTabURLs then begin
+                       if TabsOpenAction.Tag = 0 then
+                               ShowMessage('\95\\8e¦\82·\82é\83^\83u\82ª\82 \82è\82Ü\82¹\82ñ\81B');
+               end;
        end;
 end;
 
@@ -11143,81 +11182,37 @@ var
        GikoTab                 : TGikoTabAppend;
        fileName                : string;
 begin
+
        fileName := ExtractFilePath(Application.ExeName) + 'tab.sav';
        URLs := TStringList.Create();
        GikoTab := GikoSys.Setting.BrowserTabAppend;
        try
                try
-                       if FileExists(fileName) then
+                       Result := True;
+                       if FileExists(fileName) then begin
                                URLs.LoadFromFile(fileName);
+                               bound    := URLs.Count - 1;
+                               if bound > -1 then begin
+                                       GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
+                                       for i := 0 to bound do begin
+                                               item := BBSsFindThreadFromURL( URLs[ i ] );
+                                               if item <> nil then
+                                                       InsertBrowserTab( item, false );
+                                       end;
+                               end else
+                                       Result := False;
+                       end else
+                               Result := False;
                except
-                       on EFOpenError do
+                       on EFOpenError do begin
                                ShowMessage('\83^\83u\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ');
-               end;
-               bound    := URLs.Count - 1;
-               if bound = -1 then begin
-                       Result := False;
-                       Exit;
-               end;
-
-
-               GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
-               for i := 0 to URLs.Count - 1 do begin
-                       item := BBSsFindThreadFromURL( URLs[ i ] );
-                       if item <> nil then
-                               InsertBrowserTab( item, false );
+                       end;
                end;
        finally
                GikoSys.Setting.BrowserTabAppend := GikoTab;
                URLs.Free;
        end;
-       Result := True;
-end;
 
-procedure TGikoForm.TabsSaveToFileActionExecute(Sender: TObject);
-var
-       SaveTabList: TStringList;
-       Result: Boolean;
-begin
-       SaveTabList := TStringList.Create;
-       try
-               Result := GetTabURLs(SaveTabList);
-//             if TabSaveDialog.Execute then begin
-//                     SaveTabList.SaveToFile(TabSaveDialog.FileName);
-//             end;
-       finally
-               SaveTabList.Free;
-       end;
-end;
-
-procedure TGikoForm.TabsOpenFromFileActionExecute(Sender: TObject);
-var
-       i    : Integer;
-       item        : TThreadItem;
-       URLs : TStringList;
-       GikoTab: TGikoTabAppend;
-begin
-       URLs := TStringList.Create();
-       GikoTab := GikoSys.Setting.BrowserTabAppend;
-       try
-               try
-//                     if TabOpenDialog.Execute then begin
-//                             URLs.LoadFromFile(TabOpenDialog.FileName);
-//                     end;
-               except
-                       on EFOpenError do ShowMessage('\83^\83u\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ');
-               end;
-
-               GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
-               for i := 0 to URLs.Count - 1 do begin
-                       item := BBSsFindThreadFromURL( URLs[ i ] );
-                       if item <> nil then
-                               InsertBrowserTab( item, false );
-               end;
-       finally
-               GikoSys.Setting.BrowserTabAppend := GikoTab;
-               URLs.Free;
-       end;
 end;
 
 procedure TGikoForm.OnlyAHundredResActionExecute(Sender: TObject);
@@ -11850,17 +11845,24 @@ procedure TGikoForm.SameIDResAnchorActionExecute(Sender: TObject);
 var
        ThreadItem : TThreadItem;
        No : Integer;
-       body, nCSS : string;
-       firstElement: IHTMLElement;
-       document: IHTMLDocument2;
-       docAll: IHTMLElementCollection;
-       doc : Variant;
+       body : string;
 begin
        No := KokoPopupMenu.Tag;
        if No = 0 then Exit;
        ThreadItem := GetActiveContent;
        if ThreadItem = nil then Exit;
        body := GikoSys.GetSameIDResAnchor(No, ThreadItem);
+       IDAnchorPopup(body);
+end;
+//ID\83A\83\93\83J\81[\92Ç\89Á
+procedure TGikoForm.IDAnchorPopup(Abody :string);
+var
+       firstElement: IHTMLElement;
+       document: IHTMLDocument2;
+       docAll: IHTMLElementCollection;
+       doc : Variant;
+       nCSS : string;
+begin
        try
                document := FActiveContent.Browser.Document as IHTMLDocument2;
 
@@ -11868,11 +11870,11 @@ begin
                        docAll := document.all;
                        firstElement := docAll.item('idSearch', 0) as IHTMLElement;
                        if (Assigned(firstElement)) then begin
-                               if Length(body) > 0 then begin
+                               if Length(Abody) > 0 then begin
                                        doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
                                        nCSS := '<p id="idSearch" style="position:absolute;top:' + IntToStr(doc.Body.ScrollTop + 10) + 'px;right:5px;' //
                                                + 'background-color:window; border:outset 1px infobackground; z-index:10; overflow-y:auto; border-top:none">'
-                                               + body + '</p>';
+                                               + Abody + '</p>';
                                        firstElement.outerHTML := nCSS;
                                        firstElement.style.visibility := 'visible';
                                end else begin
@@ -11886,7 +11888,6 @@ begin
                end;
        except
        end;
-
 end;
 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
 procedure TGikoForm.IndividualAbon1ActionExecute(Sender: TObject);
@@ -12132,6 +12133,11 @@ begin
 
 end;
 
+procedure TGikoForm.BrowserExit(Sender: TObject);
+begin
+       IDAnchorPopup('');
+end;
+
 initialization
                                OleInitialize(nil);
 finalization
index 9a11e13..7bfc9c1 100644 (file)
@@ -96,7 +96,7 @@ type
 
 //             FExitWrite: TStringList;
 //             function StrToFloatDef(s: string; Default: Double): Double;
-               function NotDateorTimeString(const AStr : string): boolean;
+
        public
                { Public \90é\8c¾ }
                FAbon : TAbon;
@@ -225,6 +225,8 @@ type
                procedure SpamLearn( wordCount : TWordCount; isSpam : Boolean );
                //! \83X\83p\83\80\93x\90\94
                function SpamParse( const text : string; wordCount : TWordCount ) : Extended;
+        //\88ø\90\94\82ª\81A\93ú\95t\82Å\82à\8e\9e\8d\8f\82Å\82à\82È\82¢\82±\82Æ\82ð\92²\82×\82é
+               function NotDateorTimeString(const AStr : string): boolean;
        end;
 
 var
@@ -1184,7 +1186,6 @@ begin
 
                                // \83X\83L\83\93(\83t\83b\83^)
                                SaveList.Add( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) );
-
                                doc.Write(SaveList.Text);
                        finally
                                SaveList.Free;
@@ -1339,7 +1340,6 @@ begin
                                except
                                end;
                                doc.Write(SaveList.Text);
-
                        end else if GikoSys.Setting.UseCSS and FileExists(CSSFileName) then begin
                                //CSS\8eg\97p
                                //CSSFileName := GetAppDir + CSS_FILE_NAME;
@@ -1421,7 +1421,6 @@ begin
                                //SaveList.Add('</body></html>');
                                SaveList.Add('<a name="last"></a>');
                                SaveList.Add('</body></html>');
-
                                doc.Write(SaveList.Text);
                        end else begin
                                //CSS\94ñ\8eg\97p
@@ -1433,7 +1432,7 @@ begin
                                SaveList.Add('<a name="top"></a>');
                                SaveList.Add('<font size=+1 color="#FF0000">' + sTitle + '</font>');
                                SaveList.Add('<dl>');
-                SaveList.Add('<p id="idSearch"></p>');
+                               SaveList.Add('<p id="idSearch"></p>');
                                doc.Write(SaveList.Text);
                                SaveList.Clear;
                                //Application.ProcessMessages;
@@ -3954,7 +3953,7 @@ begin
                        try
                                stList.DelimitedText := AID;
                                for i := 0 to stList.Count - 1 do
-                                       if Length(stList[i]) = 8 then begin
+                                       if Length(WideString(stList[i])) = 8 then begin
                                                if NotDateorTimeString(stList[i]) then begin
                                                        AID := stList[i];
                                                        break;