summaryrefslogtreecommitdiffstats
path: root/HTML/script.js
blob: 2247169cfbe44baeffc561e7ea3cff321d2e9118 (plain)
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
/* $Id$
 *
*/

var remoteweb = 'http://start.mandriva.com/';

String.prototype.rtrim     = function() { return this.replace(/\s*$/, ""); };
String.prototype.ltrim     = function() { return this.replace(/^\s*/, ""); };
String.prototype.trim      = function() { return this.rtrim().ltrim(); };
String.prototype.encodeURI = function() { return this.replace(/\+/g,"%2B"); };

function actOnline() {
	// #1
	var release = '';
	var pack    = '';
	var lang    = '';
	try {
		var t = document.getElementsByTagName('meta');
		for( var i=0; i<t.length; i+=1 ) {
			if( t.item(i).getAttribute('name') == 'mdv:release' ) {
				release = t.item(i).getAttribute('content');
			} else if( t.item(i).getAttribute('name') == 'mdv:pack' ) {
				pack = t.item(i).getAttribute('content');
			}
		}
		lang = parent.window.document.documentElement.attributes.getNamedItem('lang').value;
	}
	catch( e ) {} 
	finally {}

	// #2
	var args = '';
        if( release !== '' ) { args = 'r='+release.trim().encodeURI(); }
	if( pack !== '' )    { if( args !== '' ) { args += '&'; } args += 'p='+pack.trim().encodeURI(); }
	if( lang !== '' )    { if( args !== '' ) { args += '&'; } args += 'l='+lang.trim(); }
	if( args !== '' )    { remoteweb += '?' + args; }
	
	// #3
	parent.location = remoteweb;
	return true;
}

function actOffline() { return true; }
function imgLoad()    { actOnline(); }
function imgError()   { var i = document.getElementById('i'); i.parentNode.removeChild(i); actOffline(); }

window.alert = function() {};

function run() {
	try {
		var i     = document.createElement('img');
		i.id      = 'i';
		i.onload  = imgLoad;
		i.onerror = imgError;
		i.src     = 'http://images.mandriva.com/images/donotremove.png';
		document.getElementsByTagName('body').item(0).appendChild(i);
	}
	catch(e) { return false; }
	return true;
}

/*
*/