|
| 1 | +<html><head> |
| 2 | +<meta content="text/html; charset=UTF-8" http-equiv="content-type"> |
| 3 | +<title>Book Review HTML</title> |
| 4 | +<LINK href="stylesheets/wrap.css" rel="stylesheet" type="text/css"> |
| 5 | +<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> |
| 6 | +<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js" type="text/javascript"></script> |
| 7 | +<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js" type="text/javascript"></script> |
| 8 | +<script src="javascripts/wrap.js" type="text/javascript"></script> |
| 9 | +<script src="javascripts/link-index.js" type="text/javascript"></script> |
| 10 | +<script src="javascripts/register-links.js" type="text/javascript"></script> |
| 11 | +<script src="javascripts/jquery.selectOnFocus.js" type="text/javascript"></script> |
| 12 | + |
| 13 | + |
| 14 | +<script type="text/javascript">//<![CDATA[ |
| 15 | +$(document).ready(function(){ |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + $('#form').submit(function(){ |
| 20 | + var $this = $(this); |
| 21 | + $this.validate(); |
| 22 | + return false; |
| 23 | + }); |
| 24 | + |
| 25 | + var getRemote = function () { |
| 26 | + // var baseUrl = 'http://localhost:8888/redirectedurl?'; |
| 27 | + var baseUrl = 'http://redirectedurl.appspot.com/redirectedurl?'; |
| 28 | + var asin = $('#asin').val().trim().replace(/[_\s]/g, ''); |
| 29 | + console.log('asin ' + asin); |
| 30 | + var imageUrl = 'http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=' + asin + '&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1'; |
| 31 | + console.log(imageUrl); |
| 32 | + $.ajax({ |
| 33 | + type: "GET", |
| 34 | + dataType: "jsonp", |
| 35 | + jsonpCallback: 'jsonCallback', |
| 36 | + url: baseUrl + 'url=' + encodeURIComponent(imageUrl), |
| 37 | + contentType: "application/json; charset=utf-8", |
| 38 | + async: false, |
| 39 | + error:jsonCallback, |
| 40 | + success:jsonCallback |
| 41 | + }); |
| 42 | + }; |
| 43 | + |
| 44 | + var jsonCallback = function (data) { |
| 45 | + console.log('success: ' + data.url); |
| 46 | + var imageLink = wrapItem({ |
| 47 | + elementSelector: '#title', |
| 48 | + linkSelector: '#asin', |
| 49 | + tagSelector:'#amazon-tag', |
| 50 | + creator: createAmazonImageTag, |
| 51 | + useAllText: true, |
| 52 | + finalImageUrl: data.url |
| 53 | + }); |
| 54 | + |
| 55 | + var authorText = wrapItem({ |
| 56 | + elementSelector: '#author', |
| 57 | + creator: createTag, |
| 58 | + openTag: '<p><strong>(By: ', |
| 59 | + closeTag: ' )</strong></p>', |
| 60 | + useAllText: true |
| 61 | + }); |
| 62 | + |
| 63 | + var review = wrapItem({ |
| 64 | + elementSelector: '#fulltext', |
| 65 | + creator: createTag, |
| 66 | + openTag: '<p>', |
| 67 | + closeTag: '</p>', |
| 68 | + useAllText: true |
| 69 | + }); |
| 70 | + if(imageLink && authorText && review) { |
| 71 | + var html = imageLink + authorText + review; |
| 72 | + $('#showtext').val( html); |
| 73 | + $('#preview').html(html); |
| 74 | + $('#imageUrl').val(data.url); |
| 75 | + } |
| 76 | + }; |
| 77 | + |
| 78 | + $('#wrap').click(function () { |
| 79 | + |
| 80 | + getRemote(); |
| 81 | + |
| 82 | + }); |
| 83 | + |
| 84 | + $("#showtext").selectOnFocus(); |
| 85 | + $("#imageUrl").selectOnFocus(); |
| 86 | + |
| 87 | +});//]]> |
| 88 | + |
| 89 | +</script> |
| 90 | + |
| 91 | + |
| 92 | +</head> |
| 93 | +<body> |
| 94 | +<form id="form"> |
| 95 | +<div class="container"> |
| 96 | +<ul class='index'></ul> |
| 97 | +<p> <h2>Book Review</h2></p> |
| 98 | +<p> Use this page to format amazon book review related articles only.</p> |
| 99 | +<div class="left"> |
| 100 | +<input type="text" id="title" value="" placeholder="Enter Book Title" required> |
| 101 | +<input type="text" id="author" value="" placeholder="Enter Book Author Name(s)" required> |
| 102 | +<input type="text" id="asin" value="" placeholder="Enter Amazon ASIN Number" required> |
| 103 | +<input type="text" id="amazon-tag" value="top-books-cs-20" style="display:none;" required> |
| 104 | +<textarea id="fulltext" value="" placeholder="Enter the Review Content Here" required></textarea> |
| 105 | +</div> |
| 106 | +<div class="center"> |
| 107 | +<div id="log"></div> |
| 108 | +<button type="submit" id="wrap">Create HTML</button> |
| 109 | +</div> |
| 110 | +<div class="right"> |
| 111 | +<textarea id="showtext"></textarea> |
| 112 | +<input id="imageUrl" type="text" style="width:100%;"/> |
| 113 | +</div > |
| 114 | +</div> |
| 115 | +<div id="preview" style="margin:5px;">Preview Area</div> |
| 116 | +</form> |
| 117 | +</body></html> |
0 commit comments