Skip to content

Commit b2feec3

Browse files
committed
Applying changes for 0.1 release from subversion repo
1 parent 6003001 commit b2feec3

File tree

3 files changed

+87
-83
lines changed

3 files changed

+87
-83
lines changed

README

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
== Webian Shell 0.1 (development preview) ==
1+
== Webian Shell 0.1 ==
22

33
Webian Shell is a graphical shell for the web, a full screen web browser for devices that don't need a desktop.
44

55
It's an implementation of a design concept called "A Graphical Shell for the Web" [1] by Ben Francis.
66

77
The code is designed to be run using Mozilla Chromeless [2] and currently lives on the Webian web site [3].
88

9-
This is a development preview of version 0.1 to be included in the Chromeless gallery. The full 0.1 release will include cross-platform packaged binaries.
10-
119
To run, check out Chromeless from github [4] and execute...
1210

1311
$ ./chromeless /path/to/shell/

appinfo.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
2-
"vendor": "Webian",
3-
"name": "Webian Shell",
4-
"version": "0.1",
5-
"developer_email": "ben at tola.me.uk",
6-
"resizable": false,
2+
"build_id": "20110604183742",
3+
"vendor": "Webian",
4+
"name": "Webian Shell",
5+
"resizable": false,
6+
"developer_email": "ben at tola.me.uk",
7+
"module_dirs": [],
8+
"version": "0.1",
79
"menubar": false
8-
}
10+
}

main.js

+78-74
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
* <http://www.gnu.org/licenses/>.
2222
*/
2323

24-
// Import Chromeless libraries
24+
// Import Chromeless modules
2525
var favicon = require("favicon");
26+
var web_content = require("web-content");
2627
const url = require("url");
28+
const fullscreen = require("fullscreen");
2729

