Skip to content

Commit

Permalink
Revert "Merge pull request #152 from Zelda-Universe/feature/hide-ads-…
Browse files Browse the repository at this point in the history
…for-authenticated-users"

This reverts commit cdbf2a6, reversing
changes made to ea80671.
  • Loading branch information
Jason Rappaport committed Jul 19, 2018
1 parent cdbf2a6 commit f0cb091
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
60 changes: 39 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,47 @@
</head>
<body>
<div id="map">
<div id="mobileAds" class="hidden">
<div id="mobileAds" align="center">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Zelda Maps -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7269573247649351"
data-ad-slot="4512666333"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- Zelda Maps -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7269573247649351"
data-ad-slot="4512666333"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div id="desktopAds" class="hidden">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Zelda Maps -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7269573247649351"
data-ad-slot="4512666333"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<div id="desktopAds" align="center">
<script>
var width = $(document).width();
var adsWidth = 0;
var adsHeight = 0;
if (width > 728) {
adsWidth = 728;
adsHeight = 90;
} else if (width > 468) {
adsWidth = 468;
adsHeight = 60;
} else {
adsWidth = 234;
adsHeight = 60;
}

document.getElementById('desktopAds').style.width = adsWidth + 'px';
document.getElementById('desktopAds').style.height = adsHeight + 'px';
</script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Zelda Maps -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7269573247649351"
data-ad-slot="4512666333"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>

Expand Down
13 changes: 3 additions & 10 deletions scripts/zmain.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ function getMaps() {

function getUserInfo() {
$.getJSON("ajax.php?command=get_user_info", function(vResults) {
if(vResults.user) zMap.setUser(vResults.user);
updateAdState();
if(vResults.user) {
zMap.setUser(vResults.user);
}
checkChangelog(vResults.user);
});
};
Expand Down Expand Up @@ -282,11 +283,3 @@ function parseBounds(input) {

return bounds;
};

function updateAdState() {
var authenticated = !!user;
var mobileAds = document.getElementById("mobileAds");
if(mobileAds) $(mobileAds).toggleClass("hidden", (!mapControl.isMobile() || authenticated));
var desktopAds = document.getElementById("desktopAds");
if(desktopAds) $(desktopAds).toggleClass("hidden", (mapControl.isMobile() || authenticated));
};
11 changes: 8 additions & 3 deletions scripts/zmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ ZMap.prototype.buildMap = function() {
L.control.infoBox.location.bounds({ position: 'bottomleft' }).addTo(map);
}
}

//@TODO: REDO!
mapControl.setCurrentMap(19, 1900);
mapControl.addTo(map);
Expand Down Expand Up @@ -687,6 +686,14 @@ ZMap.prototype.buildMap = function() {
});

_this._buildContextMenu();

if (!mapControl.isMobile()) {
var mobileAds = document.getElementById("mobileAds");
if(mobileAds) mobileAds.style.display = 'none';
} else {
var desktopAds = document.getElementById("desktopAds");
if(desktopAds) desktopAds.style.display = 'none';
}
};

ZMap.prototype.setUser = function(vUser) {
Expand Down Expand Up @@ -1414,7 +1421,6 @@ ZMap.prototype.logout = function() {
if (data.success) {
toastr.success(_this.langMsgs.LOGOUT_SUCCESS.format(user.username));
user = null;
updateAdState();
_this._buildContextMenu();
mapControl.resetContent();
showLoginControls();
Expand Down Expand Up @@ -1641,7 +1647,6 @@ ZMap.prototype._createLoginForm = function() {
if (data.success) {
checkChangelog(data.user);
_this.setUser(data.user);
updateAdState();
toastr.success(_this.langMsgs.LOGIN_SUCCESS.format(user.username));
mapControl.resetContent();
} else {
Expand Down
8 changes: 0 additions & 8 deletions styles/zmain.css
Original file line number Diff line number Diff line change
Expand Up @@ -927,14 +927,6 @@ a.icon-close2 {
left: 50%;
transform: translateX(-50%);
overflow: hidden;
width: 728px;
}

@media only screen and (max-width: 728px) {
#desktopAds { width: 468px; height: 60px; }
}
@media only screen and (max-width: 468px) {
#desktopAds { width: 234px; height: 60px; }
}

/*** General Drawer Stuff ***/
Expand Down

0 comments on commit f0cb091

Please sign in to comment.