<commit_before>/* Master.js
KC3改 Master Dataset

Represents master data from api_start2
Indexes significant data for easier access
Saves and loads significant data for future use
*/
(function(){
	"use strict";
	
	window.KC3Master = {
		isAvailable: false,
		_ship: {},
		_slotitem: {},
		_stype: {},
		_graph: {},
		
		_newShips: {},
		_newItems: {},
		
		_raw: {},
		
		init: function( raw ){
			this.load();
			
			if(typeof raw != "undefined"){
				return this.processRaw( raw );
			}
			
			this.updateRemodelTable();
			return false;
		},
		
		/* Process raw data, fresh from API
		-------------------------------------*/
		processRaw :function(raw){
			var beforeCounts = false;
			if( Object.size(this._raw) > 0) {
				beforeCounts = [ Object.size(this._raw.ship), Object.size(this._raw.slotitem) ];
			}
			
			var newCounts = [0, 0];
			var self = this;
			
			// Loops through each api_mst_
			Object.keys(raw).forEach(function(mst_name) {
				var mst_data = raw[mst_name];
				var short_mst_name = mst_name.replace("api_mst_", "");
				
				// If the current master item is an array
				if (Object.prototype.toString.call(mst_data) === '[object Array]') {
					// Add the master item to local raw, as empty object
					self._raw[short_mst_name] = {};
					
					// Store the contents into the new local raw object
					mst_data.map(function(elem, i){
						if (typeof elem.api_id != "undefined") {
							// Add elements to local raw, with their IDs as indexes
							self._raw[short_mst_name][elem.api_id] = elem;
						}else {
							// Elements have no IDs, store them with their original indexes
							self._raw[short_mst_name][i] = elem;
						}
					});
				}
			});
			
			this.updateRemodelTable();
			this.save();
			this.available = true;
			
			// If there was a count before this update, calculate how many new
			if (beforeCounts) {
				return [
					Object.size(this._raw.ship) - beforeCounts[0],
					Object.size(this._raw.slotitem) - beforeCounts[1]
				];
			} else {
				return [0,0];
			}
		},
		
		/* Data Access
		-------------------------------------*/
		ship :function(id){
			console.log(this._raw.ship[id]);
			return this._raw.ship[id] || false;
		},
		
		all_ships :function(){
			return this._raw.ship;
		},
		
		graph :function(id){
			return this._raw.shipgraph[id] || false;
		},
		
		graph_file :function(filename){
			var self = this;
			return Object.keys(this._raw.shipgraph).filter(function(key){
				return self._raw.shipgraph[key] === filename;
			})[0];
		},
		
		slotitem :function(id){
			return this._raw.slotitem[id] || false;
		},<commit_msg>Remove console log from Master.js<commit_after>/* Master.js
KC3改 Master Dataset

Represents master data from api_start2
Indexes significant data for easier access
Saves and loads significant data for future use
*/
(function(){
	"use strict";
	
	window.KC3Master = {
		isAvailable: false,
		_ship: {},
		_slotitem: {},
		_stype: {},
		_graph: {},
		
		_newShips: {},
		_newItems: {},
		
		_raw: {},
		
		init: function( raw ){
			this.load();
			
			if(typeof raw != "undefined"){
				return this.processRaw( raw );
			}
			
			this.updateRemodelTable();
			return false;
		},
		
		/* Process raw data, fresh from API
		-------------------------------------*/
		processRaw :function(raw){
			var beforeCounts = false;
			if( Object.size(this._raw) > 0) {
				beforeCounts = [ Object.size(this._raw.ship), Object.size(this._raw.slotitem) ];
			}
			
			var newCounts = [0, 0];
			var self = this;
			
			// Loops through each api_mst_
			Object.keys(raw).forEach(function(mst_name) {
				var mst_data = raw[mst_name];
				var short_mst_name = mst_name.replace("api_mst_", "");
				
				// If the current master item is an array
				if (Object.prototype.toString.call(mst_data) === '[object Array]') {
					// Add the master item to local raw, as empty object
					self._raw[short_mst_name] = {};
					
					// Store the contents into the new local raw object
					mst_data.map(function(elem, i){
						if (typeof elem.api_id != "undefined") {
							// Add elements to local raw, with their IDs as indexes
							self._raw[short_mst_name][elem.api_id] = elem;
						}else {
							// Elements have no IDs, store them with their original indexes
							self._raw[short_mst_name][i] = elem;
						}
					});
				}
			});
			
			this.updateRemodelTable();
			this.save();
			this.available = true;
			
			// If there was a count before this update, calculate how many new
			if (beforeCounts) {
				return [
					Object.size(this._raw.ship) - beforeCounts[0],
					Object.size(this._raw.slotitem) - beforeCounts[1]
				];
			} else {
				return [0,0];
			}
		},
		
		/* Data Access
		-------------------------------------*/
		ship :function(id){
			return this._raw.ship[id] || false;
		},
		
		all_ships :function(){
			return this._raw.ship;
		},
		
		graph :function(id){
			return this._raw.shipgraph[id] || false;
		},
		
		graph_file :function(filename){
			var self = this;
			return Object.keys(this._raw.shipgraph).filter(function(key){
				return self._raw.shipgraph[key] === filename;
			})[0];
		},
		
		slotitem :function(id){
			return this._raw.slotitem[id] || false;
		},
{'fraction_non_alphanumeric': 0.16312741312741313, 'fraction_numerical': 0.0042471042471042475, 'mean_word_length': 2.4425249169435217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4486596', 'n_tokens_mistral': 2169, 'n_tokens_neox': 1672, 'n_words': 417}