-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpage.js
68 lines (61 loc) · 2.14 KB
/
page.js
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
// AndroidAdditions
function l(h, t, x_id){
// load item
var x_id = x_id;
$.get(chrome.extension.getURL("content/" + h + "/"+t+".txt"), function(d, x, e){
$("<div>").addClass("androidadditon").html(d).appendTo(".add-id-" + x_id);
}, "text");
}
$(document).ready(function(){
p = document.location.pathname.substr(1);
p = p.split("/");
if(p[0] == "reference"){
// Reference guide
// Remove ref
p = jQuery.grep(p, function(k,value) {
return value != 0;
});
// Get rid of .html properly
x = p[p.length-1].split(".");
x = jQuery.grep(x, function(value) {
return value != "html";
});
p[p.length-1] = x.join(".");
h = p.join(".");
// Request Class Overview
$.get(chrome.extension.getURL("content/" + h + "/class-ov.txt"), function(d){
aa = $("<div>").addClass("androidadditon").insertAfter(".jd-descr:first").html(d);
$("img", aa).each(function(){
$(this).attr("src", chrome.extension.getURL("content/" + h + "/" + $(this).attr("src")));
});
}, "text");
$("<script>").attr("async", "true").attr("src", chrome.extension.getURL("content/" + h + "/class-ov.js")).appendTo("head");
// Get all the detail extras
var id = 0;
$(".jd-details").each(function(){
t = $(".jd-details-title", this).clone();
$("span.normal", t).remove();
t = t.text().trim();
$(this).addClass("add-id-" + id);
x_id = id;
id = id+1;
l(h, t, x_id);
});
} else if(p[0] == "design"){
// Design
$("img").each(function(){
l = $(this).attr("src").split("/"); l.shift();
var img = this;
$.get(chrome.extension.getURL("content/design/" + l.join("_") + ".txt"), function(data){
$("<div>").addClass("androidadditon").html(data).insertAfter(img);
});
});
} else if(p[0] == "guide"){
$.get(chrome.extension.getURL("content/guides/nav.html"), function(data){
li = $("<li>").addClass("nav-section").html(data).insertBefore(".nav-section:first");
$("ul a", li).each(function(){
$(this).attr("target", "_blank").attr("href", chrome.extension.getURL("guide.html") + "#" + chrome.extension.getURL("content/guides/") + $(this).attr("href")).attr("title", "This guide is not provided by Google");
});
});
}
});