dynamic-html: make sure clicking on return type works

This commit is contained in:
Josh Ponelat
2015-05-15 09:10:03 +02:00
parent 0248d6fd9f
commit 3544136ab1
6 changed files with 29 additions and 39 deletions

View File

@@ -1,13 +1,8 @@
function main() {}
window.onhashchange = function() { window.onhashchange = function() {
choose(window.location.href.toString()); choose(window.location.href.toString());
} }
var url = 'http://motyar.blogspot.com/search?q={term}', selectionImage; var selectionImage;
function showModel(e, model) {
}
function choose(url) { function choose(url) {
var f = url.split("/").slice(-1)[0].split("?")[0]; var f = url.split("/").slice(-1)[0].split("?")[0];
@@ -20,8 +15,8 @@ function choose(url) {
// rebind the models // rebind the models
$(".model a").on("click", function(e){ $(".model a").on("click", function(e){
e.preventDefault(); e.preventDefault();
var model = $(this).parent().attr("id") var model = $(this).parent().attr("data-model")
var parentOffset = $(this).parent().offset(); var parentOffset = $(this).parent().offset();
var encodedWord = encodeURI(model); var encodedWord = encodeURI(model);
if(!selectionImage) { if(!selectionImage) {
@@ -33,7 +28,7 @@ function choose(url) {
$('div.model-container').append(selectionImage); $('div.model-container').append(selectionImage);
} }
selectionImage.load("/models/" + encodedWord + ".html") selectionImage.load("models/" + encodedWord + ".html")
selectionImage.attr('href',url.replace('{term}',encodeURI(model))).css({ selectionImage.attr('href',url.replace('{term}',encodeURI(model))).css({
left: e.pageX + 20, left: e.pageX + 20,
top: e.pageY - 10, top: e.pageY - 10,

View File

@@ -13,7 +13,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>{{httpMethod}}</code> <code>{{httpMethod}}</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="{{returnBaseType}}"><a href="#">{{returnType}}</a></div> <div class="model" data-model="{{returnBaseType}}"><a href="">{{returnType}}</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
{{#allParams}} {{#allParams}}

View File

@@ -1,13 +1,8 @@
function main() {}
window.onhashchange = function() { window.onhashchange = function() {
choose(window.location.href.toString()); choose(window.location.href.toString());
} }
var url = 'http://motyar.blogspot.com/search?q={term}', selectionImage; var selectionImage;
function showModel(e, model) {
}
function choose(url) { function choose(url) {
var f = url.split("/").slice(-1)[0].split("?")[0]; var f = url.split("/").slice(-1)[0].split("?")[0];
@@ -20,8 +15,8 @@ function choose(url) {
// rebind the models // rebind the models
$(".model a").on("click", function(e){ $(".model a").on("click", function(e){
e.preventDefault(); e.preventDefault();
var model = $(this).parent().attr("id") var model = $(this).parent().attr("data-model")
var parentOffset = $(this).parent().offset(); var parentOffset = $(this).parent().offset();
var encodedWord = encodeURI(model); var encodedWord = encodeURI(model);
if(!selectionImage) { if(!selectionImage) {
@@ -33,7 +28,7 @@ function choose(url) {
$('div.model-container').append(selectionImage); $('div.model-container').append(selectionImage);
} }
selectionImage.load("/models/" + encodedWord + ".html") selectionImage.load("models/" + encodedWord + ".html")
selectionImage.attr('href',url.replace('{term}',encodeURI(model))).css({ selectionImage.attr('href',url.replace('{term}',encodeURI(model))).css({
left: e.pageX + 20, left: e.pageX + 20,
top: e.pageY - 10, top: e.pageY - 10,

View File

@@ -13,7 +13,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>PUT</code> <code>PUT</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -36,7 +36,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -59,7 +59,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="Pet"><a href="#">List</a></div> <div class="model" data-model="Pet"><a href="">List</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -82,7 +82,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="Pet"><a href="#">List</a></div> <div class="model" data-model="Pet"><a href="">List</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -105,7 +105,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="Pet"><a href="#">Pet</a></div> <div class="model" data-model="Pet"><a href="">Pet</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -128,7 +128,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -167,7 +167,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>DELETE</code> <code>DELETE</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -198,7 +198,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>

View File

@@ -13,7 +13,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="integer"><a href="#">Map</a></div> <div class="model" data-model="integer"><a href="">Map</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -28,7 +28,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="Order"><a href="#">Order</a></div> <div class="model" data-model="Order"><a href="">Order</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -51,7 +51,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="Order"><a href="#">Order</a></div> <div class="model" data-model="Order"><a href="">Order</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -74,7 +74,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>DELETE</code> <code>DELETE</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>

View File

@@ -13,7 +13,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -36,7 +36,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -62,7 +62,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>POST</code> <code>POST</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -88,7 +88,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="string"><a href="#">String</a></div> <div class="model" data-model="string"><a href="">String</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -119,7 +119,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -134,7 +134,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>GET</code> <code>GET</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id="User"><a href="#">User</a></div> <div class="model" data-model="User"><a href="">User</a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -157,7 +157,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>PUT</code> <code>PUT</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>
@@ -188,7 +188,7 @@
<h3 class="section">HTTP Method</h3> <h3 class="section">HTTP Method</h3>
<code>DELETE</code> <code>DELETE</code>
<h3 class="section">Response Type</h3> <h3 class="section">Response Type</h3>
<div class="model" id=""><a href="#"></a></div> <div class="model" data-model=""><a href=""></a></div>
<h3 class="section">Parameters</h3> <h3 class="section">Parameters</h3>
<ul> <ul>