Help - Search - Members - Calendar
Full Version: Creating a details window with external webpage
Desktop Sidebar Forums > Customizations > Panel Development & Requests
yyy
Does anybody know how to create an HTML details window which uses an external webpage, like the weather panel ?

I know I should add this:

CODE
<report name="weather">
   <![CDATA[
<html>
<head>

</body>
</html>
   ]]>
</report>


to the dsplugin file but how do I set the details window to use it ?

Another question: How do I add a link to the html webpage which can launch the properties dialog box ? For example, like the weather panel acts when you click the change city link in the details window.
eitaneko
I believe the weather panel uses an HTMLDetailsWindow, but it does NOT show an external webpage. I believe it creates its own HTML code to do what it wants. If you want to show an external page, use:
IWebBrowserDetailsWnd::Set(BSTR url);
I think that will get you an external page. You don't need to edit the dsplugin file. That is just where the weather panel stores its information b/c it is a DS built in panel. If you want to do your own HTML code, use an HTMLDetailsWindow, make a long string of the code (or multiple strings concatenated together) and send it to the set function.

To do the properties dialog, the panel uses a bit of javascript to do the trick. I'm not sure exactly how it works (prob using the DOM) but copied from the source:
<A CLASS=A1 onclick="javascript:window.external.ChangeCity();window.event.returnValue=false;" href="" >Click here to change city</A>

I can help you with this, if you wish.
yyy
No - the weather panel takes the HTML code from the dsplugin. For examle, when we wanted to have big weather icons in the details window, we changed it within the dsplugin file and we got a modified details window. That's how I want my panel to act so that people will be able to customize their own details window.
I need to know how I use the html from the dsplugin with the panel. I know theres a function called SetExternal() but I don't know how to use that.

I know about that java sciprt code but - what exactly does window.external.ChangeCity() do ? huh.gif How do I make it open the details window ? Or any other form ?

Thanks for the reply but I think I need more information rolleyes.gif
eitaneko
You can still store your HTML code in an external TXT file and load the input into a string in your program. That works the same way a DSSKIN does and lets the user change things as they want. It just doesn't have to be the basicpanels.dsplugin file.

ChangeCity is a function in the coding of the the weather panel itself. Since it is in the panel's source, you can call the show properties dialog as you please. The html just references that code when you click on the link. (I think)
GoMa
I'm not sure, but I think you can use the globalSettings parameter of Create to get the text from the IXmlNode configRoot node you get in Create, something like that:
CODE
Create(..., ..., ..., ..., ..., IXmlNode configRoot, ..., ..., ..., ...)
{
  string reportText = configRoot.GetNode("reports\report[@name=MyReportName]").GetBody();
}

This is VERY untested. laugh.gif It might be completely wrong.

As eitaneko said - to call an a method of the panel from the html code use something:
CODE
<a onclick="javascript:window.external.MethodName();window.event.returnValue=false;" href="">My link text!</a>

Again, untested and might be something the weather panel implements on its own.
yyy
Thanks eitaneko and GoMa laugh.gif I really appreciate your help smile.gif
I'll try GoMa's suggestions since I think this is what I need.

Thanks again smile.gif I'll tell you if it works.

EDIT:
No - it doesn't work sad.gif Maybe I don't do something right, but Ii don't think this is the way to do it.
GoMa
QUOTE
No - it doesn't work sad.gif Maybe I don't do something right, but Ii don't think this is the way to do it.

You mean the DSPLUGIN reading part or the calling of a method from within the HTML DetWin?
yyy
This one: string reportText = configRoot.GetNode("reports\report[@name=MyReportName]").GetBody();


