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
fec9c0ca19
commit
792f5077cb
@ -21,20 +21,20 @@ public static function get_artists($GroupIDs) {
|
||||
global $Cache, $DB;
|
||||
$Results = array();
|
||||
$DBs = array();
|
||||
foreach($GroupIDs as $GroupID) {
|
||||
if(!is_number($GroupID)) {
|
||||
foreach ($GroupIDs as $GroupID) {
|
||||
if (!is_number($GroupID)) {
|
||||
continue;
|
||||
}
|
||||
$Artists = $Cache->get_value('groups_artists_'.$GroupID);
|
||||
if(is_array($Artists)) {
|
||||
if (is_array($Artists)) {
|
||||
$Results[$GroupID] = $Artists;
|
||||
} else {
|
||||
$DBs[] = $GroupID;
|
||||
}
|
||||
}
|
||||
if(count($DBs) > 0) {
|
||||
if (count($DBs) > 0) {
|
||||
$IDs = implode(',', $DBs);
|
||||
if(empty($IDs)) {
|
||||
if (empty($IDs)) {
|
||||
$IDs = "null";
|
||||
}
|
||||
$DB->query("SELECT ta.GroupID,
|
||||
@ -48,12 +48,12 @@ public static function get_artists($GroupIDs) {
|
||||
ORDER BY ta.GroupID ASC,
|
||||
ta.Importance ASC,
|
||||
aa.Name ASC;");
|
||||
while(list($GroupID,$ArtistID,$ArtistName,$ArtistImportance,$AliasID) = $DB->next_record(MYSQLI_BOTH, false)) {
|
||||
while (list($GroupID,$ArtistID,$ArtistName,$ArtistImportance,$AliasID) = $DB->next_record(MYSQLI_BOTH, false)) {
|
||||
$Results[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
||||
$New[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
||||
}
|
||||
foreach($DBs as $GroupID) {
|
||||
if(isset($New[$GroupID])) {
|
||||
foreach ($DBs as $GroupID) {
|
||||
if (isset($New[$GroupID])) {
|
||||
$Cache->cache_value('groups_artists_'.$GroupID, $New[$GroupID]);
|
||||
}
|
||||
else {
|
||||
@ -61,7 +61,7 @@ public static function get_artists($GroupIDs) {
|
||||
}
|
||||
}
|
||||
$Missing = array_diff($GroupIDs, array_keys($Results));
|
||||
if(!empty($Missing)) {
|
||||
if (!empty($Missing)) {
|
||||
$Results += array_fill_keys($Missing, array());
|
||||
}
|
||||
}
|
||||
@ -91,21 +91,21 @@ public static function get_artist($GroupID) {
|
||||
* @param $Escape if true, output will be escaped. Think carefully before setting it false.
|
||||
*/
|
||||
public static function display_artists($Artists, $MakeLink = true, $IncludeHyphen = true, $Escape = true) {
|
||||
if(!empty($Artists)) {
|
||||
if (!empty($Artists)) {
|
||||
$ampersand = ($Escape) ? ' & ' : ' & ';
|
||||
$link = '';
|
||||
|
||||
$MainArtists = isset($Artists[1]) ? $Artists[1] : null;
|
||||
$Guests = isset($Artists[2]) ? $Artists[2] : null;
|
||||
$Composers = isset($Artists[4]) ? $Artists[4] : null;
|
||||
$Conductors = isset($Artists[5]) ? $Artists[5] : null;
|
||||
$DJs = isset($Artists[6]) ? $Artists[6] : null;
|
||||
$MainArtists = isset($Artists[1]) ? $Artists[1] : null;
|
||||
$Guests = isset($Artists[2]) ? $Artists[2] : null;
|
||||
$Composers = isset($Artists[4]) ? $Artists[4] : null;
|
||||
$Conductors = isset($Artists[5]) ? $Artists[5] : null;
|
||||
$DJs = isset($Artists[6]) ? $Artists[6] : null;
|
||||
|
||||
if ((count($MainArtists) + count($Conductors) + count($DJs) == 0) && (count($Composers) == 0)) {
|
||||
return '';
|
||||
}
|
||||
// Various Composers is not needed and is ugly and should die
|
||||
switch(count($Composers)) {
|
||||
switch (count($Composers)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
@ -122,7 +122,7 @@ public static function display_artists($Artists, $MakeLink = true, $IncludeHyphe
|
||||
|
||||
$ComposerStr = $link;
|
||||
|
||||
switch(count($MainArtists)) {
|
||||
switch (count($MainArtists)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
@ -135,8 +135,8 @@ public static function display_artists($Artists, $MakeLink = true, $IncludeHyphe
|
||||
$link .= 'Various Artists';
|
||||
}
|
||||
|
||||
/*if(!empty($Guests) && (count($MainArtists) + count($Composers) > 0) && (count($MainArtists) + count($Composers) + count($Conductors) < 3)) {
|
||||
switch(count($Guests)) {
|
||||
/*if (!empty($Guests) && (count($MainArtists) + count($Composers) > 0) && (count($MainArtists) + count($Composers) + count($Conductors) < 3)) {
|
||||
switch (count($Guests)) {
|
||||
case 1:
|
||||
$link .= ' with '.Artists::display_artist($Guests[0], $MakeLink, $Escape);
|
||||
break;
|
||||
@ -149,7 +149,7 @@ public static function display_artists($Artists, $MakeLink = true, $IncludeHyphe
|
||||
if ((count($Conductors) > 0) && (count($MainArtists) + count($Composers) > 0) && (count($Composers) < 3 || count($MainArtists) > 0)) {
|
||||
$link .= ' under ';
|
||||
}
|
||||
switch(count($Conductors)) {
|
||||
switch (count($Conductors)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
@ -169,7 +169,7 @@ public static function display_artists($Artists, $MakeLink = true, $IncludeHyphe
|
||||
}
|
||||
|
||||
// DJs override everything else
|
||||
switch(count($DJs)) {
|
||||
switch (count($DJs)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
@ -246,7 +246,7 @@ public static function delete_artist($ArtistID) {
|
||||
$Cache->delete_value('artist_groups_'.$ArtistID);
|
||||
// Record in log
|
||||
|
||||
if(!empty($LoggedUser['Username'])) {
|
||||
if (!empty($LoggedUser['Username'])) {
|
||||
$Username = $LoggedUser['Username'];
|
||||
} else {
|
||||
$Username = 'System';
|
||||
|
@ -19,18 +19,18 @@ class Format {
|
||||
'default' => 'tl_notice',
|
||||
'snatched' => 'tl_snatched',
|
||||
|
||||
'freeleech' => 'tl_free',
|
||||
'neutral leech' => 'tl_free tl_neutral',
|
||||
'personal freeleech' => 'tl_free tl_personal',
|
||||
'freeleech' => 'tl_free',
|
||||
'neutral leech' => 'tl_free tl_neutral',
|
||||
'personal freeleech'=> 'tl_free tl_personal',
|
||||
|
||||
'reported' => 'tl_reported',
|
||||
'bad tags' => 'tl_reported tl_bad_tags',
|
||||
'bad folders' => 'tl_reported tl_bad_folders',
|
||||
'bad file names' => 'tl_reported tl_bad_file_names',
|
||||
'reported' => 'tl_reported',
|
||||
'bad tags' => 'tl_reported tl_bad_tags',
|
||||
'bad folders' => 'tl_reported tl_bad_folders',
|
||||
'bad file names'=> 'tl_reported tl_bad_file_names',
|
||||
|
||||
'cassette approved' => 'tl_approved tl_cassete',
|
||||
'lossy master approved' => 'tl_approved tl_lossy_master',
|
||||
'lossy web approved' => 'tl_approved tl_lossy_web'
|
||||
'cassette approved' => 'tl_approved tl_cassete',
|
||||
'lossy master approved' => 'tl_approved tl_lossy_master',
|
||||
'lossy web approved' => 'tl_approved tl_lossy_web'
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -222,23 +222,23 @@ function contains($Substring, $String) {
|
||||
/**
|
||||
* Checks if URL points to a whatimg thumbnail.
|
||||
*/
|
||||
function has_whatimg_thumb($Url){
|
||||
function has_whatimg_thumb($Url) {
|
||||
return contains("_thumb", $Url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up imgur URL if it already has a modifier attached to the end of it.
|
||||
*/
|
||||
function clean_imgur_url($Url){
|
||||
$Extension = pathinfo($Url, PATHINFO_EXTENSION);
|
||||
$Full = preg_replace('/\.[^.]*$/', '', $Url);
|
||||
$Base = substr($Full, 0, strrpos($Full, '/'));
|
||||
$Path = substr($Full, strrpos($Full, '/') + 1);
|
||||
if (strlen($Path) == 6) {
|
||||
$Last = $Path[strlen($Path) - 1];
|
||||
if ($Last == 'm' || $Last == 'l' || $Last == 's' || $Last == 'h' || $Last == 'b') {
|
||||
$Path = substr($Path, 0, -1);
|
||||
}
|
||||
}
|
||||
return $Base . "/" . $Path . "." . $Extension;
|
||||
function clean_imgur_url($Url) {
|
||||
$Extension = pathinfo($Url, PATHINFO_EXTENSION);
|
||||
$Full = preg_replace('/\.[^.]*$/', '', $Url);
|
||||
$Base = substr($Full, 0, strrpos($Full, '/'));
|
||||
$Path = substr($Full, strrpos($Full, '/') + 1);
|
||||
if (strlen($Path) == 6) {
|
||||
$Last = $Path[strlen($Path) - 1];
|
||||
if ($Last == 'm' || $Last == 'l' || $Last == 's' || $Last == 'h' || $Last == 'b') {
|
||||
$Path = substr($Path, 0, -1);
|
||||
}
|
||||
}
|
||||
return $Base . '/' . $Path . '.' . $Extension;
|
||||
}
|
||||
|
@ -3,142 +3,142 @@
|
||||
define('LASTFM_API_URL', 'http://ws.audioscrobbler.com/2.0/?method=');
|
||||
class LastFM {
|
||||
|
||||
public static function get_artist_events($ArtistID, $Artist, $Limit = 15) {
|
||||
global $Cache;
|
||||
$ArtistEvents = $Cache->get_value('artist_events_' . $ArtistID);
|
||||
if (empty($ArtistEvents)) {
|
||||
$ArtistEvents = self::lastfm_request("artist.getEvents", array("artist" => $Artist, "limit" => $Limit));
|
||||
$Cache->cache_value('artist_events_' . $ArtistID, $ArtistEvents, 432000);
|
||||
}
|
||||
return $ArtistEvents;
|
||||
}
|
||||
public static function get_artist_events($ArtistID, $Artist, $Limit = 15) {
|
||||
global $Cache;
|
||||
$ArtistEvents = $Cache->get_value('artist_events_' . $ArtistID);
|
||||
if (empty($ArtistEvents)) {
|
||||
$ArtistEvents = self::lastfm_request("artist.getEvents", array("artist" => $Artist, "limit" => $Limit));
|
||||
$Cache->cache_value('artist_events_' . $ArtistID, $ArtistEvents, 432000);
|
||||
}
|
||||
return $ArtistEvents;
|
||||
}
|
||||
|
||||
public static function get_user_info($Username) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_user_info_' . $Username);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("user.getInfo", array("user" => $Username));
|
||||
$Cache->cache_value('lastfm_user_info_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
public static function get_user_info($Username) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_user_info_' . $Username);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("user.getInfo", array("user" => $Username));
|
||||
$Cache->cache_value('lastfm_user_info_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
|
||||
public static function compare_user_with($Username1, $Limit = 15) {
|
||||
global $Cache, $LoggedUser, $DB;
|
||||
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
|
||||
if ($DB->record_count() > 0) {
|
||||
list($Username2) = $DB->next_record();
|
||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||
if (strcasecmp($Username1, $Username2)) {
|
||||
$Temp = $Username1;
|
||||
$Username1 = $Username2;
|
||||
$Username2 = $Temp;
|
||||
}
|
||||
$Response = $Cache->get_value('lastfm_compare_' . $Username1 . '_' . $Username2);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("tasteometer.compare", array("type1" => "user", "type2" => "user", "value1" => $Username1, "value2" => $Username2, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_compare_' . $Username1 . '_' . $Username2, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
}
|
||||
public static function compare_user_with($Username1, $Limit = 15) {
|
||||
global $Cache, $LoggedUser, $DB;
|
||||
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
|
||||
if ($DB->record_count() > 0) {
|
||||
list($Username2) = $DB->next_record();
|
||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||
if (strcasecmp($Username1, $Username2)) {
|
||||
$Temp = $Username1;
|
||||
$Username1 = $Username2;
|
||||
$Username2 = $Temp;
|
||||
}
|
||||
$Response = $Cache->get_value('lastfm_compare_' . $Username1 . '_' . $Username2);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("tasteometer.compare", array("type1" => "user", "type2" => "user", "value1" => $Username1, "value2" => $Username2, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_compare_' . $Username1 . '_' . $Username2, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_last_played_track($Username) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_last_played_track_' . $Username);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("user.getRecentTracks", array("user" => $Username, "limit" => 1));
|
||||
// Take the single last played track out of the response.
|
||||
$Response = $Response['recenttracks']['track'];
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_last_played_track_' . $Username, $Response, 7200);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
public static function get_last_played_track($Username) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_last_played_track_' . $Username);
|
||||
if (empty($Response)) {
|
||||
$Response = self::lastfm_request("user.getRecentTracks", array("user" => $Username, "limit" => 1));
|
||||
// Take the single last played track out of the response.
|
||||
$Response = $Response['recenttracks']['track'];
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_last_played_track_' . $Username, $Response, 7200);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
|
||||
public static function get_top_artists($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_artists_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(1);
|
||||
$Response = self::lastfm_request("user.getTopArtists", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_artists_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
public static function get_top_artists($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_artists_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(1);
|
||||
$Response = self::lastfm_request("user.getTopArtists", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_artists_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
|
||||
public static function get_top_albums($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_albums_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(2);
|
||||
$Response = self::lastfm_request("user.getTopAlbums", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_albums_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
public static function get_top_albums($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_albums_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(2);
|
||||
$Response = self::lastfm_request("user.getTopAlbums", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_albums_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
|
||||
public static function get_top_tracks($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_tracks_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(3);
|
||||
$Response = self::lastfm_request("user.getTopTracks", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_tracks_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
public static function get_top_tracks($Username, $Limit = 15) {
|
||||
global $Cache;
|
||||
$Response = $Cache->get_value('lastfm_top_tracks_' . $Username);
|
||||
if (empty($Response)) {
|
||||
sleep(3);
|
||||
$Response = self::lastfm_request("user.getTopTracks", array("user" => $Username, "limit" => $Limit));
|
||||
$Response = json_encode($Response);
|
||||
$Cache->cache_value('lastfm_top_tracks_' . $Username, $Response, 86400);
|
||||
}
|
||||
return $Response;
|
||||
}
|
||||
|
||||
public static function clear_cache($Username, $Uid) {
|
||||
global $Cache, $LoggedUser, $DB;
|
||||
$Response = $Cache->get_value('lastfm_clear_cache_' . $LoggedUser . '_' . $_GET['id']);
|
||||
if (empty($Response)) {
|
||||
// Prevent clearing the cache on the same uid page for the next 10 minutes.
|
||||
$Response = $Cache->cache_value('lastfm_clear_cache_' . $LoggedUser . '_' . $Uid, $Username, 600);
|
||||
$Cache->delete_value('lastfm_user_info_' . $Username);
|
||||
$Cache->delete_value('lastfm_last_played_track_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_artists_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_albums_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_tracks_' . $Username);
|
||||
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
|
||||
if ($DB->record_count() > 0) {
|
||||
list($Username2) = $DB->next_record();
|
||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||
if (strcasecmp($Username, $Username2)) {
|
||||
$Temp = $Username;
|
||||
$Username = $Username2;
|
||||
$Username2 = $Temp;
|
||||
}
|
||||
$Cache->delete_value('lastfm_compare_' . $Username . '_' . $Username2);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function clear_cache($Username, $Uid) {
|
||||
global $Cache, $LoggedUser, $DB;
|
||||
$Response = $Cache->get_value('lastfm_clear_cache_' . $LoggedUser . '_' . $_GET['id']);
|
||||
if (empty($Response)) {
|
||||
// Prevent clearing the cache on the same uid page for the next 10 minutes.
|
||||
$Response = $Cache->cache_value('lastfm_clear_cache_' . $LoggedUser . '_' . $Uid, $Username, 600);
|
||||
$Cache->delete_value('lastfm_user_info_' . $Username);
|
||||
$Cache->delete_value('lastfm_last_played_track_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_artists_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_albums_' . $Username);
|
||||
$Cache->delete_value('lastfm_top_tracks_' . $Username);
|
||||
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
|
||||
if ($DB->record_count() > 0) {
|
||||
list($Username2) = $DB->next_record();
|
||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||
if (strcasecmp($Username, $Username2)) {
|
||||
$Temp = $Username;
|
||||
$Username = $Username2;
|
||||
$Username2 = $Temp;
|
||||
}
|
||||
$Cache->delete_value('lastfm_compare_' . $Username . '_' . $Username2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function lastfm_request($Method, $Args) {
|
||||
if (!defined('LASTFM_API_KEY')) {
|
||||
return false;
|
||||
}
|
||||
$Url = LASTFM_API_URL . $Method;
|
||||
if (is_array($Args)) {
|
||||
foreach ($Args as $Key => $Value) {
|
||||
$Url .= "&" . $Key . "=" . urlencode($Value);
|
||||
}
|
||||
$Url .= "&format=json&api_key=" . LASTFM_API_KEY;
|
||||
private static function lastfm_request($Method, $Args) {
|
||||
if (!defined('LASTFM_API_KEY')) {
|
||||
return false;
|
||||
}
|
||||
$Url = LASTFM_API_URL . $Method;
|
||||
if (is_array($Args)) {
|
||||
foreach ($Args as $Key => $Value) {
|
||||
$Url .= "&" . $Key . "=" . urlencode($Value);
|
||||
}
|
||||
$Url .= "&format=json&api_key=" . LASTFM_API_KEY;
|
||||
|
||||
$Curl = curl_init();
|
||||
curl_setopt($Curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($Curl, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($Curl, CURLOPT_URL, $Url);
|
||||
$Return = curl_exec($Curl);
|
||||
curl_close($Curl);
|
||||
return json_decode($Return, true);
|
||||
}
|
||||
}
|
||||
$Curl = curl_init();
|
||||
curl_setopt($Curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($Curl, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($Curl, CURLOPT_URL, $Url);
|
||||
$Return = curl_exec($Curl);
|
||||
curl_close($Curl);
|
||||
return json_decode($Return, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,12 @@ public static function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
|
||||
|
||||
$DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'");
|
||||
list($SenderName) = $DB->next_record();
|
||||
foreach($ToID as $ID) {
|
||||
foreach ($ToID as $ID) {
|
||||
$DB->query("SELECT COUNT(ConvID) FROM pm_conversations_users WHERE UnRead = '1' and UserID='$ID' AND InInbox = '1'");
|
||||
list($UnRead) = $DB->next_record();
|
||||
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $ConvID;
|
||||
}
|
||||
@ -396,7 +396,7 @@ public static function sanitize_tag($Str) {
|
||||
*/
|
||||
public static function display_array($Array, $Escape = array()) {
|
||||
foreach ($Array as $Key => $Val) {
|
||||
if((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) {
|
||||
if ((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) {
|
||||
$Array[$Key] = display_str($Val);
|
||||
}
|
||||
}
|
||||
@ -416,19 +416,20 @@ public static function is_new_torrent(&$Data) {
|
||||
|
||||
public static function display_recommend($ID, $Type, $Hide = true) {
|
||||
global $DB, $LoggedUser;
|
||||
if($Hide) {
|
||||
if ($Hide) {
|
||||
$Hide = 'style="display: none;"';
|
||||
}
|
||||
?>
|
||||
<div id="recommendation_div" data-id="<?=$ID?>" data-type="<?=$Type?>" <?=$Hide?> class="center">
|
||||
<div style="display: inline-block;" >
|
||||
<strong>Recommend to: </strong><select id="friend" name="friend">
|
||||
<option value="0" selected="selected">Choose Friend</option>
|
||||
<div style="display: inline-block;">
|
||||
<strong>Recommend to:</strong>
|
||||
<select id="friend" name="friend">
|
||||
<option value="0" selected="selected">Choose friend</option>
|
||||
</select>
|
||||
<input type="text" id="recommendation_note" placeholder="Add note..."/>
|
||||
<button id="send_recommendation" disabled>Send</button>
|
||||
<input type="text" id="recommendation_note" placeholder="Add note..." />
|
||||
<button id="send_recommendation" disabled="disabled">Send</button>
|
||||
</div>
|
||||
<div class="new" id="recommendation_status"><br/></div>
|
||||
<div class="new" id="recommendation_status"><br /></div>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class Tags
|
||||
*
|
||||
* @param string $TagList A string of tags separated by a space
|
||||
* @param boolean $Merge Merge the tag list with the Class' tags
|
||||
* Eg, compilations and soundtracks are skipped, so false
|
||||
* E.g., compilations and soundtracks are skipped, so false
|
||||
*/
|
||||
public function __construct($TagList, $Merge = true) {
|
||||
$this->Tags = array_filter(explode(' ', str_replace('_', '.', $TagList)));
|
||||
@ -148,4 +148,4 @@ public static function format_top($Max = 5, $Link = 'torrents.php?taglist=') {
|
||||
<li><a href="<?=$Link . display_str($TagName)?>"><?=display_str($TagName)?></a> (<?=$Total?>)</li>
|
||||
<? }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ static private function iterator ()
|
||||
* // no buttons or wrap preview divs.
|
||||
* // Buttons and preview divs are generated manually
|
||||
* $text = new TEXTAREA_PREVIEW('body_text', 'body_text', 'default text',
|
||||
* 50, 20, false, false, array('disabled="disabled"', 'class="text"'));
|
||||
* 50, 20, false, false, array('disabled="disabled"', 'class="text"'));
|
||||
*
|
||||
* $text->buttons(); // output buttons
|
||||
*
|
||||
@ -101,13 +101,13 @@ static private function iterator ()
|
||||
*
|
||||
* // some template
|
||||
* <div id="preview_wrap_<?=$id?>">
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* <div id="preview_<?=$id?>"></div>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* <div id="preview_<?=$id?>"></div>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </div>
|
||||
* </pre>
|
||||
*/
|
||||
@ -133,15 +133,15 @@ class TEXTAREA_PREVIEW extends TEXTAREA_PREVIEW_SUPER
|
||||
/**
|
||||
* This method creates a textarea
|
||||
*
|
||||
* @param string $Name name attribute
|
||||
* @param string $ID id attribute
|
||||
* @param string $Value default text attribute
|
||||
* @param string $Cols cols attribute
|
||||
* @param string $Rows rows attribute
|
||||
* @param bool $Preview add the preview divs near the textarea
|
||||
* @param bool $Buttons add the edit/preview buttons near the textarea
|
||||
* @param bool $Buffer doesn't output the textarea, use getBuffer()
|
||||
* @param array $ExtraAttributes array of attribute="value"
|
||||
* @param string $Name name attribute
|
||||
* @param string $ID id attribute
|
||||
* @param string $Value default text attribute
|
||||
* @param string $Cols cols attribute
|
||||
* @param string $Rows rows attribute
|
||||
* @param bool $Preview add the preview divs near the textarea
|
||||
* @param bool $Buttons add the edit/preview buttons near the textarea
|
||||
* @param bool $Buffer doesn't output the textarea, use getBuffer()
|
||||
* @param array $ExtraAttributes array of attribute="value"
|
||||
*
|
||||
* If false for $Preview, $Buttons, or $Buffer, use the appropriate
|
||||
* methods to add the those elements manually. Alternatively, use getID
|
||||
@ -149,7 +149,7 @@ class TEXTAREA_PREVIEW extends TEXTAREA_PREVIEW_SUPER
|
||||
*
|
||||
* It's important to have the right IDs as they make the JS function properly.
|
||||
*/
|
||||
public function __construct ($Name, $ID = '', $Value='', $Cols=50, $Rows=10,
|
||||
public function __construct ($Name, $ID = '', $Value = '', $Cols = 50, $Rows = 10,
|
||||
$Preview = true, $Buttons = true, $Buffer = false,
|
||||
array $ExtraAttributes = array()
|
||||
) {
|
||||
@ -215,4 +215,4 @@ public function getBuffer ()
|
||||
{
|
||||
return $this->buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ public static function geoip($IP) {
|
||||
} else {
|
||||
$Long = Tools::ip_to_unsigned($IP);
|
||||
}
|
||||
if(!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
|
||||
if (!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
|
||||
return false;
|
||||
}
|
||||
global $DB;
|
||||
$DB->query("SELECT EndIP,Code FROM geoip_country WHERE $Long >= StartIP ORDER BY StartIP DESC LIMIT 1");
|
||||
if((!list($EndIP,$Country) = $DB->next_record()) || $EndIP < $Long) {
|
||||
if ((!list($EndIP,$Country) = $DB->next_record()) || $EndIP < $Long) {
|
||||
$Country = '?';
|
||||
}
|
||||
$IPs[$IP] = $Country;
|
||||
@ -110,12 +110,12 @@ public static function get_host_by_ajax($IP) {
|
||||
public static function lookup_ip($IP) {
|
||||
//TODO: use the $Cache
|
||||
$Output = explode(' ',shell_exec('host -W 1 '.escapeshellarg($IP)));
|
||||
if(count($Output) == 1 && empty($Output[0])) {
|
||||
if (count($Output) == 1 && empty($Output[0])) {
|
||||
//No output at all implies the command failed
|
||||
return '';
|
||||
}
|
||||
|
||||
if(count($Output) != 5) {
|
||||
if (count($Output) != 5) {
|
||||
return false;
|
||||
} else {
|
||||
return trim($Output[4]);
|
||||
@ -152,7 +152,7 @@ public static function get_country_code_by_ajax($IP) {
|
||||
*/
|
||||
public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
||||
global $Cache, $DB;
|
||||
if(!is_array($UserIDs)) {
|
||||
if (!is_array($UserIDs)) {
|
||||
$UserIDs = array($UserIDs);
|
||||
}
|
||||
$DB->query("UPDATE users_info AS i JOIN users_main AS m ON m.ID=i.UserID
|
||||
@ -184,9 +184,9 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
||||
// Remove the users from the tracker.
|
||||
$DB->query("SELECT torrent_pass FROM users_main WHERE ID in (".implode(", ",$UserIDs).")");
|
||||
$PassKeys = $DB->collect('torrent_pass');
|
||||
$Concat = "";
|
||||
foreach($PassKeys as $PassKey) {
|
||||
if(strlen($Concat) > 3950) { // Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
|
||||
$Concat = '';
|
||||
foreach ($PassKeys as $PassKey) {
|
||||
if (strlen($Concat) > 3950) { // Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
|
||||
Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
|
||||
$Concat = $PassKey;
|
||||
} else {
|
||||
@ -209,7 +209,7 @@ public static function warn_user($UserID, $Duration, $Reason) {
|
||||
$DB->query("SELECT Warned FROM users_info
|
||||
WHERE UserID=".$UserID."
|
||||
AND Warned <> '0000-00-00 00:00:00'");
|
||||
if($DB->record_count() > 0) {
|
||||
if ($DB->record_count() > 0) {
|
||||
//User was already warned, appending new warning to old.
|
||||
list($OldDate) = $DB->next_record();
|
||||
$NewExpDate = date('Y-m-d H:i:s', strtotime($OldDate) + $Duration);
|
||||
|
@ -347,7 +347,7 @@ public static function make_hash($Str,$Secret) {
|
||||
* @param $Password password
|
||||
* @param $Hash password hash
|
||||
* @param $Secret salt - Only used if the hash was created
|
||||
* with the deprecated Users::make_hash() method
|
||||
* with the deprecated Users::make_hash() method
|
||||
* @return true on correct password
|
||||
*/
|
||||
public static function check_password($Password, $Hash, $Secret='') {
|
||||
@ -448,9 +448,9 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
|
||||
|
||||
if ($Badges) {
|
||||
$Str .= ($UserInfo['Donor'] == 1) ? '<a href="donate.php"><img src="'.STATIC_SERVER.'common/symbols/donor.png" alt="Donor" title="Donor" /></a>' : '';
|
||||
}
|
||||
}
|
||||
|
||||
$Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? '<a href="wiki.php?action=article&id=218"'
|
||||
$Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? '<a href="wiki.php?action=article&id=218"'
|
||||
. '><img src="'.STATIC_SERVER.'common/symbols/warned.png" alt="Warned" title="Warned'
|
||||
. ($LoggedUser['ID'] === $UserID ? ' - Expires ' . date('Y-m-d H:i', strtotime($UserInfo['Warned'])) : '')
|
||||
. '" /></a>' : '';
|
||||
|
@ -178,7 +178,7 @@ public static function binomial_score($Ups, $Total) {
|
||||
*/
|
||||
public static function get_ranking($GroupID, $Year) {
|
||||
$GroupID = (int)$GroupID;
|
||||
$Year = (int)$Year;
|
||||
$Year = (int)$Year;
|
||||
if ($GroupID <= 0 || $Year <= 0) {
|
||||
return false;
|
||||
}
|
||||
@ -229,7 +229,7 @@ public static function get_rank_year($GroupID, $Year) {
|
||||
global $Cache, $DB;
|
||||
|
||||
$GroupID = (int)$GroupID;
|
||||
$Year = (int)$Year;
|
||||
$Year = (int)$Year;
|
||||
if ($GroupID <= 0 || $Year <= 0) {
|
||||
return false;
|
||||
}
|
||||
@ -264,8 +264,8 @@ public static function get_rank_decade($GroupID, $Year) {
|
||||
global $Cache, $DB;
|
||||
|
||||
$GroupID = (int)$GroupID;
|
||||
$Year = (int)$Year;
|
||||
$Year = (int)$Year;
|
||||
$Year = (int)$Year;
|
||||
$Year = (int)$Year;
|
||||
if ((int)$GroupID <= 0 || (int)$Year <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -135,11 +135,11 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) {
|
||||
$this->Data .= $ZipData; // File data
|
||||
/* END file data */
|
||||
|
||||
/* Data descriptor
|
||||
Not needed (only needed when 3rd bitflag is set), causes problems with OS X archive utility
|
||||
/* Data descriptor
|
||||
Not needed (only needed when 3rd bitflag is set), causes problems with OS X archive utility
|
||||
$this->Data .= pack("V",$CRC32); // CRC-32
|
||||
$this->Data .= pack("V",$ZipLength); // Compressed filesize
|
||||
$this->Data .= pack("V",$DataLength); // Uncompressed filesize
|
||||
$this->Data .= pack("V",$ZipLength); // Compressed filesize
|
||||
$this->Data .= pack("V",$DataLength); // Uncompressed filesize
|
||||
END data descriptor */
|
||||
|
||||
$FileDataLength = strlen($this->Data);
|
||||
|
@ -57,7 +57,7 @@ function checked($Checked) {
|
||||
$SiteOptions = array();
|
||||
}
|
||||
|
||||
View::show_header($Username.' > Settings','user,jquery,jquery-ui,release_sort,password_validate,validate,push_settings');
|
||||
View::show_header($Username.' > Settings','user,jquery,jquery-ui,release_sort,password_validate,validate,push_settings,cssgallery');
|
||||
|
||||
|
||||
|
||||
@ -90,9 +90,19 @@ function checked($Checked) {
|
||||
<? foreach ($Stylesheets as $Style) { ?>
|
||||
<option value="<?=$Style['ID']?>"<? if ($Style['ID'] == $StyleID) { ?> selected="selected"<? } ?>><?=$Style['ProperName']?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
- Or -
|
||||
</select>
|
||||
<a href="#" id="toggle_css_gallery" class="brackets">Show gallery</a>
|
||||
- Or -
|
||||
External CSS: <input type="text" size="40" name="styleurl" id="styleurl" value="<?=display_str($StyleURL)?>" />
|
||||
<div id="css_gallery">
|
||||
<? foreach ($Stylesheets as $Style) { ?>
|
||||
<div class="preview_wrapper">
|
||||
<div class="preview_overlay"></div>
|
||||
<div class="preview_frame_wrapper"><iframe class="preview_frame" src="user.php?action=stylesheetgallery&name=<?= $Style['Name'] ?>" width="588%" height="588%"></iframe></div>
|
||||
<p class="preview_name"><input type="radio" name="stylesheet_gallery" value="<?= $Style['ID'] ?>" /> <?= $Style["ProperName"] ?></p>
|
||||
</div>
|
||||
<? } ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<? if (check_perms('site_advanced_search')) { ?>
|
||||
|
@ -14,6 +14,9 @@
|
||||
}
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'stylesheetgallery':
|
||||
include('stylesheetgallery.php');
|
||||
break;
|
||||
case 'notify':
|
||||
include('notify_edit.php');
|
||||
break;
|
||||
|
331
sections/user/stylesheetgallery.php
Normal file
331
sections/user/stylesheetgallery.php
Normal file
@ -0,0 +1,331 @@
|
||||
<?
|
||||
if (!isset($_GET['name'])) {
|
||||
if (!isset($Err)) {
|
||||
error(404);
|
||||
}
|
||||
} else {
|
||||
$Name = false;
|
||||
foreach ($Stylesheets as $Stylesheet) {
|
||||
if ($Stylesheet["Name"] === $_GET['name'])
|
||||
$Name = $_GET['name'];
|
||||
}
|
||||
if (!$Name) {
|
||||
error(404);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Stylesheet Gallery</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1;IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link href="static/styles/global.css" rel="stylesheet" type="text/css" />
|
||||
<link href="static/styles/<?= $Name ?>/style.css" title="<?= $Name ?>" rel="stylesheet" type="text/css" media="screen" />
|
||||
</head>
|
||||
<body id="user" style="overflow:hidden;">
|
||||
<div id="wrapper">
|
||||
<h1 class="hidden">Gazelle</h1>
|
||||
<div id="header">
|
||||
<div id="logo"><a href="#"></a></div>
|
||||
<div id="userinfo">
|
||||
<ul id="userinfo_username">
|
||||
<li id="nav_userinfo"><a href="#" class="username">Gazelle</a></li>
|
||||
<li id="nav_useredit" class="brackets"><a href="#">Edit</a></li>
|
||||
<li id="nav_logout" class="brackets"><a href="#">Logout</a></li>
|
||||
</ul>
|
||||
<ul id="userinfo_major">
|
||||
<li id="nav_upload" class="brackets"><a href="#">Upload</a></li>
|
||||
<li id="nav_invite" class="brackets"><a href="#">Invite (∞)</a></li>
|
||||
<li id="nav_donate" class="brackets"><a href="#">Donate</a></li>
|
||||
|
||||
</ul>
|
||||
<ul id="userinfo_stats">
|
||||
<li id="stats_seeding"><a href="#">Up</a>: <span class="stat" title="300.00000 MB">300.00 MB</span></li>
|
||||
<li id="stats_leeching"><a href="#">Down</a>: <span class="stat" title="0.00000 B">0.00 B</span></li>
|
||||
<li id="stats_ratio">Ratio: <span class="stat"><span class="r99" title="Infinite">∞</span></span></li>
|
||||
<li id="stats_required"><a href="#">Required</a>: <span class="stat" title="0.00000">0.00</span></li>
|
||||
</ul>
|
||||
|
||||
<ul id="userinfo_minor">
|
||||
<li id="nav_inbox"><a onmousedown="Stats('inbox');" href="#">Inbox</a></li>
|
||||
<li id="nav_staffinbox"><a onmousedown="Stats('staffpm');" href="#">Staff Inbox</a></li>
|
||||
<li id="nav_uploaded"><a onmousedown="Stats('uploads');" href="#">Uploads</a></li>
|
||||
<li id="nav_bookmarks"><a onmousedown="Stats('bookmarks');" href="#">Bookmarks</a></li>
|
||||
<li id="nav_notifications" ><a onmousedown="Stats('notifications');" href="#">Notifications</a></li>
|
||||
<li id="nav_subscriptions"><a onmousedown="Stats('subscriptions');" href="#">Subscriptions</a></li>
|
||||
<li id="nav_comments"><a onmousedown="Stats('comments');" href="#">Comments</a></li>
|
||||
<li id="nav_friends"><a onmousedown="Stats('friends');" href="#">Friends</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="menu">
|
||||
<h4 class="hidden">Site Menu</h4>
|
||||
<ul>
|
||||
<li id="nav_index"><a href="#">Home</a></li>
|
||||
<li id="nav_torrents"><a href="#">Torrents</a></li>
|
||||
<li id="nav_collages"><a href="#">Collages</a></li>
|
||||
<li id="nav_requests"><a href="#">Requests</a></li>
|
||||
<li id="nav_forums"><a href="#">Forums</a></li>
|
||||
<li id="nav_irc"><a href="#">IRC</a></li>
|
||||
<li id="nav_top10"><a href="#">Top 10</a></li>
|
||||
<li id="nav_rules"><a href="#">Rules</a></li>
|
||||
<li id="nav_wiki"><a href="#">Wiki</a></li>
|
||||
<li id="nav_staff"><a href="#">Staff</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="alerts">
|
||||
<div class="alertbar blend"><a href="#">New Announcement!</a></div>
|
||||
</div>
|
||||
<div id="searchbars">
|
||||
<ul>
|
||||
<li id="searchbar_torrents">
|
||||
<span class="hidden">Torrents: </span>
|
||||
<form class="search_form" name="torrents" action="" method="get">
|
||||
<input
|
||||
id="torrentssearch"
|
||||
accesskey="t"
|
||||
spellcheck="false"
|
||||
onfocus="if (this.value == 'Torrents') this.value='';"
|
||||
onblur="if (this.value == '') this.value='Torrents';"
|
||||
value="Torrents" type="text" name="searchstr" size="17"
|
||||
/>
|
||||
</form>
|
||||
</li>
|
||||
<li id="searchbar_artists">
|
||||
<span class="hidden">Artist: </span>
|
||||
<form class="search_form" name="artists" action="" method="get">
|
||||
<script type="text/javascript" src="static/functions/autocomplete.js?v=1362029969"></script>
|
||||
<input id="artistsearch" value="Artists" type="text" name="artistname" size="17"/>
|
||||
<ul id="artistcomplete" style="visibility: hidden;"><li/></ul>
|
||||
</form>
|
||||
</li>
|
||||
<li id="searchbar_requests">
|
||||
<span class="hidden">Requests: </span>
|
||||
<form class="search_form" name="requests" action="" method="get">
|
||||
<input id="requestssearch" value="Requests" type="text" name="search" size="17"/>
|
||||
</form>
|
||||
</li>
|
||||
<li id="searchbar_forums">
|
||||
<span class="hidden">Forums: </span>
|
||||
<form class="search_form" name="forums" action="" method="get">
|
||||
<input value="search" type="hidden" name="action" />
|
||||
<input id="forumssearch" value="Forums" type="text" name="search" size="17"/>
|
||||
</form>
|
||||
</li>
|
||||
<li id="searchbar_log">
|
||||
<span class="hidden">Log: </span>
|
||||
<form class="search_form" name="log" action="" method="get">
|
||||
<input id="logsearch" value="Log" type="text" name="search" size="17"/>
|
||||
</form>
|
||||
</li>
|
||||
<li id="searchbar_users">
|
||||
<span class="hidden">Users: </span>
|
||||
<form class="search_form" name="users" action="" method="get">
|
||||
<input type="hidden" name="action" value="search" />
|
||||
<input id="userssearch" value="Users" type="text" name="search" size="20"/>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="content">
|
||||
<div class="thin">
|
||||
<h2>Forums</h2>
|
||||
<div class="forum_list">
|
||||
<h3>Site</h3>
|
||||
<table class="forum_index">
|
||||
<tbody>
|
||||
<tr class="colhead">
|
||||
<td style="width:2%;"></td>
|
||||
<td style="width:25%;">Forum</td>
|
||||
<td>Last post</td>
|
||||
<td style="width:7%;">Topics</td>
|
||||
<td style="width:7%;">Posts</td>
|
||||
</tr>
|
||||
<tr class="rowb">
|
||||
<td title="Unread" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">Announcements</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="New Site Announcements" href="#">New Site Announcements</a>
|
||||
</span>
|
||||
<span title="Jump to last read" class="last_read" style="float: left;">
|
||||
<a href="#"></a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Rippy</a> <span title="Aug 14 1992, 18:35" class="time">Just now</span></span>
|
||||
</td>
|
||||
<td>385</td>
|
||||
<td>95,197</td>
|
||||
</tr>
|
||||
<tr class="rowa">
|
||||
<td title="Read" class="read"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">What.CD</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="Dear Mortals, you have violated the rule..." href="#">Dear Mortals, you have violated the rule...</a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Drone</a> <span title="Sep 9 1992, 10:55" class="time">3 mins ago</span></span>
|
||||
</td>
|
||||
<td>2,624</td>
|
||||
<td>110,432</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Community</h3>
|
||||
<table class="forum_index">
|
||||
<tbody><tr class="colhead">
|
||||
<td style="width:2%;"></td>
|
||||
<td style="width:25%;">Forum</td>
|
||||
<td>Last post</td>
|
||||
<td style="width:7%;">Topics</td>
|
||||
<td style="width:7%;">Posts</td>
|
||||
</tr>
|
||||
<tr class="rowb">
|
||||
<td title="Unread" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">The Lounge</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="Last stand against Drone?" href="#">Last stand against Drone?</a>
|
||||
</span>
|
||||
<span title="Jump to last read" class="last_read" style="float: left;">
|
||||
<a href="#"></a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Ajax</a> <span class="time">Just now</span></span>
|
||||
</td>
|
||||
<td>37,531</td>
|
||||
<td>1,545,089</td>
|
||||
</tr>
|
||||
<tr class="rowa">
|
||||
<td title="Unread" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">The Lounge +1</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="No fun allowed" href="#">No fun allowed</a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Drone</a> <span class="time">10 mins ago</span></span>
|
||||
</td>
|
||||
<td>424</td>
|
||||
<td>490,163</td>
|
||||
</tr>
|
||||
<tr class="rowb">
|
||||
<td title="Read" class="read"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">The Library</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="List of forbidden literature" href="#">List of forbidden literature</a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Drone</a> <span class="time">7 hours ago</span></span>
|
||||
</td>
|
||||
<td>424</td>
|
||||
<td>490,163</td>
|
||||
</tr>
|
||||
<tr class="rowa">
|
||||
<td title="Read" class="read"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">Concerts, Events & Meets</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="[Region] The Void" href="#">[Region] The Void</a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Drone</a> <span class="time">25 mins ago</span></span>
|
||||
</td>
|
||||
<td>305</td>
|
||||
<td>15,231</td>
|
||||
</tr>
|
||||
<tr class="rowb">
|
||||
<td title="Unread" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">Technology</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="How did Drone take over the site?" href="#">How did Drone take over the site?</a>
|
||||
</span>
|
||||
<span title="Jump to last read" class="last_read" style="float: left;">
|
||||
<a href="#"></a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Etheryte</a> <span class="time">5 mins ago</span></span>
|
||||
</td>
|
||||
<td>25,031</td>
|
||||
<td>386,278</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Music</h3>
|
||||
<table class="forum_index">
|
||||
<tbody>
|
||||
<tr class="colhead">
|
||||
<td style="width:2%;"></td>
|
||||
<td style="width:25%;">Forum</td>
|
||||
<td>Last post</td>
|
||||
<td style="width:7%;">Topics</td>
|
||||
<td style="width:7%;">Posts</td>
|
||||
</tr>
|
||||
<tr class="rowb">
|
||||
<td title="Unread" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">Music</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="Where did all the non-drone threads go?" href="#">Where did all the non-drone threads go?</a>
|
||||
</span>
|
||||
<span title="Jump to last read" class="last_read" style="float: left;">
|
||||
<a href="#"></a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Ananke</a> <span class="time">1 min ago</span></span>
|
||||
</td>
|
||||
<td>22,564</td>
|
||||
<td>608,253</td>
|
||||
</tr>
|
||||
<tr class="rowa">
|
||||
<td title="Unead" class="unread"></td>
|
||||
<td>
|
||||
<h4 class="min_padding">
|
||||
<a href="#">Vanity House</a>
|
||||
</h4>
|
||||
</td>
|
||||
<td>
|
||||
<span class="last_topic" style="float:left;">
|
||||
<a title="Drone - Drone [EP] (drone, noise)" href="#">Drone - Drone [EP] (drone, noise)</a>
|
||||
</span>
|
||||
<span class="last_poster" style="float:right;">by <a href="#">Drone</a> <span class="time">Just now</span></span>
|
||||
</td>
|
||||
<td>3,948</td>
|
||||
<td>24,269</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -200,37 +200,38 @@
|
||||
?>
|
||||
</h2>
|
||||
<div class="linkbox">
|
||||
<br /><br />
|
||||
<?
|
||||
if($ViewingOwn) {
|
||||
if(($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
|
||||
if ($ViewingOwn) {
|
||||
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
|
||||
$DB->query("SELECT TopicID FROM users_subscriptions WHERE UserID = '$LoggedUser[ID]'");
|
||||
$UserSubscriptions = $DB->collect(0);
|
||||
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
|
||||
$DB->set_query_id($Posts);
|
||||
}
|
||||
|
||||
if(!$ShowUnread){ ?>
|
||||
<br /><br />
|
||||
<? if($ShowGrouped) { ?>
|
||||
if (!$ShowUnread) {
|
||||
if ($ShowGrouped) { ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=0" class="brackets">Show all posts</a>
|
||||
<? } else { ?>
|
||||
<? } else { ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=1" class="brackets">Show all posts (grouped)</a>
|
||||
<? } ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a>
|
||||
<? } ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a>
|
||||
<? } else { ?>
|
||||
<br /><br />
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=0" class="brackets">Show all posts</a>
|
||||
<?
|
||||
if(!$ShowGrouped) {
|
||||
?><a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a> <?
|
||||
}
|
||||
else {
|
||||
?><a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=0" class="brackets">Only display posts with unread replies</a> <?
|
||||
}
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=0" class="brackets">Show all posts</a>
|
||||
<? if (!$ShowGrouped) { ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a>
|
||||
<? } else { ?>
|
||||
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=0" class="brackets">Only display posts with unread replies</a>
|
||||
<? }
|
||||
}
|
||||
?>
|
||||
<a href="userhistory.php?action=subscriptions" class="brackets">Go to subscriptions</a>
|
||||
<?
|
||||
} else {
|
||||
?>
|
||||
<a href="forums.php?action=search&type=body&user=<?=$Username?>" class="brackets">Search</a>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -18,13 +18,15 @@ function editOrdering() {
|
||||
var elems = $('#torrents_tables table').objects;
|
||||
for(i in elems) {
|
||||
var elemID = elems[i].id;
|
||||
if(elemID == undefined) { continue; }
|
||||
if(elemID.indexOf('torrents_') == 0) {
|
||||
if (elemID == undefined) {
|
||||
continue;
|
||||
}
|
||||
if (elemID.indexOf('torrents_') == 0) {
|
||||
$('#'+elemID).show();
|
||||
dragObjects[elemID] = new dragObject(elemID, elemID+'_handle', startDrag, moveDrag, endDrag);
|
||||
var classes = elems[i].className.split(' ');
|
||||
for(var j=0; classes.length; j++) {
|
||||
if(classes[j].indexOf('releases_') == 0) {
|
||||
if (classes[j].indexOf('releases_') == 0) {
|
||||
$('.'+classes[j].replace('_table', '')).hide();
|
||||
$('.artist_editcol').show();
|
||||
$('.artist_normalcol').hide();
|
||||
@ -46,17 +48,23 @@ function saveOrdering() {
|
||||
for(i in elems) {
|
||||
var elemID = elems[i].id;
|
||||
var releaseType = null;
|
||||
if(elemID == undefined) { continue; }
|
||||
if(elemID.indexOf('torrents_') == 0) {
|
||||
if (elemID == undefined) {
|
||||
continue;
|
||||
}
|
||||
if (elemID.indexOf('torrents_') == 0) {
|
||||
var classes = elems[i].className.split(' ');
|
||||
for(var j=0; classes.length; j++) {
|
||||
if(classes[j] == null) { break; }
|
||||
if(classes[j].indexOf('releases_') == 0) {
|
||||
if (classes[j] == null) {
|
||||
break;
|
||||
}
|
||||
if (classes[j].indexOf('releases_') == 0) {
|
||||
releaseType = classes[j].split('_')[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(releaseType != null) { releaseTypes += '"' + releaseType + '":' + ($('#releases_' + releaseType + '_defaultopen').raw().checked ? 1 : 0) + ","; }
|
||||
if (releaseType != null) {
|
||||
releaseTypes += '"' + releaseType + '":' + ($('#releases_' + releaseType + '_defaultopen').raw().checked ? 1 : 0) + ",";
|
||||
}
|
||||
}
|
||||
releaseTypes = releaseTypes.substring(0, releaseTypes.length-1) + '}';
|
||||
var postData = new Array();
|
||||
@ -70,17 +78,23 @@ function saveOrderingCallback(response) {
|
||||
//Show/hide
|
||||
var releaseTypes = json.decode(response);
|
||||
for(releaseType in releaseTypes) {
|
||||
if(releaseTypes[releaseType] == 1) { setShow(releaseType, true); }
|
||||
else { setShow(releaseType, false); }
|
||||
if (releaseTypes[releaseType] == 1) {
|
||||
setShow(releaseType, true);
|
||||
} else {
|
||||
setShow(releaseType, false);
|
||||
}
|
||||
}
|
||||
|
||||
//Ordering in linkbox
|
||||
var prevOrderedLink = null;
|
||||
for(releaseType in releaseTypes) {
|
||||
var elem = $('#torrents_' + releaseType + '_anchorlink').raw();
|
||||
if(elem == undefined) { continue; }
|
||||
if(prevOrderedLink == null) { prevOrderedLink = elem; }
|
||||
else {
|
||||
if (elem == undefined) {
|
||||
continue;
|
||||
}
|
||||
if (prevOrderedLink == null) {
|
||||
prevOrderedLink = elem;
|
||||
} else {
|
||||
prevOrderedLink.parentNode.insertBefore(elem, prevOrderedLink.nextSibling);
|
||||
prevOrderedLink = elem;
|
||||
}
|
||||
@ -90,23 +104,33 @@ function saveOrderingCallback(response) {
|
||||
var elems = $('#torrents_tables table').objects;
|
||||
for(i in elems) {
|
||||
var elemID = elems[i].id;
|
||||
if(elemID == undefined) { continue; }
|
||||
if(elemID.indexOf('torrents_') == 0) {
|
||||
if (elemID == undefined) {
|
||||
continue;
|
||||
}
|
||||
if (elemID.indexOf('torrents_') == 0) {
|
||||
var classes = elems[i].className.split(' ');
|
||||
var empty = false;
|
||||
for(var j=0; classes.length; j++) {
|
||||
if(classes[j] == null) { break; }
|
||||
if(classes[j].indexOf('releases_') == 0) {
|
||||
if (classes[j] == null) {
|
||||
break;
|
||||
}
|
||||
if (classes[j].indexOf('releases_') == 0) {
|
||||
$('.artist_editcol').hide();
|
||||
$('.artist_normalcol').show();
|
||||
}
|
||||
if(classes[j].indexOf('empty') == 0) { empty = true; }
|
||||
if (classes[j].indexOf('empty') == 0) {
|
||||
empty = true;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
$('#'+elemID).hide();
|
||||
}
|
||||
if(empty) { $('#'+elemID).hide(); }
|
||||
}
|
||||
}
|
||||
|
||||
for(i in dragObjects) { dragObjects[i].StopListening(); }
|
||||
for(i in dragObjects) {
|
||||
dragObjects[i].StopListening();
|
||||
}
|
||||
dragObjects = null;
|
||||
|
||||
$('#savinglayout').hide();
|
||||
@ -122,30 +146,32 @@ function saveOrderingCallback(response) {
|
||||
}
|
||||
|
||||
function setDefaultShow(id, show) {
|
||||
if(id == 'all') {
|
||||
if (id == 'all') {
|
||||
var elems = $('#torrents_tables table').objects;
|
||||
for(i in elems) {
|
||||
var elemID = elems[i].id;
|
||||
var releaseType = null;
|
||||
if(elemID == undefined) { continue; }
|
||||
if(elemID.indexOf('torrents_') == 0) {
|
||||
if (elemID == undefined) {
|
||||
continue;
|
||||
}
|
||||
if (elemID.indexOf('torrents_') == 0) {
|
||||
var classes = elems[i].className.split(' ');
|
||||
for(var j=0; classes.length; j++) {
|
||||
if(classes[j] == null) { break; }
|
||||
if(classes[j].indexOf('releases_') == 0) {
|
||||
if (classes[j] == null) {
|
||||
break;
|
||||
}
|
||||
if (classes[j].indexOf('releases_') == 0) {
|
||||
releaseType = classes[j].split('_')[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
setDefaultShow(releaseType, show);
|
||||
}
|
||||
}
|
||||
else if(show) {
|
||||
} else if (show) {
|
||||
$('#releases_'+id+'_openlink').hide();
|
||||
$('#releases_'+id+'_closedlink').show();
|
||||
$('#releases_'+id+'_defaultopen').raw().checked = 'checked';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('#releases_'+id+'_openlink').show();
|
||||
$('#releases_'+id+'_closedlink').hide();
|
||||
$('#releases_'+id+'_defaultopen').raw().checked = '';
|
||||
@ -153,12 +179,11 @@ function setDefaultShow(id, show) {
|
||||
}
|
||||
|
||||
function setShow(id, show) {
|
||||
if(show) {
|
||||
if (show) {
|
||||
$('#releases_'+id+'_viewlink').hide();
|
||||
$('#releases_'+id+'_hidelink').show();
|
||||
$('.releases_'+id).show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('#releases_'+id+'_viewlink').show();
|
||||
$('#releases_'+id+'_hidelink').hide();
|
||||
$('.releases_'+id).hide();
|
||||
@ -183,7 +208,7 @@ function startDrag(element) {
|
||||
}
|
||||
|
||||
function moveDrag(element) {
|
||||
if(
|
||||
if (
|
||||
(element.offsetTop > (dragObjectPlaceholder.offsetTop + parseInt(dragObjectPlaceholder.style.height))) ||
|
||||
((element.offsetTop + parseInt(dragObjectPlaceholder.style.height)) < dragObjectPlaceholder.offsetTop)
|
||||
) {
|
||||
@ -192,21 +217,27 @@ function moveDrag(element) {
|
||||
|
||||
for(var i=0; i < elems.length; i++) {
|
||||
elem = elems[i];
|
||||
if(elem == element || elem.nodeName != 'TABLE') { continue; }
|
||||
if (elem == element || elem.nodeName != 'TABLE') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if((element.offsetTop > dragObjectPlaceholder.offsetTop) && (elem.offsetTop - element.offsetTop) > parseInt(element.style.height)) {
|
||||
if ((element.offsetTop > dragObjectPlaceholder.offsetTop) && (elem.offsetTop - element.offsetTop) > parseInt(element.style.height)) {
|
||||
bestItem = elem;
|
||||
break;
|
||||
}
|
||||
else if((element.offsetTop < dragObjectPlaceholder.offsetTop) && (elem.offsetTop + parseInt(element.style.height)) > element.offsetTop) {
|
||||
} else if ((element.offsetTop < dragObjectPlaceholder.offsetTop) && (elem.offsetTop + parseInt(element.style.height)) > element.offsetTop) {
|
||||
bestItem = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bestItem == dragObjectPlaceholder) { return; }
|
||||
if (bestItem == dragObjectPlaceholder) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(bestItem != 'END') { element.parentNode.insertBefore(dragObjectPlaceholder, element.parentNode.childNodes[i]); }
|
||||
else { element.parentNode.appendChild(dragObjectPlaceholder); }
|
||||
if (bestItem != 'END') {
|
||||
element.parentNode.insertBefore(dragObjectPlaceholder, element.parentNode.childNodes[i]);
|
||||
} else {
|
||||
element.parentNode.appendChild(dragObjectPlaceholder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,19 +254,29 @@ function endDrag(element) {
|
||||
|
||||
//Slightly modified from: http://www.switchonthecode.com/tutorials/javascript-draggable-elements
|
||||
function addEvent(element, eventName, callback) {
|
||||
if(element.addEventListener) { element.addEventListener(eventName, callback, false); }
|
||||
else if(element.attachEvent) { element.attachEvent("on" + eventName, callback); }
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener(eventName, callback, false);
|
||||
} else if (element.attachEvent) {
|
||||
element.attachEvent("on" + eventName, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function removeEvent(element, eventName, callback) {
|
||||
if(element.removeEventListener) { element.removeEventListener(eventName, callback, false); }
|
||||
else if(element.detachEvent) { element.detachEvent("on" + eventName, callback); }
|
||||
if (element.removeEventListener) {
|
||||
element.removeEventListener(eventName, callback, false);
|
||||
} else if (element.detachEvent) {
|
||||
element.detachEvent("on" + eventName, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function cancelEvent(e) {
|
||||
e = e ? e : window.event;
|
||||
if(e.stopPropagation) { e.stopPropagation(); }
|
||||
if(e.preventDefault) { e.preventDefault(); }
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
}
|
||||
e.cancelBubble = true;
|
||||
e.cancel = true;
|
||||
e.returnValue = false;
|
||||
@ -248,50 +289,75 @@ function Position(x, y) {
|
||||
|
||||
this.Add = function(val) {
|
||||
var newPos = new Position(this.X, this.Y);
|
||||
if(val != null) {
|
||||
if(!isNaN(val.X)) { newPos.X += val.X; }
|
||||
if(!isNaN(val.Y)) { newPos.Y += val.Y; }
|
||||
if (val != null) {
|
||||
if (!isNaN(val.X)) {
|
||||
newPos.X += val.X;
|
||||
}
|
||||
if (!isNaN(val.Y)) {
|
||||
newPos.Y += val.Y;
|
||||
}
|
||||
}
|
||||
return newPos;
|
||||
}
|
||||
|
||||
this.Subtract = function(val) {
|
||||
var newPos = new Position(this.X, this.Y);
|
||||
if(val != null) {
|
||||
if(!isNaN(val.X)) { newPos.X -= val.X; }
|
||||
if(!isNaN(val.Y)) { newPos.Y -= val.Y; }
|
||||
if (val != null) {
|
||||
if (!isNaN(val.X)) {
|
||||
newPos.X -= val.X;
|
||||
}
|
||||
if (!isNaN(val.Y)) {
|
||||
newPos.Y -= val.Y;
|
||||
}
|
||||
}
|
||||
return newPos;
|
||||
}
|
||||
|
||||
this.Check = function() {
|
||||
var newPos = new Position(this.X, this.Y);
|
||||
if(isNaN(newPos.X)) { newPos.X = 0; }
|
||||
if(isNaN(newPos.Y)) { newPos.Y = 0; }
|
||||
if (isNaN(newPos.X)) {
|
||||
newPos.X = 0;
|
||||
}
|
||||
if (isNaN(newPos.Y)) {
|
||||
newPos.Y = 0;
|
||||
}
|
||||
return newPos;
|
||||
}
|
||||
|
||||
this.Apply = function(element, horizontal, vertical) {
|
||||
if(!isNaN(this.X) && horizontal) { element.style.left = this.X + 'px'; }
|
||||
if(!isNaN(this.Y) && vertical) { element.style.top = this.Y + 'px'; }
|
||||
if (!isNaN(this.X) && horizontal) {
|
||||
element.style.left = this.X + 'px';
|
||||
}
|
||||
if (!isNaN(this.Y) && vertical) {
|
||||
element.style.top = this.Y + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function absoluteCursorPostion(eventObj) {
|
||||
eventObj = eventObj ? eventObj : window.event;
|
||||
|
||||
if(isNaN(window.scrollX)) {
|
||||
if (isNaN(window.scrollX)) {
|
||||
return new Position(eventObj.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, eventObj.clientY + document.documentElement.scrollTop + document.body.scrollTop);
|
||||
} else {
|
||||
return new Position(eventObj.clientX + window.scrollX, eventObj.clientY + window.scrollY);
|
||||
}
|
||||
else { return new Position(eventObj.clientX + window.scrollX, eventObj.clientY + window.scrollY); }
|
||||
}
|
||||
|
||||
function dragObject(element, handlerElement, startCallback, moveCallback, endCallback) {
|
||||
if(typeof(element) == "string") { element = $('#' + element).raw(); }
|
||||
if(element == null) { return; }
|
||||
if (typeof(element) == "string") {
|
||||
element = $('#' + element).raw();
|
||||
}
|
||||
if (element == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(handlerElement) == "string") { handlerElement = $('#' + handlerElement).raw(); }
|
||||
if(handlerElement == null) { handlerElement = element; }
|
||||
if (typeof(handlerElement) == "string") {
|
||||
handlerElement = $('#' + handlerElement).raw();
|
||||
}
|
||||
if (handlerElement == null) {
|
||||
handlerElement = element;
|
||||
}
|
||||
|
||||
var cursorStartPos = null;
|
||||
var elementStartPos = null;
|
||||
@ -300,14 +366,18 @@ function dragObject(element, handlerElement, startCallback, moveCallback, endCal
|
||||
var disposed = false;
|
||||
|
||||
function dragStart(eventObj) {
|
||||
if(dragging || !listening || disposed) { return; }
|
||||
if (dragging || !listening || disposed) {
|
||||
return;
|
||||
}
|
||||
dragging = true;
|
||||
|
||||
cursorStartPos = absoluteCursorPostion(eventObj);
|
||||
elementStartPos = new Position(parseInt(element.offsetLeft), parseInt(element.offsetTop));
|
||||
elementStartPos = elementStartPos.Check();
|
||||
|
||||
if(startCallback != null) { startCallback(element); }
|
||||
if (startCallback != null) {
|
||||
startCallback(element);
|
||||
}
|
||||
|
||||
addEvent(document, "mousemove", dragGo);
|
||||
addEvent(document, "mouseup", dragStopHook);
|
||||
@ -316,24 +386,32 @@ function dragObject(element, handlerElement, startCallback, moveCallback, endCal
|
||||
}
|
||||
|
||||
function dragGo(eventObj) {
|
||||
if(!dragging || disposed) { return; }
|
||||
if (!dragging || disposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newPos = absoluteCursorPostion(eventObj);
|
||||
newPos = newPos.Add(elementStartPos).Subtract(cursorStartPos);
|
||||
newPos.Apply(element, false, true);
|
||||
if(moveCallback != null) { moveCallback(element); }
|
||||
if (moveCallback != null) {
|
||||
moveCallback(element);
|
||||
}
|
||||
|
||||
return cancelEvent(eventObj);
|
||||
}
|
||||
|
||||
function dragStop() {
|
||||
if(!dragging || disposed) { return; }
|
||||
if (!dragging || disposed) {
|
||||
return;
|
||||
}
|
||||
removeEvent(document, "mousemove", dragGo);
|
||||
removeEvent(document, "mouseup", dragStopHook);
|
||||
cursorStartPos = null;
|
||||
elementStartPos = null;
|
||||
|
||||
if(endCallback != null) { endCallback(element); }
|
||||
if (endCallback != null) {
|
||||
endCallback(element);
|
||||
}
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
@ -343,7 +421,9 @@ function dragObject(element, handlerElement, startCallback, moveCallback, endCal
|
||||
}
|
||||
|
||||
this.Dispose = function() {
|
||||
if(disposed) { return; }
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
this.StopListening(true);
|
||||
element = null;
|
||||
handlerElement = null
|
||||
@ -354,16 +434,22 @@ function dragObject(element, handlerElement, startCallback, moveCallback, endCal
|
||||
}
|
||||
|
||||
this.StartListening = function() {
|
||||
if(listening || disposed) { return; }
|
||||
if (listening || disposed) {
|
||||
return;
|
||||
}
|
||||
listening = true;
|
||||
addEvent(handlerElement, "mousedown", dragStart);
|
||||
}
|
||||
|
||||
this.StopListening = function(stopCurrentDragging) {
|
||||
if(!listening || disposed) { return; }
|
||||
if (!listening || disposed) {
|
||||
return;
|
||||
}
|
||||
removeEvent(handlerElement, "mousedown", dragStart);
|
||||
listening = false;
|
||||
|
||||
if(stopCurrentDragging && dragging) { dragStop(); }
|
||||
if (stopCurrentDragging && dragging) {
|
||||
dragStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,13 @@ var postid;
|
||||
function QuoteJump(event, post) {
|
||||
var button = event.button;
|
||||
var hash = "#post" + post;
|
||||
if(button == 0) {
|
||||
if($(hash).raw() != null) {
|
||||
if (button == 0) {
|
||||
if ($(hash).raw() != null) {
|
||||
window.location.hash = hash;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window.open("forums.php?action=viewthread&postid="+post, '_self');
|
||||
}
|
||||
} else if(button == 1) {
|
||||
} else if (button == 1) {
|
||||
window.open("forums.php?action=viewthread&postid="+post, '_window');
|
||||
}
|
||||
}
|
||||
@ -36,37 +35,37 @@ function Quote(post, user, link) {
|
||||
}
|
||||
|
||||
function Edit_Form(post,key) {
|
||||
postid = post;
|
||||
//If no edit is already going underway or a previous edit was finished, make the necessary dom changes.
|
||||
if(!$('#editbox' + postid).objects[0] || $('#editbox' + postid + '.hidden').objects[0]) {
|
||||
$('#reply_box').hide();
|
||||
if (location.href.match(/torrents\.php/) ||
|
||||
location.href.match(/artist\.php/)) {
|
||||
boxWidth="50";
|
||||
} else {
|
||||
boxWidth="80";
|
||||
postid = post;
|
||||
//If no edit is already going underway or a previous edit was finished, make the necessary dom changes.
|
||||
if (!$('#editbox' + postid).objects[0] || $('#editbox' + postid + '.hidden').objects[0]) {
|
||||
$('#reply_box').hide();
|
||||
if (location.href.match(/torrents\.php/) ||
|
||||
location.href.match(/artist\.php/)) {
|
||||
boxWidth="50";
|
||||
} else {
|
||||
boxWidth="80";
|
||||
}
|
||||
postuserid = $('#post' + postid + ' strong a').raw().getAttribute('href').split('=')[1]
|
||||
/* jQuery isnt enabled on comments, artist comments, or basically anywhere but thread.php
|
||||
Re-enable this clause as soon as hateradio's "bye sizzle" changes go into effect, changing
|
||||
the jQuery object to $ (which will, then, be jQuery rather than sizzle)
|
||||
postuserid = jQuery('#post' + postid + ' strong a').attr('href').split('=')[1];
|
||||
*/
|
||||
if (postuserid != userid) {
|
||||
pmbox = '<span id="pmbox'+postid+'">PM user on edit? <input type="checkbox" name="pm" value="1" /></span>';
|
||||
} else {
|
||||
pmbox = '';
|
||||
};
|
||||
$('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML;
|
||||
$('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML;
|
||||
$('#content' + postid).raw().innerHTML = "<div id=\"preview" + postid + "\"></div><form id=\"form" + postid + "\" method=\"post\" action=\"\">"+pmbox+"<input type=\"hidden\" name=\"auth\" value=\"" + authkey + "\" /><input type=\"hidden\" name=\"key\" value=\"" + key + "\" /><input type=\"hidden\" name=\"post\" value=\"" + postid + "\" /><textarea id=\"editbox" + postid + "\" onkeyup=\"resize('editbox" + postid + "');\" name=\"body\" cols=\""+boxWidth+"\" rows=\"10\"></textarea></form>";
|
||||
$('#bar' + postid).raw().innerHTML = '<input type="button" value="Preview" onclick="Preview_Edit(' + postid + ');" /><input type="button" value="Post" onclick="Save_Edit(' + postid + ')" /><input type="button" value="Cancel" onclick="Cancel_Edit(' + postid + ');" />';
|
||||
}
|
||||
postuserid = $('#post' + postid + ' strong a').raw().getAttribute('href').split('=')[1]
|
||||
/* jQuery isnt enabled on comments, artist comments, or basically anywhere but thread.php
|
||||
Re-enable this clause as soon as hateradio's "bye sizzle" changes go into effect, changing
|
||||
the jQuery object to $ (which will, then, be jQuery rather than sizzle)
|
||||
postuserid = jQuery('#post' + postid + ' strong a').attr('href').split('=')[1];
|
||||
*/
|
||||
if (postuserid != userid) {
|
||||
pmbox = '<span id="pmbox'+postid+'">PM user on edit? <input type="checkbox" name="pm" value="1" /></span>';
|
||||
} else {
|
||||
pmbox = '';
|
||||
};
|
||||
$('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML;
|
||||
$('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML;
|
||||
$('#content' + postid).raw().innerHTML = "<div id=\"preview" + postid + "\"></div><form id=\"form" + postid + "\" method=\"post\" action=\"\">"+pmbox+"<input type=\"hidden\" name=\"auth\" value=\"" + authkey + "\" /><input type=\"hidden\" name=\"key\" value=\"" + key + "\" /><input type=\"hidden\" name=\"post\" value=\"" + postid + "\" /><textarea id=\"editbox" + postid + "\" onkeyup=\"resize('editbox" + postid + "');\" name=\"body\" cols=\""+boxWidth+"\" rows=\"10\"></textarea></form>";
|
||||
$('#bar' + postid).raw().innerHTML = '<input type="button" value="Preview" onclick="Preview_Edit(' + postid + ');" /><input type="button" value="Post" onclick="Save_Edit(' + postid + ')" /><input type="button" value="Cancel" onclick="Cancel_Edit(' + postid + ');" />';
|
||||
}
|
||||
/* If it's the initial edit, fetch the post content to be edited.
|
||||
* If editing is already underway and edit is pressed again, reset the post
|
||||
* (keeps current functionality, move into brackets to stop from happening).
|
||||
*/
|
||||
ajax.get("?action=get_post&post=" + postid, function(response){
|
||||
/* If it's the initial edit, fetch the post content to be edited.
|
||||
* If editing is already underway and edit is pressed again, reset the post
|
||||
* (keeps current functionality, move into brackets to stop from happening).
|
||||
*/
|
||||
ajax.get("?action=get_post&post=" + postid, function(response){
|
||||
$('#editbox' + postid).raw().value = html_entity_decode(response);
|
||||
resize('editbox' + postid);
|
||||
});
|
||||
@ -146,10 +145,10 @@ function Delete(post) {
|
||||
ajax.get("requests.php?action=delete_comment&auth=" + authkey + "&postid=" + postid, function () {
|
||||
$('#post' + postid).hide();
|
||||
});
|
||||
} else if (location.href.match(/artist\.php/)) {
|
||||
ajax.get("artist.php?action=delete_comment&auth="+authkey+ "&postid=" + postid, function (){
|
||||
$('#post' + postid).hide();
|
||||
});
|
||||
} else if (location.href.match(/artist\.php/)) {
|
||||
ajax.get("artist.php?action=delete_comment&auth="+authkey+ "&postid=" + postid, function (){
|
||||
$('#post' + postid).hide();
|
||||
});
|
||||
} else {
|
||||
ajax.get("torrents.php?action=delete_post&auth=" + authkey + "&postid=" + postid, function () {
|
||||
$('#post' + postid).hide();
|
||||
@ -180,17 +179,19 @@ function Quick_Edit() {
|
||||
function Newthread_Preview(mode) {
|
||||
$('#newthreadpreviewbutton').toggle();
|
||||
$('#newthreadeditbutton').toggle();
|
||||
if(mode) { // Preview
|
||||
if (mode) { // Preview
|
||||
ajax.post("ajax.php?action=preview","newthreadform", function(response){
|
||||
$('#contentpreview').raw().innerHTML = response;
|
||||
});
|
||||
$('#newthreadtitle').raw().innerHTML = $('#title').raw().value;
|
||||
var pollanswers = $('#answer_block').raw();
|
||||
if(pollanswers && pollanswers.children.length > 4) {
|
||||
if (pollanswers && pollanswers.children.length > 4) {
|
||||
pollanswers = pollanswers.children;
|
||||
$('#pollquestion').raw().innerHTML = $('#pollquestionfield').raw().value;
|
||||
for(var i=0; i<pollanswers.length; i+=2) {
|
||||
if(!pollanswers[i].value) { continue; }
|
||||
if (!pollanswers[i].value) {
|
||||
continue;
|
||||
}
|
||||
var el = document.createElement('input');
|
||||
el.id = 'answer_'+(i+1);
|
||||
el.type = 'radio';
|
||||
@ -203,7 +204,7 @@ function Newthread_Preview(mode) {
|
||||
$('#pollanswers').raw().appendChild(el);
|
||||
$('#pollanswers').raw().appendChild(document.createElement('br'));
|
||||
}
|
||||
if($('#pollanswers').raw().children.length > 4) {
|
||||
if ($('#pollanswers').raw().children.length > 4) {
|
||||
$('#pollpreview').show();
|
||||
}
|
||||
}
|
||||
@ -211,7 +212,7 @@ function Newthread_Preview(mode) {
|
||||
$('#pollpreview').hide();
|
||||
$('#newthreadtitle').raw().innerHTML = 'New Topic';
|
||||
var pollanswers = $('#pollanswers').raw();
|
||||
if(pollanswers) {
|
||||
if (pollanswers) {
|
||||
var el = document.createElement('div');
|
||||
el.id = 'pollanswers';
|
||||
pollanswers.parentNode.replaceChild(el, pollanswers);
|
||||
|
44
static/functions/cssgallery.js
Normal file
44
static/functions/cssgallery.js
Normal file
@ -0,0 +1,44 @@
|
||||
(function($) {
|
||||
$(document).ready(function () {
|
||||
// If the custom stylesheet field is empty, select the current style from the previews
|
||||
if (!$('input#styleurl').val()){
|
||||
$('input[name="stylesheet_gallery"][value="'+$('select#stylesheet').val()+'"]').click();
|
||||
}
|
||||
// If an overlay is clicked, select the right item in the dropdown and clear the custom CSS field
|
||||
$('div.preview_overlay').click(function() {
|
||||
var radiobutton = $(this).parent().find('input');
|
||||
radiobutton.prop('checked', true);
|
||||
$('select#stylesheet').val(radiobutton.attr('value'));
|
||||
$('input#styleurl').val('');
|
||||
})
|
||||
// If the input is clicked, redirect it to the overlay click event
|
||||
$('input[name="stylesheet_gallery"]').change(function() {
|
||||
$(this).parent().parent().find('div.preview_overlay').click();
|
||||
})
|
||||
// If the dropdown is changed, select the appropriate item in gallery, clear the custom CSS field
|
||||
$('select#stylesheet').change(function() {
|
||||
$('input[name="stylesheet_gallery"][value="'+$(this).val()+'"]').prop('checked', true);
|
||||
$('input#styleurl').val('');
|
||||
})
|
||||
// If the custom CSS field is changed, clear radio buttons
|
||||
$('input#styleurl').keydown(function() {
|
||||
$('input[name="stylesheet_gallery"]').each(function() {
|
||||
$(this).prop('checked', false);
|
||||
})
|
||||
})
|
||||
// If the input is empty, select appropriate gallery item again by the dropdown
|
||||
$('input#styleurl').keyup(function() {
|
||||
if (!$(this).val()){
|
||||
$('select#stylesheet').change();
|
||||
}
|
||||
})
|
||||
// Allow the CSS gallery to be expanded/contracted
|
||||
$('#toggle_css_gallery').click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#css_gallery').slideToggle(function () {
|
||||
$('#toggle_css_gallery').text($(this).is(':visible') ? 'Hide gallery' : 'Show gallery');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
})(jQuery);
|
@ -1,363 +1,359 @@
|
||||
|
||||
(function ($) {
|
||||
var username;
|
||||
// How many entries to show per category before expanding
|
||||
var initialCount = 3;
|
||||
var tasteometer = "";
|
||||
var lastPlayedTrack = "";
|
||||
var sharedArtists = "";
|
||||
var topArtists = "";
|
||||
var topAlbums = "";
|
||||
var topTracks = "";
|
||||
var expanded = false;
|
||||
// Failed request flag.
|
||||
var flag = 0;
|
||||
$(document).ready(function () {
|
||||
// Avoid conflicting with other jQuery instances (userscripts et al).
|
||||
$.noConflict();
|
||||
// Fetch the username (appended from php) to base all get requests on.
|
||||
username = $('#lastfm_username').text();
|
||||
var div = $('#lastfm_stats');
|
||||
// Fetch the required data.
|
||||
// If data isn't cached, delays are issued in the class to avoid too many parallel requests to Last.fm
|
||||
getTasteometer(div);
|
||||
getLastPlayedTrack(div);
|
||||
getTopArtists(div);
|
||||
getTopAlbums(div);
|
||||
getTopTracks(div);
|
||||
// Allow expanding the show information to more than three entries.
|
||||
// Attach to document as lastfm_expand links are added dynamically when fetching the data.
|
||||
$(document).on('click', "#lastfm_expand", function () {
|
||||
// Make hidden entries visible and remove the expand button.
|
||||
if ( $(this).attr("href") == "#sharedartists" ){
|
||||
sharedArtists = sharedArtists.replace(/\ class="hidden"/g,"");
|
||||
sharedArtists = sharedArtists.replace(/<li>\[<a\ href=\"#sharedartists.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#topartists" ){
|
||||
topArtists = topArtists.replace(/\ class="hidden"/g,"");
|
||||
topArtists = topArtists.replace(/<li>\[<a\ href=\"#topartists.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#topalbums" ){
|
||||
topAlbums = topAlbums.replace(/\ class="hidden"/g,"");
|
||||
topAlbums = topAlbums.replace(/<li>\[<a\ href=\"#topalbums.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#toptracks" ){
|
||||
topTracks = topTracks.replace(/\ class="hidden"/g,"");
|
||||
topTracks = topTracks.replace(/<li>\[<a\ href=\"#toptracks.*\]<\/li>/,"");
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
// Allow expanding or collapsing the Last.fm data.
|
||||
$("#lastfm_expand").on('click', function () {
|
||||
if(expanded == false){
|
||||
expanded = true;
|
||||
$(this).html("Show less info");
|
||||
} else {
|
||||
expanded = false;
|
||||
$(this).html("Show more info");
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
// Hide the reload button until data is expanded.
|
||||
$("#lastfm_reload_container").addClass("hidden");
|
||||
// Allow reloading the data manually.
|
||||
$.urlParam = function(name){
|
||||
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||
return results[1] || 0;
|
||||
}
|
||||
$("#lastfm_reload").on('click', function () {
|
||||
// Clear the cache and the necessary variables.
|
||||
$.get('user.php?action=lastfm_clear_cache&username=' + username + '&uid=' + $.urlParam('id'), function (response) {
|
||||
});
|
||||
tasteometer = "";
|
||||
lastPlayedTrack = "";
|
||||
sharedArtists = "";
|
||||
topArtists = "";
|
||||
topAlbums = "";
|
||||
topTracks = "";
|
||||
// Revert the sidebar box to its initial state.
|
||||
$("#lastfm_stats").html("");
|
||||
//$(".box_lastfm").children("ul").append('<li id="lastfm_loading">Loading...</li>');
|
||||
$("#lastfm_stats").append('<li id="lastfm_loading">Loading...</li>');
|
||||
// Remove the stats reload button.
|
||||
$("#lastfm_reload_container").remove();
|
||||
getTasteometer(div);
|
||||
getLastPlayedTrack(div);
|
||||
getTopArtists(div);
|
||||
getTopAlbums(div);
|
||||
getTopTracks(div);
|
||||
});
|
||||
});
|
||||
var username;
|
||||
// How many entries to show per category before expanding
|
||||
var initialCount = 3;
|
||||
var tasteometer = "";
|
||||
var lastPlayedTrack = "";
|
||||
var sharedArtists = "";
|
||||
var topArtists = "";
|
||||
var topAlbums = "";
|
||||
var topTracks = "";
|
||||
var expanded = false;
|
||||
// Failed request flag.
|
||||
var flag = 0;
|
||||
$(document).ready(function () {
|
||||
// Avoid conflicting with other jQuery instances (userscripts et al).
|
||||
$.noConflict();
|
||||
// Fetch the username (appended from php) to base all get requests on.
|
||||
username = $('#lastfm_username').text();
|
||||
var div = $('#lastfm_stats');
|
||||
// Fetch the required data.
|
||||
// If data isn't cached, delays are issued in the class to avoid too many parallel requests to Last.fm
|
||||
getTasteometer(div);
|
||||
getLastPlayedTrack(div);
|
||||
getTopArtists(div);
|
||||
getTopAlbums(div);
|
||||
getTopTracks(div);
|
||||
// Allow expanding the show information to more than three entries.
|
||||
// Attach to document as lastfm_expand links are added dynamically when fetching the data.
|
||||
$(document).on('click', "#lastfm_expand", function () {
|
||||
// Make hidden entries visible and remove the expand button.
|
||||
if ( $(this).attr("href") == "#sharedartists" ) {
|
||||
sharedArtists = sharedArtists.replace(/\ class="hidden"/g,"");
|
||||
sharedArtists = sharedArtists.replace(/<li>\[<a\ href=\"#sharedartists.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#topartists" ) {
|
||||
topArtists = topArtists.replace(/\ class="hidden"/g,"");
|
||||
topArtists = topArtists.replace(/<li>\[<a\ href=\"#topartists.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#topalbums" ) {
|
||||
topAlbums = topAlbums.replace(/\ class="hidden"/g,"");
|
||||
topAlbums = topAlbums.replace(/<li>\[<a\ href=\"#topalbums.*\]<\/li>/,"");
|
||||
} else if ( $(this).attr("href") == "#toptracks" ) {
|
||||
topTracks = topTracks.replace(/\ class="hidden"/g,"");
|
||||
topTracks = topTracks.replace(/<li>\[<a\ href=\"#toptracks.*\]<\/li>/,"");
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
// Allow expanding or collapsing the Last.fm data.
|
||||
$("#lastfm_expand").on('click', function () {
|
||||
if (expanded == false) {
|
||||
expanded = true;
|
||||
$(this).html("Show less info");
|
||||
} else {
|
||||
expanded = false;
|
||||
$(this).html("Show more info");
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
// Hide the reload button until data is expanded.
|
||||
$("#lastfm_reload_container").addClass("hidden");
|
||||
// Allow reloading the data manually.
|
||||
$.urlParam = function(name) {
|
||||
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||
return results[1] || 0;
|
||||
}
|
||||
$("#lastfm_reload").on('click', function () {
|
||||
// Clear the cache and the necessary variables.
|
||||
$.get('user.php?action=lastfm_clear_cache&username=' + username + '&uid=' + $.urlParam('id'), function (response) {
|
||||
});
|
||||
tasteometer = "";
|
||||
lastPlayedTrack = "";
|
||||
sharedArtists = "";
|
||||
topArtists = "";
|
||||
topAlbums = "";
|
||||
topTracks = "";
|
||||
// Revert the sidebar box to its initial state.
|
||||
$("#lastfm_stats").html("");
|
||||
//$(".box_lastfm").children("ul").append('<li id="lastfm_loading">Loading...</li>');
|
||||
$("#lastfm_stats").append('<li id="lastfm_loading">Loading...</li>');
|
||||
// Remove the stats reload button.
|
||||
$("#lastfm_reload_container").remove();
|
||||
getTasteometer(div);
|
||||
getLastPlayedTrack(div);
|
||||
getTopArtists(div);
|
||||
getTopAlbums(div);
|
||||
getTopTracks(div);
|
||||
});
|
||||
});
|
||||
|
||||
// Allow updating the sidebar element contents as get requests are completed.
|
||||
function updateDivContents(div) {
|
||||
var html = "";
|
||||
// Pass all data vars, gets that haven't completed yet append empty strings.
|
||||
html += tasteometer;
|
||||
html += lastPlayedTrack;
|
||||
html += sharedArtists;
|
||||
html += topArtists;
|
||||
html += topAlbums;
|
||||
html += topTracks;
|
||||
html += '<li id="lastfm_loading">Loading...</li>';
|
||||
div.html(html);
|
||||
// If the data isn't expanded hide most of the info.
|
||||
if( expanded == false ){
|
||||
$("#lastfm_stats").children(":not(.lastfm_essential)").addClass("hidden");
|
||||
$("#lastfm_reload_container").addClass("hidden");
|
||||
} else {
|
||||
$("#lastfm_reload_container").removeClass("hidden");
|
||||
}
|
||||
// Once all requests are completed, remove the loading message.
|
||||
if(tasteometer && lastPlayedTrack && sharedArtists && topArtists && topAlbums && topTracks){
|
||||
$('#lastfm_loading').remove();
|
||||
}
|
||||
}
|
||||
// Allow updating the sidebar element contents as get requests are completed.
|
||||
function updateDivContents(div) {
|
||||
var html = "";
|
||||
// Pass all data vars, gets that haven't completed yet append empty strings.
|
||||
html += tasteometer;
|
||||
html += lastPlayedTrack;
|
||||
html += sharedArtists;
|
||||
html += topArtists;
|
||||
html += topAlbums;
|
||||
html += topTracks;
|
||||
html += '<li id="lastfm_loading">Loading...</li>';
|
||||
div.html(html);
|
||||
// If the data isn't expanded hide most of the info.
|
||||
if ( expanded == false ) {
|
||||
$("#lastfm_stats").children(":not(.lastfm_essential)").addClass("hidden");
|
||||
$("#lastfm_reload_container").addClass("hidden");
|
||||
} else {
|
||||
$("#lastfm_reload_container").removeClass("hidden");
|
||||
}
|
||||
// Once all requests are completed, remove the loading message.
|
||||
if (tasteometer && lastPlayedTrack && sharedArtists && topArtists && topAlbums && topTracks) {
|
||||
$('#lastfm_loading').remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Escape ampersands with url code to avoid breaking the search links
|
||||
function escapeAmpUrl(input){
|
||||
return input.replace(/&/g,"%26");
|
||||
}
|
||||
// Escape ampersands with url code to avoid breaking the search links
|
||||
function escapeAmpUrl(input) {
|
||||
return input.replace(/&/g,"%26");
|
||||
}
|
||||
|
||||
// Escape ampersands with html code to avoid breaking the search links
|
||||
function escapeHtml(input){
|
||||
return input.replace(/&/g,"&").replace(/</g,"<");
|
||||
}
|
||||
// Escape ampersands with html code to avoid breaking the search links
|
||||
function escapeHtml(input) {
|
||||
return input.replace(/&/g,"&").replace(/</g,"<");
|
||||
}
|
||||
|
||||
|
||||
// Functions for fetching the required data are as follows.
|
||||
// Also gets the data for shared artists as they're bundled.
|
||||
function getTasteometer(div) {
|
||||
if ($("#lastfm_stats").attr("data-uid")){
|
||||
//Own profile, don't show tasteometer and shared artists.
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
} else {
|
||||
$.get('user.php?action=lastfm_compare&username=' + username, function (response) {
|
||||
// Two separate elements are received from one Last.fm API call.
|
||||
var tasteometerHtml = "";
|
||||
var sharedArtistsHtml = "";
|
||||
if ( response ){
|
||||
json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Tasteometer: " + json['message']);
|
||||
// Specified non-existant username for Last.fm, remove Last.fm box from page.
|
||||
if (json['error'] == "7" ){
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
}
|
||||
} else if (json == null) {
|
||||
// No Last.fm compare possible.
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
} else {
|
||||
var j = json['comparison']['result'];
|
||||
var a = j['artists']['artist'];
|
||||
tasteometerHtml += '<li class="lastfm_essential">Compatibility: ';
|
||||
var compatibility = Math.round(j['score'] * 100);
|
||||
var background;
|
||||
// Functions for fetching the required data are as follows.
|
||||
// Also gets the data for shared artists as they're bundled.
|
||||
function getTasteometer(div) {
|
||||
if ($("#lastfm_stats").attr("data-uid")) {
|
||||
//Own profile, don't show tasteometer and shared artists.
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
} else {
|
||||
$.get('user.php?action=lastfm_compare&username=' + username, function (response) {
|
||||
// Two separate elements are received from one Last.fm API call.
|
||||
var tasteometerHtml = "";
|
||||
var sharedArtistsHtml = "";
|
||||
if ( response ) {
|
||||
json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Tasteometer: " + json['message']);
|
||||
// Specified non-existant username for Last.fm, remove Last.fm box from page.
|
||||
if (json['error'] == "7" ) {
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
}
|
||||
} else if (json == null) {
|
||||
// No Last.fm compare possible.
|
||||
tasteometer = " ";
|
||||
sharedArtists = " ";
|
||||
} else {
|
||||
var j = json['comparison']['result'];
|
||||
var a = j['artists']['artist'];
|
||||
tasteometerHtml += '<li class="lastfm_essential">Compatibility: ';
|
||||
var compatibility = Math.round(j['score'] * 100);
|
||||
var background;
|
||||
if (compatibility < 0 || compatibility > 100) {
|
||||
compatibility = "Unknown";
|
||||
tasteometerHtml += compatibility;
|
||||
} else {
|
||||
if (compatibility < 50){
|
||||
if (compatibility < 50) {
|
||||
background = 'rgb(255, '+Math.floor(255*compatibility/50)+', 0)'
|
||||
} else {
|
||||
background = 'rgb('+Math.floor((1-(compatibility-50)/50)*255)+', 255, 0)'
|
||||
}
|
||||
tasteometerHtml += compatibility + '%\r\
|
||||
<li class="lastfm_essential">\r\
|
||||
<div id="lastfm_compatibilitybar_container">\n\
|
||||
<div id="lastfm_compatibilitybar" style="width: '+compatibility+'%; background: '+background+';">\n\
|
||||
</div>\r\
|
||||
</div>\r\
|
||||
</li>';
|
||||
<li class="lastfm_essential">\r\
|
||||
<div id="lastfm_compatibilitybar_container">\n\
|
||||
<div id="lastfm_compatibilitybar" style="width: '+compatibility+'%; background: '+background+';">\n\
|
||||
</div>\r\
|
||||
</div>\r\
|
||||
</li>';
|
||||
}
|
||||
// Only print shared artists if there are any
|
||||
if (j['artists']['matches'] != 0){
|
||||
sharedArtistsHtml += '<li>Shared artists:</li><li><ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (a.length < 3) k = a.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
sharedArtistsHtml += '<li><a href="artist.php?artistname=' + escapeAmpUrl(a[i]['name']) + '">' + escapeHtml(a[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( a.length > 3 ){
|
||||
for (i = 3; i < a.length; i++) {
|
||||
sharedArtistsHtml += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(a[i]['name']) + '">' + escapeHtml(a[i]['name']) + '</a></li>'
|
||||
}
|
||||
sharedArtistsHtml += '<li><a href="#sharedartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
sharedArtistsHtml += '</ul></li>';
|
||||
sharedArtists = sharedArtistsHtml;
|
||||
} else {
|
||||
// Allow removing loading message regardless.
|
||||
sharedArtists = " ";
|
||||
sharedArtistsHtml += '<li class="lastfm_expand"><a href="#sharedartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
tasteometerHtml += "</li>";
|
||||
tasteometer = tasteometerHtml;
|
||||
}
|
||||
} else {
|
||||
sharedArtists = " ";
|
||||
tasteometer = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
}
|
||||
// Only print shared artists if there are any
|
||||
if (j['artists']['matches'] != 0) {
|
||||
sharedArtistsHtml += '<li>Shared artists:</li><li><ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (a.length < 3) k = a.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
sharedArtistsHtml += '<li><a href="artist.php?artistname=' + escapeAmpUrl(a[i]['name']) + '">' + escapeHtml(a[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( a.length > 3 ) {
|
||||
for (i = 3; i < a.length; i++) {
|
||||
sharedArtistsHtml += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(a[i]['name']) + '">' + escapeHtml(a[i]['name']) + '</a></li>'
|
||||
}
|
||||
sharedArtistsHtml += '<li><a href="#sharedartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
sharedArtistsHtml += '</ul></li>';
|
||||
sharedArtists = sharedArtistsHtml;
|
||||
} else {
|
||||
// Allow removing loading message regardless.
|
||||
sharedArtists = " ";
|
||||
sharedArtistsHtml += '<li class="lastfm_expand"><a href="#sharedartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
tasteometerHtml += "</li>";
|
||||
tasteometer = tasteometerHtml;
|
||||
}
|
||||
} else {
|
||||
sharedArtists = " ";
|
||||
tasteometer = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getLastPlayedTrack(div) {
|
||||
$.get('user.php?action=lastfm_last_played_track&username=' + username, function (response) {
|
||||
var html = "";
|
||||
if ( response ){
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Last played track: " + json['message']);
|
||||
lastPlayedTrack = " ";
|
||||
}
|
||||
else if (json == null) {
|
||||
// No last played track available.
|
||||
// Allow removing the loading message regardless.
|
||||
lastPlayedTrack = " ";
|
||||
} else {
|
||||
// Fix Last.fm API returning more than one entry despite limit on certain conditions.
|
||||
if ( typeof(json[0]) === "object" ) json = json[0];
|
||||
html += '<li class="lastfm_essential">Last played: ';
|
||||
html += '<a href="artist.php?artistname=' + escapeAmpUrl(json['artist']['#text']) + '">' + escapeHtml(json['artist']['#text']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(json['artist']['#text']) +'&filelist=' + escapeAmpUrl(json['name']) + '">' + escapeHtml(json['name']) + '</a>';
|
||||
html += "</li>";
|
||||
lastPlayedTrack = html;
|
||||
}
|
||||
} else {
|
||||
lastPlayedTrack = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
function getLastPlayedTrack(div) {
|
||||
$.get('user.php?action=lastfm_last_played_track&username=' + username, function (response) {
|
||||
var html = "";
|
||||
if ( response ) {
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Last played track: " + json['message']);
|
||||
lastPlayedTrack = " ";
|
||||
} else if (json == null) {
|
||||
// No last played track available.
|
||||
// Allow removing the loading message regardless.
|
||||
lastPlayedTrack = " ";
|
||||
} else {
|
||||
// Fix Last.fm API returning more than one entry despite limit on certain conditions.
|
||||
if ( typeof(json[0]) === "object" ) json = json[0];
|
||||
html += '<li class="lastfm_essential">Last played: ';
|
||||
html += '<a href="artist.php?artistname=' + escapeAmpUrl(json['artist']['#text']) + '">' + escapeHtml(json['artist']['#text']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(json['artist']['#text']) +'&filelist=' + escapeAmpUrl(json['name']) + '">' + escapeHtml(json['name']) + '</a>';
|
||||
html += "</li>";
|
||||
lastPlayedTrack = html;
|
||||
}
|
||||
} else {
|
||||
lastPlayedTrack = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
|
||||
function getTopArtists(div) {
|
||||
$.get('user.php?action=lastfm_top_artists&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ){
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Top artists: " + json['message']);
|
||||
topArtists = " ";
|
||||
}
|
||||
else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topArtists = " ";
|
||||
} else if ( json['topartists']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topArtists = " ";
|
||||
} else {
|
||||
html = "<li>Top Artists:</li>";
|
||||
html += "<li>";
|
||||
var j = json['topartists']['artist'];
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length>3 ){
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#topartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topArtists = html;
|
||||
}
|
||||
} else {
|
||||
topArtists = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
function getTopArtists(div) {
|
||||
$.get('user.php?action=lastfm_top_artists&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ) {
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Top artists: " + json['message']);
|
||||
topArtists = " ";
|
||||
} else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topArtists = " ";
|
||||
} else if ( json['topartists']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topArtists = " ";
|
||||
} else {
|
||||
html = "<li>Top Artists:</li>";
|
||||
html += "<li>";
|
||||
var j = json['topartists']['artist'];
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length > 3 ) {
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#topartists" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topArtists = html;
|
||||
}
|
||||
} else {
|
||||
topArtists = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
|
||||
function getTopAlbums(div) {
|
||||
$.get('user.php?action=lastfm_top_albums&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ){
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Top albums: " + json['message']);
|
||||
topAlbums = " ";
|
||||
}
|
||||
else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topAlbums = " ";
|
||||
} else if ( json['topalbums']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topAlbums = " ";
|
||||
} else {
|
||||
var j = json['topalbums']['album'];
|
||||
html = "<li>Top Albums:</li>";
|
||||
html += "<li>";
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?searchstr=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length>3 ){
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?searchstr=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#topalbums" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topAlbums = html;
|
||||
}
|
||||
} else {
|
||||
topAlbums = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
function getTopAlbums(div) {
|
||||
$.get('user.php?action=lastfm_top_albums&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ) {
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Top albums: " + json['message']);
|
||||
topAlbums = " ";
|
||||
} else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topAlbums = " ";
|
||||
} else if ( json['topalbums']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topAlbums = " ";
|
||||
} else {
|
||||
var j = json['topalbums']['album'];
|
||||
html = "<li>Top Albums:</li>";
|
||||
html += "<li>";
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?searchstr=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length>3 ) {
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?searchstr=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#topalbums" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topAlbums = html;
|
||||
}
|
||||
} else {
|
||||
topAlbums = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
|
||||
function getTopTracks(div) {
|
||||
$.get('user.php?action=lastfm_top_tracks&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ){
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Toptracks: " + json['message']);
|
||||
topTracks = " ";
|
||||
}
|
||||
else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topTracks = " ";
|
||||
} else if ( json['toptracks']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topTracks = " ";
|
||||
} else {
|
||||
html = "<li>Top Tracks:</li>";
|
||||
html += "<li>";
|
||||
var j = json['toptracks']['track'];
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '&filelist=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length>3 ){
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '&filelist=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#toptracks" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topTracks = html;
|
||||
}
|
||||
} else {
|
||||
topTracks = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
function getTopTracks(div) {
|
||||
$.get('user.php?action=lastfm_top_tracks&username=' + username, function (response) {
|
||||
var html;
|
||||
if ( response ) {
|
||||
var json = JSON.parse(response);
|
||||
if (json != null && json['error']) {
|
||||
console.log("Toptracks: " + json['message']);
|
||||
topTracks = " ";
|
||||
} else if (json == null) {
|
||||
console.log("Error: json == null");
|
||||
topTracks = " ";
|
||||
} else if ( json['toptracks']['total']==0 ) {
|
||||
// No top artists for the specified user, possibly a new Last.fm account.
|
||||
// Allow removing the loading message regardless.
|
||||
topTracks = " ";
|
||||
} else {
|
||||
html = "<li>Top Tracks:</li>";
|
||||
html += "<li>";
|
||||
var j = json['toptracks']['track'];
|
||||
html += '<ul class="nobullet">';
|
||||
var k = initialCount;
|
||||
if (j.length < 3) k = j.length;
|
||||
for (var i = 0; i < k; i++) {
|
||||
html += '<li><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '&filelist=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
if ( j.length>3 ) {
|
||||
for (i = 3; i < j.length; i++) {
|
||||
html += '<li class="hidden"><a href="artist.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '">' + escapeHtml(j[i]['artist']['name']) + '</a> - <a href="torrents.php?artistname=' + escapeAmpUrl(j[i]['artist']['name']) + '&filelist=' + escapeAmpUrl(j[i]['name']) + '">' + escapeHtml(j[i]['name']) + '</a></li>'
|
||||
}
|
||||
html+= '<li><a href="#toptracks" id="lastfm_expand" onclick="return false" class="brackets">Expand</a></li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
html += "</li>";
|
||||
topTracks = html;
|
||||
}
|
||||
} else {
|
||||
topTracks = " ";
|
||||
}
|
||||
updateDivContents(div);
|
||||
});
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
@ -23,108 +23,105 @@ var $popup_state = 0;
|
||||
var $musicbrainz_state = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
loadCSS();
|
||||
enableMusicBrainzButton();
|
||||
controlPopup();
|
||||
loadCSS();
|
||||
enableMusicBrainzButton();
|
||||
controlPopup();
|
||||
|
||||
$("#musicbrainz_button").click(function() {
|
||||
var $album = $("#title").val();
|
||||
var $artist = $("#artist").val();
|
||||
if($artist.length > 0 || $album.length > 0) {
|
||||
jQuery('#results1').empty();
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results1').show();
|
||||
jQuery('#results2').show();
|
||||
$searched = true;
|
||||
var $artist_encoded = encodeURIComponent($artist);
|
||||
var $album_encoded = encodeURIComponent($album);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url : "http://www.musicbrainz.org/ws/2/release-group/?query=artist:%22" + $artist_encoded + "%22%20AND%20releasegroup:%22" + $album_encoded + "%22",
|
||||
dataType: "xml",
|
||||
success: showReleaseGroups
|
||||
});
|
||||
$("#musicbrainz_button").click(function() {
|
||||
var $album = $("#title").val();
|
||||
var $artist = $("#artist").val();
|
||||
if ($artist.length > 0 || $album.length > 0) {
|
||||
jQuery('#results1').empty();
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results1').show();
|
||||
jQuery('#results2').show();
|
||||
$searched = true;
|
||||
var $artist_encoded = encodeURIComponent($artist);
|
||||
var $album_encoded = encodeURIComponent($album);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url : "http://www.musicbrainz.org/ws/2/release-group/?query=artist:%22" + $artist_encoded + "%22%20AND%20releasegroup:%22" + $album_encoded + "%22",
|
||||
dataType: "xml",
|
||||
success: showReleaseGroups
|
||||
});
|
||||
|
||||
}
|
||||
else { alert("Please fill out artist and/or album fields.");}
|
||||
});
|
||||
} else { alert("Please fill out artist and/or album fields.");}
|
||||
});
|
||||
|
||||
$("#results1").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if($id != "results1") {
|
||||
jQuery('#results1').hide();
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results2').show();
|
||||
jQuery('#popup_back').empty();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "https://musicbrainz.org/ws/2/release-group/" + $id + "?inc=artist-credits%2Breleases+tags+media",
|
||||
dataType: "xml",
|
||||
success: showReleases
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#results2").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if($id != "mb" && $id != "results2") {
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results2').show();
|
||||
$("#results1").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if ($id != "results1") {
|
||||
jQuery('#results1').hide();
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results2').show();
|
||||
jQuery('#popup_back').empty();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "https://musicbrainz.org/ws/2/release-group/" + $id + "?inc=artist-credits%2Breleases+tags+media",
|
||||
dataType: "xml",
|
||||
success: showReleases
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "https://musicbrainz.org/ws/2/release/" + $id + "?inc=artist-credits%2Blabels%2Bdiscids%2Brecordings+tags+media+label-rels",
|
||||
dataType: "xml",
|
||||
success: populateForm
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#results2").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if ($id != "mb" && $id != "results2") {
|
||||
jQuery('#results2').empty();
|
||||
jQuery('#results2').show();
|
||||
|
||||
$("#popup_back").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if($id == "back" ) {
|
||||
jQuery('#results2').hide();
|
||||
jQuery('#results1').show();
|
||||
jQuery('#popup_back').empty();
|
||||
jQuery('#popup_title').text("Choose Release Group");
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "https://musicbrainz.org/ws/2/release/" + $id + "?inc=artist-credits%2Blabels%2Bdiscids%2Brecordings+tags+media+label-rels",
|
||||
dataType: "xml",
|
||||
success: populateForm
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#remaster").click(function(event) {
|
||||
if($("#remaster").attr("checked") && $searched == true) {
|
||||
populateEditionsForm();
|
||||
}
|
||||
else if($searched == true) {
|
||||
depopulateEditionsForm();
|
||||
}
|
||||
$("#popup_back").click(function(event) {
|
||||
var $id = event.target.id;
|
||||
if ($id == "back" ) {
|
||||
jQuery('#results2').hide();
|
||||
jQuery('#results1').show();
|
||||
jQuery('#popup_back').empty();
|
||||
jQuery('#popup_title').text("Choose Release Group");
|
||||
}
|
||||
});
|
||||
|
||||
$("#remaster").click(function(event) {
|
||||
if ($("#remaster").attr("checked") && $searched == true) {
|
||||
populateEditionsForm();
|
||||
} else if ($searched == true) {
|
||||
depopulateEditionsForm();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Shows the release groups
|
||||
* @param xml
|
||||
*/
|
||||
function showReleaseGroups(xml)
|
||||
{
|
||||
var $count = $(xml).find("release-group-list").attr("count");
|
||||
if($count == 0 ) {
|
||||
alert("Could not find on MusicBrainz");
|
||||
}
|
||||
else {
|
||||
jQuery('#popup_title').text("Choose Release Group");
|
||||
openPopup();
|
||||
}
|
||||
function showReleaseGroups(xml) {
|
||||
var $count = $(xml).find("release-group-list").attr("count");
|
||||
if ($count == 0 ) {
|
||||
alert("Could not find on MusicBrainz");
|
||||
} else {
|
||||
jQuery('#popup_title').text("Choose Release Group");
|
||||
openPopup();
|
||||
}
|
||||
|
||||
$(xml).find("release-group").each(function()
|
||||
{
|
||||
var $title = $(this).find("title:first").text();
|
||||
var $artist = $(this).find("name:first").text();
|
||||
var $type = $(this).attr("type");
|
||||
var $score = $(this).attr("ext:score");
|
||||
var $releaseId = $(this).attr("id");
|
||||
var $result = $artist + " - " + $title + " [Type: " + $type + ", Score: " + $score + "]"
|
||||
$("<a href='#null'>" + $result + "<p/>").attr("id", $releaseId).appendTo("#results1");
|
||||
});
|
||||
$(xml).find("release-group").each(function() {
|
||||
var $title = $(this).find("title:first").text();
|
||||
var $artist = $(this).find("name:first").text();
|
||||
var $type = $(this).attr("type");
|
||||
var $score = $(this).attr("ext:score");
|
||||
var $releaseId = $(this).attr("id");
|
||||
var $result = $artist + " - " + $title + " [Type: " + $type + ", Score: " + $score + "]"
|
||||
$("<a href='#null'>" + $result + "<p/>").attr("id", $releaseId).appendTo("#results1");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,297 +129,299 @@ function showReleaseGroups(xml)
|
||||
* @param xml
|
||||
*/
|
||||
function showReleases(xml) {
|
||||
var $date_release_group = $(xml).find("first-release-date").text();
|
||||
$year_original = $date_release_group.substring(0,4);
|
||||
$release_type = $(xml).find("release-group").attr("type");
|
||||
$release_group_id = $(xml).find("release-group").attr("id");
|
||||
jQuery('#popup_title').html("Choose Release " + "<a href='https://musicbrainz.org/release-group/"
|
||||
+ $release_group_id + "'target=_new>(View on MusicBrainz)</a>");
|
||||
jQuery('#popup_back').html("<a href='#null' id='back'>[Go Back]</a>");
|
||||
var $date_release_group = $(xml).find("first-release-date").text();
|
||||
$year_original = $date_release_group.substring(0,4);
|
||||
$release_type = $(xml).find("release-group").attr("type");
|
||||
$release_group_id = $(xml).find("release-group").attr("id");
|
||||
jQuery('#popup_title').html("Choose Release " + "<a href='https://musicbrainz.org/release-group/"
|
||||
+ $release_group_id + "' target='_new' class='brackets'>View on MusicBrainz</a>");
|
||||
jQuery('#popup_back').html("<a href='#null' id='back' class='brackets'>Go back</a>");
|
||||
|
||||
$(xml).find("release").each(function()
|
||||
{
|
||||
var $release_id = $(this).attr("id");
|
||||
var $title = $(this).find("title").text();
|
||||
var $status = $(this).find("status").text();
|
||||
var $date = $(this).find("date").text();
|
||||
var $year = $date.substring(0,4);
|
||||
var $country = $(this).find("country").text();
|
||||
var $format; var $tracks;
|
||||
$(this).find("medium-list").each(function() {
|
||||
$(this).find("medium").each(function() {
|
||||
$format = $(this).find("format").text();
|
||||
$(this).find("track-list").each(function() {
|
||||
$tracks = $(this).attr("count");
|
||||
}); }); });
|
||||
var $result = $title + " [Year: " + $year + ", Format: " + $format + ", Tracks: " + $tracks + ", Country: " + $country + "]";
|
||||
$("<a href='#null'>" + $result + "</a>").attr("id", $release_id).appendTo("#results2");
|
||||
$(xml).find("release").each(function() {
|
||||
var $release_id = $(this).attr("id");
|
||||
var $title = $(this).find("title").text();
|
||||
var $status = $(this).find("status").text();
|
||||
var $date = $(this).find("date").text();
|
||||
var $year = $date.substring(0,4);
|
||||
var $country = $(this).find("country").text();
|
||||
var $format; var $tracks;
|
||||
$(this).find("medium-list").each(function() {
|
||||
$(this).find("medium").each(function() {
|
||||
$format = $(this).find("format").text();
|
||||
$(this).find("track-list").each(function() {
|
||||
$tracks = $(this).attr("count");
|
||||
});
|
||||
});
|
||||
});
|
||||
var $result = $title + " [Year: " + $year + ", Format: " + $format + ", Tracks: " + $tracks + ", Country: " + $country + "]";
|
||||
$("<a href='#null'>" + $result + "</a>").attr("id", $release_id).appendTo("#results2");
|
||||
|
||||
$("<a href='https://musicbrainz.org/release/" + $release_id +"' target=_new> (View on MB)</a>" + "<p/>").attr("id", "mb").appendTo("#results2");
|
||||
$("<a href='https://musicbrainz.org/release/" + $release_id +"' target='_new' class='brackets'>View on MusicBrainz</a>" + "<p/>").attr("id", "mb").appendTo("#results2");
|
||||
});
|
||||
|
||||
parseTags(xml);
|
||||
}
|
||||
/**
|
||||
* Parses the tags to the gazelle conventions
|
||||
* @param xml
|
||||
*/
|
||||
function parseTags(xml) {
|
||||
$tags = "";
|
||||
$(xml).find("tag").each(function() {
|
||||
|
||||
/**
|
||||
* Parses the tags to the gazelle conventions
|
||||
* @param xml
|
||||
*/
|
||||
function parseTags(xml) {
|
||||
$tags = "";
|
||||
$(xml).find("tag").each(function() {
|
||||
$tag = cleanTag($(this).find("name").text());
|
||||
if(isValidTag($tag)) {
|
||||
$tags += "," + $tag;
|
||||
}
|
||||
if (isValidTag($tag)) {
|
||||
$tags += "," + $tag;
|
||||
}
|
||||
});
|
||||
if($tags.charAt(0) == ',') {
|
||||
$tags = $tags.substring(1);
|
||||
}
|
||||
}
|
||||
if ($tags.charAt(0) == ',') {
|
||||
$tags = $tags.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanTag($t) {
|
||||
function cleanTag($t) {
|
||||
$t = $t.replace(/ +(?= )/g,',');
|
||||
$t = $t.replace('-','.');
|
||||
$t = $t.replace(' ','.');
|
||||
$t = $t.replace('-','.');
|
||||
$t = $t.replace(' ','.');
|
||||
return $t;
|
||||
}
|
||||
/**
|
||||
* Populates the upload form
|
||||
* @param xml
|
||||
*/
|
||||
function populateForm(xml) {
|
||||
closePopup();
|
||||
}
|
||||
|
||||
var $release_id = $(xml).find("release").attr("id");
|
||||
var $release_title = $(xml).find("release").find("title:first").text();
|
||||
var $artist = $(xml).find("artist-credit:first").find("name:first").text();
|
||||
var $date = $(xml).find("release").find("date").text();
|
||||
$year_release = $date.substring(0,4);
|
||||
var $country = $(xml).find("country").text();
|
||||
var $asin = $(xml).find("asin").text();
|
||||
var $barcode = $(xml).find("barcode").text();
|
||||
$catalog_number = $(xml).find("catalog-number").text();
|
||||
$record_label = $(xml).find("label").find("sort-name").text();
|
||||
var $track_count = $(xml).find("track-list").attr("count");
|
||||
var $track_titles = new Array();
|
||||
$(xml).find("track-list").find("title").each(function() {
|
||||
var $title = $(this).text();
|
||||
$track_titles.push($title);
|
||||
});
|
||||
/**
|
||||
* Populates the upload form
|
||||
* @param xml
|
||||
*/
|
||||
function populateForm(xml) {
|
||||
closePopup();
|
||||
|
||||
clear();
|
||||
$("#artist").val($artist);
|
||||
$("#title").val($release_title);
|
||||
$("#year").val($year_original);
|
||||
$("#record_label").val($record_label);
|
||||
$("#catalogue_number").val($catalog_number);
|
||||
$("#tags").val($tags);
|
||||
$("#releasetype").val(getReleaseType());
|
||||
var $amazon_link = "";
|
||||
if($asin.length > 0) {
|
||||
var $release_id = $(xml).find("release").attr("id");
|
||||
var $release_title = $(xml).find("release").find("title:first").text();
|
||||
var $artist = $(xml).find("artist-credit:first").find("name:first").text();
|
||||
var $date = $(xml).find("release").find("date").text();
|
||||
$year_release = $date.substring(0,4);
|
||||
var $country = $(xml).find("country").text();
|
||||
var $asin = $(xml).find("asin").text();
|
||||
var $barcode = $(xml).find("barcode").text();
|
||||
$catalog_number = $(xml).find("catalog-number").text();
|
||||
$record_label = $(xml).find("label").find("sort-name").text();
|
||||
var $track_count = $(xml).find("track-list").attr("count");
|
||||
var $track_titles = new Array();
|
||||
$(xml).find("track-list").find("title").each(function() {
|
||||
var $title = $(this).text();
|
||||
$track_titles.push($title);
|
||||
});
|
||||
|
||||
clear();
|
||||
$("#artist").val($artist);
|
||||
$("#title").val($release_title);
|
||||
$("#year").val($year_original);
|
||||
$("#record_label").val($record_label);
|
||||
$("#catalogue_number").val($catalog_number);
|
||||
$("#tags").val($tags);
|
||||
$("#releasetype").val(getReleaseType());
|
||||
|
||||
var $amazon_link = "";
|
||||
if ($asin.length > 0) {
|
||||
$amazin_link = "[url=http://amazon.com/exec/obidos/ASIN/" + $asin + "]Amazon[/url]" + "\n";
|
||||
}
|
||||
var $country_text = "";
|
||||
if($country.length > 0) {
|
||||
$country_text = "Country: " + $country + "\n";
|
||||
}
|
||||
var $barcode_text = "";
|
||||
if($barcode.length > 0) {
|
||||
$barcode_text = "Barcode: " + $barcode + "\n";
|
||||
}
|
||||
var $description = $amazon_link +
|
||||
"[url=https://musicbrainz.org/release-group/" + $release_group_id + "]MusicBrainz[/url]" + "\n" + "\n" +
|
||||
$country_text +
|
||||
$barcode_text +
|
||||
"Tracks: " + $track_count + "\n" + "\n" +
|
||||
"Track List:" + "\n";
|
||||
for (var i=0; i < $track_titles.length; i++) {
|
||||
$description = $description + "[#]" + $track_titles[i] + "\n";
|
||||
};
|
||||
$("#album_desc").val($description);
|
||||
}
|
||||
|
||||
function populateEditionsForm() {
|
||||
$('#remaster_true').show();
|
||||
$("#record_label").val("");
|
||||
$("#catalogue_number").val("");
|
||||
$("#remaster_year").val($year_release);
|
||||
$("#remaster_record_label").val($record_label);
|
||||
$("#remaster_catalogue_number").val($catalog_number);
|
||||
}
|
||||
|
||||
function depopulateEditionsForm() {
|
||||
$("#record_label").val($record_label);
|
||||
$("#catalogue_number").val($catalog_number);
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
}
|
||||
|
||||
function closeEditionsForm() {
|
||||
if($("#remaster").attr("checked")) {
|
||||
$('#remaster_true').hide();
|
||||
}
|
||||
|
||||
$("#remaster").attr("checked", false);
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Gets the release type
|
||||
* @returns value of type
|
||||
*/
|
||||
function getReleaseType() {
|
||||
var $value;
|
||||
switch($release_type) {
|
||||
case "Album":
|
||||
$value = 1;
|
||||
break;
|
||||
case "Soundtrack":
|
||||
$value = 3;
|
||||
break;
|
||||
case "EP":
|
||||
$value = 5;
|
||||
break;
|
||||
case "Compilation":
|
||||
$value = 7;
|
||||
break;
|
||||
case "Single":
|
||||
$value = 9;
|
||||
break;
|
||||
case "Live":
|
||||
$value = 11;
|
||||
break;
|
||||
case "Remix":
|
||||
$value = 13;
|
||||
break;
|
||||
case "Interview":
|
||||
$value = 15;
|
||||
break;
|
||||
default:
|
||||
$value = "---";
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* Enables the musicbrainz button only when the "Music" type is selected and a format isn't being uploaded
|
||||
*/
|
||||
function enableMusicBrainzButton() {
|
||||
if ($('#categories').is(':disabled') == false) {
|
||||
$("#categories").click(function() {
|
||||
if($("#categories").val() != 0 ) {
|
||||
$("#musicbrainz_button").attr("disabled", "disabled");
|
||||
}
|
||||
else {
|
||||
$("#musicbrainz_button").removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#musicbrainz_button").attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
/**
|
||||
*Clears fields in the upload form
|
||||
*/
|
||||
function clear() {
|
||||
closeEditionsForm();
|
||||
$("#artist").val("");
|
||||
$("#title").val("");
|
||||
$("#year").val("");
|
||||
$("#record_label").val("");
|
||||
$("#catalogue_number").val("");
|
||||
$("#tags").val("");
|
||||
$("#releasetype").val("");
|
||||
$("#album_desc").val("");
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the popup
|
||||
* @returns
|
||||
*/
|
||||
function openPopup(){
|
||||
centerPopup();
|
||||
if($popup_state==0){
|
||||
$("#popup_background").css({
|
||||
"opacity": "0.7"
|
||||
});
|
||||
$("#popup_background").fadeIn("fast");
|
||||
$("#musicbrainz_popup").fadeIn("fast");
|
||||
$popup_state = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the popup
|
||||
* @returns
|
||||
*/
|
||||
function closePopup(){
|
||||
if($popup_state==1){
|
||||
$("#popup_background").fadeOut("fast");
|
||||
$("#musicbrainz_popup").fadeOut("fast");
|
||||
jQuery('#popup_back').html("");
|
||||
$popup_state = 0;
|
||||
}
|
||||
}
|
||||
var $country_text = "";
|
||||
if ($country.length > 0) {
|
||||
$country_text = "Country: " + $country + "\n";
|
||||
}
|
||||
var $barcode_text = "";
|
||||
if ($barcode.length > 0) {
|
||||
$barcode_text = "Barcode: " + $barcode + "\n";
|
||||
}
|
||||
var $description = $amazon_link +
|
||||
"[url=https://musicbrainz.org/release-group/" + $release_group_id + "]MusicBrainz[/url]" + "\n" + "\n" +
|
||||
$country_text +
|
||||
$barcode_text +
|
||||
"Tracks: " + $track_count + "\n" + "\n" +
|
||||
"Track List:" + "\n";
|
||||
for (var i = 0; i < $track_titles.length; i++) {
|
||||
$description = $description + "[#]" + $track_titles[i] + "\n";
|
||||
};
|
||||
$("#album_desc").val($description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Centers the popup on the screen
|
||||
* @returns
|
||||
*/
|
||||
function centerPopup(){
|
||||
function populateEditionsForm() {
|
||||
$('#remaster_true').show();
|
||||
$("#record_label").val("");
|
||||
$("#catalogue_number").val("");
|
||||
$("#remaster_year").val($year_release);
|
||||
$("#remaster_record_label").val($record_label);
|
||||
$("#remaster_catalogue_number").val($catalog_number);
|
||||
}
|
||||
|
||||
function depopulateEditionsForm() {
|
||||
$("#record_label").val($record_label);
|
||||
$("#catalogue_number").val($catalog_number);
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
}
|
||||
|
||||
function closeEditionsForm() {
|
||||
if ($("#remaster").attr("checked")) {
|
||||
$('#remaster_true').hide();
|
||||
}
|
||||
|
||||
$("#remaster").attr("checked", false);
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the release type
|
||||
* @returns value of type
|
||||
*/
|
||||
function getReleaseType() {
|
||||
var $value;
|
||||
switch ($release_type) {
|
||||
case "Album":
|
||||
$value = 1;
|
||||
break;
|
||||
case "Soundtrack":
|
||||
$value = 3;
|
||||
break;
|
||||
case "EP":
|
||||
$value = 5;
|
||||
break;
|
||||
case "Compilation":
|
||||
$value = 7;
|
||||
break;
|
||||
case "Single":
|
||||
$value = 9;
|
||||
break;
|
||||
case "Live":
|
||||
$value = 11;
|
||||
break;
|
||||
case "Remix":
|
||||
$value = 13;
|
||||
break;
|
||||
case "Interview":
|
||||
$value = 15;
|
||||
break;
|
||||
default:
|
||||
$value = "---";
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the musicbrainz button only when the "Music" type is selected and a format isn't being uploaded
|
||||
*/
|
||||
function enableMusicBrainzButton() {
|
||||
if ($('#categories').is(':disabled') == false) {
|
||||
$("#categories").click(function() {
|
||||
if ($("#categories").val() != 0 ) {
|
||||
$("#musicbrainz_button").attr("disabled", "disabled");
|
||||
} else {
|
||||
$("#musicbrainz_button").removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#musicbrainz_button").attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears fields in the upload form
|
||||
*/
|
||||
function clear() {
|
||||
closeEditionsForm();
|
||||
$("#artist").val("");
|
||||
$("#title").val("");
|
||||
$("#year").val("");
|
||||
$("#record_label").val("");
|
||||
$("#catalogue_number").val("");
|
||||
$("#tags").val("");
|
||||
$("#releasetype").val("");
|
||||
$("#album_desc").val("");
|
||||
$("#remaster_year").val("");
|
||||
$("#remaster_record_label").val("");
|
||||
$("#remaster_catalogue_number").val("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the popup
|
||||
* @returns
|
||||
*/
|
||||
function openPopup() {
|
||||
centerPopup();
|
||||
if ($popup_state == 0) {
|
||||
$("#popup_background").css({
|
||||
"opacity": "0.7"
|
||||
});
|
||||
$("#popup_background").fadeIn("fast");
|
||||
$("#musicbrainz_popup").fadeIn("fast");
|
||||
$popup_state = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the popup
|
||||
* @returns
|
||||
*/
|
||||
function closePopup() {
|
||||
if ($popup_state == 1) {
|
||||
$("#popup_background").fadeOut("fast");
|
||||
$("#musicbrainz_popup").fadeOut("fast");
|
||||
jQuery('#popup_back').html("");
|
||||
$popup_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Centers the popup on the screen
|
||||
* @returns
|
||||
*/
|
||||
function centerPopup() {
|
||||
//TODO Center dynamically based on scroll position
|
||||
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
var windowHeight = document.documentElement.clientHeight;
|
||||
var popupHeight = $("#musicbrainz_popup").height();
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
var windowHeight = document.documentElement.clientHeight;
|
||||
var popupHeight = $("#musicbrainz_popup").height();
|
||||
var scrollPosition = window.pageYOffset;
|
||||
var percentage = (scrollPosition/windowHeight) * 100;
|
||||
var popupWidth = $("#musicbrainz_popup").width();
|
||||
$("#musicbrainz_popup").css({
|
||||
"position": "absolute ! important",
|
||||
var popupWidth = $("#musicbrainz_popup").width();
|
||||
$("#musicbrainz_popup").css({
|
||||
"position": "absolute ! important",
|
||||
//"top": windowHeight/2-popupHeight/2,
|
||||
"left": windowWidth/2-popupWidth/2 + "! important"
|
||||
});
|
||||
"left": windowWidth/2-popupWidth/2 + "! important"
|
||||
});
|
||||
|
||||
$("#popup_background").css({
|
||||
"height": windowHeight
|
||||
});
|
||||
}
|
||||
$("#popup_background").css({
|
||||
"height": windowHeight
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the popup state based on user input
|
||||
* @returns
|
||||
*/
|
||||
function controlPopup() {
|
||||
$("#popup_close").click(function(){
|
||||
closePopup();
|
||||
});
|
||||
/**
|
||||
* Controls the popup state based on user input
|
||||
* @returns
|
||||
*/
|
||||
function controlPopup() {
|
||||
$("#popup_close").click(function() {
|
||||
closePopup();
|
||||
});
|
||||
|
||||
$(document).keypress(function(e){
|
||||
if(e.keyCode==27 && $popup_state==1){
|
||||
closePopup();
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).keypress(function(e) {
|
||||
if (e.keyCode == 27 && $popup_state == 1) {
|
||||
closePopup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadCSS() {
|
||||
var $link = document.createElement('link')
|
||||
$link.href = 'static/styles/musicbrainz.css';
|
||||
$link.rel = 'stylesheet';
|
||||
$link.type = 'text/css';
|
||||
document.body.appendChild($link);
|
||||
$link = null;
|
||||
}
|
||||
function loadCSS() {
|
||||
var $link = document.createElement('link')
|
||||
$link.href = 'static/styles/musicbrainz.css';
|
||||
$link.rel = 'stylesheet';
|
||||
$link.type = 'text/css';
|
||||
document.body.appendChild($link);
|
||||
$link = null;
|
||||
}
|
||||
|
||||
} ) ( jQuery );
|
||||
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ var password2;
|
||||
|
||||
$("#new_pass_1").keyup(function() {
|
||||
password1 = $("#new_pass_1").val();
|
||||
if(password1.length != old) {
|
||||
if (password1.length != old) {
|
||||
disableSubmit();
|
||||
calculateComplexity(password1);
|
||||
old = password1.length;
|
||||
@ -32,50 +32,49 @@ $("#new_pass_1").keyup(function() {
|
||||
|
||||
$("#new_pass_1").change(function() {
|
||||
password1 = $("#new_pass_1").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
|
||||
if(password1.length == 0 && password2.length==0) {
|
||||
if (password1.length == 0 && password2.length == 0) {
|
||||
enableSubmit();
|
||||
}
|
||||
else if(getStrong() == true) {
|
||||
} else if (getStrong() == true) {
|
||||
validatePassword(password1);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#new_pass_1").focus(function() {
|
||||
password1 = $("#new_pass_1").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
if(password1.length > 0) {
|
||||
if (password1.length > 0) {
|
||||
checkMatching(password1, password2);
|
||||
}
|
||||
});
|
||||
|
||||
$("#new_pass_2").keyup(function() {
|
||||
password2 = $("#new_pass_2").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
checkMatching(password1, password2);
|
||||
});
|
||||
|
||||
$("#new_pass_1").blur(function() {
|
||||
password1 = $("#new_pass_1").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
if(password1.length == 0 && password2.length==0) {
|
||||
enableSubmit();
|
||||
}
|
||||
password1 = $("#new_pass_1").val();
|
||||
password2 = $("#new_pass_2").val();
|
||||
if (password1.length == 0 && password2.length == 0) {
|
||||
enableSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function validatePassword(password) {
|
||||
if(isUserPage()) {
|
||||
if (isUserPage()) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'text',
|
||||
type: 'POST',
|
||||
dataType: 'text',
|
||||
url : 'ajax.php?action=password_validate',
|
||||
data: 'password=' + password,
|
||||
async: false,
|
||||
success: function(value) {
|
||||
if(value == 'false') {
|
||||
success: function(value) {
|
||||
if (value == 'false') {
|
||||
setStatus(COMMON);
|
||||
}
|
||||
}
|
||||
@ -87,7 +86,7 @@ function calculateComplexity(password) {
|
||||
var length = password.length;
|
||||
var username;
|
||||
|
||||
if(isUserPage()) {
|
||||
if (isUserPage()) {
|
||||
username = $(".username").text();
|
||||
}
|
||||
else {
|
||||
@ -96,33 +95,33 @@ function calculateComplexity(password) {
|
||||
|
||||
var irckey;
|
||||
|
||||
if(isUserPage()) {
|
||||
if (isUserPage()) {
|
||||
irckey = $("#irckey").val();
|
||||
}
|
||||
|
||||
if(length >= 8) {
|
||||
if (length >= 8) {
|
||||
setStatus(WEAK);
|
||||
}
|
||||
if(length >= 8 && isStrongPassword(password)) {
|
||||
if (length >= 8 && isStrongPassword(password)) {
|
||||
setStatus(STRONG);
|
||||
}
|
||||
if(length > 0 && length < 8) {
|
||||
if (length > 0 && length < 8) {
|
||||
setStatus(SHORT);
|
||||
}
|
||||
if(length == 0) {
|
||||
if (length == 0) {
|
||||
setStatus(CLEAR);
|
||||
}
|
||||
if(isUserPage()) {
|
||||
if(irckey.length > 0){
|
||||
if(password.toLowerCase() == irckey.toLowerCase()) {
|
||||
if (isUserPage()) {
|
||||
if (irckey.length > 0){
|
||||
if (password.toLowerCase() == irckey.toLowerCase()) {
|
||||
setStatus(MATCH_IRCKEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(username.length > 0) {
|
||||
if(password.toLowerCase() == username.toLowerCase()) {
|
||||
if (username.length > 0) {
|
||||
if (password.toLowerCase() == username.toLowerCase()) {
|
||||
setStatus(MATCH_USERNAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,21 +130,18 @@ function isStrongPassword(password) {
|
||||
}
|
||||
|
||||
function checkMatching(password1, password2) {
|
||||
if(password2.length > 0) {
|
||||
if(password1 == password2 && getStrong() == true) {
|
||||
$("#pass_match").text("Passwords match").css("color", "green");
|
||||
enableSubmit();
|
||||
}
|
||||
else if(getStrong() == true) {
|
||||
$("#pass_match").text("Passwords do not match").css("color", "red");
|
||||
disableSubmit();
|
||||
}
|
||||
else{
|
||||
$("#pass_match").text("Password isn't strong").css("color", "red");
|
||||
disableSubmit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (password2.length > 0) {
|
||||
if (password1 == password2 && getStrong() == true) {
|
||||
$("#pass_match").text("Passwords match").css("color", "green");
|
||||
enableSubmit();
|
||||
} else if (getStrong() == true) {
|
||||
$("#pass_match").text("Passwords do not match").css("color", "red");
|
||||
disableSubmit();
|
||||
} else {
|
||||
$("#pass_match").text("Password isn't strong").css("color", "red");
|
||||
disableSubmit();
|
||||
}
|
||||
} else {
|
||||
$("#pass_match").text("");
|
||||
}
|
||||
}
|
||||
@ -155,41 +151,41 @@ function getStrong() {
|
||||
}
|
||||
|
||||
function setStatus(strength) {
|
||||
if(strength == WEAK) {
|
||||
if (strength == WEAK) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Weak").css("color", "red");
|
||||
}
|
||||
if(strength == STRONG) {
|
||||
if (strength == STRONG) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Strong").css("color", "green");
|
||||
}
|
||||
if(strength == SHORT) {
|
||||
if (strength == SHORT) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Too Short").css("color", "red");
|
||||
}
|
||||
if(strength == MATCH_IRCKEY) {
|
||||
if (strength == MATCH_IRCKEY) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Password cannot match IRC Key").css("color", "red");
|
||||
}
|
||||
if(strength == MATCH_USERNAME) {
|
||||
if (strength == MATCH_USERNAME) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Password cannot match Username").css("color", "red");
|
||||
}
|
||||
if(strength == COMMON) {
|
||||
if (strength == COMMON) {
|
||||
disableSubmit();
|
||||
$("#pass_strength").text("Password is too common").css("color", "red");
|
||||
}
|
||||
if(strength == CLEAR) {
|
||||
if (strength == CLEAR) {
|
||||
$("#pass_strength").text("");
|
||||
}
|
||||
}
|
||||
|
||||
function disableSubmit() {
|
||||
$('input[type="submit"]').attr('disabled','disabled');
|
||||
$('input[type="submit"]').attr('disabled','disabled');
|
||||
}
|
||||
|
||||
function enableSubmit() {
|
||||
$('input[type="submit"]').removeAttr('disabled');
|
||||
$('input[type="submit"]').removeAttr('disabled');
|
||||
}
|
||||
|
||||
function isUserPage() {
|
||||
|
@ -1,28 +1,24 @@
|
||||
(function ($) {
|
||||
var PUSHOVER = 5;
|
||||
var TOASTY = 4;
|
||||
$(document).ready(function() {
|
||||
if($("#pushservice").val() > 0) {
|
||||
$('#pushsettings').show();
|
||||
}
|
||||
$("#pushservice").change(function() {
|
||||
if($(this).val() > 0) {
|
||||
$('#pushsettings').show(500);
|
||||
|
||||
if($(this).val() == TOASTY) {
|
||||
$('#pushservice_title').text("Device ID");
|
||||
}
|
||||
else if($(this).val() == PUSHOVER) {
|
||||
$('#pushservice_title').text("User Key");
|
||||
}
|
||||
else {
|
||||
$('#pushservice_title').text("API Key");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#pushsettings').hide(500);
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
$(document).ready(function() {
|
||||
if($("#pushservice").val() > 0) {
|
||||
$('#pushsettings').show();
|
||||
}
|
||||
$("#pushservice").change(function() {
|
||||
if($(this).val() > 0) {
|
||||
$('#pushsettings').show(500);
|
||||
|
||||
if($(this).val() == TOASTY) {
|
||||
$('#pushservice_title').text("Device ID");
|
||||
} else if($(this).val() == PUSHOVER) {
|
||||
$('#pushservice_title').text("User Key");
|
||||
} else {
|
||||
$('#pushservice_title').text("API Key");
|
||||
}
|
||||
} else {
|
||||
$('#pushsettings').hide(500);
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
|
@ -41,11 +41,10 @@
|
||||
});
|
||||
$("#recommendation_note").keypress(function(e) {
|
||||
state = $("#send_recommendation").attr("disabled");
|
||||
if (typeof state === 'undefined' && e.keyCode == 13)
|
||||
{
|
||||
e.preventDefault();
|
||||
send_recommendation();
|
||||
}
|
||||
if (typeof state === 'undefined' && e.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
send_recommendation();
|
||||
}
|
||||
});
|
||||
});
|
||||
function send_recommendation() {
|
||||
|
@ -7,7 +7,7 @@ jQuery(document).ready(function ($) {
|
||||
a.push($(this).attr('id'));
|
||||
});
|
||||
$('#sorthide').val(JSON.stringify(a));
|
||||
};
|
||||
};
|
||||
|
||||
serialize();
|
||||
|
||||
@ -27,14 +27,14 @@ jQuery(document).ready(function ($) {
|
||||
|
||||
$('#toggle_sortable').click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#sortable_container').slideToggle(function () {
|
||||
$('#sortable_container').slideToggle(function () {
|
||||
$('#toggle_sortable').text($(this).is(':visible') ? 'Collapse' : 'Expand');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#reset_sortable').click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#sortable').html(sortable_list_default); // var sortable_list_default is found on edit.php
|
||||
serialize();
|
||||
$('#sortable').html(sortable_list_default); // var sortable_list_default is found on edit.php
|
||||
serialize();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
function Vote(amount, requestid) {
|
||||
if(typeof amount == 'undefined') {
|
||||
if (typeof amount == 'undefined') {
|
||||
amount = parseInt($('#amount').raw().value);
|
||||
}
|
||||
if(amount == 0) {
|
||||
if (amount == 0) {
|
||||
amount = 20 * 1024 * 1024;
|
||||
}
|
||||
|
||||
var index;
|
||||
var votecount;
|
||||
if(!requestid) {
|
||||
if (!requestid) {
|
||||
requestid = $('#requestid').raw().value;
|
||||
votecount = $('#votecount').raw();
|
||||
index = false;
|
||||
@ -22,16 +21,16 @@ function Vote(amount, requestid) {
|
||||
if (amount > 20*1024*1024) {
|
||||
upload = $('#current_uploaded').raw().value;
|
||||
download = $('#current_downloaded').raw().value;
|
||||
rr = $('#current_rr').raw().value;
|
||||
rr = $('#current_rr').raw().value;
|
||||
if (amount > .3*(upload - rr * download)) {
|
||||
if(!confirm('This vote is more than 30% of your buffer. Please confirm that you wish to place this large a vote.')) {
|
||||
if (!confirm('This vote is more than 30% of your buffer. Please confirm that you wish to place this large a vote.')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ajax.get('requests.php?action=takevote&id=' + requestid + '&auth=' + authkey + '&amount=' + amount, function (response) {
|
||||
if(response == 'bankrupt') {
|
||||
if (response == 'bankrupt') {
|
||||
error_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request");
|
||||
return;
|
||||
} else if (response == 'dupesuccess') {
|
||||
@ -40,7 +39,7 @@ function Vote(amount, requestid) {
|
||||
votecount.innerHTML = (parseInt(votecount.innerHTML)) + 1;
|
||||
}
|
||||
|
||||
if($('#total_bounty').results() > 0) {
|
||||
if ($('#total_bounty').results() > 0) {
|
||||
totalBounty = parseInt($('#total_bounty').raw().value);
|
||||
totalBounty += (amount * (1 - $('#request_tax').raw().value));
|
||||
$('#total_bounty').raw().value = totalBounty;
|
||||
@ -58,11 +57,11 @@ function Vote(amount, requestid) {
|
||||
function Calculate() {
|
||||
var mul = (($('#unit').raw().options[$('#unit').raw().selectedIndex].value == 'mb') ? (1024*1024) : (1024*1024*1024));
|
||||
var amt = Math.floor($('#amount_box').raw().value * mul);
|
||||
if(amt > $('#current_uploaded').raw().value) {
|
||||
if (amt > $('#current_uploaded').raw().value) {
|
||||
$('#new_uploaded').raw().innerHTML = "You can't afford that request!";
|
||||
$('#new_bounty').raw().innerHTML = "0.00 MB";
|
||||
$('#button').raw().disabled = true;
|
||||
} else if(isNaN($('#amount_box').raw().value)
|
||||
} else if (isNaN($('#amount_box').raw().value)
|
||||
|| (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value*mul < 100*1024*1024)
|
||||
|| (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value*mul < 20*1024*1024)) {
|
||||
$('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
|
||||
@ -79,7 +78,9 @@ function Calculate() {
|
||||
|
||||
function AddArtistField() {
|
||||
var ArtistCount = document.getElementsByName("artists[]").length;
|
||||
if (ArtistCount >= 200) { return; }
|
||||
if (ArtistCount >= 200) {
|
||||
return;
|
||||
}
|
||||
var ArtistField = document.createElement("input");
|
||||
ArtistField.type = "text";
|
||||
ArtistField.id = "artist";
|
||||
@ -100,7 +101,7 @@ function AddArtistField() {
|
||||
var x = $('#artistfields').raw();
|
||||
x.appendChild(document.createElement("br"));
|
||||
x.appendChild(ArtistField);
|
||||
x.appendChild(document.createTextNode('\n'));
|
||||
x.appendChild(document.createTextNode('\n'));
|
||||
x.appendChild(ImportanceField);
|
||||
ArtistCount++;
|
||||
}
|
||||
@ -110,17 +111,17 @@ function RemoveArtistField() {
|
||||
if (ArtistCount == 1) { return; }
|
||||
var x = $('#artistfields').raw();
|
||||
|
||||
while(x.lastChild.tagName != "INPUT") {
|
||||
while (x.lastChild.tagName != "INPUT") {
|
||||
x.removeChild(x.lastChild);
|
||||
}
|
||||
x.removeChild(x.lastChild);
|
||||
x.removeChild(x.lastChild); //Remove trailing new line.
|
||||
x.removeChild(x.lastChild); //Remove trailing new line.
|
||||
ArtistCount--;
|
||||
}
|
||||
|
||||
function Categories() {
|
||||
var cat = $('#categories').raw().options[$('#categories').raw().selectedIndex].value;
|
||||
if(cat == "Music") {
|
||||
if (cat == "Music") {
|
||||
$('#artist_tr').show();
|
||||
$('#releasetypes_tr').show();
|
||||
$('#formats_tr').show();
|
||||
@ -129,7 +130,7 @@ function Categories() {
|
||||
ToggleLogCue();
|
||||
$('#year_tr').show();
|
||||
$('#cataloguenumber_tr').show();
|
||||
} else if(cat == "Audiobooks" || cat == "Comedy") {
|
||||
} else if (cat == "Audiobooks" || cat == "Comedy") {
|
||||
$('#year_tr').show();
|
||||
$('#artist_tr').hide();
|
||||
$('#releasetypes_tr').hide();
|
||||
@ -164,12 +165,12 @@ function Toggle(id, disable) {
|
||||
var master = $('#toggle_' + id).raw().checked;
|
||||
for (var x in arr) {
|
||||
arr[x].checked = master;
|
||||
if(disable == 1) {
|
||||
if (disable == 1) {
|
||||
arr[x].disabled = master;
|
||||
}
|
||||
}
|
||||
|
||||
if(id == "formats") {
|
||||
if (id == "formats") {
|
||||
ToggleLogCue();
|
||||
}
|
||||
}
|
||||
@ -178,11 +179,11 @@ function ToggleLogCue() {
|
||||
var formats = document.getElementsByName('formats[]');
|
||||
var flac = false;
|
||||
|
||||
if(formats[1].checked) {
|
||||
if (formats[1].checked) {
|
||||
flac = true;
|
||||
}
|
||||
|
||||
if(flac) {
|
||||
if (flac) {
|
||||
$('#logcue_tr').show();
|
||||
} else {
|
||||
$('#logcue_tr').hide();
|
||||
@ -191,7 +192,7 @@ function ToggleLogCue() {
|
||||
}
|
||||
|
||||
function ToggleLogScore() {
|
||||
if($('#needlog').raw().checked) {
|
||||
if ($('#needlog').raw().checked) {
|
||||
$('#minlogscore_span').show();
|
||||
} else {
|
||||
$('#minlogscore_span').hide();
|
||||
|
@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
/* Prototypes */
|
||||
if(!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s+|\s+$/g,'');
|
||||
};
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s+|\s+$/g,'');
|
||||
};
|
||||
}
|
||||
|
||||
var listener = {
|
||||
@ -41,17 +41,17 @@ function function_exists(function_name) {
|
||||
}
|
||||
|
||||
function html_entity_decode(str) {
|
||||
var el = document.createElement("div");
|
||||
el.innerHTML = str;
|
||||
for(var i = 0, ret = ''; i < el.childNodes.length; i++) {
|
||||
ret += el.childNodes[i].nodeValue;
|
||||
}
|
||||
return ret;
|
||||
var el = document.createElement("div");
|
||||
el.innerHTML = str;
|
||||
for (var i = 0, ret = ''; i < el.childNodes.length; i++) {
|
||||
ret += el.childNodes[i].nodeValue;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function get_size(size) {
|
||||
var steps = 0;
|
||||
while(size>=1024) {
|
||||
while (size>=1024) {
|
||||
steps++;
|
||||
size=size/1024;
|
||||
}
|
||||
@ -97,20 +97,20 @@ function get_ratio_color(ratio) {
|
||||
}
|
||||
|
||||
function ratio(dividend, divisor, color) {
|
||||
if(!color) {
|
||||
if (!color) {
|
||||
color = true;
|
||||
}
|
||||
if(divisor == 0 && dividend == 0) {
|
||||
if (divisor == 0 && dividend == 0) {
|
||||
return '--';
|
||||
} else if(divisor == 0) {
|
||||
} else if (divisor == 0) {
|
||||
return '<span class="r99">∞</span>';
|
||||
} else if(dividend == 0 && divisor > 0) {
|
||||
} else if (dividend == 0 && divisor > 0) {
|
||||
return '<span class="r00">-∞</span>';
|
||||
}
|
||||
var rat = ((dividend/divisor)-0.005).toFixed(2); //Subtract .005 to floor to 2 decimals
|
||||
if(color) {
|
||||
if (color) {
|
||||
var col = get_ratio_color(rat);
|
||||
if(col) {
|
||||
if (col) {
|
||||
rat = '<span class="'+col+'">'+rat+'</span>';
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ var util = function (selector, context) {
|
||||
util.fn = util.prototype = {
|
||||
objects: new Array(),
|
||||
init: function (selector, context) {
|
||||
if(typeof(selector) == 'object') {
|
||||
if (typeof(selector) == 'object') {
|
||||
this.objects[0] = selector;
|
||||
} else {
|
||||
this.objects = Sizzle(selector, context);
|
||||
|
@ -284,7 +284,7 @@ function UpVoteGroup(groupid, authkey) {
|
||||
//No increment
|
||||
} else if (response == 'success') {
|
||||
// Increment both the upvote count and the total votes count
|
||||
$('#upvotes').raw().innerHTML = (parseInt($('#upvotes').raw().innerHTML)) + 1;
|
||||
$('#upvotes').raw().innerHTML = (parseInt($('#upvotes').raw().innerHTML)) + 1;
|
||||
$('#totalvotes').raw().innerHTML = (parseInt($('#totalvotes').raw().innerHTML)) + 1;
|
||||
}
|
||||
}
|
||||
@ -317,4 +317,4 @@ function UnvoteGroup(groupid, authkey) {
|
||||
$('#upvoted').hide();
|
||||
$('#downvoted').hide();
|
||||
voteLock = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
function ChangeTo(to) {
|
||||
if(to == "text") {
|
||||
if (to == "text") {
|
||||
$('#admincommentlinks').hide();
|
||||
$('#admincomment').show();
|
||||
resize('admincomment');
|
||||
@ -7,7 +7,7 @@ function ChangeTo(to) {
|
||||
for(var i = 0; i < buttons.length; i++) {
|
||||
buttons[i].setAttribute('onclick',"ChangeTo('links'); return false;");
|
||||
}
|
||||
} else if(to == "links") {
|
||||
} else if (to == "links") {
|
||||
ajax.post("ajax.php?action=preview","form", function(response){
|
||||
$('#admincommentlinks').raw().innerHTML = response;
|
||||
$('#admincomment').hide();
|
||||
@ -30,7 +30,7 @@ function AlterParanoia() {
|
||||
// Required Ratio is almost deducible from downloaded, the count of seeding and the count of snatched
|
||||
// we will "warn" the user by automatically checking the required ratio box when they are
|
||||
// revealing that information elsewhere
|
||||
if(!$('input[name=p_ratio]').raw()) {
|
||||
if (!$('input[name=p_ratio]').raw()) {
|
||||
return;
|
||||
}
|
||||
var showDownload = $('input[name=p_downloaded]').raw().checked || ($('input[name=p_uploaded]').raw().checked && $('input[name=p_ratio]').raw().checked);
|
||||
@ -96,11 +96,11 @@ function ParanoiaReset(checkbox, drops) {
|
||||
var selects = $('select');
|
||||
for (var i = 0; i < selects.results(); i++) {
|
||||
if (selects.raw(i).name.match(/^p_/)) {
|
||||
if(drops == 0) {
|
||||
if (drops == 0) {
|
||||
selects.raw(i).selectedIndex = 0;
|
||||
} else if(drops == 1) {
|
||||
} else if (drops == 1) {
|
||||
selects.raw(i).selectedIndex = selects.raw(i).options.length - 2;
|
||||
} else if(drops == 2) {
|
||||
} else if (drops == 2) {
|
||||
selects.raw(i).selectedIndex = selects.raw(i).options.length - 1;
|
||||
}
|
||||
AlterParanoia();
|
||||
@ -148,11 +148,10 @@ function ToggleWarningAdjust(selector) {
|
||||
|
||||
addDOMLoadEvent(ToggleIdenticons);
|
||||
function ToggleIdenticons() {
|
||||
var selected = $('#disableavatars').raw().selectedIndex;
|
||||
if(selected == 2 || selected == 3) {
|
||||
$('#identicons').show();
|
||||
}
|
||||
else {
|
||||
$('#identicons').hide();
|
||||
}
|
||||
}
|
||||
var selected = $('#disableavatars').raw().selectedIndex;
|
||||
if (selected == 2 || selected == 3) {
|
||||
$('#identicons').show();
|
||||
} else {
|
||||
$('#identicons').hide();
|
||||
}
|
||||
}
|
||||
|
@ -470,3 +470,54 @@ tr.torrent .bookmark>a:after {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* Stylesheet gallery in user profile editing */
|
||||
#css_gallery {
|
||||
display: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.preview_wrapper{
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 29%;
|
||||
height: 120px;
|
||||
margin: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.preview_overlay {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
position: absolute;
|
||||
background: transparent;
|
||||
z-index: 1;
|
||||
right: 0;
|
||||
left: 0;
|
||||
cursor: pointer;
|
||||
/* IE 8 */
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
/* IE 5-7 */
|
||||
filter: alpha(opacity=0);
|
||||
/* Netscape */
|
||||
-moz-opacity: 0;
|
||||
/* Safari 1.x */
|
||||
-khtml-opacity: 0;
|
||||
/* Good browsers */
|
||||
opacity: 0;
|
||||
}
|
||||
.preview_frame_wrapper {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.preview_frame {
|
||||
-ms-zoom: 0.17;
|
||||
-moz-transform: scale(0.17);
|
||||
-moz-transform-origin: 0 0;
|
||||
-o-transform: scale(0.17);
|
||||
-o-transform-origin: 0 0;
|
||||
-webkit-transform: scale(0.17);
|
||||
-webkit-transform-origin: 0 0;
|
||||
}
|
||||
.preview_name {
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user