Mercurial > qqw
changeset 45:afa24ecb0d45
add message box
| author | sheep@ghostwheel |
|---|---|
| date | Sun, 07 Mar 2010 19:36:19 +0100 |
| parents | 09c9efb2ca72 |
| children | 5afa948f1b47 |
| files | dw.css dw.js |
| diffstat | 2 files changed, 48 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.css Sun Mar 07 18:27:07 2010 +0100 +++ b/dw.css Sun Mar 07 19:36:19 2010 +0100 @@ -76,3 +76,28 @@ #mapdef { display: none; } + +#game p.message { + background: #206; + color: #ddd; + text-shadow: #003 2px 2px 2px; + border: 4px solid #ddd; + border-radius: 8px; + -moz-border-radius: 8px; + -o-border-radius: 8px; + padding: 16px; + margin: 8px auto; + width: 400px; + box-shadow: inset #002 0 0 4px; + -moz-box-shadow: inset #002 0 0 4px; + -webkit-box-shadow: inset #002 0 0 4px; + -o-box-shadow: inset #002 0 0 4px; + font-size: 12px; + font-weight: bold; + font-family: sans-serif; + white-space: pre-wrap; + word-wrap: break-word; + white-space: -moz-pre-wrap; + white-space: -pre-wrap; + white-space: -o-pre-wrap; +}
--- a/dw.js Sun Mar 07 18:27:07 2010 +0100 +++ b/dw.js Sun Mar 07 19:36:19 2010 +0100 @@ -328,7 +328,8 @@ self.y = ny; self.steps = 8; } else if (module.field.get_prop(nx, ny, 'message')) { - alert(module.field.get_prop(nx, ny, 'message')); + var text = module.field.get_prop(nx, ny, 'message'); + module.Message(text); } } @@ -354,6 +355,10 @@ walk(1); } else if (k == 40) { // down walk(2); + } else if (k > 0) { + if (module.message) { + module.message.close(); + } } } else if (self.steps == 4) { var url = module.field.get_prop(self.x, self.y, 'url'); @@ -387,6 +392,23 @@ return self; }; + module.Message = function (text) { + if (module.message) { + module.message.close(); + } + self = document.createElement('p'); + self.className = 'message'; + self.innerText = text; + + self.close = function () { + document.getElementById('game').removeChild(self); + module.message = null; + }; + + document.getElementById('game').appendChild(self); + module.message = self; + return self; + }; module.keypress = function (e) { // Callback for handling keypresses.
