mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-14 03:16:25 +00:00
107 lines
2.1 KiB
JavaScript
107 lines
2.1 KiB
JavaScript
(function($) {
|
|
|
|
var artistId, artistName;
|
|
var artistTags;
|
|
$(document).ready(function() {
|
|
initArtistCloud();
|
|
});
|
|
function initArtistCloud() {
|
|
$("#currentArtist").text();
|
|
|
|
artistTags = $("#artistTags").find('ul');
|
|
artistName = $("#content").find("h2:first").text();
|
|
artistId = window.location.search.split("?id=")[1];
|
|
addArtistMain(artistName);
|
|
loadArtists();
|
|
}
|
|
|
|
|
|
function loadArtists() {
|
|
$.getJSON('ajax.php?action=similar_artists&id='+artistId, function(data) {
|
|
var items = [];
|
|
|
|
$.each(data, function(key, val) {
|
|
addArtist(val['id'], val['name'], val['score']);
|
|
});
|
|
|
|
createCloud();
|
|
});
|
|
|
|
}
|
|
|
|
function addArtist(id, name, score) {
|
|
var item = $('<li><a data-weight="' + score + '">' + name + '</a></li>');
|
|
// var item = $('<li><a class="green large">' + name + '</a></li>');
|
|
|
|
|
|
$(item).click(function(e) {
|
|
e.preventDefault();
|
|
reinit(id, name);
|
|
});
|
|
|
|
artistTags.append(item);
|
|
|
|
}
|
|
|
|
function addArtistMain(name) {
|
|
var item = $('<li><a data-weight="350">' + name + '</a></li>');
|
|
|
|
// var item = $('<li><a class="red large">' + name + '</a></li>');
|
|
|
|
$("#currentArtist").attr('href', 'artist.php?id=' + artistId);
|
|
$("#currentArtist").text(artistName);
|
|
|
|
|
|
$(item).click(function(e) {
|
|
e.preventDefault();
|
|
reinit(artistId, name);
|
|
});
|
|
|
|
artistTags.append(item);
|
|
}
|
|
|
|
function reinit(id, name) {
|
|
artistId = id;
|
|
artistName = name;
|
|
artistTags.empty();
|
|
addArtistMain(artistName);
|
|
loadArtists();
|
|
}
|
|
|
|
function createCloud() {
|
|
if(!$('#similarArtistsCanvas').tagcanvas({
|
|
|
|
// textFont: 'Impact,"Arial Black",sans-serif',
|
|
wheelZoom: false,
|
|
freezeActive: true,
|
|
weightSize:0.15,
|
|
interval:20,
|
|
textFont: null,
|
|
textColour: null,
|
|
textHeight: 25,
|
|
outlineColour:'#f96',
|
|
outlineThickness:4,
|
|
maxSpeed:0.04,
|
|
minBrightness:0.1,
|
|
depth:0.92,
|
|
pulsateTo:0.2,
|
|
pulsateTime:0.75,
|
|
initial:[0.1,-0.1],
|
|
decel:0.98,
|
|
reverse:true,
|
|
shadow:'#ccf',
|
|
shadowBlur:3,
|
|
weight : true,
|
|
weightFrom:'data-weight'
|
|
|
|
},'artistTags')) {
|
|
// something went wrong, hide the canvas container
|
|
$('#flip_view_2').hide();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} ) ( jQuery );
|
|
|