[gbrainy] Fix to web client: exceptions and show tip & solution in all games
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fix to web client: exceptions and show tip & solution in all games
- Date: Sun, 24 Jul 2011 10:35:42 +0000 (UTC)
commit d6306befabb1d14139a7205ebc83e0e5b7e7ca7f
Author: Jordi Mas <jmas softcatala org>
Date: Sun Jul 24 12:35:16 2011 +0200
Fix to web client: exceptions and show tip & solution in all games
src/Clients/WebForms/AllGames.aspx | 12 +++++++-----
src/Clients/WebForms/GameImage.cs | 32 +++++++++++++++++---------------
src/Clients/WebForms/jscripts.js | 2 +-
3 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/src/Clients/WebForms/AllGames.aspx b/src/Clients/WebForms/AllGames.aspx
index 7d91f9f..6ae49db 100644
--- a/src/Clients/WebForms/AllGames.aspx
+++ b/src/Clients/WebForms/AllGames.aspx
@@ -12,15 +12,17 @@
<br/>
<asp:Panel Visible = "<%# ((GameContainer) Container.DataItem).TipVisible %>" runat="server">
- <a onclick="toggleVisibleById('<%# ((GameContainer) Container.DataItem).ID%>_tip');return false;" href="">See Tip</a>
- <div id = "<%# ((GameContainer) Container.DataItem).ID%>_tip" style = "display:none">
+
+ <a onclick="toggleVisibleById('tip_<%# ((GameContainer) Container.DataItem).ID%>');return false;" href="">See Tip</a>
+
+ <div id = "tip_<%# ((GameContainer) Container.DataItem).ID%>" style = "display:none">
<br/>
<%# ((GameContainer) Container.DataItem).Tip %>
</div>
</asp:Panel>
-
- <a onclick="toggleVisibleById('<%# ((GameContainer) Container.DataItem).ID%>_solution');return false;" href="">See Solution</a>
- <div id = "<%# ((GameContainer) Container.DataItem).ID%>_solution" style = "display:none">
+
+ <a onclick="toggleVisibleById('solution_<%# ((GameContainer) Container.DataItem).ID%>');return false;" href="">See Solution</a>
+ <div id = "solution_<%# ((GameContainer) Container.DataItem).ID%>" style = "display:none">
<br/>
<%# ((GameContainer) Container.DataItem).Solution %>
</div>
diff --git a/src/Clients/WebForms/GameImage.cs b/src/Clients/WebForms/GameImage.cs
index 5aba54c..7449553 100644
--- a/src/Clients/WebForms/GameImage.cs
+++ b/src/Clients/WebForms/GameImage.cs
@@ -31,6 +31,7 @@ namespace gbrainy.Clients.WebForms
public const int IMAGE_WIDTH = 400;
public const int IMAGE_HEIGHT = 400;
static public string IMAGES_DIR = "tmp/";
+ static public string EXTENSION = ".png";
gbrainy.Core.Main.Game game;
@@ -53,6 +54,7 @@ namespace gbrainy.Clients.WebForms
try
{
+ file = Path.GetFullPath (file);
cairo_image = new Cairo.ImageSurface (Cairo.Format.ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT);
cr = new gbrainy.Core.Main.CairoContextEx (cairo_image, "sans 12", 96);
@@ -66,9 +68,9 @@ namespace gbrainy.Clients.WebForms
Logger.Debug ("Game.CreateImage. Wrote image {0}", file);
}
- catch (Exception)
+ catch (Exception e)
{
- Logger.Error ("Game.CreateImage. Error writting {0}", file);
+ Logger.Error ("Game.CreateImage. Error writting {0} {1}", file, e);
return false;
}
@@ -88,7 +90,7 @@ namespace gbrainy.Clients.WebForms
{
string file;
- file = IMAGES_DIR + sessionid + ".png";
+ file = IMAGES_DIR + sessionid + EXTENSION;
return file;
}
@@ -112,18 +114,18 @@ namespace gbrainy.Clients.WebForms
{
Container container = widget as Container;
- if (container != null)
- {
- foreach (Widget child in container.Children)
- {
- area_shapes.Add (new GameImageAreaShape (ProcessWidget (child),
- "?answer=" + child.DataEx.ToString (),
- area_shapes.Count));
- }
- }
- else {
- /*area_shapes.Add (new AreaShape (ProcessWidget (widget),
- "?answer=" + child.DataEx.ToString ()));*/
+ if (container == null)
+ continue;
+
+ foreach (Widget child in container.Children)
+ {
+ // Some puzzles use Widgets to layout elements but are not clickable
+ if (child.DataEx == null)
+ continue;
+
+ area_shapes.Add (new GameImageAreaShape (ProcessWidget (child),
+ "?answer=" + child.DataEx.ToString (),
+ area_shapes.Count));
}
}
diff --git a/src/Clients/WebForms/jscripts.js b/src/Clients/WebForms/jscripts.js
index 9e7545a..d5fb329 100644
--- a/src/Clients/WebForms/jscripts.js
+++ b/src/Clients/WebForms/jscripts.js
@@ -3,6 +3,6 @@ toggleVisibleById = function (elementId) {
};
toggleVisible = function (element) {
- element.style.display == 'none' ? 'block' : 'none';
+ element.style.display = 'none' ? 'block' : 'none';
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]