Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Add target icon for make-shift submit button. probably need a bette…

…r icon

- Add feat add, edit & deleting functionality
- Fix skill editing.
  • Loading branch information...
commit 35e5163c7dd8339cad4e22f9f2583b9a5c452d2e 1 parent 32cba30
Jonathan Borzilleri authored
5 htdocs/.htaccess
View
@@ -19,10 +19,11 @@ RewriteRule ^import$ import.html
RewriteRule ^upload$ importProcess.php?action=upload
RewriteRule ^([0-9]+)/delete$ playerEdit.html?action=delete&id=$1
RewriteRule ^([0-9]+)/edit$ playerEdit.html?action=edit&id=$1
-RewriteRule ^([0-9]+)/skills$ skillEdit.html?id=$1
+RewriteRule ^([0-9]+)/(skills|feats)$ skillEdit.html?id=$1
RewriteRule ^([0-9]+)/skills/save$ skillEditProcess.php?action=save&id=$1
RewriteRule ^([0-9]+)/skills/delete$ skillEditProcess.php?action=delete&id=$1
-RewriteRule ^([0-9]+)/feats featEdit.html?id=$1
+RewriteRule ^([0-9]+)/feats/save$ featEditProcess.php?action=save&id=$1
+RewriteRule ^([0-9]+)/feats/delete$ featEditProcess.php?action=delete&id=$1
RewriteRule ^([0-9]+)/power$ power.html?id=$1
RewriteRule ^([0-9]+)/power/new$ powerEdit.html?action=add&id=$1
RewriteRule ^([0-9]+)/power/([0-9]+)/edit$ powerEdit.html?action=edit&id=$1&p_id=$2
11 htdocs/css/default.css
View
@@ -319,4 +319,15 @@ li.noCheck div.listLabel {
#SkillTable tbody, #FeatTable tbody {
border : 1px solid #D8D7C5;
boder-top : 0;
+}
+
+#SkillTable .icon, #FeatTable .icon {
+ cursor : pointer;
+}
+
+#SkillDiv {
+ float : left;
+}
+#FeatDiv {
+ margin-left: 450px;
}
3  htdocs/css/statBlock.css
View
@@ -130,7 +130,4 @@ a.ajaxLink:active {
}
#FeatTable {
width : 315px;
-}
-#FeatTable .icon {
- cursor : pointer;
}
26 htdocs/featEdit.html
View
@@ -27,4 +27,30 @@
<? endforeach; ?>
</tbody>
</table>
+
+<input type="hidden" name="id" id="id" />
+<input type="text" name="name" id="name" />
+<textarea name="description" id="description" rows="6" cols="15"></textarea>
+
+
+
+<script type="text/javascript" charset="utf-8">
+$(window).load(function() {
+ $('img.feat_view').each(function(i) {
+ $(this).qtip({
+ show: {
+ solo: true,
+ when: {
+ event: 'click'
+ }
+ },
+ hide: {
+ when: {
+ event: 'unfocus'
+ }
+ }
+ });
+ });
+});
+</script>
<?php include('footer.php'); ?>
35 htdocs/featEditProcess.php
View
@@ -0,0 +1,35 @@
+<?php
+include('autohandler.php');
+
+$target_uri = "/";
+
+$char = Doctrine::getTable('Player')->findOneById($_REQUEST['id']);
+if( !$char || !$char->exists() ) {
+ loadPage($target_uri);
+}
+$target_uri = "/{$char->id}/skills";
+
+switch($action) {
+ case 'save':
+ $feat = $char->Feats->get(@$_POST['f_id']);
+ $success = $feat->updateFromForm();
+
+ if( $success ) {
+ $feat->save();
+ }
+ break;
+ case 'delete':
+ if( empty($_POST['submit']) || 'delete' != substr($_POST['submit'],0,6) ) {
+ break;
+ }
+ $f_id = substr($_POST['submit'],7);
+ $feat = $char->Feats->get($f_id);
+ $feat->delete();
+ break;
+ default:
+ break;
+}
+
+loadPage($target_uri);
+include('footer.php');
+?>
5 htdocs/header.php
View
@@ -20,9 +20,8 @@
<li class="item"
><a href="<?=SITE_URL;?>/<?=$char->id;?>/power">Powers</a></li>
<li class="item"
- ><a href="<?=SITE_URL;?>/<?=$char->id;?>/skills">Skills</a></li>
- <li class="item"
- ><a href="<?=SITE_URL;?>/<?=$char->id;?>/feats">Feats</a></li>
+ ><a href="<?=SITE_URL;?>/<?=$char->id;?>/skills"
+ >Skills &amp; Feats</a></li>
<li class="item"
><a href="<?=SITE_URL;?>/<?=$char->id;?>/delete">Delete</a></li>
</ul>
BIN  htdocs/images/icon_target.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 htdocs/javascript/skills.js
View
@@ -1,15 +1,56 @@
function editSkill(id) {
- id = id.substring(1);
+ id = id.substring(5);
var tr = $('#s'+id);
var form = $('#blankFormRow');
- $(form).find('td.skillName input').val($(tr).find('td.skillName').text());
- $(form).find('td.skillBonus input').val($(tr).find('td.skillBonus').text());
- $(form).find('td.skillAbility select').val($(tr).find('td.skillAbility span.skillAbilityName').text());
- $(form).find('td.skillTrained input').attr('checked', $(tr).find('td.skillTrained').text()==5);
+ $('#SkillForm #name').val($(tr).find('td.skillName').text());
+ $('#SkillForm #bonus').val($(tr).find('td.skillBonus').text());
+ $('#SkillForm #ability').val($(tr).find('td.skillAbility span.skillAbilityName').text());
+ $('#SkillForm #trained').attr('checked', $(tr).find('td.skillTrained').text()==5);
+ $('#SkillForm #form_key').val($('#SkillForm #form_key').val().substring(0,11)+id);
$('#s_id').val(id);
}
+function editFeat(id) {
+ id = id.substring(5);
+ var tr = $('#f'+id);
+
+ $('#feat_id').val(id);
+ $('#feat_name').val($(tr).find('td.featName').text());
+ $('#feat_description').text($(tr).find('td.featDescription img').attr('title'));
+}
+
$(window).load(function() {
- $('#SkillTable a.skillEditLink').click(function() { editSkill(this.id); });
+ $('#SkillTable a.skillEditLink').click(function() { editSkill(this.id); });
+ $('#NewSkillButton').click(function() {
+ $('#SkillForm #name').val('');
+ $('#SkillForm #bonus').val('');
+ $('#SkillForm #ability').val('');
+ $('#SkillForm #trained').attr('checked',false);
+ $('#SkillForm #form_key').val($('#SkillForm #form_key').val().substring(0,11)+'0');
+ $('#s_id').val('');
+ });
+
+ $('#FeatTable a.featEditLink').click(function() { editFeat(this.id); });
+ $('#NewFeatButton').click(function() {
+ $('#feat_id').val('');
+ $('#feat_name').val('');
+ $('#feat_description').text('');
+ });
+
+ $('img.feat_view').each(function(i) {
+ $(this).qtip({
+ show: {
+ solo: true,
+ when: {
+ event: 'click'
+ }
+ },
+ hide: {
+ when: {
+ event: 'unfocus'
+ }
+ }
+ });
+ });
});
190 htdocs/skillEdit.html
View
@@ -1,5 +1,6 @@
<?php
-$form_key = 'skill_edit_'.(empty($_REQUEST['p_id'])?0:$_REQUEST['p_id']);
+$skill_form_key = 'skill_edit_0';
+$feat_form_key = 'feat_edit_0';
$css_include = array('forms.css');
$js_include = array('skills.js');
include('autohandler.php');
@@ -8,70 +9,133 @@
loadPage('/');
}
-$skill = new Skill();
?>
-
-<form method="post" action="<?=SITE_URL;?>/<?=$char->id;?>/skills/save">
-<input type="hidden" name="s_id" id="s_id" value="" />
-<table id="SkillTable">
- <thead>
- <tr class="row0">
- <td colspan="2">&nbsp;</td>
- <th><label for="name">Skill Name</label></th>
- <th><label for="ability">Ability</label></th>
- <th><label for="bonus">Misc</label></th>
- <th colspan="2"><label for="trained">Train</label></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row0" id="blankFormRow">
- <td class="icon"><input type="image" class="icon" alt="submit"
- src="<?=MEDIA_URL;?>/images/icon_medical.png" /></td>
- <td class="skillName" colspan="2">
- <input type="text" id="name" name="name" size="20" maxlength="255"
- value=""/>
- </td>
- <td class="skillAbility">
- <select id="ability" name="ability">
- <option value="Str">Str</option>
- <option value="Con">Con</option>
- <option value="Dex">Dex</option>
- <option value="Int">Int</option>
- <option value="Wis">Wis</option>
- <option value="Cha">Cha</option>
- </select>
- </td>
- <td class="skillBonus">
- <input type="text" id="bonus" name="bonus" size="2" maxlength="3" />
- </td>
- <td class="skillTrained">
- <input type="checkbox" id="trained" name="trained" value="1" /></td>
- <td>&nbsp;</td>
- </tr>
+<div id="SkillDiv">
+ <form method="post" id="SkillForm"
+ action="<?=SITE_URL;?>/<?=$char->id;?>/skills/save">
+ <table id="SkillTable">
+ <thead>
+ <tr class="row0">
+ <td colspan="2">&nbsp;</td>
+ <th><label for="name">Skill Name</label></th>
+ <th><label for="ability">Ability</label></th>
+ <th><label for="bonus">Misc</label></th>
+ <th colspan="2"><label for="trained">Train</label></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="row0" id="blankFormRow">
+ <td class="icon">
+ <a id="NewSkillButton" href="javascript:;">
+ <img class="icon" alt="new" title="New Skill"
+ src="<?=MEDIA_URL;?>/images/icon_medical.png" /></a>
+ </td>
+ <td class="skillName" colspan="2">
+ <input type="hidden" name="s_id" id="s_id" value="" />
+ <input type="text" id="name" name="name" size="20" maxlength="255"/>
+ </td>
+ <td class="skillAbility">
+ <select id="ability" name="ability">
+ <option value="Str">Str</option>
+ <option value="Con">Con</option>
+ <option value="Dex">Dex</option>
+ <option value="Int">Int</option>
+ <option value="Wis">Wis</option>
+ <option value="Cha">Cha</option>
+ </select>
+ </td>
+ <td class="skillBonus">
+ <input type="text" id="bonus" name="bonus" size="2" maxlength="3"/>
+ </td>
+ <td class="skillTrained">
+ <input type="checkbox" id="trained" name="trained" value="1" />
+ </td>
+ <td class="icon">
+ <input type="hidden" name="form_key" id="form_key"
+ value="<?=$skill_form_key;?>" />
+ <input type="image" class="icon" alt="submit" title="Save Skill"
+ src="<?=MEDIA_URL;?>/images/icon_target.png" /></td>
+ </tr>
- <? $i=1; foreach($char->Skills as $s): ?>
- <tr id="s<?=$s->id;?>" class="row<?=$i;$i=($i+1)%2;?>">
- <td class="icon">
- <a href="javascript:;" class="skillEditLink" id="e<?=$s->id;?>">
- <img src="<?=MEDIA_URL;?>/images/icon_gear2.png"
- alt="edit" class="icon" /></a>
- </td>
- <td class="totalBonus"><?=$s->getMod();?></td>
- <td class="skillName"><?=$s->name;?></td>
- <td class="skillAbility">
- <span class="skillAbilityName"><?=$s->ability;?></span>
- (<?=$char->getMod($s->ability,1,1);?>)
- </td>
- <td class="skillBonus"><?=$s->bonus?$s->bonus:'';?></td>
- <td class="skillTrained"><?=$s->trained?Skill::TRAINED_BONUS:'';?></td>
- <td class="icon"><input type="image" class="icon" name="submit"
- value="delete_<?=$s->id;?>"
- src="<?=MEDIA_URL;?>/images/icon_skull-n-crossbones.png"/>
- </td>
- </tr>
- <? endforeach; ?>
- </tbody>
-</table>
+ <? $i=1; foreach($char->Skills as $s): ?>
+ <tr id="s<?=$s->id;?>" class="row<?=$i;$i=($i+1)%2;?>">
+ <td class="icon">
+ <a href="javascript:;" class="skillEditLink" id="sedit<?=$s->id;?>">
+ <img src="<?=MEDIA_URL;?>/images/icon_gear2.png" title="Edit Skill"
+ alt="edit" class="icon" /></a>
+ </td>
+ <td class="totalBonus"><?=$s->getMod();?></td>
+ <td class="skillName"><?=$s->name;?></td>
+ <td class="skillAbility">
+ <span class="skillAbilityName"><?=$s->ability;?></span>
+ (<?=$char->getMod($s->ability,1,1);?>)
+ </td>
+ <td class="skillBonus"><?=$s->bonus?$s->bonus:'';?></td>
+ <td class="skillTrained"><?=$s->trained?Skill::TRAINED_BONUS:'';?></td>
+ <td class="icon"><input type="image" class="icon" name="submit"
+ value="delete_<?=$s->id;?>" title="Delete Skill"
+ src="<?=MEDIA_URL;?>/images/icon_skull-n-crossbones.png"/>
+ </td>
+ </tr>
+ <? endforeach; ?>
+ </tbody>
+ </table>
+ </form>
+</div>
+
+<div>
+<form method="post" id="FeatForm"
+ action="<?=SITE_URL;?>/<?=$char->id;?>/feats/save">
+ <div class="formRow">
+ <label for="feat_name">Name:</label>
+ <div class="field">
+ <input type="hidden" name="f_id" id="feat_id" />
+ <input type="text" class="text" name="name" id="feat_name" /></div>
+ </div>
+ <div class="formRow">
+ <label for="feat_description">Description:</label>
+ <div class="field"><textarea name="description" id="feat_description"
+ rows="7" cols="20"></textarea></div>
+ </div>
+ <div class="formRow">
+ <label>&nbsp;</label>
+ <div class="field"><input type="submit" value="Submit" /></div>
+ </div>
</form>
+<form method="post" action="<?=SITE_URL;?>/<?=$char->id;?>/feats/delete">
+ <div id="FeatDiv">
+ <table id="FeatTable" class="rowBorder">
+ <thead>
+ <tr class="row0">
+ <td class="icon"><a id="NewFeatButton" href="javascript:;"
+ title="New Feat"><img class="icon" alt="new"
+ src="<?=MEDIA_URL;?>/images/icon_medical.png" /></a>
+ </td>
+ <th>Feats</th>
+ </tr>
+ </thead>
+ <tbody>
+ <? $i=1; foreach($char->Feats as $f): ?>
+ <tr id="f<?=$f->id;?>" class="row<?=$i;$i=($i+1)%2;?>">
+ <td class="icon">
+ <a href="javascript:;" class="featEditLink" id="fedit<?=$f->id;?>">
+ <img src="<?=MEDIA_URL;?>/images/icon_gear2.png"
+ title="Edit Feat" alt="edit" class="icon" /></a>
+ </td>
+ <td class="featName"><?=$f->name;?></td>
+ <td class="icon">
+ <input type="image" class="icon feat_delete" name="submit"
+ value="delete_<?=$f->id;?>" alt="delete" title="Delete Feat"
+ src="<?=MEDIA_URL;?>/images/icon_skull-n-crossbones.png" /></td>
+ <td class="icon featDescription">
+ <img title="<?=$f->description;?>" class="icon feat_view" alt="view"
+ src="<?=MEDIA_URL;?>/images/icon_magnifying-glass.png" />
+ </td>
+ </tr>
+ <? endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+</div>
<?php include('footer.php'); ?>
1  includes/inc/globals.master.php
View
@@ -13,6 +13,7 @@
Doctrine::getTable('Power')->setAttribute(Doctrine::ATTR_COLL_KEY,'id');
Doctrine::getTable('Keyword')->setAttribute(Doctrine::ATTR_COLL_KEY,'id');
Doctrine::getTable('Skill')->setAttribute(Doctrine::ATTR_COLL_KEY,'name');
+Doctrine::getTable('Feat')->setAttribute(Doctrine::ATTR_COLL_KEY,'id');
/**#@+
* Constants
42 includes/models/Feat.php
View
@@ -10,7 +10,45 @@
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 5845 2009-06-09 07:36:57Z jwage $
*/
-class Feat extends BaseFeat
-{
+class Feat extends BaseFeat {
+
+ public function updateFromForm() {
+ global $msg;
+ $cache = array();
+ $cache['error'] = array();
+
+ // Skill Name
+ $cache['name'] = $_POST['name'];
+ if( empty($_POST['name']) ) {
+ $msg->add('Feat name may not be blank.', Message::WARNING);
+ $cache['error'][] = 'name';
+ }
+ else {
+ $this->name = $_POST['name'];
+ }
+
+ // Feat Description
+ $cache['description'] = $_POST['description'];
+ if( empty($_POST['description']) ) {
+ $msg->add('Feat description may not be blank.', Message::WARNING);
+ $cache['error'][] = 'description';
+ }
+ else {
+ $this->description = $_POST['description'];
+ }
+ // End Model Data Updates
+
+ // Update the form cache in the session if necessary.
+ if( !empty($_POST['form_key']) ) {
+ if( empty($cache['error']) ) {
+ unset($_SESSION[$_POST['form_key']]);
+ }
+ else {
+ $cache['form_key'] = $_POST['form_key'];
+ $_SESSION['form_cache'] = $cache;
+ }
+ }
+ return empty($cache['error']);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.