<commit_before>﻿function CheckAlert() {
	$.getJSON( "http://www.oref.org.il/WarningMessages/alerts.json", function( data ) {
		//data.data = ["אשקלון 238, עוטף עזה 238"];
		correctData = CorrectDataFormat(data.data);
		if (correctData.length > 0) {
			console.log(Date());
			console.log("All alarms: " + correctData.toString());
			newAlarms = UpdateValues(correctData ,currentAlarmDict);
			if (newAlarms.length>0) {
				setRedIcon();
				console.info(Date());
				notify(newAlarms);
				console.info("New alarms: " + newAlarms.toString());
			}
		}
		RemoveStaleValues(currentAlarmDict);
	});
}

function CorrectDataFormat(rawData) {
	newData = [];
	if (rawData == null)
		return null;
	for(var i=0;i<rawData.length;i++) {
		newData =$.extend(true, newData, rawData[i].split(","));		
	}
	newData = $.map(newData, $.trim);
	return newData;
}


function UpdateValues(data,dict) {
	newValues = [];
	for(var i=0;i<data.length;i++) {
		if (!(data[i] in dict)) {
			newValues.push(data[i]);
		}
		dict[data[i]] = Math.floor(alarmValidTime / refreshTime);
	}
	return newValues;
}

function RemoveStaleValues(data) {
	for (var key in data) { 		
		data[key]=data[key]-1;
		if (data[key]<=0) {
			delete data[key];
		}
	}
	return data;
}

var alertCount = 0;
var prevData = [];
var refreshTime = 5000;
var alarmValidTime = 30000; //30 seconds<commit_msg>Fixes for data merge<commit_after>﻿function CheckAlert() {
	$.getJSON( "http://www.oref.org.il/WarningMessages/alerts.json", function( data ) {
		//data.data = ["אשקלון 238, עוטף עזה 238"];
		correctData = CorrectDataFormat(data.data);
		if (correctData.length > 0) {
			console.log(Date());
			console.log("Raw alarms: " + data.data.toString());
			console.log("All alarms: " + correctData.toString());
			newAlarms = UpdateValues(correctData ,currentAlarmDict);
			if (newAlarms.length>0) {
				setRedIcon();
				console.info(Date());
				notify(newAlarms);
				console.info("New alarms: " + newAlarms.toString());
			}
		}
		RemoveStaleValues(currentAlarmDict);
	});
}

function CorrectDataFormat(rawData) {
	newData = [];
	if (rawData == null)
		return null;
	for(var i=0;i<rawData.length;i++) {
		newData = $.merge(newData, rawData[i].split(","));
	}
	newData = $.map(newData, $.trim);
	return newData;
}


function UpdateValues(data,dict) {
	newValues = [];
	for(var i=0;i<data.length;i++) {
		if (!(data[i] in dict)) {
			newValues.push(data[i]);
		}
		dict[data[i]] = Math.floor(alarmValidTime / refreshTime);
	}
	return newValues;
}

function RemoveStaleValues(data) {
	for (var key in data) { 		
		data[key]=data[key]-1;
		if (data[key]<=0) {
			delete data[key];
		}
	}
	return data;
}

var alertCount = 0;
var prevData = [];
var refreshTime = 5000;
var alarmValidTime = 30000; //30 seconds
{'fraction_non_alphanumeric': 0.1779475982532751, 'fraction_numerical': 0.017467248908296942, 'mean_word_length': 4.157598499061914, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2685418', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1030, 'n_words': 192}