<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
a .invisible {
font-size: 0;
line-height: 0;
}
</style>
</head>
<body>
<h3>標準設定</h3>
<ul class="normal">
<li><a href="http://t.co/AAAAAAA">処理しない</a></li>
<li><a href="http://t.co/AAAAAAA">http://google.co.jp/AAABBBCCCDDD/EEE?FF=GGG</a></li>
<li><a href="http://t.co/AAAAAAA">http://google.co.jp/too_short/</a></li>
<li><a href="http://t.co/AAAAAAA">http://日本語URL.com/AAABBBCCCDDD/EEE?FF=GGG</a></li>
<li><a href="http://t.co/AAAAAAA">http://google.co.jp/AAABBBCCCDDD/日本語パラメーター</a></li>
</ul>
<h3>文字数少な目の設定</h3>
<ul class="short">
<li> <a href="http://t.co/AAAAAAA">処理しない</a></li>
<li> <a href="http://t.co/AAAAAAA">http://google.co.jp/AAABBBCCCDDD/EEE?FF=GGG</a></li>
<li> <a href="http://t.co/AAAAAAA">http://google.co.jp/too_short/</a></li>
</ul>
<h3>省略記号の変更</h3>
<ul class="ellipsis">
<li> <a href="http://t.co/AAAAAAA">処理しない</a></li>
<li> <a href="http://t.co/AAAAAAA">http://google.co.jp/AAABBBCCCDDD/EEE?FF=GGG</a></li>
<li> <a href="http://t.co/AAAAAAA">http://google.co.jp/too_short/</a></li>
</ul>
<h3>前方の省略</h3>
<ul class="large_front">
<li> <a href="http://t.co/AAAAAAA">http://domai_nagai.domain-nagai.domain_nagai.co.jp/aaa/bbb/ccc?eee=fff&ggg=hijklmn</a></li>
<li> <a href="http://t.co/AAAAAAA">http://domai_nagai.domain-nagai.domain_nagai.co.jp/too_short/</a></li>
<li><a href="http://t.co/AAAAAAA">http://長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い日本語URL.com/AAABBBCCCDDD/EEE?FF=GGG</a></li>
</ul>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$(function(){
$('.normal a').twellipsis();
$('.short a').twellipsis({length:5});
$('.ellipsis a').twellipsis({'tco-ellipsis':'---'});
$('.large_front a').twellipsis({length_front:37});
});
</script>
</body>
</html>
(function($) {
var setting = {};
$.fn.twellipsis = function(options){
//options
var defaults = {
length: 14,
length_front: 37,
'tco-ellipsis': '...'
};
setting = $.extend(defaults, options);
//run
run(this);
//
return this;
};
var run = function(elements){
$(elements).each(function(){
if( $(this).prop("tagName") == 'A' ){
_omit(this);
}
});
};
var _omit = function(a){
text = $(a).text();
var segments = _split(text);
if( !segments ){ return; }
$(a).empty();
$(a).attr('data-expanted-url',text);
var invisible = segments[1] + '://';
var display = '';
var ellipsis = '';
if( segments[2].length > setting.length_front ){
display += segments[2].slice(-setting.length_front) + '/';
invisible += segments[2].slice(0,segments[2].length-setting.length_front);
ellipsis = setting['tco-ellipsis'];
}else{
display += segments[2] + '/';
}
$(a).append(
$('<span>').addClass('tco-ellipsis').text( ellipsis ),
$('<span>').addClass('invisible').text( invisible )
);
invisible = '';
ellipsis = '';
if( segments[3].length > setting.length ){
display += segments[3].slice(0,setting.length);
invisible = segments[3].slice(setting.length);
ellipsis = setting['tco-ellipsis'];
}else{
display += segments[3];
}
$(a).append(
$('<span>').addClass('js-display-url').text( display ),
$('<span>').addClass('invisible').text( invisible ),
$('<span>').addClass('tco-ellipsis').append(
$('<span>').addClass('invisible').html( ' ' ),
ellipsis
)
);
};
var _split = function(url){
var regex = /^(.+):\/\/(.+?)\/(.+)$/;
var m = regex.exec(url);
if( !m ){ return false; }
return m;
};
})(jQuery);
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. |