That spaces life. Linked file from README

This commit is contained in:
Josh Sherman 2014-09-17 13:23:35 -04:00
parent fea34835e1
commit 92f93fe325
3 changed files with 87 additions and 86 deletions

View file

@ -1,6 +1,7 @@
jquery.soundcloud
=================
# jquery.soundcloud
jQuery plugin to inject the SoundCloud player.
Check `example.html` for more information.
Check [example.html][example] for more information.
[example]: https://github.com/joshtronic/jquery.soundcloud/blob/master/example.html

View file

@ -1,32 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>jQuery SoundCloud Plugin</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="./jquery.soundcloud.js" charset="utf-8"></script>
<script>
$(function()
{
$('.soundcloud').soundcloud({ client_id: 'b0d6766e74d8b02f74459447c186b12e' });
});
</script>
</head>
<body>
<h1>jQuery SoundCloud Plugin</h1>
<head>
<title>jQuery SoundCloud Plugin</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="./jquery.soundcloud.js" charset="utf-8"></script>
<script>
$(function()
{
$('.soundcloud').soundcloud({ client_id: 'b0d6766e74d8b02f74459447c186b12e' });
});
</script>
</head>
<body>
<h1>jQuery SoundCloud Plugin</h1>
<h2>Maximum Config</h2>
<div
class="soundcloud"
data-url="https://soundcloud.com/joshtronic/baby-got-back"
data-auto_play="true"
data-color="336699"
data-iframe="false"
data-maxheight="81px"
data-max-width="500px"
data-show_comments="true"
></div>
<h2>Maximum Config</h2>
<div
class="soundcloud"
data-url="https://soundcloud.com/joshtronic/baby-got-back"
data-auto_play="true"
data-color="336699"
data-iframe="false"
data-maxheight="81px"
data-max-width="500px"
data-show_comments="true"
></div>
<h2>Minimal Config</h2>
<div class="soundcloud" data-url="https://soundcloud.com/joshtronic/baby-got-back"></div>
</body>
<h2>Minimal Config</h2>
<div class="soundcloud" data-url="https://soundcloud.com/joshtronic/baby-got-back"></div>
</body>
</html>

View file

@ -1,66 +1,66 @@
(function($)
{
$.fn.soundcloud = function(options)
{
// Default settings
var defaults = {
auto_play: false,
//callback: false,
client_id: false,
color: false,
iframe: true,
maxheight: false,
maxwidth: false,
show_comments: true,
url: false
};
$.fn.soundcloud = function(options)
{
// Default settings
var defaults = {
auto_play: false,
//callback: false,
client_id: false,
color: false,
iframe: true,
maxheight: false,
maxwidth: false,
show_comments: true,
url: false
};
// Overrides the defaults with passed in options
options = $.extend({}, defaults, options);
// Overrides the defaults with passed in options
options = $.extend({}, defaults, options);
var elements = this;
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
var elements = this;
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
if (typeof SC === 'undefined')
{
$.getScript(
protocol + 'connect.soundcloud.com/sdk.js',
function()
{
elements.each(function(index, element)
{
try
{
// Overrides the options with the data attributes
parameters = $.extend({}, options, $(this).data());
if (typeof SC === 'undefined')
{
$.getScript(
protocol + 'connect.soundcloud.com/sdk.js',
function()
{
elements.each(function(index, element)
{
try
{
// Overrides the options with the data attributes
parameters = $.extend({}, options, $(this).data());
// Checks that we have a client ID
if (!parameters.client_id)
{
throw 'Missing client ID.';
}
// Checks that we have a client ID
if (!parameters.client_id)
{
throw 'Missing client ID.';
}
SC.initialize({ client_id: parameters.client_id });
SC.initialize({ client_id: parameters.client_id });
// Request the embed HTML
SC.oEmbed(
parameters.url,
parameters,
function(oEmbed)
{
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
}
);
}
catch (error)
{
console.log('[jQuery.SoundCloud] [error] ' + error);
}
});
}
);
}
// Request the embed HTML
SC.oEmbed(
parameters.url,
parameters,
function(oEmbed)
{
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
}
);
}
catch (error)
{
console.log('[jQuery.SoundCloud] [error] ' + error);
}
});
}
);
}
return this;
}
return this;
}
})(jQuery);