From 407519f19e66f7e27bc2116adc8738ec241dee0b Mon Sep 17 00:00:00 2001 From: Vipin Nair Date: Sun, 11 Dec 2011 23:04:15 +0530 Subject: [PATCH 01/12] Combined all the three storybox JSON's into one and eliminated duplicates, if any, in the different sections of front page storybox data --- functions/interface.php | 68 ++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/functions/interface.php b/functions/interface.php index 46903a8..6a8333f 100644 --- a/functions/interface.php +++ b/functions/interface.php @@ -72,16 +72,6 @@ function getTagSearchJson($tag,$page) return json_encode($json); } -/** -* Helper Function. Returs an array(size $count) of the CID's of most popular videos -* @param integer $count The number of videos that should be returned. -* @return array Array of Popular Videos CID's. -*/ -function getPopularVideoArray($count){ - $sql="Select cn_id from content_video order by cn_views desc limit $count"; - return resource2array(dbquery($sql)); -} - /** * Helper Function. Returs an array(size $count) of the CID's of featured videos * @param integer $count The number of videos that should be returned. @@ -105,27 +95,27 @@ function getTopRatedVideoArray($count) } /** -* Returs the JSON strings of the $count of $type ofStorybox Video content -* and their details. -* $type = featured | toprated | popular +* Helper Function. Returs an array(size $count) of the CID's of most popular videos * @param integer $count The number of videos that should be returned. -* @return string Featured Videos JSON. +* @return array Array of Popular Videos CID's. */ -function getStoryBoxJson($type,$count){ - switch ($type) { - case "featured": $contentarray = getFeaturedVideoArray($count); - break; - case "popular": $contentarray = getPopularVideoArray($count); - break; - case "toprated": $contentarray = getTopRatedVideoArray($count); - break; - } - $json=array(); +function getPopularVideoArray($count){ + $sql="Select cn_id from content_video order by cn_views desc limit $count"; + return resource2array(dbquery($sql)); +} + +/** +* Helper Function. Returns data for each CID in input array as an array +* @param array $contentarray An array of content ID's +* @return array Data for all CID's in input as an array +*/ +function getStoryBoxDataArray($contentarray){ $vcount=count($contentarray); + $data = array(); for($i=0;$i<$vcount;$i++) { $obj=new video($contentarray[$i]); - array_push($json,array( 'cid'=>$obj->getContentId(), + array_push($data,array( 'cid'=>$obj->getContentId(), 'title'=>$obj->getTitle(), 'viewcount'=>$obj->getViewCount(), 'poster'=>$obj->getPoster(), @@ -134,8 +124,36 @@ function getStoryBoxJson($type,$count){ 'fullname'=>user::getFullNameS($obj->getUserId()), 'userpic'=>user::getUserPictureS($obj->getUserId()))); } + return $data; +} + +/** +* Returs a combined JSON for all the story box sections +* Utilizes various helper functions +* @param integer $fcount The number of videos in featured section +* @param integer $tcount The number of videos in toprated section +* @param integer $pcount The number of videos in popular section +* @return string JSON string containing all Storybox data +*/ +function getCombinedStoryBoxJson($fcount, $tcount, $pcount){ + $featuredarray = getFeaturedVideoArray($fcount); + + //Remove any featured array content from toprated + $topratedarray = getTopRatedVideoArray($tcount+$fcount); + $topratedarray = array_values(array_diff($topratedarray, $featuredarray)); + array_splice($topratedarray,$tcount); + + //Remove both of the above from popular + $populararray = getPopularVideoArray($pcount+$tcount+$fcount); + $populararray = array_values(array_diff($populararray,array_merge($featuredarray, $topratedarray))); + array_splice($populararray,$pcount); + + $json = array( "featured" => getStoryBoxDataArray($featuredarray), + "toprated" => getStoryBoxDataArray($topratedarray), + "popular" => getStoryBoxDataArray($populararray)); return json_encode($json); } + /** * Returns liked/disliked videos of a user. * @param integer $uid User ID From bfa9c8ee802c89b855fdf422deadd693f29816d4 Mon Sep 17 00:00:00 2001 From: Vipin Nair Date: Sun, 11 Dec 2011 23:14:18 +0530 Subject: [PATCH 02/12] Returns a combined storybox JSON --- json/storybox.json.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 json/storybox.json.php diff --git a/json/storybox.json.php b/json/storybox.json.php new file mode 100644 index 0000000..4560260 --- /dev/null +++ b/json/storybox.json.php @@ -0,0 +1,20 @@ + From 55f74c1dc2dcde461452c01233e3448c6055889c Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Thu, 15 Dec 2011 14:27:29 +0530 Subject: [PATCH 03/12] jquery grayout --- js/functions.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/js/functions.js b/js/functions.js index ec414cd..f8c9cfb 100644 --- a/js/functions.js +++ b/js/functions.js @@ -188,6 +188,26 @@ Paathshaala.validate.video(); }); }, + grayOut : function (option){ + if(option) { + $("
") + .attr('id', 'darkenScreenObject') + .css({ + 'position': 'absolute', + 'top': '0px', + 'left': '0px', + backgroundColor: '#030303', + 'opacity': '0.25', + 'width': '100%', + 'height': $(document).height(), + zIndex: 99 + }) + .appendTo("body"); + + } else { + $('div#darkenScreenObject').remove(); + } + }, hashTag : function(elem) { var data = $(elem).html(), reg = /#(\w{1,})/g, @@ -201,10 +221,10 @@ }, hideEditProfile : function() { $('#editProfile').fadeOut("fast"); - grayOut(false); + this.grayOut(false); }, hideFeedback : function () { - grayOut(false); + this.grayOut(false); $('div#feedback').hide(); }, imageError : function() { @@ -276,11 +296,11 @@ }); }, showEditProfile: function () { - grayOut(true); + this.grayOut(true); $('div#editProfile').load('editprofile.html').fadeIn("slow"); }, showFeedback : function() { - grayOut(true); + this.grayOut(true); $('div#feedback').show() $('div#feedback').load('feedback.html', function(){ $('div#feedback ul.links li').click(function() { @@ -650,10 +670,6 @@ /* ! Paathshaala */ -function grayOut(vis,options){var options=options||{},zindex=options.zindex||99,opacity=options.opacity||20,opaque=(opacity/80),bgcolor=options.bgcolor||'#030303',dark=document.getElementById('darkenScreenObject');if(!dark){var tbody=document.getElementsByTagName("body")[0],tnode=document.createElement('div');tnode.style.position='fixed';tnode.style.top='0px';tnode.style.left='0px';tnode.style.overflow='hidden';tnode.style.display='none';tnode.id='darkenScreenObject';tbody.appendChild(tnode);dark=document.getElementById('darkenScreenObject');} -if(vis){if(document.body&&(document.body.scrollWidth||document.body.scrollHeight)){var pageWidth='100%';var pageHeight='2000px';} -dark.style.opacity=opaque;dark.style.MozOpacity=opaque;dark.style.filter='alpha(opacity='+opacity+')';dark.style.zIndex=zindex;dark.style.backgroundColor=bgcolor;dark.style.width=pageWidth;dark.style.height=pageHeight;dark.style.display='block';}else{dark.style.display='none';}} - $(document).ready(function(){ P.searchBox(); P.dashBoard(); @@ -661,4 +677,4 @@ $(document).ready(function(){ P.comments(); P.quirks(); P.validate.join(); -}); \ No newline at end of file +}); From 9f42ae5af18464e99b5c848d0b29511c34bcd3a1 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Thu, 15 Dec 2011 14:54:05 +0530 Subject: [PATCH 04/12] IE support removed completely --- js/functions.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/functions.js b/js/functions.js index f8c9cfb..2654fc2 100644 --- a/js/functions.js +++ b/js/functions.js @@ -671,10 +671,17 @@ /* ! Paathshaala */ $(document).ready(function(){ - P.searchBox(); - P.dashBoard(); - P.imageError(); - P.comments(); - P.quirks(); - P.validate.join(); + if($.browser.msie) { + $("div#indexMesssage").remove(); + $("
").attr('id','indexMesssage') + .html("Have a life, use a modern browser. We dont support Internet Explorer.") + .appendTo("#container"); + } else { + P.searchBox(); + P.dashBoard(); + P.imageError(); + P.comments(); + P.quirks(); + P.validate.join(); + } }); From 279b0f51008a12ce51eeea59bc4a323f5c54dab8 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Thu, 15 Dec 2011 17:48:01 +0530 Subject: [PATCH 05/12] Piwik tracking optional --- functions/default.settings.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/default.settings.php b/functions/default.settings.php index 06751cb..49b7c22 100644 --- a/functions/default.settings.php +++ b/functions/default.settings.php @@ -28,4 +28,7 @@ $global_couch_user = ''; // $global_couch_password = ''; // +//Piwik Settings +$global_piwik_status = false; // + ?> From 0db5ff9dc05c4b8e612289c9ceb295c1c3ec5cac Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Thu, 15 Dec 2011 17:49:50 +0530 Subject: [PATCH 06/12] Piwik tracking based on global variable from settings.php --- source.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source.php b/source.php index ff9a95e..81fc7e1 100644 --- a/source.php +++ b/source.php @@ -1,5 +1,6 @@ @@ -15,7 +16,12 @@ $feedback = "feedback button
"; -$piwik = ""; +if ($global_piwik_status == true) { + $piwik = ""; +} else { + $piwik = ""; +} + $nullImage="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJCgcqHkarI5cAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQ4y2P8//8/AyWAiYFCMGrAqAGjBgwWAwBjmgMd7D3zQQAAAABJRU5ErkJggg=="; From 66883328dd8166de85c0dc6df3047e8b4d1857f7 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 13:42:19 +0530 Subject: [PATCH 07/12] Removed unwanted files --- json/featured.json.php | 11 ----------- json/popular.json.php | 11 ----------- json/toprated.json.php | 11 ----------- 3 files changed, 33 deletions(-) delete mode 100644 json/featured.json.php delete mode 100644 json/popular.json.php delete mode 100644 json/toprated.json.php diff --git a/json/featured.json.php b/json/featured.json.php deleted file mode 100644 index 4a0e197..0000000 --- a/json/featured.json.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/json/popular.json.php b/json/popular.json.php deleted file mode 100644 index 96c98f2..0000000 --- a/json/popular.json.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/json/toprated.json.php b/json/toprated.json.php deleted file mode 100644 index cc89ee6..0000000 --- a/json/toprated.json.php +++ /dev/null @@ -1,11 +0,0 @@ - From ad00d94538f645da66c6147d4798829f1ed06adf Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 13:44:37 +0530 Subject: [PATCH 08/12] Renamed for clarity --- json/{storybox.json.php => homeStorybox.json.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename json/{storybox.json.php => homeStorybox.json.php} (100%) diff --git a/json/storybox.json.php b/json/homeStorybox.json.php similarity index 100% rename from json/storybox.json.php rename to json/homeStorybox.json.php From 8bc5f90e2af09bbe15455a75cac3a607203f8e93 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 14:53:47 +0530 Subject: [PATCH 09/12] Small tweak on more/less buttons --- css/storybox.less | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/css/storybox.less b/css/storybox.less index 6777f2a..075e107 100644 --- a/css/storybox.less +++ b/css/storybox.less @@ -16,11 +16,14 @@ div.groupBox { } .more, .less { -display:block; -font-size:14px; -position: absolute; -right: 200px; -cursor: url('../pics/pointer.png') , auto; + display:block; + font-size:14px; + position: absolute; + right: 200px; + cursor: pointer; + &:hover { + text-decoration:underline; + } } .less { From a58d21963bf9d49f6aca2f0285c96cfd17e316dc Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 14:55:13 +0530 Subject: [PATCH 10/12] UI support for SHA : 407519 --- js/functions.js | 132 ++++++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/js/functions.js b/js/functions.js index 2654fc2..b8c4f70 100644 --- a/js/functions.js +++ b/js/functions.js @@ -347,81 +347,91 @@ }, updateStoryBox : function (type) { /* - type : Featured/ Top Rated / Popular + type : homePage / 'Liked videos' ... All box layout updated with same code New ui needed for upload video trigger */ - var videoBox = function (myobj) { - if( myobj.fullname.length > 18 ) - myobj.fullname = myobj.fullname.slice(0 ,15 ) + '...'; - return Paathshaala.templates.box.supplant(myobj); - }, - link, - title = $("").addClass('groupTitle'), - more = $("").addClass('more').html("Show more"), - less = $("").addClass('less').html("Show less"); - title = title.html(type); + var more = $("").addClass('more').html("Show more"), + less = $("").addClass('less').html("Show less"), + complete = function(){ + $('img.metaImage').error(function(){ + $(this).attr('src','pics/default.png'); + }); + $('img.thumbnail').error(function(){ + $(this).attr('src','pics/error.png'); + }); + + $('span.more').click(function(){ + $(this).hide(); + $(this).parent().find('.Hidden').slideDown('fast'); + $(this).parent().find('.less').fadeIn(); + }); + $('span.less').click(function(){ + $(this).parent().find('.Hidden').slideUp('fast'); + $(this).parent().find('.more').fadeIn(); + $(this).hide(); + }); + }, + videoBox = function (myobj) { + if( myobj.fullname.length > 18 ) + myobj.fullname = myobj.fullname.slice(0 ,15 ) + '...'; + return Paathshaala.templates.box.supplant(myobj); + }, + groupBox = function(title, json) { + try { + // throw exception if json is invalid + if ($.isEmptyObject(json) ) + throw "Empty JSON"; + title = $("").addClass('groupTitle').html(title) + var i, + groupBox = $("
").addClass('groupBox'), + groupBox2 = $("
").addClass('Hidden').addClass('groupBox'); + if (json.length === 4 ) { + for (i =0; i <4 ; i +=1) + groupBox = groupBox.append(videoBox(json[i])); + $('div#container').append(title).append(groupBox); + } else { /* All multi boxes handled in same way if more than 4 */ + for (i =0; i <4 ; i +=1) + groupBox = groupBox.append(videoBox(json[i])); + for (i =4; i < json.length ; i +=1) + groupBox2 = groupBox2.append(videoBox(json[i])); + $('div#container').append($("
").append(title , groupBox , more , groupBox2 , less)); + } + } catch(e) { + // handle invalid json case + if (e === "Empty JSON") + console.log("Empty JSON recived from server"); + } finally { + // i wonder what to do here. + } + }; + switch (type) { - case 'Featured' : - link = 'json/featured.json.php'; - break; - case 'Top Rated' : - link = 'json/toprated.json.php'; - break; - case 'Popular': - link = 'json/popular.json.php'; + case 'homePage': + $.getJSON( 'json/homeStorybox.json.php' , function(json){ + groupBox('Featured', json.featured); + groupBox('Popular', json.popular); + groupBox('Top Rated', json.toprated); + }).complete(function(){ complete(); }); break; case 'Liked videos': - link = 'json/uservideolikes.json.php'; + $.getJSON( 'json/uservideolikes.json.php' , function(json){ + groupBox('Liked videos', json); + }).complete(function(){ complete(); }); break; case 'Disliked videos': - link = 'json/uservideodislikes.json.php'; + $.getJSON( 'json/uservideodislikes.json.php' ,function(json){ + groupBox('Disliked videos', json); + }).complete(function(){ complete(); }); break; case 'My Uploads': - link = 'json/uservideouploads.json.php'; + $.getJSON( 'json/uservideouploads.json.php' , function(json){ + groupBox('My Uploads', json); + }).complete(function(){ complete(); }); break; } - $.getJSON( link , function(json) { - if (json.length !== 0 ) { - var i, - groupBox = $("
").addClass('groupBox'), - groupBox2 = $("
").addClass('Hidden').addClass('groupBox'); - if (json.length === 4 ) { - for (i =0; i <4 ; i +=1) - groupBox = groupBox.append(videoBox(json[i])); - $('div#container').append(title).append(groupBox); - } else { /* All multi boxes handled in same way if more than 4 */ - for (i =0; i <4 ; i +=1) - groupBox = groupBox.append(videoBox(json[i])); - for (i =4; i < json.length ; i +=1) - groupBox2 = groupBox2.append(videoBox(json[i])); - $('div#container').append($("
").append(title , groupBox , more , groupBox2 , less)); - } - } else { - $('div#container').append(title).append(groupBox); - } - }).complete(function(){ - - $('img.metaImage').error(function(){ - $(this).attr('src','pics/default.png'); - }); - $('img.thumbnail').error(function(){ - $(this).attr('src','pics/error.png'); - }); - $('span.more').click(function(){ - $(this).hide(); - $(this).parent().find('.Hidden').slideDown('fast'); - $(this).parent().find('.less').fadeIn(); - }); - $('span.less').click(function(){ - $(this).parent().find('.Hidden').slideUp('fast'); - $(this).parent().find('.more').fadeIn(); - $(this).hide(); - }); - - }); } }; From 734a644a506913d8401d4eaa5248c4ab89e430cd Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 14:55:59 +0530 Subject: [PATCH 11/12] storyBox calls updated for utilizing single json update. Depends on SHA : 407519f19e66f7e27bc2116adc8738ec241dee0b --- index.php | 8 +++----- js/functions.js | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 3b9aeeb..3d2aaa7 100755 --- a/index.php +++ b/index.php @@ -23,11 +23,9 @@ echo $piwik; ?> diff --git a/js/functions.js b/js/functions.js index b8c4f70..63d3f0e 100644 --- a/js/functions.js +++ b/js/functions.js @@ -382,7 +382,7 @@ // throw exception if json is invalid if ($.isEmptyObject(json) ) throw "Empty JSON"; - title = $("").addClass('groupTitle').html(title) + title = $("").addClass('groupTitle').html(title); var i, groupBox = $("
").addClass('groupBox'), groupBox2 = $("
").addClass('Hidden').addClass('groupBox'); From 97a9a5401806ef2c124776b70e8893eb09f7d3fb Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Fri, 16 Dec 2011 17:12:26 +0530 Subject: [PATCH 12/12] Edits as per HTML validator report. --- css/structure.less | 4 +-- source.php | 86 ++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/css/structure.less b/css/structure.less index 9b5f99b..e8d6197 100644 --- a/css/structure.less +++ b/css/structure.less @@ -109,7 +109,7 @@ margin: 0; height: 100px; /* min logo size */ position: relative; - #logo{ + #logo1, #logo2{ background :@offWhite; border-color: #D2D2D2; border-right: 1px solid #DDDDDD; @@ -201,7 +201,7 @@ z-index:-2; position:relative; top:40px; /* Height of bottom bar */ - #logo{ + #logo1, #logo2{ border-color: #D2D2D2; background:#f5f5f5; background: -webkit-gradient(linear, left top, left bottom, from(@gray1), to(white)); diff --git a/source.php b/source.php index 81fc7e1..5eb83f1 100644 --- a/source.php +++ b/source.php @@ -5,8 +5,8 @@ $header=" - - + + "; $scripts=" @@ -27,68 +27,68 @@ if(!isset($_SESSION['uid'])){ $topBar = "
- +

- +
Enter your credentials
-
-
-
-
-
-
+
+
+
+
+
+
-"; +"; } else{ $topBar = "
- +

- +
- + ".$_SESSION['fullname']." - +
- "; + "; } $bottomBar = "
- +

"; -if(isset($_SESSION['uid'])) -{ -$commentSubmit = "
-
-
- - ".$_SESSION['fullname']." -
- -
-
-
"; +if(isset($_SESSION['uid'])) { + $commentSubmit = "
+
+
+ + ".$_SESSION['fullname']." +
+ +
+
+
"; } -else -{ +else { $commentSubmit="Please log in to comment."; } - - ?>