/** * Created by USER on 12-11-2016. */ $(document).ready(function() { //var jsondata = [{"link":"http://google.com","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"green-top","icon":"images/icon2.png","color_bottom":"green","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"purple-top","icon":"images/icon3.png","color_bottom":"purple-dark","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"blue-top","icon":"images/icon4.png","color_bottom":"blue","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"orange-top","icon":"images/icon5.png","color_bottom":"orange","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"yellow-top","icon":"images/icon6.png","color_bottom":"yellow-two","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"purple-top","icon":"images/icon7.png","color_bottom":"purple-dark","first_name":"First","last_name":"Last","position":"Position or Title of Person"},{"link":"http://google.com","color_top":"blue-top","icon":"images/icon9.png","color_bottom":"blue","first_name":"First","last_name":"Last","position":"Position or Title of Person"}]; //var jsondata = [{"link":"","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"Adam","last_name":"Abate","position":"Associate Professor ","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon2.png","color_bottom":"yellow-two","first_name":"Steven","last_name":"Altschuler","position":"Professor ","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon3.png","color_bottom":"yellow-two","first_name":"Michelle","last_name":"Arkin","position":"Associate Professor ","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon4.png","color_bottom":"yellow-two","first_name":"Patricia","last_name":"Babbitt","position":"Professor ","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon5.png","color_bottom":"yellow-two","first_name":"Joseph","last_name":"Derisi","position":"Professor ","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon6.png","color_bottom":"yellow-two","first_name":"Tejal","last_name":"Desai","position":"Chair, Bioengineering","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon7.png","color_bottom":"yellow-two","first_name":"Hana","last_name":"El Samad","position":"Associate Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon8.png","color_bottom":"yellow-two","first_name":"Michael","last_name":"Fischbach","position":"Associate Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"Ryan","last_name":"Hernandez","position":"Associate Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon2.png","color_bottom":"yellow-two","first_name":"Bo","last_name":"Huang","position":"Associate Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon3.png","color_bottom":"yellow-two","first_name":"John","last_name":"Irwin","position":"CMPTL & DATA SCI RSCH SPEC 5","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon4.png","color_bottom":"yellow-two","first_name":"Matt","last_name":"Jacobson","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon5.png","color_bottom":"yellow-two","first_name":"Regis","last_name":"Kelly","position":"Professor - Director, QB3 Institute","school":"UCSF Chancellor/EVC/FAS"},{"link":"","color_top":"yellow-top","icon":"images/icon6.png","color_bottom":"yellow-two","first_name":"Tanja","last_name":"Kortemme","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon7.png","color_bottom":"yellow-two","first_name":"Nevan","last_name":"Krogan","position":"Professor - Director QBI","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon8.png","color_bottom":"yellow-two","first_name":"John","last_name":"Kurhanewicz","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"Peder","last_name":"Larson","position":"Associate Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon2.png","color_bottom":"yellow-two","first_name":"Hao","last_name":"Li","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon3.png","color_bottom":"yellow-two","first_name":"Janine","last_name":"Lupo","position":"Assistant Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon4.png","color_bottom":"yellow-two","first_name":"Sharmilla","last_name":"Majumdar","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon5.png","color_bottom":"yellow-two","first_name":"Sarah","last_name":"Nelson","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon6.png","color_bottom":"yellow-two","first_name":"Feroz","last_name":"Papa","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon7.png","color_bottom":"yellow-two","first_name":"Adam","last_name":"Renslo","position":"Associate Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon8.png","color_bottom":"yellow-two","first_name":"Sabrina","last_name":"Ronen","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"Shuvo","last_name":"Roy","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon2.png","color_bottom":"yellow-two","first_name":"Judy","last_name":"Sakanari","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon3.png","color_bottom":"yellow-two","first_name":"Andrej","last_name":"Sali","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon4.png","color_bottom":"yellow-two","first_name":"Rada","last_name":"Savic","position":"Assistant Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon5.png","color_bottom":"yellow-two","first_name":"Brian","last_name":"Shoichet","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon6.png","color_bottom":"yellow-two","first_name":"Dan","last_name":"Vigneron","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon7.png","color_bottom":"yellow-two","first_name":"Jonathan","last_name":"Weissman","position":"Professor","school":"UCSF School of Medicine"},{"link":"","color_top":"yellow-top","icon":"images/icon8.png","color_bottom":"yellow-two","first_name":"Jim","last_name":"Wells","position":"Professor - Chair, Pharmaceutical Chemistry","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon1.png","color_bottom":"yellow-two","first_name":"Lani","last_name":"Wu","position":"Professor","school":"UCSF School of Pharmacy"},{"link":"","color_top":"yellow-top","icon":"images/icon2.png","color_bottom":"yellow-two","first_name":"Xiaoliang","last_name":"Zhang","position":"Professor","school":"UCSF School of Medicine"}]; AddMoreContent(); $('#filter_form select').on('change',function () { var element=$(this); if(element.val()=="") { element.parent().removeClass('select-box-active'); } else { element.parent().addClass('select-box-active'); } $('#investigators').fadeOut().html(""); AddMoreContent() }) }); function AddMoreContent() { if($('#request').val()==0) { $.ajax({ url : "ajax/investigators.php", method:"POST", data : $('#filter_form').serialize()+'&length='+$('#investigators .investigators-post').length, beforeSend:function () { $('#request').val(1); }, success: function(msg){ msg = typeof msg != 'object' ? JSON.parse(msg) : msg; if(msg.length==0) { $(window).unbind('scroll'); } else { $(window).unbind('scroll').scroll(function(){ if ($(window).scrollTop() > $(document).height() - $(window).height()-450){ AddMoreContent(); } }); } setData(msg); $('.article_appear').fadeIn().removeClass('article_appear'); $('#request').val(0); } }); } } function setData(msg) { currentLength=$('#investigators .investigators-post').length; var structure = '
'; var return_content=""; var colors=[['yellow-top','yellow-two'],['green-top','green'],['orange-top','orange'],['blue-top','blue'],['purple-top','purple-dark']]; var max_count = colors.length; var color_counter=currentLength%max_count; for(var i in msg) { var classes=""; currentLength=currentLength+1; if(currentLength%3 == 1) { classes="padding-right-ten padding-tablet-left"; } else if(currentLength%3 == 2) { classes = "padding-ten padding-tablet-middle"; } else if(currentLength%3 == 0) { classes = "padding-left-ten padding-tablet-right"; } var result=structure; result = result.replace(/article_class/g,classes); result = result.replace(/article_link/g,msg[i]['link']); result = result.replace(/article_color_top/g,colors[color_counter][0]); //result = result.replace(/article_color_top/g,'yellow-top'); result = result.replace(/article_color_bottom/g,colors[color_counter][1]); //result = result.replace(/article_color_bottom/g,'yellow-two'); result = result.replace(/article_icon/g,msg[i]['icon']); result = result.replace(/article_first_name/g,msg[i]['first_name']); result = result.replace(/article_last_name/g,msg[i]['last_name']); result = result.replace(/article_position/g,msg[i]['position']); result = result.replace(/article_school/g,msg[i]['school']); return_content+=result; color_counter++; if(color_counter==max_count) { color_counter=0; } } $('#investigators').append(return_content).fadeIn(); }