<commit_before>/*!
 * noted.js Javascript app
 * http://noted.jongala.com/
 *
 * Copyright 2010, <NAME>.
 * <EMAIL>
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

/* 
 * flipTo plugin
 */
(function($){
	$.fn.flipTo = function(targetClass,currentClass) {
		if (currentClass === 'undefined') currentClass='';
		return this.each(function(){
			$element = $(this);
			$element.addClass('flipouttoleft');
			flipTimer = setTimeout(function(){
				$element.addClass('flipinfromleft ' + targetClass).removeClass('flipouttoleft ' + currentClass);
			},500); // match time to transition speed
		});
	};
})(jQuery);


gutter = 20; 		// gutter between newly created notes

if (!console) {
	var console = {log: function(msg) {}};
}


function noted() {
	
	var self = this;

	/* OVERVIEW:
	
	 * Flow goes like this:
	 * init_notes loads a list of note names from note_list, and for each note found, passes the data to build_note
	 * build_note takes note data, clones the (invisible) template note element, 
	   populates it with note data, sets CSS and color stuff, etc.
	 * save_note serializes note data and items, and saves it to localStorage
	
	 */

/* ========================================================================

	DATA UTILITIES

======================================================================== */

	
	// Shut it down. Shut it down!
	this.nuke = function(){
		// destroy all notes
		$('#board .note').remove();
		
		// clear note_list
		delete localStorage.note_list;
		delete localStorage.next_note_id;
		
		
		
		console.log('******nuked******');
	};


/* ========================================================================

	INIT NOTES

======================================================================== */

	/* 
	 * Reads note_list, a string of comma-separated note id integers
	 * If notes are found, it loops through them, and for each one passes its data
	 * to build_note();
	 * If no notes are found, it calls create_note.
	 */

	var init_notes = function() {
		
		// GET NOTE INDECES	
		next_note_id = localStorage.next_note_id;
		note_list = localStorage.note_list;
		
		if( note_list === undefined || note_list === null || !note_list.length ) {

			self.save_local_data('note_list','');	// give create_note a base list
			self.save_local_data('next_note_id',0);	// set first note id number
			self.create_note();	// create a note with default data
			
			firstnote = $('#board li.note')[0];
			//self.save_note(firstnote);
		

		} else { // INITIALIZE NORMALLY
			
			note_list = note_list.split(',');
			
			console.log('init_notes() : found ' + note_list.length + ' notes');
		
			// IF NO NOTES FOUND, CREATE ONE
			if (!note_list.length) {
				
				console.log('Creating first note');
			
				self.create_note();
				//console.log('init_notes(): new_note_id:' + new_note_id);
				<commit_msg>Auto launch Welcome note on first launch<commit_after>/*!
 * noted.js Javascript app
 * http://noted.jongala.com/
 *
 * Copyright 2010, <NAME>.
 * <EMAIL>
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

/* 
 * flipTo plugin
 */
(function($){
	$.fn.flipTo = function(targetClass,currentClass) {
		if (currentClass === 'undefined') currentClass='';
		return this.each(function(){
			$element = $(this);
			$element.addClass('flipouttoleft');
			flipTimer = setTimeout(function(){
				$element.addClass('flipinfromleft ' + targetClass).removeClass('flipouttoleft ' + currentClass);
			},500); // match time to transition speed
		});
	};
})(jQuery);


gutter = 20; 		// gutter between newly created notes

if (!console) {
	var console = {log: function(msg) {}};
}


function noted() {
	
	var self = this;

	/* OVERVIEW:
	
	 * Flow goes like this:
	 * init_notes loads a list of note names from note_list, and for each note found, passes the data to build_note
	 * build_note takes note data, clones the (invisible) template note element, 
	   populates it with note data, sets CSS and color stuff, etc.
	 * save_note serializes note data and items, and saves it to localStorage
	
	 */

/* ========================================================================

	DATA UTILITIES

======================================================================== */

	
	// Shut it down. Shut it down!
	this.nuke = function(){
		// destroy all notes
		$('#board .note').remove();
		
		// clear note_list
		delete localStorage.note_list;
		delete localStorage.next_note_id;
		
		
		
		console.log('******nuked******');
	};


/* ========================================================================

	INIT NOTES

======================================================================== */

	/* 
	 * Reads note_list, a string of comma-separated note id integers
	 * If notes are found, it loops through them, and for each one passes its data
	 * to build_note();
	 * If no notes are found, it calls create_note.
	 */

	var init_notes = function() {
		
		// GET NOTE INDECES	
		next_note_id = localStorage.next_note_id;
		note_list = localStorage.note_list;
		
		if( note_list === undefined || note_list === null || !note_list.length ) {

			console.log("==============================\nFirst Launch\n==============================");

			var welcome_timer = setTimeout(function(){$('#welcome_trigger').click()},500);

			self.save_local_data('note_list','');	// give create_note a base list
			self.save_local_data('next_note_id',0);	// set first note id number
			self.create_note();	// create a note with default data
			
			firstnote = $('#board li.note')[0];
			//self.save_note(firstnote);
		

		} else { // INITIALIZE NORMALLY
			
			note_list = note_list.split(',');
			
			console.log('init_notes() : found ' + note_list.length + ' notes');
		
			// IF NO NOTES FOUND, CREATE ONE
			if (!note_list.length) {
				
				console.log('Creating first note');
			
				self.create_note();
				//console.log('init_notes(): new_note_id:' + new_note_id);
				
{'fraction_non_alphanumeric': 0.2327138791227189, 'fraction_numerical': 0.0041855014230704835, 'mean_word_length': 3.7450357426528993, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2424641', 'n_tokens_mistral': 2039, 'n_tokens_neox': 1702, 'n_words': 483}