mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 02:46:30 +00:00
Empty commit
This commit is contained in:
parent
8cce965bdb
commit
de9865a4f2
@ -92,6 +92,12 @@
|
||||
case 'better':
|
||||
require(SERVER_ROOT.'/sections/ajax/better/index.php');
|
||||
break;
|
||||
case 'password_validate':
|
||||
require(SERVER_ROOT.'/sections/ajax/password_validate.php');
|
||||
break;
|
||||
case 'similar_artists':
|
||||
require(SERVER_ROOT.'/sections/ajax/similar_artists.php');
|
||||
break;
|
||||
default:
|
||||
// If they're screwing around with the query string
|
||||
print json_encode(array('status' => 'failure'));
|
||||
|
28
sections/ajax/similar_artists.php
Normal file
28
sections/ajax/similar_artists.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$artist_id = $_GET["id"];
|
||||
|
||||
$DB->query("
|
||||
SELECT
|
||||
s2.ArtistID,
|
||||
ag.Name,
|
||||
ass.Score
|
||||
FROM artists_similar AS s1
|
||||
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
|
||||
JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
|
||||
JOIN artists_group AS ag ON ag.ArtistID=s2.ArtistID
|
||||
WHERE s1.ArtistID=".$artist_id."
|
||||
ORDER BY ass.Score DESC
|
||||
LIMIT 14");
|
||||
|
||||
|
||||
while(list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)){
|
||||
if($Score<0){
|
||||
continue;
|
||||
}
|
||||
$results[] = array('id' => (int) $ArtistID, 'name' => $Name, 'score' => (int) $Score);
|
||||
}
|
||||
|
||||
print json_encode($results);
|
||||
exit();
|
||||
?>
|
@ -801,14 +801,90 @@ function compare($X, $Y){
|
||||
?>
|
||||
|
||||
<div id="similar_artist_map" class="box">
|
||||
<div class="head"><strong>Similar artist map</strong></div>
|
||||
<div style="width:<?=WIDTH?>px;height:<?=HEIGHT?>px;position:relative;background-image:url(static/similar/<?=$ArtistID?>.png?t=<?=time()?>)">
|
||||
<div id="flipper_head" class="head">
|
||||
<strong id="flipper_title">Similar Artist Map</strong>
|
||||
<a id="flip_to" href="#null" onclick="flipView();"></a>
|
||||
</div>
|
||||
<div id="flip_view_1" style="display:block;width:<?=WIDTH?>px;height:<?=HEIGHT?>px;position:relative;background-image:url(static/similar/<?=$ArtistID?>.png?t=<?=time()?>)">
|
||||
<?
|
||||
$Similar->write_artists();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<? } // if $NumSimilar>0 ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<? } // if $NumSimilar>0
|
||||
|
||||
if($NumSimilar>0) { ?>
|
||||
|
||||
<div id="flip_view_2" style="display:none;width:<?=WIDTH?>px;height:<?=HEIGHT?>px;">
|
||||
<canvas width="<?=WIDTH?>px" height="<?=HEIGHT-20?>px" id="similarArtistsCanvas"></canvas>
|
||||
<div id="artistTags" style="display:none;">
|
||||
<ul/>
|
||||
</div>
|
||||
<strong style="margin-left:10px;"><a id="currentArtist" href="#null">Loading...</a></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var cloudLoaded = false;
|
||||
|
||||
function flipView() {
|
||||
var state = document.getElementById('flip_view_1').style.display == 'block';
|
||||
|
||||
if(state) {
|
||||
|
||||
document.getElementById('flip_view_1').style.display='none';
|
||||
document.getElementById('flip_view_2').style.display='block';
|
||||
document.getElementById('flipper_title').innerHTML = 'Similar Artist Cloud';
|
||||
document.getElementById('flip_to').innerHTML = ' [Switch to Map]';
|
||||
|
||||
if(!cloudLoaded) {
|
||||
require("static/functions/jquery.js", function () {
|
||||
require("static/functions/tagcanvas.js", function () {
|
||||
require("static/functions/artist_cloud.js", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
cloudLoaded = true;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
document.getElementById('flip_view_1').style.display='block';
|
||||
document.getElementById('flip_view_2').style.display='none';
|
||||
document.getElementById('flipper_title').innerHTML = 'Similar Artist Map';
|
||||
document.getElementById('flip_to').innerHTML = ' [Switch to Cloud]';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//TODO move this to global, perhaps it will be used elsewhere in the future
|
||||
//http://stackoverflow.com/questions/7293344/load-javascript-dynamically
|
||||
function require(file, callback) {
|
||||
var script = document.getElementsByTagName('script')[0],
|
||||
newjs = document.createElement('script');
|
||||
|
||||
// IE
|
||||
newjs.onreadystatechange = function () {
|
||||
if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
|
||||
newjs.onreadystatechange = null;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
// others
|
||||
newjs.onload = function () {
|
||||
callback();
|
||||
};
|
||||
newjs.src = file;
|
||||
script.parentNode.insertBefore(newjs, script);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<? } ?>
|
||||
<div class="box">
|
||||
<div class="head"><strong>Artist info</strong></div>
|
||||
<div class="body"><?=$Text->full_format($Body)?></div>
|
||||
|
@ -10,7 +10,7 @@
|
||||
Be honest - at this point, lying will get you nowhere.<br /><br/><br/>
|
||||
</p>
|
||||
|
||||
<strong>Before joining the disabled channel please read our <br/> "Golden Rules" which can be found <a style="color:#1464F4;" href="#" onclick="toggle_visibility('golden_rules')">here.</a></strong> <br/><br/>
|
||||
<strong>Before joining the disabled channel please read our <br/> <span style="color:gold;">Golden Rules</span> which can be found <a style="color:#1464F4;" href="#" onclick="toggle_visibility('golden_rules')">here.</a></strong> <br/><br/>
|
||||
|
||||
<script type="text/javascript">
|
||||
function toggle_visibility(id) {
|
||||
|
106
static/functions/artist_cloud.js
Normal file
106
static/functions/artist_cloud.js
Normal file
@ -0,0 +1,106 @@
|
||||
(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 );
|
||||
|
21
static/functions/tagcanvas.js
Normal file
21
static/functions/tagcanvas.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user