(function() {
'use strict';
var campname = ('.header-location').text;
$(document).bind('keydown', function(e) {
if (e.keyCode == 82) {
// press the letter R
window.location.href='ServletCharacterControl?type=createCampsite&name=camp';
}
return false;
});
})();
<div class="header-location above-page-popup">
<a href="#"style="font-size: 10px;">
Aera Countryside
</a>
</div>
var helloWorld = function() {
console.log("Hello world!");
}
// creates a popup with HTML content
var mkPopup = function(content) {
// close all other popups, increment popup counter
closePagePopup();
currentPopupStackIndex++;
exitFullscreenChat();
var pagePopupId = "page-popup" + currentPopupStackIndex;
//No elements have z-index on the combat screen, so we
//cant have page-popup-glass there because it relies on
//z-index to not cover everything
var structure = "<div id='"+pagePopupId+"'><div id='" +
pagePopupId+"-content' style='min-height:150px;' " +
"class='page-popup'><img id='banner-loading-icon' " +
"src='javascript/images/wait.gif' border=0/></div>" +
"<div class='page-popup-glass'></div><a class='page-popup-X' " +
"onclick='closePagePopup()'>X</a></div>";
// checks if current page is doesn't have #page-popup-root
// and adds the needed div if it is
if ($("#page-popup-root").length == 0) {
$('<div id="page-popup-root"></div>').insertAfter(".chat_box");
}
//Create popup
$("#page-popup-root").append(structure);
//If chat box doesnt have z index, remove glass box
if( $(".chat_box").css('z-index') != '1000100') {
$(".page-popup-glass").remove();
}
//Fill popup with content
$("#"+pagePopupId+"-content").html(content);
// pressing escape will close the popup
if (currentPopupStackIndex === 1) {
$(document).bind("keydown",function(e) {
if ((e.keyCode == 27)) {
closePagePopup();
}
});
}
// hides previous popup if there was one
if (currentPopupStackIndex > 1) {
$("#page-popup" + (currentPopupStackIndex-1)).hide();
}
};
function pagePopup(url)
{
if (url.indexOf("?")>0)
url+="&ajax=true";
else
url+="?ajax=true";
exitFullscreenChat();
var stackIndex = incrementStackIndex();
var pagePopupId = "page-popup"+stackIndex;
$("#page-popup-root").append("<div id='"+pagePopupId+"' class='page-popup'><div id='"+pagePopupId+"-content' src='"+url+"'><img id='banner-loading-icon' src='javascript/images/wait.gif' border=0/></div></div>");
$("#"+pagePopupId+"-content").load(url);
}
just finished the better call saul finale... anyways about the popups
There are two main reasons to use a pagePopup instead of a promptPopup
1.) A prompt is using for yes or no questions or submit / cancel but it's not particularly necessary in this case
2.) The code of the game uses pagePopups for almost everything and the only thing it uses a prompt for is this one scenario
```(function() {
'use strict';
var name = function() {
$('.header-location a').text();
};
$(document).bind('keydown', function(e) {
if (e.keyCode == 82) {
// press the letter R
window.location.href='ServletCharacterControl?type=createCampsite&name=' + name;
}
return false;
});
})();```
```javascript
code
```
```javascript (function() {
'use strict';
var name = function() {
$('.header-location a').text();
};
$(document).bind('keydown', function(e) {
if (e.keyCode == 82) {
// press the letter R
window.location.href='ServletCharacterControl?type=createCampsite&name=' + name;
}
return false;
});
})();```
(function() {
'use strict';
var name = function() {
$('.header-location a').text();
};
$(document).bind('keydown', function(e) {
if (e.keyCode == 82) {
// press the letter R
window.location.href='ServletCharacterControl?type=createCampsite&name=' + name;
}
return false;
});
})();
var name = function() {
$( '.header-location a').text();
};
console.log(name();)
console returned: "";
$('#lightbox').live('click', function() {
$('#lightbox').hide();
});
var duckArray = ['duck', 'duck', 'duck', 'goose', 'duck'];
var uniqFowl = duckArray.sort()
.reduce(function(a, b) {
if (a === b) {
return a;
} else {
return a + ',' + b;
}
}).split(',');
console.log(uniqFowl);
function storeSellItem(itemId)
{
promptPopup("Sell Item", "How much do you want to sell this item for?", "0", function(confirm){
window.location.href="ServletCharacterControl?type=storeSellItem&itemId="+itemId+"&amount="+confirm;
});
}
oh it appears for my previous problem that filter is what you use instead of reduce
var duckArray = ['duck', 'duck', 'duck', 'goose', 'duck', 'duck', 'goose', 'swan'];
var uniqFowl = duckArray.sort().filter(function(entry, i, array) {
if (!i) {
return true;
}
return entry != array[i - 1];
})
console.log(uniqFowl);
returns ["duck", "goose", "swan"]
var duckArray = ['duck', 'duck', 'duck', 'goose', 'duck', 'duck', 'goose', 'swan'];
var uniqFowl = duckArray.sort().filter(function(entry, i, array) {
// true if i is 0, or entry is not a duplicate of the previous value
return !i || entry != array[i - 1];
})
console.log(uniqFowl);