- Mejora en el alta de una dedicatoria para detectar título y artista.

git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@15 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
This commit is contained in:
David Arranz 2012-07-18 17:27:44 +00:00
parent d62dbe2c0b
commit f4f712a3c8
5 changed files with 59 additions and 26 deletions

View File

@ -52,6 +52,8 @@ form.standard-form .loading {
border-radius: 3px;
padding: 5px;
background: #f5f5f5;
display: none;
}
#user-list li {

View File

@ -44,6 +44,12 @@ jQuery(document).ready(function(){
// Get youtube video's thumbnail url
// using jYoutube jQuery plugin
url = j.jYoutube(j('#video_url').val());
title = getYouTubeInfo(j('#video_url').val(),
function(artist, song){
j('#artist_name').val(artist);
j('#song_name').val(song);
});
// Now append this image to <div id="thumbs">
j('#thumbs').html(j('<img src="'+url+'" />'));

View File

@ -11,23 +11,47 @@
*
*/
(function($){
$.extend({
jYoutube: function( url, size ){
if(url === null){ return ""; }
$.extend({
jYoutube: function( url, size ){
if(url === null){
return "";
}
size = (size === null) ? "big" : size;
var vid;
var results;
size = (size === null) ? "big" : size;
var vid;
var results;
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
results = url.match(regExp);
results = url.match("[\\?&]v=([^&#]*)");
vid = (results && (results[7].length == 11 )) ? results[7] : "";
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
} else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}
})
})(jQuery);
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
}else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}
})
})(jQuery);
function getYouTubeInfo(url, handleData) {
if(url === null){
return "";
}
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var results = url.match(regExp);
var vid = (results && (results[7].length == 11 )) ? results[7] : "";
jQuery.ajax({
url: "http://gdata.youtube.com/feeds/api/videos/"+vid+"?v=2&alt=json",
dataType: "jsonp",
success: function (data) {
var otitle = data.entry[ "title" ].$t;
var ntitle = otitle.match('^(.*) - (.*)$');
var song = (ntitle && (ntitle[2].length > 0 )) ? ntitle[2] : "";
var artist = (ntitle && (ntitle[1].length > 0 )) ? ntitle[1] : otitle;
handleData(artist, song);
}
});
}

View File

@ -9,8 +9,9 @@
<?php global $bp, $post, $gp_settings; ?>
<?php get_header( 'buddypress' ); ?>
<?php locate_template( array( 'video-slider.php' ), true ); ?>
<?php if ( !bp_is_current_action( 'new-dedication' ) ) : ?>
<?php locate_template( array( 'video-slider.php' ), true ); ?>
<?php endif; ?>
<div id="content<?php if ( !bp_is_current_action( 'new-dedication' ) ) { ?> fullwidth<?php } ?>">
<div class="padder">

View File

@ -9,11 +9,6 @@ global $bp;
<div class="columns two first blank text-left">
<ol>
<li>
<label for="dedication_text">Dedication text</label>
<textarea name="dedication_text" class="dedication_text required" id="dedication_text"></textarea>
<input name="private-dedication" type="checkbox" />This dedication is private.
</li>
<li>
<label for="dedicate_to_input"><?php _e("Enter a member to dedicate:", 'bp-dedication') ?></label>
@ -25,17 +20,22 @@ global $bp;
</ul>
</li>
<li>
<label for="dedication_text">Dedication text</label>
<textarea name="dedication_text" class="dedication_text required" id="dedication_text"></textarea>
<input name="private-dedication" type="checkbox" />This dedication is private.
</li>
<li>
<label for="video_url">Video for dedication</label>
<input type="text" name="video_url" class="video_url required url" id="video_url" />
</li>
<li>
<label for="artist_name">Artist name</label>
<input type="text" name="artist_name" class="artist_name required" id="artist_name"/>
<input type="text" name="artist_name" class="artist_name" id="artist_name"/>
</li>
<li>
<label for="song_name">Song name</label>
<input type="text" name="song_name" class="song_name required" id="song_name"/>
<input type="text" name="song_name" class="song_name" id="song_name"/>
</li>
<?php /*
<li>