<commit_before>"use strict"; 

/*
  Copyright 2014 Google Inc. All rights reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

String.prototype.format = function() {
    var str = this;
    for (var i = 0; i < arguments.length; i++) 
        str = str.replace(new RegExp('_|-'+i+'-|_', 'gi'), arguments[i]);
    return str;
};



function requestURL(url,method,data,headerParams,responseType){
	return new Promise( function(resolve,reject){
		var oReq = new XMLHttpRequest();
		oReq.open(method, url, true);
		for(var param in headerParams)
			oReq.setRequestHeader(param, headerParams[param]);
		oReq.responseType = responseType;
		oReq.onload = function (oEvent) {
			if(oReq.status == 200)
				resolve(oReq.response);
			else
				reject(oReq.status+' '+oReq.statusText);
		};
		oReq.onerror = function() {
  			reject(Error("Network Error"));
		};
		oReq.send(data);
	});
}

var CHAR_ARRAY = [ 97,98,231];
var FILENAME = 'my.ttf';


function determineCharacters(){
	return new Promise(function(resolve,reject){
		resolve(CHAR_ARRAY);
	});
}

function requestCharacters(chars){
	return requestURL('/incremental_fonts/request','POST',JSON.stringify({'font':'noto','arr':chars}),{'Content-Type':'application/json'},'arraybuffer');
}

function requestQuota(size){
	return new Promise(function(resolve,reject){
		navigator.webkitPersistentStorage.requestQuota(size + size/3,
			function(grantedSize) { 
				resolve(grantedSize); 
			}, 
			reject
		);		
	});
}

function setTheFont(font_src){
	console.log(font_src)
	var font = new FontFace("myfont", "url("+font_src+")", {});
	document.fonts.add(font);
	font.load(); 

}

function requestTemporaryFileSystem(grantedSize){
	window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
	return new Promise(function(resolve,reject){<commit_msg>Added converting innerTexts in head and body of html<commit_after>"use strict"; 

/*
  Copyright 2014 Google Inc. All rights reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

String.prototype.format = function() {
    var str = this;
    for (var i = 0; i < arguments.length; i++) 
        str = str.replace(new RegExp('_|-'+i+'-|_', 'gi'), arguments[i]);
    return str;
};



function requestURL(url,method,data,headerParams,responseType){
	return new Promise( function(resolve,reject){
		var oReq = new XMLHttpRequest();
		oReq.open(method, url, true);
		for(var param in headerParams)
			oReq.setRequestHeader(param, headerParams[param]);
		oReq.responseType = responseType;
		oReq.onload = function (oEvent) {
			if(oReq.status == 200)
				resolve(oReq.response);
			else
				reject(oReq.status+' '+oReq.statusText);
		};
		oReq.onerror = function() {
  			reject(Error("Network Error"));
		};
		oReq.send(data);
	});
}

var CHAR_ARRAY = [ 97,98,231];
var FILENAME = 'my.ttf';

function strToCodeArray(str){
	console.log(str);
	var len = str.length;
	var arr = [];
	var dummy = {};
	var code;
	for(var i=0;i<len;i++)
	{
		code = str.charCodeAt(i);
		if(!dummy.hasOwnProperty(code)){
			arr.push(code);
			dummy[code]=0;
		}
	}
	return arr;
}

function determineCharacters(){
	return new Promise(function(resolve,reject){
		var arr = strToCodeArray(document.body.innerText+document.head.innerText);
		console.log(arr);
		resolve(arr);
	});
}

function requestCharacters(chars){
	return requestURL('/incremental_fonts/request','POST',JSON.stringify({'font':'noto','arr':chars}),{'Content-Type':'application/json'},'arraybuffer');
}

function requestQuota(size){
	return new Promise(function(resolve,reject){
		navigator.webkitPersistentStorage.requestQuota(size + size/3,
			function(grantedSize) { 
				resolve(grantedSize); 
			}, 
			reject
		);		
	});
}

function setTheFont(font_src){
	console.log(font_src)
	var font = new FontFace("myfont", "url("+font_src+")", {});
	document.fonts.add(font);
	font.load(); 

}

function requestTemporaryFileSystem(grantedSize){
	window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
	return new Promise(function(resolve,reject){
{'fraction_non_alphanumeric': 0.13406156901688182, 'fraction_numerical': 0.008341608738828202, 'mean_word_length': 4.595555555555555, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, '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': '4322163', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1569, 'n_words': 402}