Skip to content

Commit

Permalink
possible to add share custom clientid through URL
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryDEV committed Jun 23, 2017
1 parent c04929c commit 99e67a3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
22 changes: 17 additions & 5 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ function checkIfStock() {
}
}

function setUrl(pid, region) {
var region = adidasRegions[region].countryCode;
var parameters = '?pid=' + pid + '&region=' + region;
function setUrl(pid, region, clientId) {
var region = adidasRegions[region];
var parameters = '?pid=' + pid + '&region=' + region.countryCode;

if (clientId != region.clientIds[0]) {
parameters += '&clientid=' + clientId;
}

window.history.pushState('query', pid, parameters);
}

Expand All @@ -262,20 +267,27 @@ function loadUrl() {

var pid = gup('pid', location.href);
var region = gup('region', location.href);
var clientid = gup('clientid', location.href);

if (pid != null && region != null) {
var adiRegion;
for (var r in adidasRegions) {
if (adidasRegions[r].countryCode == region) {
adiRegion = r;
$('#stockRegion').val(r);
$('#clientId').val(adidasRegions[r].clientIds[0]);
if (clientid == null) {
$('#clientId').val(adidasRegions[r].clientIds[0]);
}
break;
}
}

$('#productId').val(pid);
}

if (clientid != null) {
$('#clientId').val(clientid);
}
}

$(function () {
Expand All @@ -289,7 +301,7 @@ $(function () {
$('form.st').submit(function (e) {
e.preventDefault();

setUrl($('#productId').val(), $('#stockRegion').val());
setUrl($('#productId').val(), $('#stockRegion').val(), $('#clientId').val());
ga('send', 'event', {
'eventCategory': 'Stock',
'eventAction': 'Searched',
Expand Down
6 changes: 6 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ span.show {
padding: 16px;
}

.partner {
margin-top: 24px;
width: 100%;
height: auto;
}

@media all and (max-width: 500px) {
.stock-block {
width: 31%;
Expand Down
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ <h1>YZY.IO
</div>
</div>
</div>

<div class="partner">
part
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- YZY.io -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-2749579258515528"
data-ad-slot="5623085414"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</div>
<!--<div class="footer">-->
Expand Down

0 comments on commit 99e67a3

Please sign in to comment.