blob: 3686a385f6a2037219a2a7e5c2bcd8271c7652df (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var fileXHREnabled = function() {
var xhr = new XMLHttpRequest();
try {
xhr.onreadystatechange = function() {};
xhr.onerror = function() {};
xhr.open("GET", "nothing.xml", true);
xhr.send(null);
} catch (e) {
return false;
}
xhr.abort();
return true;
}();
var officialURL = 'http://code.google.com/chrome/extensions/';
function getCurrentBranch() {
var branchNames = ['beta', 'dev', 'trunk'];
if (location.href.indexOf(officialURL) != 0)
return '';
var branch = location.href.substring(
officialURL.length,
location.href.indexOf('/', officialURL.length));
if (branchNames.indexOf(branch) == -1)
return 'stable';
return branch;
}
// Regenerate page if we are passed the "?regenerate" search param
// or if the user-agent is chrome AND the document is being served
// from the file:/// scheme.
if (window.location.search == "?regenerate" ||
(navigator.userAgent.indexOf("Chrome") > -1) &&
(window.location.href.match("^file:")) &&
fileXHREnabled) {
// Hide body content initially to minimize flashing.
document.write('<style id="hider" type="text/css">');
document.write('body { display:none!important; }');
document.write('</style>');
window.onload = window.renderPage;
window.postRender = function() {
var elm = document.getElementById("hider");
elm.parentNode.removeChild(elm);
// Since populating the page is done asynchronously, the DOM doesn't exist
// when the browser tries to resolve any #anchors in the URL. So we reset
// the URL once we're done, which forces the browser to scroll to the anchor
// as it normally would.
if (location.hash.length > 1)
location.href = location.href;
}
} else if ((navigator.userAgent.indexOf("Chrome") > -1) &&
(window.location.href.match("^file:")) &&
!fileXHREnabled) {
window.onload = function() {
// Display the warning to use the --allow-file-access-from-files.
document.getElementById("devModeWarning").style.display = "block";
}
} else {
window.onload = function() {
var currentBranch = getCurrentBranch();
if (currentBranch == '') {
document.getElementById('unofficialWarning').style.display = 'block';
document.getElementById('goToOfficialDocs').onclick = function() {
location.href = officialURL;
};
} else if (currentBranch != 'stable') {
document.getElementById("branchName").textContent =
currentBranch.toUpperCase();
document.getElementById('branchWarning').style.display = 'block';
document.getElementById('branchChooser').onchange = function() {
location.href = officialURL + this.value + "/";
};
}
}
}
|