var SocialStream = SocialStream || {}; SocialStream.Linkser = SocialStream.Linkser || {}; SocialStream.Linkser.initiate = function() { $.preloadImages("assets/loading.gif"); var urlDetect = function() { this.currentValue = $("#input_activities").val(); if(this.lastValue == null) this.lastValue = ""; var regexp = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/ if(regexp.test($("#input_activities").val())) { $("#link_url").val($("#input_activities").val()); $("#link_loaded").val(false); $("#new_post").attr("action", "/links"); if(this.currentValue != this.lastValue) { $("#link_preview").html($('').attr('src', 'assets/loading.gif').addClass('loading')); this.lastValue = this.currentValue; var url = this.currentValue; var urlDetect = this; $.ajax({ type : "GET", url : "/linkser_parse?url=" + url, success : function(html) { if($("#input_activities").val() == url) {//Only show if input value is still the same $("#link_preview").html(html); $("#link_loaded").val(true); } }, error : function(xhr, ajaxOptions, thrownError) { if($("#input_activities").val() == url) {//Only show if input value is still the same $("#link_preview").html($('