I still haven't tried the java script thing.
GoMa
I think there was a misunderstanding here - I thought you put the "report" tag inside a "reports" tag like it is in the basic panels. Try this:
CODE
Create(..., ..., ..., ..., ..., IXmlNode configRoot, ..., ..., ..., ...)
{
 string reportText = configRoot.GetNode("report[@name=MyReportName]").GetBody();
}
yyy
Thanks but I don't think this is the right way to do it. Maybe KeithI can take a look at the DS source code and tell me how the weather panel does it ?
GoMa
I think it's very right way to do it. It's similar to what kdam suggested Prism to do. What's wrong with it? Doesn't it work? I made a little test (not with the actual report node but something else) and it worked ok. unsure.gif
yyy
When did Prism used it ? I just think that even if I get teh body of that node, I'll have to remove some text from it since it will be:

<![CDATA[
<html>
<head>

And I don't need the <![CDATA[. It just seems as if it isn't the right way to do it. I still haven't tried it, though. I just think that there's an easier way to do it.
GoMa
CDATA just says that the code inside it should not be parsed as XML but as raw text (the body of the containing node).
Prism wanted to know how to get data from the DSPLUGIN file. It's actually the same thing apart from you wanting to get it from the global config and he from the panel config inside the DSPLUGIN file.
And I consider 1 line of code easy. ohmy.gif
yyy
I also want to get it from the dsplugin. Can you please show me your test app so I'll know how to do it ?
Prism
I can't remember when did I do it. GoMa, could you please link me for this thread?
eitaneko
yyy, what panel are you trying to do this for anyways? Are you talking about putting this stuff in the basicpanels.dsplugin file, or the dsplugin you distribute with your panel?
yyy
It's a new one. I'll tell you soon. I want to get it from the dsplugin of the panel. I don't need those which are in the basicpanels.dsplugin.
eitaneko
Got it. That was what I was confused about. Let me know if the javascript stuff works. I might want to use it in the alarm panel as well.
yyy
Ok. I believe it works - it doesn't seem too hard to do. But the external webpage thing seems complicated.
GoMa
I have this in Create:
CODE
IXmlNode node = configRoot.GetNode("report[@name=abc]");
MessageBox.Show(node.GetBody());

And this in the dsplugin:
CODE
<?xml version="1.0" encoding="utf-8" ?>
<plugin progid="DSPanelTest.Plugin" compatible="88" >
<defaults>
  <!-- ..... -->
</defaults>

<report name="abc">
  <![CDATA[
  <html>
  <head>
  </body>
  </html>
  ]]>
</report>

</plugin>


It works. The messagebox is shown with:
QUOTE
<html>
<head>
</body>
</html>
yyy
That's exactly what I did and it didn't work sad.gif I'll try it again later. I also want t oadd informatin from the panel to the webpage and I saw that the weather panel does it using $value$. So - does it mean that I need to "analyze" the string and change it before I set it in the details window ?
GoMa
Yes. Use String.Replace.
yyy
Oh, thanks smile.gif Good idea fun_08.gif
yyy
Thanks a lot GoMa - it works laugh.gif clap.gif Your'e great fun_08.gif
GoMa
No problem, and thanks. smile.gif
norlander
Hi yyy,

Let me know how you make out with this, I have always liked the weather panel and think that concept would be perfect for my intranet. I would love to be able to view my intranet websites via a panel like the weather panel.

Cheers,
Lee
yyy
Hi,
Sorry but I don't think I understand you - why do you need to know how to do it ? Do you develop a panel ?
norlander
Hi yyy,

I have not developed a panel yet, but I would be intrested in developing a panel like the weather panel for my intranet.

Cheers,
Lee
yyy
laugh.gif Great - I'll be happy to see your panels smile.gif If you need any help don't hesitate to ask smile.gif

So here it is with C#:

In the Create function I add this:
CODE
detailsHTML = configRoot.GetNode("report[@name=reportname]").GetBody();



And in the list OnShowDetails function I add this:
CODE

public void OnShowDetails(IListOutput list, IListRow row)
 {
 IHTMLDetailsWnd details = m_sidebar.GetControlFactory().CreateHTMLDetailsWnd();
           ((IDetailsWnd)details).Init(m_sidebar.GetGlobalSettings(),m_sidebar.GetSkinManager(),m_panelConfig, this,"Title");
           
           tagPOINT origin;
           origin.x = 0;
           origin.y = 0;

           tagSIZE size;
           size.cx = 0;
           size.cy = 0;
           
           ((IDetailsWnd)details).Create((int)Handle, (int)EDetailFlags.DC_IGNOREORIGIN | (int)EDetailFlags.DC_IGNORESIZE, ref origin, ref size);

           details.Set(detailsHTML);

           list.TakeoverDetails(details, row);
}


And in the *.dsplugin write this:
HTML
<?xml version="1.0" encoding="utf-8" ?>
<plugin progid="Panel.Plugin" compatible="86" >
<defaults>

<panel name="Panel" >
<item name="decorated" value="1"/>
<item name="frequency" value="1"/>
</panel>

</defaults>

<report name="reportname">
<![CDATA[
<html>

<head>
</head>
<body>
</body>
</html>
]]>
</report>


</plugin>


I might add this as a top in the SDK Documentation forum.
yyy
Just one more thing:

I noticed that the weather panel uses a special command to perform the same action for each day.
For example, it is written:
HTML
$FOR_EACH_ITEM$<<

<TR>

<TD CLASS=$STYLE$ WIDTH=100>
<A target=_blank HREF=$LINK$>$DAY$</A><BR>
$DATE$
</TD>

<TD CLASS=$STYLE$ WIDTH=41><IMG SRC="file://$ICON" BORDER=0></TD>
<TD CLASS=$STYLE$ >$DESCRIPTION$</TD>
<TD CLASS=$STYLE$ WIDTH=63><DIV ALIGN=CENTER><B>$TEMPERATURE$</B></DIV></TD>

</TR>

>>

in order to write the same code for each day which the panel can get weather forecast about.

I want to do the same thing but I don't know how sad.gif
How can I get the code which appears between $FOR_EACH_ITEM$<< and >> , and then put it back in the string which contains the whole html text ?

I don't know how to find where in the text the $FOR_EACH_ITEM$<< command appears.

Does somebody know what is the easiest way to do it?
GoMa
You could use the Regex.Replace method.
yyy
Thanks but - maybe you also know how to use Regex.Replace in order to do it ?
Sorry to bother you but I absolutely have no idea how to use it rolleyes.gif
yyy
laugh.gif Someone from Neowin forums (weenur) helped me find how to do it:

I don't need regular expressions - but just to use IndexOf:

CODE
string s1;
 const string token1 = "$FOR_EACH_ITEM$<<";
 const string token2 = ">>";
 s1 = detailsHTML;
 s1 = s1.Substring( s1.IndexOf( token1 ) + token1.Length ).Trim();
 s1 = s1.Substring( 0, s1.IndexOf( token2 ) ).Trim();
 details.Set(s1);


That's it laugh.gif
mgcorr
Hi,
I'm trying to show an external web page in a details window and found this thread. What I'd like to do is pass a fixed URL to the details window which points to a dynamic web page so the data can be updated by the server.

I tried using the IWebBrowserDetailsWnd.Set() method, passing it a URL, but this didn't seem to do anything - just a blank details window.

From reading this thread, it sounds like the web page contents to be displayed in the IHTMLDetailsWnd details window is retrieved from within the .dsplugin file. What i'm having trouble following is how the actual web page contents are put into the .dsplugin file. From yyy's posts it looks like all he has is

<report name="abc">
<![CDATA[
<html>
<head>
</body>
</html>
]]>
</report>

How does this get updated and how does this get filled with the full HTML page content?

thanks,
Michael
GoMa
You don't have to use the "reports" element. See my answer in your other post.
mike_b1954
Hey GoMa !!

CONGRATS ON BREAKING THE 5000 POST BARRIER ! !

GoMa
Ooh, didn't notice. smile.gif I don't look there too much anymore. laugh.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.