Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
include("main.php");
include("main.php");
$sub = "";
?>

<!DOCTYPE html>
Expand Down Expand Up @@ -73,15 +74,16 @@
</select>
</div>
-->
<div class="col-xs-1"></div>
<div id="favorites-button" class="col-xs-1" id="options-button">favorites</div>
<div id="options-button" class="col-xs-1">options</div>
<div id="about-button" class="col-xs-1">about</div>
</form>
</div>
<div class="row" id="main-top">
<div class="col-xs-6">
<div class="col-xs-3 col-md-2 col-lg-1 text-center text-center"><span class="glyphicon glyphicon-arrow-up"></span></div>
<div id="subnameheader" class="col-xs-6 col-md-8 col-lg-10 text-center text-center"></div>
<div class="col-xs-3 col-md-2 col-lg-4"><span class="glyphicon glyphicon-arrow-up"></span></div>
<div id="subnameheader" class="col-xs-3 col-md-6 col-lg-4 text-center text-center"></div>
<div class="col-xs-2 col-md-4 col-lg-3 text-center text-center" id="favorite-toggle">&#9734;</div>
<div class="col-xs-3 col-md-2 col-lg-1 text-center text-center"><span class="glyphicon glyphicon-comment"></span></div>
</div>
<div class="col-xs-6">
Expand All @@ -102,6 +104,14 @@

</div>
<div id="rightcolumn" class="col-xs-6">
<div id="favorites" style="display: none" class="row">
<div class="col-xs-12">
<h4>Favorites</h4>
<div id="favorites-cont">

</div>
</div>
</div>
<div id="options" style="display:none" class="row">
<div class="col-xs-6">
<h4>Options</h4>
Expand Down
79 changes: 72 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var ResultLimit = 40;
var favorite = false;
var sub;
$(function()
{
// Global Variables
Expand All @@ -11,8 +13,8 @@ $(function()
OP = "";

// Run
init();
hashLocation();
init();
resize();
setTitle();
getPopularSubs();
Expand Down Expand Up @@ -159,11 +161,44 @@ $(document).on("keyup", "#input-title", function() // Change page title
}
});

$(document).on("click", ".favorite", function()
{
sub = $(this)[0].innerHTML;
ClearLeftSide();
window.location.hash = "#"+sub;
getItems(sub, sort);
});

$(document).on("click", "#showimage", function() // Show story image
{
$('#storyimage').toggle();
$('#showimage').text() == " Show Image" ? $('#showimage').html("<span class='glyphicon glyphicon-picture'></span> Hide Image") : $('#showimage').html("<span class='glyphicon glyphicon-picture'></span> Show Image");
});
$(document).on("click", "#favorites-button", function(){
ClearRightSide();
$('#favorites').show();
});
$(document).on("click", "#favorite-toggle", function(){
if(!favorite){
var f = readCookie("favorites");
createCookie("favorites", f+","+sub);
$("#favorite-toggle").empty();
$("#favorite-toggle").append("&#9733;");
$("#favorites-cont").append("<div class='favorite'>"+sub+"</div>");
favorite = true;
}else{
var f = readCookie("favorites");
if(f!=""&&f!=null)
f = f.replace((","+sub), "");
else
f= "";
createCookie("favorites", f);
$("#favorite-toggle").empty();
$("#favorite-toggle").append("&#9734;");
$("#favorites-cont").find("div").remove(":contains('"+sub+"')");
favorite = false;
}
});

$("#getmore").click(function() // Load more
{
Expand Down Expand Up @@ -201,7 +236,18 @@ $(window).resize(function(){

function init()
{
console.log(readCookie("showLogo"));
var f = readCookie("favorites");
if(f!=""&&f!=null){
var favorites = f.split(",");
for(var i=1;i<favorites.length;i++){
$("#favorites-cont").append("<div class='favorite'>"+favorites[i]+"</div>");
if(favorites[i]==sub){
favorite = true;
$("#favorite-toggle").empty();
$("#favorite-toggle").append("&#9733;");
}
}
}
if(readCookie("showLogo") == "0"){
$("#logo").hide();
$("#logo-filler").show();
Expand Down Expand Up @@ -265,13 +311,30 @@ function ClearRightSide() // Clear all stories
$("#storyheader").html("");
$("#about").hide();
$("#options").hide();
$('#favorites').hide();
$("#story").html("");
$("#comments").html("");
}

function getItems(sub, sort) // Get stories
{
$("#input-sub").val("");
var f = readCookie("favorites");
if(f!=null){
f = f.split(",");
for(var i=0;i<f.length;i++){
if(f[i]==sub){
favorite = true;
$("#favorite-toggle").empty();
$("#favorite-toggle").append("&#9733;");
break;
}else{
favorite = false;
$("#favorite-toggle").empty();
$("#favorite-toggle").append("&#9734;");
}
}
}
document.title = sub;
if (readCookie("title") == null)
{
Expand All @@ -284,14 +347,13 @@ function getItems(sub, sort) // Get stories
document.title = sub;
}
}

var subUrl = (sub == "" ) ? "" : "/r/"+sub;
var limitUrl = "limit=" + limit;
var afterUrl = (after == null) ? "" : "&after="+after;
var countUrl = (count == 0) ? "" : "&count="+count;

$("#subnameheader").html(loadHtml);

switch(sort)
{
case "hot":
Expand Down Expand Up @@ -423,9 +485,12 @@ $('#input-sub').keyup(function(e) {

$(document).on("click", ".result", function(){
ClearLeftSide();
window.location.hash = "#"+$(this)[0].innerText;
sub = $(this)[0].innerText;
getItems($(this)[0].innerText, sort);
var s = $(this)[0].innerHTML;
s = s.replace("<span class=\"match\">", "");
s = s.replace("</span>", "");
window.location.hash = "#"+s;
sub = s;
getItems(s, sort);
});

function getPopularSubs()
Expand Down
15 changes: 12 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ input[type=checkbox]
margin-left: 5px;
}

#logo, #options-button, #about-button
#logo, #options-button, #about-button, #favorites-button
{
font-family: 'Open Sans', sans-serif;
font-size: 16px;
Expand Down Expand Up @@ -253,14 +253,23 @@ p
overflow: scroll;
}

.result {
.result, .favorite {
width: 100%;
font-size: 14px;
padding: 8px;
border-bottom: 1px solid #eee;
cursor: pointer;
color: #428bca;
}
.result:hover {
.result:hover, .favorite:hover {
background-color: rgba(66, 139, 202, 0.04);
}

#favorite-icon
{
width: 50%;
}
#favorite-toggle
{
cursor: pointer;
}