2830
// Set up console for debugging
2931
//console.log('hello world');
@@ -56,82 +58,28 @@ function clock() {
5658
* Make iFrame
5759
*
5860
* Creates a special iFrame which acts like a browser and will contain the
59-
* content of a new window. Event listeners are added to monitor progress
60-
* of page loading.
61+
* content of a new window.
6162
*
6263
* @return new iFrame object
6364
*/
6465
function makeIframe(windowId) {
6566
var iFrame = document.createElement("iframe");
6667
$(iFrame).attr("privilege", "content");
6768
$(iFrame).attr("class", "window_iframe");
68-
69-
var url_input = $('#window_' + windowId + ' .url_input');
70-
71-
// Add event listeners to iFrame...
72-
73-
// Check progress of page load...
74-
iFrame.addEventListener("ChromelessLoadProgress", function (e) {
75-
$(url_input).addClass('loading');
76-
$(url_input).css('-moz-background-size', e.percentage+"%");
77-
$(url_input).css('background-size', e.percentage+"%");
78-
}
79-
,false);
80-
81-
// When page starts to load...
82-
iFrame.addEventListener("ChromelessLoadStart", function(e) {
83-
// Update address bar
84-
$(url_input).val(e.url);
85-
// Set go button as stop button
86-
$("#window_" + windowId + " .go_button").attr("src", "stop.png");
87-
// If URL has changed, add to history and update index
88-
if (e.url !== urlHistory[windowId][urlHistory[windowId][0]]) {
89-
// Remove previous future if new future being created!
90-
if (urlHistory[windowId][0] < urlHistory[windowId].length) {
91-
urlHistory[windowId].splice(
92-
urlHistory[windowId][0] + 1,
93-
urlHistory[windowId].length - urlHistory[windowId][0]);
94-
}
95-
96-
// Add new URL to history
97-
urlHistory[windowId].push(e.url);
98-
99-
// Update index
100-
urlHistory[windowId][0]++;
101-
}
102-
}, false, true);
103-
104-
// When page and contents are completely loaded...
105-
iFrame.addEventListener("ChromelessLoadStop", function(e) {
106-
// Set URL input textbox to loaded state
107-
$(url_input).removeClass('loading');
108-
$(url_input).addClass('loaded');
109-
// Change "Go" button to "Refresh"
110-
$('#window_' + windowId + ' .go_button').attr("src", "refresh.png");
111-
// Display document title if set
112-
var window_iframe = $("#windows .selected .window_iframe")[0];
113-
var document_title = require("iframe-controls").title(window_iframe);
114-
if(document_title) {
115-
$('#window_' + windowId + ' .document_title').addClass("active");
116-
$('#window_' + windowId + ' .document_title').text(document_title);
117-
} else {
118-
$('#window_' + windowId + ' .document_title').removeClass("active");
119-
}
120-
}, false, true);
121-
12269
return iFrame;
12370
}
12471

12572
/**
12673
* Register Window Event Listeners
12774
*
12875
* Registers event listeners for the currently selected window to detect
129-
* user actions like go, back forward etc.
76+
* user actions like go, back forward etc. and attaches progress monitor to
77+
* iFrame.
13078
*
13179
* @param {String} windowId of window to register listeners for
13280
*/
13381
function registerWindowEventListeners(windowId) {
134-
var url_input = $("#window_" + windowId + " .url_input");
82+
var url_input = $('#window_' + windowId + ' .url_input');
13583
var go_button = $("#window_" + windowId + " .go_button");
13684

13785
// When URL input text box is selected, change "Refresh" button to "Go" button and remove loaded state
@@ -152,11 +100,11 @@ function registerWindowEventListeners(windowId) {
152100
$("#window_" + windowId + " .url_form").submit(function() {
153101
navigate($(this).parents(".window").attr("id").substring(7)); return false;
154102
});
155-
$("#window_" + windowId + " .go_button").click(function() {
103+
$(go_button).click(function() {
156104
// If loading then act as stop button
157105
if($('#windows .selected .url_input').hasClass('loading')) {
158106
var window_iframe = $("#windows .selected .window_iframe")[0];
159-
require("iframe-controls").stopload(window_iframe);
107+
web_content.stopload(window_iframe);
160108
$(go_button).attr("src", "refresh.png");
161109
} else {
162110
// otherwise act as go/refresh
@@ -194,6 +142,71 @@ function registerWindowEventListeners(windowId) {
194142
});
195143
}
196144

145+
/**
146+
* Attach iFrame Progress Monitor
147+
*
148+
* Attach progress monitor to react to page load progress.
149+
*
150+
* @param {String} windowId of window containing iFrame to listen to
151+
*/
152+
function attachIframeProgressMonitor(windowId) {
153+
var progressMonitor = web_content.ProgressMonitor();
154+
var window_iframe = $('#window_' + windowId + ' .window_iframe');
155+
var url_input = $('#window_' + windowId + ' .url_input');
156+
157+
// Add progress monitor to iFrame...
158+
progressMonitor.attach(window_iframe[0]);
159+
160+
// Check progress of page load...
161+
progressMonitor.on('progress', function(percent) {
162+
$(url_input).addClass('loading');
163+
$(url_input).css('-moz-background-size', percent+"%");
164+
$(url_input).css('background-size', percent+"%");
165+
});
166+
167+
// When page starts to load...
168+
progressMonitor.on('load-start', function(url) {
169+
// Update address bar
170+
$(url_input).val(url);
171+
// Set go button as stop button
172+
$("#window_" + windowId + " .go_button").attr("src", "stop.png");
173+
// If URL has changed, add to history and update index
174+
if (url !== urlHistory[windowId][urlHistory[windowId][0]]) {
175+
// Remove previous future if new future being created!
176+
if (urlHistory[windowId][0] < urlHistory[windowId].length) {
177+
urlHistory[windowId].splice(
178+
urlHistory[windowId][0] + 1,
179+
urlHistory[windowId].length - urlHistory[windowId][0]);
180+
}
181+
182+
// Add new URL to history
183+
urlHistory[windowId].push(url);
184+
185+
// Update index
186+
urlHistory[windowId][0]++;
187+
}
188+
});
189+
190+
// When page and contents are completely loaded...
191+
progressMonitor.on('load-stop', function() {
192+
// Set URL input textbox to loaded state
193+
$(url_input).removeClass('loading');
194+
$(url_input).addClass('loaded');
195+
// Change "Go" button to "Refresh"
196+
$('#window_' + windowId + ' .go_button').attr("src", "refresh.png");
197+
});
198+
199+
200+
// When title changes...
201+
progressMonitor.on('title-change', function(document_title) {
202+
if(document_title) {
203+
$('#window_' + windowId + ' .document_title').addClass("active");
204+
$('#window_' + windowId + ' .document_title').text(document_title);
205+
}
206+
});
207+
208+
}
209+
197210
/**
198211
* Select Tab
199212
*
@@ -244,6 +257,9 @@ function newTab(url) {
244257
// Register window event listeners
245258
registerWindowEventListeners(windowId);
246259

260+
// Attach iFrame progress monitor
261+
attachIframeProgressMonitor(windowId);
262+
247263
// Create history array for window, using first element as index
248264
urlHistory[windowId] = [];
249265
urlHistory[windowId][0] = 0;
@@ -331,18 +347,6 @@ function activateWindows() {
331347
$("#tabs").removeClass("detached");
332348
}
333349

334-
335-
/**
336-
* Full Screen
337-
*
338-
* Toggle full screen mode
339-
*/
340-
function fullScreen() {
341-
const fullscreen = require("fullscreen");
342-
fullscreen.toggle(window);
343-
}
344-
345-
346350
// When Shell starts up...
347351
$(document).ready(function() {
348352

@@ -368,5 +372,5 @@ $(document).ready(function() {
368372
});
369373

370374
// Wait for MS Windows to catch up, then toggle full screen mode
371-
setTimeout("fullScreen()", 2000);
375+
setTimeout("fullscreen.toggle(window)", 2000);
372376
});

0 commit comments

Comments
 (0)