Implemented hash link for each expression

This commit is contained in:
Borys Levytskyi
2015-04-12 22:04:34 +03:00
parent 057db296a5
commit d9e2173e5e
4 changed files with 23 additions and 4 deletions

View File

@@ -9,6 +9,8 @@ code { font-size: 1.2em; font-weight: bold; }
.result .input { margin-bottom: 10px; } .result .input { margin-bottom: 10px; }
.result .content { padding-left: 10px} .result .content { padding-left: 10px}
.result .cur { color: lightgray; margin-right: 5px; } .result .cur { color: lightgray; margin-right: 5px; }
.hashLink { text-decoration: none; margin-left: 5px; }
.hashLink:hover { text-decoration: underline; margin-left: 5px; }
.expression .label { font-weight: bold; padding-right: 5px; text-align: right; } .expression .label { font-weight: bold; padding-right: 5px; text-align: right; }
.expression .bin { letter-spacing: 3px; } .expression .bin { letter-spacing: 3px; }
@@ -38,6 +40,9 @@ code { font-size: 1.2em; font-weight: bold; }
.light .on { color: #121212; } .light .on { color: #121212; }
.light .prefix { color: #888} .light .prefix { color: #888}
.light .other { color: #bbb } .light .other { color: #bbb }
.light .hashLink, .light .hashLink:visited { color: #ddd }
.light .hashLink:hover { color: #888 }
/* Dark */ /* Dark */
.dark { background: #121212; color: white;} .dark { background: #121212; color: white;}
@@ -48,5 +53,6 @@ code { font-size: 1.2em; font-weight: bold; }
.dark .zero { color: #999;} .dark .zero { color: #999;}
.dark .prefix { color: #999} .dark .prefix { color: #999}
.dark .other { color: #444;} .dark .other { color: #444;}
.dark .hashLink, .dark .hashLink:visited { color: #333 }
.dark .hashLink:hover { color: #999 }

View File

@@ -116,9 +116,9 @@
</div> </div>
</script> </script>
<script data-template="resultView" type="text/template"> <script data-template="resultView" data-compiled="" type="text/template">
<div class="result"> <div class="result">
<div class="input mono"><span class="cur">&gt;</span>{input}</div> <div class="input mono"><span class="cur">&gt;</span>{m.input}<a class="hashLink" title="Link for this expression" href="{window.location.pathname}#{m.inputHash}">#</a></div>
<div class="content"></div> <div class="content"></div>
</div> </div>
</script> </script>
@@ -199,7 +199,8 @@
cmd.execute('help'); cmd.execute('help');
if(window.location.hash.length > 1) { if(window.location.hash.length > 1) {
cmd.execute(window.location.hash.substr(1).replace(/,/g,' '));
cmd.execute(app.get('hash').decodeHash(window.location.hash));
} }
else { else {

View File

@@ -27,6 +27,7 @@
function DisplayResult (input, content) { function DisplayResult (input, content) {
this.input = input; this.input = input;
this.inputHash = app.get('hash').encodeHash(input);
this.content = content; this.content = content;
} }

View File

@@ -6,4 +6,15 @@
app.set('should', core.should); app.set('should', core.should);
app.set('bindr', core.bindr); app.set('bindr', core.bindr);
app.set('hash', function () {
return {
encodeHash: function(string) {
return encodeURI(string.trim()).replace(/\s/g,',');
},
decodeHash: function(hashValue) {
return decodeURI(hashValue).replace(/^\#/, '').replace(/,/g,' ');
}
}
})
})(window.app, window.core); })(window.app, window.core);