diff --git a/classes/class_artists.php b/classes/class_artists.php index aff961c5..5a503c9e 100644 --- a/classes/class_artists.php +++ b/classes/class_artists.php @@ -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'; diff --git a/classes/class_format.php b/classes/class_format.php index 8abfcc39..669f8b5f 100644 --- a/classes/class_format.php +++ b/classes/class_format.php @@ -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' ); /** diff --git a/classes/class_image_tools.php b/classes/class_image_tools.php index 0ce6cf06..b36671d8 100644 --- a/classes/class_image_tools.php +++ b/classes/class_image_tools.php @@ -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; } diff --git a/classes/class_lastfm.php b/classes/class_lastfm.php index 11f20054..d3096d07 100644 --- a/classes/class_lastfm.php +++ b/classes/class_lastfm.php @@ -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); + } + } } diff --git a/classes/class_misc.php b/classes/class_misc.php index 9c3eb12a..12c6d132 100644 --- a/classes/class_misc.php +++ b/classes/class_misc.php @@ -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;"'; } ?>
class="center"> -
- Recommend to: + - - + +
-

+

Tags = array_filter(explode(' ', str_replace('_', '.', $TagList))); @@ -148,4 +148,4 @@ public static function format_top($Max = 5, $Link = 'torrents.php?taglist=') {
  • ()
  • buttons(); // output buttons * @@ -101,13 +101,13 @@ static private function iterator () * * // some template *
    - * - * - * - * - *
    - *
    - *
    + * + * + * + * + *
    + *
    + *
    *
    * */ @@ -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; } -} \ No newline at end of file +} diff --git a/classes/class_tools.php b/classes/class_tools.php index d8ad39d7..4800a832 100644 --- a/classes/class_tools.php +++ b/classes/class_tools.php @@ -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); diff --git a/classes/class_users.php b/classes/class_users.php index 045fe724..700a172e 100644 --- a/classes/class_users.php +++ b/classes/class_users.php @@ -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) ? 'Donor' : ''; - } + } - $Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? 'Warned' : ''; diff --git a/classes/class_votes.php b/classes/class_votes.php index fa4b5475..d881b7f2 100644 --- a/classes/class_votes.php +++ b/classes/class_votes.php @@ -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; } diff --git a/classes/class_zip.php b/classes/class_zip.php index 8aa28fb6..e46d5186 100644 --- a/classes/class_zip.php +++ b/classes/class_zip.php @@ -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); diff --git a/sections/user/edit.php b/sections/user/edit.php index be87309f..f2d754e7 100644 --- a/sections/user/edit.php +++ b/sections/user/edit.php @@ -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) { - -      - Or -      +    + Show gallery +     - Or -     External CSS: + diff --git a/sections/user/index.php b/sections/user/index.php index eeac0064..c9e9d011 100644 --- a/sections/user/index.php +++ b/sections/user/index.php @@ -14,6 +14,9 @@ } switch ($_REQUEST['action']) { + case 'stylesheetgallery': + include('stylesheetgallery.php'); + break; case 'notify': include('notify_edit.php'); break; diff --git a/sections/user/stylesheetgallery.php b/sections/user/stylesheetgallery.php new file mode 100644 index 00000000..61d2e460 --- /dev/null +++ b/sections/user/stylesheetgallery.php @@ -0,0 +1,331 @@ + + + + + Stylesheet Gallery + + + + + + +
    +

    Gazelle

    + +
    +
    +

    Forums

    +
    +

    Site

    + + + + + + + + + + + + + + + + + + + + + + + + +
    ForumLast postTopicsPosts
    +

    + Announcements +

    +
    + + New Site Announcements + + + + + by Rippy Just now + 38595,197
    +

    + What.CD +

    +
    + + Dear Mortals, you have violated the rule... + + by Drone 3 mins ago + 2,624110,432
    +

    Community

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ForumLast postTopicsPosts
    +

    + The Lounge +

    +
    + + Last stand against Drone? + + + + + by Ajax Just now + 37,5311,545,089
    +

    + The Lounge +1 +

    +
    + + No fun allowed + + by Drone 10 mins ago + 424490,163
    +

    + The Library +

    +
    + + List of forbidden literature + + by Drone 7 hours ago + 424490,163
    +

    + Concerts, Events & Meets +

    +
    + + [Region] The Void + + by Drone 25 mins ago + 30515,231
    +

    + Technology +

    +
    + + How did Drone take over the site? + + + + + by Etheryte 5 mins ago + 25,031386,278
    +

    Music

    + + + + + + + + + + + + + + + + + + + + + + + + +
    ForumLast postTopicsPosts
    +

    + Music +

    +
    + + Where did all the non-drone threads go? + + + + + by Ananke 1 min ago + 22,564608,253
    +

    + Vanity House +

    +
    + + Drone - Drone [EP] (drone, noise) + + by Drone Just now + 3,94824,269
    +
    +
    +
    + + \ No newline at end of file diff --git a/sections/userhistory/post_history.php b/sections/userhistory/post_history.php index 28dfeb7b..4f12ec59 100644 --- a/sections/userhistory/post_history.php +++ b/sections/userhistory/post_history.php @@ -200,37 +200,38 @@ ?> diff --git a/static/functions/artists.js b/static/functions/artists.js index 2cc20ad7..f5e775cd 100644 --- a/static/functions/artists.js +++ b/static/functions/artists.js @@ -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(); + } } } diff --git a/static/functions/comments.js b/static/functions/comments.js index 8b516452..b25969a7 100644 --- a/static/functions/comments.js +++ b/static/functions/comments.js @@ -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 = 'PM user on edit? '; + } else { + pmbox = ''; + }; + $('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML; + $('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML; + $('#content' + postid).raw().innerHTML = "
    "+pmbox+"
    "; + $('#bar' + postid).raw().innerHTML = ''; } - 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 = 'PM user on edit? '; - } else { - pmbox = ''; - }; - $('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML; - $('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML; - $('#content' + postid).raw().innerHTML = "
    "+pmbox+"
    "; - $('#bar' + postid).raw().innerHTML = ''; - } - /* 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 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); diff --git a/static/functions/cssgallery.js b/static/functions/cssgallery.js new file mode 100644 index 00000000..fb207a49 --- /dev/null +++ b/static/functions/cssgallery.js @@ -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); diff --git a/static/functions/lastfm.js b/static/functions/lastfm.js index ea7f1dea..03d22520 100644 --- a/static/functions/lastfm.js +++ b/static/functions/lastfm.js @@ -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(/
  • \[/,""); - } else if ( $(this).attr("href") == "#topartists" ){ - topArtists = topArtists.replace(/\ class="hidden"/g,""); - topArtists = topArtists.replace(/
  • \[/,""); - } else if ( $(this).attr("href") == "#topalbums" ){ - topAlbums = topAlbums.replace(/\ class="hidden"/g,""); - topAlbums = topAlbums.replace(/
  • \[/,""); - } else if ( $(this).attr("href") == "#toptracks" ){ - topTracks = topTracks.replace(/\ class="hidden"/g,""); - topTracks = topTracks.replace(/
  • \[/,""); - } - 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('
  • Loading...
  • '); - $("#lastfm_stats").append('
  • Loading...
  • '); - // 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(/
  • \[/,""); + } else if ( $(this).attr("href") == "#topartists" ) { + topArtists = topArtists.replace(/\ class="hidden"/g,""); + topArtists = topArtists.replace(/
  • \[/,""); + } else if ( $(this).attr("href") == "#topalbums" ) { + topAlbums = topAlbums.replace(/\ class="hidden"/g,""); + topAlbums = topAlbums.replace(/
  • \[/,""); + } else if ( $(this).attr("href") == "#toptracks" ) { + topTracks = topTracks.replace(/\ class="hidden"/g,""); + topTracks = topTracks.replace(/
  • \[/,""); + } + 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('
  • Loading...
  • '); + $("#lastfm_stats").append('
  • Loading...
  • '); + // 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 += '
  • Loading...
  • '; - 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 += '
  • Loading...
  • '; + 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(/ 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\ -
  • \r\ -
    \n\ -
    \n\ -
    \r\ -
    \r\ -
  • '; +
  • \r\ +
    \n\ +
    \n\ +
    \r\ +
    \r\ +
  • '; } - // Only print shared artists if there are any - if (j['artists']['matches'] != 0){ - sharedArtistsHtml += '
  • Shared artists:
  • '; - sharedArtists = sharedArtistsHtml; - } else { - // Allow removing loading message regardless. - sharedArtists = " "; - sharedArtistsHtml += '
  • Expand
  • ' - } - tasteometerHtml += ""; - tasteometer = tasteometerHtml; - } - } else { - sharedArtists = " "; - tasteometer = " "; - } - updateDivContents(div); - }); - } - } + // Only print shared artists if there are any + if (j['artists']['matches'] != 0) { + sharedArtistsHtml += '
  • Shared artists:
  • '; + sharedArtists = sharedArtistsHtml; + } else { + // Allow removing loading message regardless. + sharedArtists = " "; + sharedArtistsHtml += '
  • Expand
  • ' + } + tasteometerHtml += ""; + 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 += '
  • Last played: '; - html += '' + escapeHtml(json['artist']['#text']) + ' - ' + escapeHtml(json['name']) + ''; - html += "
  • "; - 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 += '
  • Last played: '; + html += '' + escapeHtml(json['artist']['#text']) + ' - ' + escapeHtml(json['name']) + ''; + html += "
  • "; + 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 = "
  • Top Artists:
  • "; - html += "
  • "; - var j = json['topartists']['artist']; - html += ''; - html += "
  • "; - 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 = "
  • Top Artists:
  • "; + html += "
  • "; + var j = json['topartists']['artist']; + html += ''; + html += "
  • "; + 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 = "
  • Top Albums:
  • "; - html += "
  • "; - html += ''; - html += "
  • "; - 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 = "
  • Top Albums:
  • "; + html += "
  • "; + html += ''; + html += "
  • "; + 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 = "
  • Top Tracks:
  • "; - html += "
  • "; - var j = json['toptracks']['track']; - html += ''; - html += "
  • "; - 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 = "
  • Top Tracks:
  • "; + html += "
  • "; + var j = json['toptracks']['track']; + html += ''; + html += "
  • "; + topTracks = html; + } + } else { + topTracks = " "; + } + updateDivContents(div); + }); + } })(jQuery); diff --git a/static/functions/musicbrainz.js b/static/functions/musicbrainz.js index 7c0a7995..b8334f0a 100644 --- a/static/functions/musicbrainz.js +++ b/static/functions/musicbrainz.js @@ -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 + "]" - $("" + $result + "

    ").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 + "]" + $("" + $result + "

    ").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 " + "(View on MusicBrainz)"); - jQuery('#popup_back').html("[Go Back]"); + 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 " + "View on MusicBrainz"); + jQuery('#popup_back').html("Go back"); - $(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 + "]"; - $("" + $result + "").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 + "]"; + $("" + $result + "").attr("id", $release_id).appendTo("#results2"); - $(" (View on MB)" + "

    ").attr("id", "mb").appendTo("#results2"); + $("View on MusicBrainz" + "

    ").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 ); - - - diff --git a/static/functions/password_validate.js b/static/functions/password_validate.js index 924fd76a..833b2767 100644 --- a/static/functions/password_validate.js +++ b/static/functions/password_validate.js @@ -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() { diff --git a/static/functions/push_settings.js b/static/functions/push_settings.js index ed74fa2a..218270f8 100644 --- a/static/functions/push_settings.js +++ b/static/functions/push_settings.js @@ -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)); diff --git a/static/functions/recommend.js b/static/functions/recommend.js index b11e2b09..1d1afcd7 100644 --- a/static/functions/recommend.js +++ b/static/functions/recommend.js @@ -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() { diff --git a/static/functions/release_sort.js b/static/functions/release_sort.js index 1ee0973e..bc8103d3 100644 --- a/static/functions/release_sort.js +++ b/static/functions/release_sort.js @@ -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(); }); -}); \ No newline at end of file +}); diff --git a/static/functions/requests.js b/static/functions/requests.js index 57b5e5b2..6a869376 100644 --- a/static/functions/requests.js +++ b/static/functions/requests.js @@ -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(); diff --git a/static/functions/script_start.js b/static/functions/script_start.js index 35ac5daf..79e1bb55 100644 --- a/static/functions/script_start.js +++ b/static/functions/script_start.js @@ -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 ''; - } else if(dividend == 0 && divisor > 0) { + } else if (dividend == 0 && divisor > 0) { return '-∞'; } 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 = ''+rat+''; } } @@ -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); diff --git a/static/functions/torrent.js b/static/functions/torrent.js index 62f10660..c7981d28 100644 --- a/static/functions/torrent.js +++ b/static/functions/torrent.js @@ -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; -} \ No newline at end of file +} diff --git a/static/functions/user.js b/static/functions/user.js index a8e468ca..f5a28563 100644 --- a/static/functions/user.js +++ b/static/functions/user.js @@ -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(); - } -} \ No newline at end of file + var selected = $('#disableavatars').raw().selectedIndex; + if (selected == 2 || selected == 3) { + $('#identicons').show(); + } else { + $('#identicons').hide(); + } +} diff --git a/static/styles/global.css b/static/styles/global.css index a4f4999c..ca739ca4 100644 --- a/static/styles/global.css +++ b/static/styles/global.css @@ -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; +}