Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created June 21, 2011 02:41
Show Gist options
  • Save rummelonp/1037132 to your computer and use it in GitHub Desktop.
Save rummelonp/1037132 to your computer and use it in GitHub Desktop.
turntable.fm の Room Info を JSON にして表示
// javascript:(function(){(function()%20{%20var%20content%20=%20$(%27.content%27);%20var%20room%20=%20{%20creator:%20content.find(%27.creator%27).text(),%20description:%20content.find(%27.description%27).text(),%20recent_songs:%20content.find(%27.songlog%20.song%27).map(function()%20{%20var%20song%20=%20$(this);%20return%20{%20thumb:%20song.find(%27.thumb%27).attr(%27src%27)%20||%20%27%27,%20title:%20song.find(%27.title%27).text(),%20details:%20song.find(%27.details%20div%27).first().text(),%20score:%20song.find(%27.details%20.score%27).text()%20};%20}).toArray()%20};%20var%20json%20=%20JSON.stringify(room,%20null,%202);%20$(document.createElement(%27div%27)).dialog({draggable:%20false})%20.prev().css({backgroundColor:%20%27#E4BD33%27})%20.append($(document.createElement(%27textarea%27))%20.attr({cols:%2040,%20rows:%2020})%20.val(json));})();})()
(function() {
var content = $('.content');
var room = {
creator: content.find('.creator').text(),
description: content.find('.description').text(),
recent_songs: content.find('.songlog .song').map(function() {
var song = $(this);
return {
thumb: song.find('.thumb').attr('src') || '',
title: song.find('.title').text(),
details: song.find('.details div').first().text(),
score: song.find('.details .score').text()
};
}).toArray()
};
var json = JSON.stringify(room, null, 2);
$(document.createElement('div')).dialog({draggable: false})
.prev().css({backgroundColor: '#E4BD33'})
.append($(document.createElement('textarea'))
.attr({cols: 40, rows: 20})
.val(json));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment