File size: 2,554 Bytes
597ee18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*

 (c) DHTMLX Ltd, 2011

 Licensing: You allowed to use this component for free under GPL or you need to obtain Commercial/Enterprise license to use it in non-GPL project

 Contact: sales@dhtmlx.com

 */
 function source_loader(filename, type, callback) {
	type = type || "js";
	switch (type) {
		case "js":
			var source = document.createElement('script');
			source.setAttribute("type", "text/javascript");
			source.setAttribute("src", filename);
			break;
		case "css":
			var source = document.createElement("link");
			source.setAttribute("rel", "stylesheet");
			source.setAttribute("type", "text/css");
			source.setAttribute("href", filename);
			document.getElementsByTagName("head")[0].appendChild(source);
			break;
		default:
			//do nothing
			break;
	}
	if (callback) {
		if (navigator.appName.indexOf("Microsoft") != -1){
			source.onreadystatechange = function() {
				if ((this.readyState == 'complete')||(this.readyState == 'loaded')) {
					callback();
				}
			};
		}
		else
			source.onload = callback;
	}
	document.getElementsByTagName("head")[0].appendChild(source);
	return source;
}

/*! DEPENDS */
var depends = {
	js: [ 'spreadsheet.php?load=js' ],
	css: [
		'dhtmlx_core.css',
		'dhtmlxspreadsheet.css'
	]
};
if (window.cfg.skin === 'dhx_web') {
	depends.css.push('dhtmlxspreadsheet_dhx_web.css');
	depends.css.push('skins/dhtmlxgrid_dhx_web.css');
	depends.css.push('skins/dhtmlxtoolbar_dhx_web.css');
}

for (var i = 0; i < depends.js.length; i++)
	source_loader(window.cfg['dhx_rel_path'] + depends.js[i], 'js', onload_func);
for (var i = 0; i < depends.css.length; i++)
	source_loader(window.cfg['dhx_rel_path'] + depends.css[i], 'css');


/*! INITIALIZATION */
var dhx_sh;
function onload_func() {
	window.setTimeout(function() {
		dhx_sh = new window.dhtmlxSpreadSheet({
			load: window.cfg.load || window.cfg['dhx_rel_path'] + "php/data.php",
			save: window.cfg.save || window.cfg['dhx_rel_path'] + "php/data.php",
			parent: window.cfg.parent || null,
			icons_path: window.cfg['dhx_rel_path'] + "imgs/icons/",
			image_path: window.cfg['dhx_rel_path'] + "imgs/",
			skin: window.cfg.skin || 'dhx_skyblue',
			autowidth: typeof(window.cfg.autowidth) !== 'undefined' ? window.cfg.autowidth : false,
			autoheight: typeof(window.cfg.autoheight) !== 'undefined' ? window.cfg.autoheight : false,
			math: typeof(window.cfg.math) !== 'undefined' ? window.cfg.math : false
		});
		dhx_sh.load(window.cfg.sheet||"1", window.cfg.key||null);
	}, 1);
}