LHelp can't handle javascript:helppopup links, but here is solution for this problem ("patch")
Original Reporter info from Mantis: SunyD @soner-a
-
Reporter name: Soner
Original Reporter info from Mantis: SunyD @soner-a
- Reporter name: Soner
Description:
I made changes in lhelp.pas to handle links like "javascript:helppopup('xzy.htm')" or "javascript:popuplink('xzy.htm')".
Read the comments in following text. (Copy it in one editor with pascal-syntax-higlighter)
---------
Comment out code here: Lazarus\components\chmhelp\lhelp\ChmDataProvider.pas
function TIpChmDataProvider.CanHandle(const URL: string): Boolean;
var
HelpFile: String;
Reader: TChmReader = nil;
begin
Result := True;
if Pos('Java', URL) =1 then Result := False;
if (fChm.ObjectExists(StripInPageLink(url), Reader)= 0)
and (fChm.ObjectExists(StripInPageLink(BuildUrl(fCurrentPath,Url)), Reader) = 0) then Result := False;
//DebugLn('CanHandle ',Url,' = ', Result);
//if not Result then if fChm.ObjectExists(BuildURL('', URL)) > 0 Then result := true;
{XXX soner: comment outed, because dead code nothing, moved to chmcontentprovider.pas ... XXXXXXX
if (Pos('javascript:helppopup(''', LowerCase(URL)) = 1) then begin
HelpFile := Copy(URL, 23, Length(URL) - (23-1));
HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);
//DebugLn('HelpFile = ', HelpFile);
end;
XXX END of comment out by Soner XXXXXXXXXXXXXXXXXXXX }
if (not Result) and (Pos('#', URL) = 1) then Result := True;
end;
Add code here:Lazarus\components\chmhelp\lhelp\chmcontentprovider.pas
procedure TChmContentProvider.IpHtmlPanelHotClick(Sender: TObject);
var
HelpFile: String; //soner from ChmDataProvider.pas
aPos: integer; //soner added
begin
// Soner moved from ChmDataProvider.pas to here ...
// chm-links looks like: mk:@MSITStore:D:\LazPortable\docs\chm\iPro.chm::/html/lh3zs3.htm
if (Pos('javascript:helppopup(''', LowerCase(fHtml.HotURL)) = 1)or
(Pos('javascript:popuplink(''', LowerCase(fHtml.HotURL)) = 1) //soner added
then begin
HelpFile := Copy(fHtml.HotURL, 23, Length(fHtml.HotURL) - (23-1));
HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);
if (Pos('/',HelpFile)=0)and(Pos('.chm:',HelpFile)=0) then begin //looks like?: 'xyz.htm'
aPos:=LastDelimiter('/', fHtml.CurURL);
if aPos>0 then HelpFile:=Copy(fHtml.CurURL,1,aPos)+HelpFile;
end
else if (Pos('.chm:',HelpFile)=0) then begin //looks like?: 'folder/xyz.htm' or '/folder/xyz.htm'
if HelpFile[1]<>'/' then HelpFile:='/'+HelpFile;
aPos:=LastDelimiter(':', fHtml.CurURL);
if aPos>0 then HelpFile:=Copy(fHtml.CurURL,1,aPos)+HelpFile;
end;
DoLoadUri(HelpFile); //open it in current iphtmlpanel.
{ Soner: Normally it should be the HelpPopupForm opened, but HelpPopupForm is empty, it is
something to do.}
end
else
// end of Soner's changes
OpenURL(fHtml.HotURL);
end;
Steps to reproduce:
-
open the included chm-file in lhelp
-
klick on links with title:
Hierarchy -
the link will be opened in extern browser.
-
Now make the my changes to lhelp make 2. again.
now the link will be opened in lhelp.
Mantis conversion info:
- Mantis ID: 31732
- OS: Windows
- Build: Svn-Rev. 54278
- Platform: i386-win
- Version: 1.6.4
- Fixed in version: 1.9 (SVN)
- Fixed in revision: 54872 (#f9266d01)
- Target version: 1.8