function registration(){$.ajax({url:"/keychain/exists/"+$(".reg-username").val(),success:function(e){"true"===e?($(".username-alert").show(),$(".reg-key").hide(),$(".wot_register").hide()):($(".username-alert").hide(),$(".wot_register_check").is(":checked")&&$(".reg-key").show(),$(".wot_register").show())}})}function pullRatings(){return $.ajax({async:!1,cache:!1,type:"GET",dataType:"text",url:"/keychain/sync/pull/ratings"}).always(function(e){window.pullResponse=e}),window.pullResponse}function checkRatings(){return $.ajax({async:!1,cache:!1,type:"GET",dataType:"text",url:"/keychain/ratings"}).always(function(e){window.checkResponse=e}),window.checkResponse}function pushRatings(){var e=$(".encrypted-message").val();$.ajax({async:!1,cache:!1,type:"POST",url:"/keychain/sync/push/ratings",data:{signed_message:e},dataType:"text"}).always(function(e){"true"==e?($(".sync-status").text("Sync complete!"),$(".sync-status").show(),$(".sync-close").show(),$(".sync-form").hide(),$(".sync-push").hide()):($(".sync-status").text("Could not push the data. Try again later."),$(".sync-status").show())})}function syncWoT(){$("#syncModal").modal("show"),"true"===pullRatings()?($(".sync-status").hide(),"[]"==checkRatings()?($(".sync-status").text("Sync complete!"),$(".sync-status").show()):($(".sync-form").show(),$(".sync-close").hide())):$(".sync-status").text("Pull Failed.")}function parseVideo(e){if(e.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),RegExp.$3.indexOf("youtu")>-1)var s="youtube";else if(RegExp.$3.indexOf("vimeo")>-1)var s="vimeo";return{type:s,id:RegExp.$6}}function getKramdown(e){var s;return $.ajax({async:!1,cache:!1,type:"POST",dataType:"text",url:"/posts/kramdown",data:{body:e}}).success(function(e){s="false"!=e?e:"Oops! There was an error trying to get a preview!"}),s}$(".reg-username").on("input",function(){registration()}),$(".wot_register_check").change(function(){registration(),$(".wot_register_check").not(":checked")&&($(".username-alert").hide(),$(".reg-key").hide())});var pullResponse=!1,checkResponse=!1;$(document).ready(function(){$(".markdown-editor").markdown({parser:function(e){return getKramdown(e)}}),$(".non-js").hide(),$(".no-js").show()}),$("document").ready(function(){$(".reply-box-avatar").addClass("js-reply-box-avatar"),$(function(){$("[data-toggle='tooltip']").tooltip(),$(".file-inputs").bootstrapFileInput(),$(".no-js-show").hide(),$(".no-js").show()}),$(".show-payments-list").click(function(e){var s=$(this);s.hasClass("fa-plus-square-o")?($("#payments-list").slideDown(),s.removeClass("fa-plus-square-o").addClass("fa-minus-square-o")):($("#payments-list").slideUp(),s.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"))}),$(".show-milestones-list").click(function(e){var s=$(this);s.hasClass("fa-plus-square-o")?($("#milestones-list").slideDown(),s.removeClass("fa-plus-square-o").addClass("fa-minus-square-o")):($("#milestones-list").slideUp(),s.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"))}),$("#expand-all").click(function(){$(".post .content-block").slideDown()}),$("#collapse-all").click(function(){$(".post .content-block").slideUp()}),$(".video-integration a").each(function(e,s){var a=$(this);video_uri=$(this).attr("href");var t=/(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?([^<]+)/g,o=/(?:http:\/\/)?(?:www\.)?(?:vimeo\.com)\/([^<]+)/g,i=/(?:http:\/\/)?(?:dailymotion\.com|dai\.ly)\/([^<]+)/g,n=t.exec(video_uri),r=o.exec(video_uri),c=i.exec(video_uri),l='<span class="fa-stack video-preview" video-id="'+e+'"><i class="fa fa-square-o fa-stack-2x"></i><i class="fa fa-video-camera fa-stack-1x"></i></span><span class="yt-preview-'+e+'" style="display:none">';n?a.after(l+'<div class="videowrapper"><iframe width="640" height="360" src="http://www.youtube.com/embed/'+n[1]+'?modestbranding=1&rel=0&wmode=transparent&theme=light&color=white" frameborder="0" allowfullscreen></iframe></div></span>'):r?a.after(l+'<div class="videowrapper"><iframe src="//player.vimeo.com/video/'+r[1]+'" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div></span>'):c&&a.after(l+'<div class="videowrapper"><iframe frameborder="0" width="560" height="315" src="http://www.dailymotion.com/embed/video/'+c[1]+'?logo=0&foreground=ffffff&highlight=1bb4c6&background=000000" allowfullscreen></iframe></div></span>')}),$(".video-preview").click(function(e){var s=$(this).attr("video-id");$(this).hasClass("active")?($(".yt-preview-"+s).hide(),$(this).removeClass("active")):($(".yt-preview-"+s).show(),$(this).addClass("active"))}),autosize($("textarea"))});