1<!--
2/**
3 * Copyright  2006  V Narayan Raman
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *    http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17-->
18<html>
19<head><title>Configure Sahi</title></head>
20<script type="text/javascript" src="/_s_/spr/util.js"></script>
21<style>
22body, body * {
23	font-family: verdana;
24	font-size: 9pt;
25}
26body {
27	margin: 10px;
28}
29.hitab {color:brown;text-decoration:none;font-weight:bold;font-size:14px;}
30.dimtab {color:3333FF;text-decoration:underline;}
31li {margin:10px}
32</style>
33<script>
34function init(){
35	var tabGroup = new TabGroup("tabGroup", ["tbrowser_types", "tuserdata", "texclude_inject", "tdownload_urls", "tdownload_contenttypes", "tblock_ssl_domains"], "tbrowser_types");
36}
37//TabGroup Start
38function $(id){
39	return document.getElementById(id);
40}
41var getTarget = function (e) {
42    var targ;
43    if (!e) e = window.event;
44    if (e.target) targ = e.target;
45    else if (e.srcElement) targ = e.srcElement;
46    if (targ.nodeType == 3) // defeat Safari bug
47        targ = targ.parentNode;
48    return targ;
49};
50
51TabGroup = function(name, ids, defaultId){
52	this.name = name;
53	this.ids = [];
54	this.defaultId = defaultId;
55	this.addAll(ids);
56	this.show(this.defaultId);
57	TabGroup.instances[TabGroup.instances.length] = this;
58};
59TabGroup.instances = [];
60TabGroup.prototype.addAll = function(ids){
61	for ( var i = 0; i < ids.length; i++) {
62		this.add(ids[i]);
63	}
64};
65TabGroup.prototype.add = function(id){
66	this.ids[this.ids.length] = id;
67	$(id).onclick_ = $(id).onclick;
68	$(id).onclick = null;
69	this.addEvent($(id), "click", this.wrap(this.onclick, this));
70};
71TabGroup.prototype.addEvent = function (el, ev, fn) {
72    if (!el) return;
73    if (el.attachEvent) {
74        el.attachEvent("on" + ev, fn);
75    } else if (el.addEventListener) {
76        el.addEventListener(ev, fn, false);
77    }
78};
79TabGroup.prototype.wrap = function (fn, el) {
80	if (!el) el = this;
81	return function(){fn.apply(el, arguments);};
82};
83TabGroup.prototype.onclick = function(e){
84	var el = getTarget(e);
85	var thisId = el.id;
86	this.show(thisId, true);
87};
88TabGroup.prototype.show = function(thisId, isEvent){
89	if (!thisId || !$(thisId)) thisId = this.defaultId;
90	if (!thisId) return;
91
92	for ( var i = 0; i < this.ids.length; i++) {
93		var id = this.ids[i];
94		if (!$(id)) continue;
95		$(id+"box").style.display = (id == thisId) ? "block" : "none";
96		$(id).className = "dimTab";
97	}
98	var el = $(thisId);
99	el.className = "hiTab";
100//	if (el.onclick && !isEvent) el.onclick();
101	if (el.onclick_) el.onclick_();
102	this.selectedTab = thisId;
103	currentActiveTab = this.selectedTab;
104};
105TabGroup.prototype.getSelectedTab = function (e) {
106	return this.selectedTab;
107};
108TabGroup.prototype.showDefault = function (force) {
109	if (force || this.selectedTab == null) this.show();
110};
111TabGroup.getState = function(){
112	var s = [];
113	for (var i=0; i<TabGroup.instances.length; i++){
114		var tg = TabGroup.instances[i];
115		s[s.length] = {id:tg.name, value:tg.getSelectedTab(), type:"tab"};
116	}
117	return s;
118};
119TabGroup.showDefaults = function(){
120	for (var i=0; i<TabGroup.instances.length; i++){
121		TabGroup.instances[i].showDefault();
122	}
123};
124// TabGroup End
125
126var g_file;
127function loadFile(fileName){
128	var file = "config/" + fileName;
129	g_file = file;
130	var textFile = sahiSendToServer("/_s_/dyn/ConfigureUI_readFile?fileName="+file);
131	$("editor").value = textFile;
132}
133function save(){
134	try{
135		var saveInfo = document.getElementById('saveInfo');
136		saveInfo.style.display='block';
137		setTimeout("saveInfo.style.display='none'",3000);
138	sahiSendToServer("/_s_/dyn/ConfigureUI_saveFile?fileName="+encodeURIComponent(g_file)+
139			"&contents="+encodeURIComponent($("editor").value));
140	}catch(e){alert(e)}
141}
142</script>
143<body onload="init()">
144<h1>Configure Sahi</h1>
145<br/><br/>
146<table><tr><td style="vertical-align:top;">
147<div style="float:left;width:250px;height:500px;line-height:22px;">
148<img src="/_s_/spr/images/sahi_os_logo2.png"/><br/><br/>
149<a href="#" id="tbrowser_types" onclick="loadFile('browser_types.xml');">browser_types.xml</a><br/>
150<a href="#" id="tuserdata" onclick="loadFile('userdata.properties');">userdata.properties</a><br/>
151<a href="#" id="texclude_inject" onclick="loadFile('exclude_inject.txt');">exclude_inject.txt</a><br/>
152<a href="#" id="tdownload_urls" onclick="loadFile('download_urls.txt');">download_urls.txt</a><br/>
153<a href="#" id="tdownload_contenttypes" onclick="loadFile('download_contenttypes.txt');">download_contenttypes.txt</a><br/>
154<a href="#" id="tblock_ssl_domains" onclick="loadFile('block_ssl_domains.txt');">block_ssl_domains.txt</a><br/>
155
156
157<div style="background-color:lightblue;margin:50px 20px 10px 0px;padding:10px">
158<div id="tbrowser_typesbox" class="content" style="display:none">
159<h2>browser_types.xml</h2>
160browser_types.xml configures the various browsers that Sahi can use.
161Note that browser options for various browsers are different and it
162is advisable to use the defaults provided and only change the paths where needed.
163</div>
164
165<div id="tuserdatabox" class="content" style="display:none">
166<h2>userdata.properties</h2>
167Sahi can be configured using two files:
168<ol style="margin:5px;padding:5px;">
169<li>sahi/userdata/config/ userdata.properties</li>
170<li>sahi/config/sahi.properties (<a href="/_s_/dyn/ConfigureUI_view?fileName=config/sahi.properties&useBase=true" target="_blank">View</a>)</li>
171</ol>
172Sahi first looks for a property in userdata.properties, and if not found, looks for it in sahi.properties.<br/>
173It is recommended to modify/add properties to userdata.properties. <br/>
174Every property in sahi.properties can be overridden in userdata.properties
175<br/><br/>
176</div>
177
178<div class="content" id="texclude_injectbox" style="display:none">
179<h2>exclude_inject.txt</h2>
180Sahi controls the browser by injecting javascript into web pages.
181However there are various requests like XMLHttpRequests, javascript, css, etc. where Sahi should not inject its code.
182While this is correctly detected and handled in most cases, there are instances where one may need to explicitly ask Sahi not to inject code.
183In such instances, patterns can be added to exclude_inject.txt. When a URL matches this pattern, Sahi will NOT inject its code.
184</div>
185
186<div class="content" id="tdownload_urlsbox" style="display:none">
187<h2>download_urls.txt</h2>
188Sahi automatically downloads and saves files into sahi/usedata/temp/downloads directory.
189If Sahi is unable to detect a request as a download, you can force it to download the file by adding URL patterns to this file.
190</div>
191
192<div id="tdownload_contenttypesbox" style="display:none">
193<h2>download_contenttypes.txt</h2>
194Sahi automatically downloads and saves files into sahi/usedata/temp/downloads directory.
195If Sahi is unable to detect a request as a download, you can force it to download the file by adding relevant content-types to this file.
196</div>
197
198<div id="tblock_ssl_domainsbox" style="display:none">
199<h2>block_ssl_domains.txt</h2>
200If a domain is added here, any HTTPS calls to this domain will return a 404 error.
201Browsers like firefox make HTTPS requests to addons.mozilla.org and sb-ssl.google.com which can hang playback.
202Adding these domains to block_ssl_domains.txt will prevent hangs.
203</div>
204
205</div>
206<div style="display:none;background:#F8FFA1;border:solid 1px red;margin:30px 20px 10px 0px;padding:10px" id="saveInfo"> Your configuration has been saved. Please restart Sahi</div>
207</div>
208</td><td>
209<div style="float:left;width:770px;height:800px;line-height:22px;">
210<textarea style="width:750px;height:85%;" id="editor" wrap="off" spellcheck="false"></textarea><br/>
211<input type="button" value="Save" onclick="save()"/>
212</div>
213</td></tr></table>
214</body>
215</html>