summaryrefslogtreecommitdiff
path: root/2016_mirror_browser/firefox-old/index.js
blob: 6c143c7be886ceeb2a84fca4f035a573f6e04331 (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
var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");
var self = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
var state = false;

var button = ToggleButton({
	id: "my-button",
	label: "mirror",
	icon: {
		"16": "./icon-16.png",
		"32": "./icon-32.png",
		"64": "./icon-64.png"
	},
	onChange: handleChange
});

var panel = panels.Panel({
	width: 500,
	height: 180,
	contentURL: self.url("panel.html"),
	contentScriptFile: self.url("onoff.js"),
	onHide: handleHide
});

function handleChange(state) {
	if (state.checked) {
		panel.show({
			position: button
		});
	}
}

function handleHide() {
	button.state('window', {checked: false});
}

panel.port.on("lrmirror", function (text) {
	if(text == "on"){
		state = true;
		pageMod.PageMod({
			include: "*",
			attachTo: ["existing", "top"],
			contentScript: 'document.getElementsByTagName("body")[0].style = "transform: rotateY(180deg)"'
		});
	} else if (text == "off"){
		state == false;
		pageMod.PageMod({
			include: "*",
			attachTo: ["existing", "top"],
			contentScript: 'document.getElementsByTagName("body")[0].style = "transform: rotateY(0deg)"'
		});
	}
});

panel.port.on("udmirror", function (text) {
	if(text == "on"){
		state = true;
		pageMod.PageMod({
			include: "*",
			attachTo: ["existing", "top"],
			contentScript: 'document.getElementsByTagName("body")[0].style = "transform: rotateX(180deg)"'
		});
	} else if (text == "off"){
		state == false;
		pageMod.PageMod({
			include: "*",
			attachTo: ["existing", "top"],
			contentScript: 'document.getElementsByTagName("body")[0].style = "transform: rotateX(0deg)"'
		});
	}
});