<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<style>
*{
user-select: none;
user-select: none;
user-select: none;
user-select: none;
}
#popup{
display:none;
z-index: 9002;
max-height:400px;
overflow:hidden;
position:absolute;
top:10px;
left:10px;
border-radius:5px;
border:1px solid white;
background-color:white;
}
#popup_title{
border-bottom:1px solid black;
color:white;
font-weight:bold;
text-align:center;
border-radius:5px 5px 0px 0px;
background: #1e5799; /* Old browsers */
background: linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
background: gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */
background: linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */
background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */
}
#popup *{
padding:5px;
}
#popup ul{
list-style:none;
padding:0px;
margin:0px;
width:200px;
overflow:hidden;
}
#popup li{
padding:10px;
border-bottom:1px solid silver;
}
#popup ul li{
text-indent:10px;
}
#mask {
background-color:rgba(0,0,0,0.5);
position:absolute;
z-index: 9001;
top:0px;
left:0px;
width:100%;
height:100%;
display:none;
}
</style>
<body>
<div id="mask">
<div id="popup">
</div>
</div>
<button onclick="list()">show list</button>
</body>
</html>
function show_list(title,list,callback) {
var ul = document.createElement("ul");
var popup = document.getElementById('popup');
var maskDiv = document.getElementById('mask');
while( popup.hasChildNodes() ){
popup.removeChild(popup.lastChild);
}
popup.innerHTML = '<div id="popup_title">'+title+'</div>';
for(var i = 0;i<list.length;i++){
var li = document.createElement("li");
li.appendChild(document.createTextNode(list[i]));
var value = list[i];
li.onclick = function(value) {
popup.style.display="none";
maskDiv.style.display = "none";
callback(value.target.childNodes[0].nodeValue);
};
ul.appendChild(li);
}
popup.appendChild(ul);
maskDiv.style.display = 'block';
popup.style.display = 'block';
popup.style.top = ((window.innerHeight/2) - (popup.offsetHeight/2))+'px';
popup.style.left = ((window.innerWidth/2) - (popup.offsetWidth/2))+'px';
}
function list(){
var items = ["option1","option2"];
show_list('Select a option',items,function(value){
alert(value);
});
}
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |