Sabtu, 17 Agustus 2013

jv

// Platform specific JS :: PC
// Global Vars
var current_slide = 1;
var current_appId = 0;
var active_app_slide = 1;
var device_search_flag = 1;
var abTakeoverProdLink = "";
// utils
function baseForSubDomains() {
var tmp = document.domain.split('.');
if( tmp.length <2 ) return document.domain;
return "." + tmp[ tmp.length-2] + "." + tmp[ tmp.length-1];
}
// Cookie Management
function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+";Domain=" + baseForSubDomains() + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function deleteCookie(name) {setCookie(name,"",-1);}
//Set Your Device JS
var divScroll = 0;
var gCalloutTimer = '';
var gCalloutTimerOn = false;
var selected_url_part;
var selected_image;
var selected_deviceid;
var fB_connecting = 0;
function cleanPhoneBox( obj ) {
if( obj.value == obj.defaultValue ) {
obj.value = '';
obj.className = '';
}
}
function fillPhoneBox( obj ) {
if( obj.value == '' ) {
obj.value = obj.defaultValue;
obj.className = 'search_tool_tip';
}
}
function suggestPhone(data) { // Recieves data from JSON call
$('#box').html('');
row_count = 1;
$.each ( data, function ( id, phone ) {
$('#searchPhoneResultsContainer').append('<div onclick="set_search_field_value(\'' + phone.title + '\',\'' + phone.image + '\',\'' + phone.url_part + '\',\'' + phone.id + '\');" style="cursor:pointer;-moz-border-radius:6px 6px 6px 6px;-webkit-border-radius:6px 6px 6px 6px;border:1px solid #D3D3D3;padding:2px;margin:2px;height:120px;width:75px;display:table;float:left;"><span style="font-size:11px;"><img style="width:50px;" src="http://view.getjar.mobi/mr_device_images/thumb/'+phone.image+'" alt="" /><br/>'+ phone.title +'</span></div>');
if(row_count == 4){
row_count = 1;
$('#searchPhoneResultsContainer').append('<br clear="all"/>');
}
else {row_count++;}
});
device_search_flag = 1;
}
function onBodyLoad() {
// ONCE A DAY REMIND TO SELCET PHONE
if(  !getCookie('udvs') && !getCookie('popped') ) {
setCookie('popped','1',1);
openInlinePopup('#popup_choose_phone');
}
}
var lasttimeout = 0;
function search_phones(ajaxdomain) {
search_string = $('#key').val();
if(search_string.length >= 2 && device_search_flag == 1) {
if( lasttimeout ) clearTimeout(lasttimeout);
lasttimeout = setTimeout('search_phones_call(\"'+ajaxdomain+'\", \"'+search_string+'\")', 300 );
}
}
function search_phones_call( ajaxdomain, search_string ) {
device_search_flag = 0;
$('#searchPhoneResultsContainer').empty();
$.ajax({
    type:"GET",
    url : ajaxdomain + '?jsoncallback=?',
    data: {
        query: search_string,
        nocache: Math.floor((Math.random()*1000000)+1)
    },
    dataType:'json'
});
}
function search_recommented_apps() {
url_domain = document.domain;
$.ajax({
    type:"GET",
    url :"http://"+url_domain+"/get-recommended-apps/",
    success: function(data){
    $('#recommendedAppsContainer').empty();
        //Availabe Fields : appId, clickId, title, image, shortDescription, downloadCount, productPage
    $.each ( data, function ( appId, app ) {
    $('#recommendedAppsContainer').append('<div class="recommended_app_container"><img class="recommend_apps_image roundedcorners" src="'+app.image+'"/><a href="'+app.productPage+'" style="font-weight:bold;line-height:17px;">'+app.title+'</a><br style="line-height:40px;"/>'+app.shortDescription.substring(0,100)+'<br style="line-height:40px;"/>'+app.downloadCount+' downloads</div>');
    });        
    },
    dataType:'json'
});
}
function set_search_field_value(new_value,image,url_part, deviceid){
selected_url_part = url_part;
selected_image = image;
selected_deviceid = deviceid;
$("#selected_device_preview").attr("src", "http://view.getjar.mobi/mr_device_images/thumb/" + selected_image);
confirm_device();
}
function confirm_device(){
reopenInlinePopup('#set_device_confirm');
setCookie("deviceimage","http://view.getjar.mobi/mr_device_images/thumb/" + selected_image,100);
}
function change_device(){reopenInlinePopup('#popup_choose_phone');}
function set_device_values(ajaxdomain){
var oldUrl = getCookie("udvs");
if( !oldUrl ) oldUrl = "google-nexus-one";
oldUrl = "-for-" + oldUrl;
setCookie("udvs", selected_url_part, 100 );
    //setcookie("gjsetdeviceredirect", "1" , time()+30, "/", $this->cookieDomain);
window.location = window.location.href.replace(oldUrl, "-for-" + selected_url_part );
}
function set_user_country(){
if($("#userCountry").val() != "0"){
setCookie("gjloc",$("#userCountry").val(),100);
window.location.reload();
}
}
// Misc
function manage_comment(textbox,countfield){
debug = 0;
if(debug != 1){
i=1000;
val=textbox.value;
if(val.length>i) {textbox.value = val.substring(0,i);textbox.focus();}
document.getElementById(countfield).innerHTML=i-parseInt(textbox.value.length);
}
else {alert("Debug Mode");}
}
function feedNav(direction, appCount){
total_page_count = Math.ceil(appCount/10);
if(direction == "next") {
if(total_page_count > active_app_slide){
new_slide = active_app_slide + 1;
active_app_slide++;
}
else{
new_slide = 1;
active_app_slide = 1;
}
}
if(direction == "prev") {
new_slide = active_app_slide - 1;
active_app_slide--;
}
if(new_slide == 0){new_slide = total_page_count;}
if(new_slide < 0){new_slide = 1;}
for(c=1;c<=total_page_count;c++){$("#appslide"+c).hide();}
$("#appsmore").hide();
$("#appnav").hide();
new_slide_to_show = "#appslide"+new_slide;
//alert(new_slide_to_show);
$("#appnav").show();
$(new_slide_to_show).show();
$(window).scrollTop(0);
}
function validate_post_feed_entry_product(feed_type, form_id, gjid){
the_form = document.forms[form_id];
comment = the_form.popup_comment_box.value;
if(comment && comment != ""){the_form.submit();}
else {
$("#comment_message").html("<span style='color:red;font-weight:bold;'>Please enter a comment</span>");
$("#comment_message2").html("<span style='color:red;font-weight:bold;'>Please enter a comment</span>");
}
}
function manage_app_pref_submit(feed_type,form_id,gjid){
the_form = document.forms[form_id];
hidden_value_form = document.forms[form_id];
comment = $("#sharedapps_popup_comment_box").val();
hidden_value_form["myappspost"].value = feed_type;
hidden_value_form["pref"].value = feed_type;
hidden_value_form["comment"].value = comment;
hidden_value_form["sharedpref"].value = 1;
hidden_value_form["appId"].value = current_appId;
hidden_value_form["redirect"].value = window.location;
hidden_value_form.submit();
}
function product_page_prepop(udvs,isProductBuild){
alert(fB_connecting);
if(udvs && isProductBuild == "1"){ // device set, build found
$('#popup_download').lightbox();
return;
}
if(udvs && isProductBuild == "0"){ // device set, no build found
search_recommented_apps();
$('#popup_recommended_apps').lightbox();
return;
}
if(!udvs){ // device set, no build found
$('#popup_choose_phone').lightbox();
setCookie("prepop","dl",100);
return;
}
}
function set_sharepref(isChecked){
if(isChecked){$('#sharepref').val('on');}
else{$('#sharepref').val('');}
}
function flip_slide(flip_direction,slide_count) {
if(flip_direction == "prev"){current_slide = current_slide - 1;}
if(flip_direction == "next"){current_slide = current_slide + 1;}
if(current_slide < 1){current_slide = 1;}
if(current_slide >= slide_count){current_slide = slide_count;}
$("#dot_1, #dot_2, #dot_3, #dot_4, #dot_5").css("background","#58595B");
$("#dot_1, #dot_2, #dot_3, #dot_4, #dot_5").css("opacity","0.2");
$("#dot_"+current_slide).css("background","#FABB2A");
$("#dot_"+current_slide).css("opacity","1.0");
}
function openInlinePopup(selector) {
  $.colorbox({
    current: false,
    fixed: true,
    href: selector,
    inline: true,
    onCleanup: function() { $(selector).css('display','none'); }, // hiding popup content
    onClosed: function() { $('#cboxContent').removeClass('showInline'); },
    onLoad: function() { $('#cboxClose').css('display','none'); $('.popup .close').click(function() { $.colorbox.close() }); },
    onOpen: function() { $(selector).css('display','block'); $('#cboxContent').addClass('showInline'); }, // displaying popup content
    rel: 'nofollow',
  });
}
function reopenInlinePopup(selector) {
// first close and then fire open sequence
// this combination allows to fire all colorbox handlers
// otherwise it just switch the content
$(document).bind('cbox_closed', function(){
  openInlinePopup(selector);
  $(document).unbind('cbox_closed');
});
$.colorbox.close();
}
function play_overtake() {
$('#angrybirds_plank').delay(1000).animate({marginTop:0},1000,function() {
$('#bg_mask').toggle(1500,function(){setCookie("active_theme","ab",1);});
$('#angrybirds_big_rip').delay(3000).toggle(0,function() {
$('#top_ad,#takeover_angrybirds').toggle();
$('#angrybirds_plank').delay(9000).animate({marginTop:0},0,function() {
$("#angrybirds_plank, #angrybirds_bottom_plank, #angrybirds_big_rip").fadeOut(1500);
setCookie("angrybirds_views","1",1);
});
}); 
});
}
function takeoverDirector() {
pt1Audio = $('#abAudioPt1').get(0);
alert(pt1Audio.duration);
pt2Audio = $('#abAudioPt2').get(0);
$(pt1Audio).bind('ended', function() {
pt2Audio.play();
$('#angrybirds_big_rip').show();
});
pt1Audio.play();
$('#angrybirds_plank').animate({marginTop:0},1000,function() {});
$('#bg_mask').toggle(1500,function(){setCookie("active_theme","ab",1);});
}
function takeover_click(redirect){
setCookie("angrybirds_views","1",1);
$("#angrybirds_plank, #angrybirds_bottom_plank, #angrybirds_big_rip").hide();
if(redirect) document.location = abTakeoverProdLink;
}
$(document).ready(function() {
$('a[name=suckafree]').click(function(e) {
 e.preventDefault();
 if($('#popup_comment_box').val().length > 1){$('#userFeedbackComment').submit();}
});
// automatically binds lightbox to screenshot thumbnails
$(".thumbs a").colorbox({
    current: false,
    fixed: true,
    maxHeight: '90%',
    maxWidth: '90%',
    next: '<span></span>',
    opacity: '0.6',
    previous: '<span></span>',
    rel: 'thumbs',
    title: '<span>'+$('.thumbsHeadline').text()+'</span>',
});
 
// binds event to the button to open popup
$('.overlay').click(function(event) {
event.preventDefault();
openInlinePopup($(this).attr('rel'));
});
 
$('.popup .overlay').unbind('click').click(function(event) {
event.preventDefault();
reopenInlinePopup($(this).attr('rel'));
});
// takeoverDirector();
play_overtake();
});

Tidak ada komentar:

Posting Komentar