<commit_before>
window.Microblog = window.Microblog || {}

;(function($) {
	
	Microblog.Timeline = function () {
		var feed = $('#StatusFeed');
		
		var refreshTime = 10000;
		var pendingUpdate = false;
		var pendingLoad = false;
		
		var loading = false;
		
		var refreshTimeline = function (since) {
			if (pendingUpdate) {
				return pendingUpdate;
			}

			if (!since) {
				var times = $('abbr.postTime:first');
				// top down latest, so take the first one's time
				since = $(times).attr('data-created');
			}
			
			loading = true;
			pendingUpdate = getPosts({since: since});
			
			pendingUpdate.done(function () {
				pendingUpdate = null;
				loading = false;
				setTimeout(function () {
					refreshTimeline();
				}, refreshTime);
			})
			return pendingUpdate;
		}
		
		setTimeout(function () {
			refreshTimeline();
		}, refreshTime)
		
		var morePosts = function () {
			if (pendingLoad) {
				return pendingLoad;
			}
			var allPosts = $('.microPost');
			var earliest = $(allPosts[allPosts.length-1]).attr('data-id');
			if (earliest) {
				pendingLoad = getPosts({before: earliest}, true);
				return pendingLoad;
			}
		}

		var getPosts = function (params, append, callback) {
			var url = $('input[name=timelineUpdateUrl]').val();
			if (!url) {
				return;
			}
			return $.get(url, params, function (data) {
				if (data && data.length > 0) {
					var newPosts = $('<div class="newposts">');
					if (append) {
						newPosts.appendTo(feed);
					} else {
						newPosts.prependTo(feed);
					}

					newPosts.append(data);
					newPosts.effect("highlight", {}, 3000);
				}
			});
		}

		return {
			refresh: refreshTimeline,
			more: morePosts
		}
	}();

	$(function () {

		$.entwine('microblog', function ($) {
			$('.timeago').entwine({
				onmatch: function () {
					if ($.fn.timeago) {
						this.timeago();
					}
				}
			})
			$('textarea.expandable').entwine({
				onmatch: function () {
					this.keydown(function (e) {
						if (e.which == 13) {
							$(this).addClass('expanded-content');
						}
					})
				}
			});
			
			$('.moreposts').entwine({
				onclick: function () {
					var _this = this;
					// caution - leak possible!! need to switch to new 'from' stuff in entwine
					Microblog.Timeline.more().done(function () {
						_this.appendTo('#StatusFeed')
					});
					
					return false;
				}
			})
			
			$('form.replyForm').entwine({
				onmatch: function () {
					$(this).attr('action', $('#Form_PostForm').attr('action'));
					this.ajaxForm(function (done) {
						$(this).find('textarea').empty();
						Microblog.Timeline.refresh();
					})
				}
			})
			
			$('#Form_PostForm').entwine({
				onmatch: function () {
					this.ajaxForm(function (done) {
						$('#Form_PostForm_Content').empty();
						Microblog.Timeline.refresh();
					})
				}
			});
			
			$('.fileUploadForm').entwine({
				onmatch: function () {
					var uploadList = $('#uploadedFiles');
					$(this).fileupload({
						dataType: 'json',
						dropZone: $('#dropZone'),
						formData: function(form) {
							var formData = [
								{name: 'SecurityID', value: $('input[name=SecurityID]').val()}
								// {name: 'ID', value: $(form).find(':input[name=ID]').val()}
							];
							return formData;
						},
						drop: function (e, data) {
							$.each(data.files, function (index, file) {<commit_msg>Fix refresh of 'more posts'<commit_after>
window.Microblog = window.Microblog || {}

;(function($) {
	
	Microblog.Timeline = function () {
		var feed = $('#StatusFeed');
		
		var refreshTime = 10000;
		var pendingUpdate = false;
		var pendingLoad = false;
		
		var loading = false;
		
		var refreshTimeline = function (since) {
			if (pendingUpdate) {
				return pendingUpdate;
			}

			if (!since) {
				var times = $('abbr.postTime:first');
				// top down latest, so take the first one's time
				since = $(times).attr('data-created');
			}
			
			loading = true;
			pendingUpdate = getPosts({since: since});
			
			pendingUpdate.done(function () {
				pendingUpdate = null;
				loading = false;
				setTimeout(function () {
					refreshTimeline();
				}, refreshTime);
			})
			return pendingUpdate;
		}
		
		setTimeout(function () {
			refreshTimeline();
		}, refreshTime)
		
		var morePosts = function () {
			if (pendingLoad) {
				return pendingLoad;
			}
			var allPosts = $('.microPost');
			var earliest = $(allPosts[allPosts.length-1]).attr('data-id');
			if (earliest) {
				pendingLoad = getPosts({before: earliest}, true).done(function () {
					pendingLoad = null;
				});
				return pendingLoad;
			}
		}

		var getPosts = function (params, append, callback) {
			var url = $('input[name=timelineUpdateUrl]').val();
			if (!url) {
				return;
			}
			return $.get(url, params, function (data) {
				if (data && data.length > 0) {
					var newPosts = $('<div class="newposts">');
					if (append) {
						newPosts.appendTo(feed);
					} else {
						newPosts.prependTo(feed);
					}

					newPosts.append(data);
					newPosts.effect("highlight", {}, 3000);
				}
			});
		}

		return {
			refresh: refreshTimeline,
			more: morePosts
		}
	}();

	$(function () {

		$.entwine('microblog', function ($) {
			$('.timeago').entwine({
				onmatch: function () {
					if ($.fn.timeago) {
						this.timeago();
					}
				}
			})
			$('textarea.expandable').entwine({
				onmatch: function () {
					this.keydown(function (e) {
						if (e.which == 13) {
							$(this).addClass('expanded-content');
						}
					})
				}
			});
			
			$('.moreposts').entwine({
				onclick: function () {
					var _this = this;
					// caution - leak possible!! need to switch to new 'from' stuff in entwine
					Microblog.Timeline.more().done(function () {
						_this.appendTo('#StatusFeed')
					});
					
					return false;
				}
			})
			
			$('form.replyForm').entwine({
				onmatch: function () {
					$(this).attr('action', $('#Form_PostForm').attr('action'));
					this.ajaxForm(function (done) {
						$('form.replyForm').find('textarea').val('');
						Microblog.Timeline.refresh();
					})
				}
			})
			
			$('#Form_PostForm').entwine({
				onmatch: function () {
					this.ajaxForm(function (done) {
						$('#Form_PostForm').find('textarea').val('');
						Microblog.Timeline.refresh();
					})
				}
			});
			
			$('.fileUploadForm').entwine({
				onmatch: function () {
					var uploadList = $('#uploadedFiles');
					$(this).fileupload({
						dataType: 'json',
						dropZone: $('#dropZone'),
						formData: function(form) {
							var formData = [
								{name: 'SecurityID', value: $('input[name=SecurityID]').val()}
								// {name: 'ID', value: $(form).find(':input[name=ID]').val()}
							];
							return formData;
						},
						drop: function (e, data) {
							$.each(data.files, function (index, file) {
{'fraction_non_alphanumeric': 0.17783353010625738, 'fraction_numerical': 0.0038370720188902006, 'mean_word_length': 2.5537493445201886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4717230', 'n_tokens_mistral': 3070, 'n_tokens_neox': 2139, 'n_words': 428}