changed storage system to be less obstusive (it doesnt need redirects anymore...)

This commit is contained in:
phil 2013-07-03 07:55:15 +02:00
parent f8ae5fc4c9
commit f483a9ac55
8 changed files with 213 additions and 162 deletions

View file

@ -59,8 +59,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"ability1": { "title": "Ability 1 name", "description": "Ability 1 description" },
"ability2": { "title": "Ability 2 name", "description": "Ability 2 description" },
@ -74,6 +78,6 @@ categories: [ Character-Sheet ]
"ability10": { "title": "", "description": "" },
"ability11": { "title": "", "description": "" },
"ability12": { "title": "", "description": "" }
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -55,8 +55,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"benefit1": { "title": "Common Feats", "description": "Boost Non-Attack Skill Roll - Heroic Dodge - Make a Quick Action - Parry - Relentless Charge - Reroll Failed Attack/Skill/Willpower roll - Run and Gun - Shake Continuous Effect - Shake Knockdown - Shake Stationary - Sprint - Two-Fister - Walk it Off" },
"benefit2": { "title": "Benefit/Feat name", "description": "Benefit/Feat description" },
@ -69,6 +73,6 @@ categories: [ Character-Sheet ]
"benefit9": { "title": "", "description": "" },
"benefit10": { "title": "", "description": "" },
"benefit11": { "title": "", "description": "" }
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -103,8 +103,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"gear1": { "title": "Gear 1", "benefit": "Benefit 1" },
"gear2": { "title": "Gear 2", "benefit": "Benefit 2" },
@ -129,6 +133,6 @@ categories: [ Character-Sheet ]
"gear21": { "title": "", "benefit": "" },
"gear22": { "title": "", "benefit": "" },
"gear23": { "title": "", "benefit": "" }
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -59,8 +59,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"note1": { "title": "Permanent Injuries", "text": "None" },
"note2": { "title": "Spoken Languages", "text": "" },
@ -74,6 +78,6 @@ categories: [ Character-Sheet ]
"note10": { "title": "", "text": "" },
"note11": { "title": "", "text": "" },
"note12": { "title": "", "text": "" }
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -158,8 +158,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"s1": { "title": "Skill 1 name", "stat": "", "base": "", "lvl": "", "sum": "" },
"s2": { "title": "Skill 2 name", "stat": "", "base": "", "lvl": "", "sum": "" },
@ -182,6 +186,6 @@ categories: [ Character-Sheet ]
"s19": { "title": "", "stat": "", "base": "", "lvl": "", "sum": "" },
"s20": { "title": "", "stat": "", "base": "", "lvl": "", "sum": "" },
"s21": { "title": "", "stat": "", "base": "", "lvl": "", "sum": "" }
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -121,8 +121,12 @@ categories: [ Character-Sheet ]
</div>
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"spell1": { "title": "Spell 1", "cost": 0, "rng": 0, "aoe": "-", "pow": 0, "up": "NO", "off": "YES", "description": "Spell 1 description" },
"spell2": { "title": "Spell 2", "cost": 0, "rng": 0, "aoe": "-", "pow": 0, "up": "NO", "off": "YES", "description": "Spell 2 description" },
@ -135,6 +139,6 @@ categories: [ Character-Sheet ]
"spell9": { "title": "", "cost": "", "rng": "", "aoe": "", "pow": "", "up": "", "off": "", "description": "" },
"spell10": { "title": "", "cost": "", "rng": "", "aoe": "", "pow": "", "up": "", "off": "", "description": "" },
"spell11": { "title": "", "cost": "", "rng": "", "aoe": "", "pow": "", "up": "", "off": "", "description": "" },
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -87,8 +87,12 @@ categories: [ Character-Sheet ]
<input id="xp" type="text" />
</form>
</div>
<p>
<a href="javascript:hero.url();">Store inserted data in URL</a>
</p>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>
<script type="text/javascript">
var Hero = {
var hero = new Heroic({
"name": "Hero's name",
"archetype": "Archetype",
"race": "Race",
@ -125,6 +129,6 @@ categories: [ Character-Sheet ]
"r1m2": false,
"r2": false,
"m2": false
};
});
hero.bind();
</script>
<script type="text/javascript" src="/static/javascripts/heroic.js"></script>

View file

@ -1,3 +1,20 @@
function Heroic(Hero) {
var self = this;
self.search = "";
self.url = function() {
//var root = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
document.location.search = self.search;
//return root+"?"+self.search;
};
self.redirect = function(link) {
link.href = self.url();
link.click();
//var sheet = document.querySelector("div.sheet");
//var parent = sheet.parentNode;
//var content = parent.innerHTML;
//parent.innerHTML = content+'<a href="'+self.url()+'">Link to this sheet</a>';
};
self.bind = function() {
var query = window.location.search;
var Query = (query == "") ? {} : JSON.parse(unescape(query.substring(1)));
@ -32,7 +49,9 @@ var autoresizableTextarea = function(textarea) {
};
var redirect = function() {
document.location.search = encodeURIComponent(JSON.stringify(Hero));
//document.location.search = encodeURIComponent(JSON.stringify(Hero));
self.search = encodeURIComponent(JSON.stringify(Hero));
console.log(self.search);
};
var switchWeapons = function() {
@ -144,6 +163,10 @@ var initialize = function() {
var names = document.querySelectorAll("section > input.name");
for (name in names) { names[name].value = Hero["name"]; }
redirect();
};
document.addEventListener("DOMContentLoaded", initialize, false);
};
}