(function ($) {
// first Run get t/l rooms from LS
getTotalRooms(); // how many rooms from LS
runRooms(); // less or more options
$(".pop").each(function() {
var $pElem= $(this);
$pElem.popover(
{
title: getPopTitle($pElem.attr("id")),
content: getPopContent($pElem.attr("id")),
trigger: 'click',
}
);
}).click(function() {
$(this).popover('toggle');
runRooms(); // less or more options
SetCorrectddlVals();// show num ppl in rooms
});;
// CONTENT AND TITLE FILL
function getPopTitle(target) {
return $("#" + target + "_content > div.popTitle").html();
};
function getPopContent(target) {
var $popContent = $("#" + target + "_content > div.popContent").html();
runRooms(); // less or more options
return $popContent;
};
// FNs
function getTotalRooms() {
if (!localStorage.getItem("rmCnt")) {
localStorage.setItem('rmCnt', 'room-1=1');
$("#num-adults option[value='" + count.length + "']").attr("selected", "selected");
} else {
var string = localStorage.getItem("rmCnt");
var count = string.split("&"); // for the room ddl
// preSelect the # rooms from LS length
} // end localCheck
$("#num-adults option[value='" + count.length + "']").attr("selected", "selected");
}
function SetCorrectddlVals(){
var string = localStorage.getItem("rmCnt");
var count = string.split("&");
$.each(count, function (ele, i) {
var id = this.split("=")[0];
var cnt = this.split("=")[1];
$(".popover #" + id + " option[value='" + cnt + "']").prop("selected", "selected");
});
}//
// DDLs
/*---------------------------------------------------
DDL changes both setting string : PREPARE THE ROOM LISTS
----------------------------------------------------*/
$(document).on('change', '#num-adults', function (elem, i) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.