-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf042ce
commit 9ec0503
Showing
3 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<html> | ||
<body> | ||
|
||
<style> | ||
.content { line-height: 24px; font-family: monospace; font-size: 14px; color: #636363; text-transform: uppercase; top: 38%; position: relative; text-align: center; perspective: 1000px } | ||
.content h1, .content h2 { font-weight: normal; letter-spacing: 1px; } | ||
.content h2 { font-size: 15px; } | ||
.content #details { | ||
text-align: left; display: inline-block; width: 350px; background-color: white; padding: 17px 27px; border-radius: 0px; | ||
box-shadow: 0px 2px 7px -1px #d8d8d8; text-transform: none; margin: 15px; transform: scale(0) rotateX(90deg); transition: all 0.6s cubic-bezier(0.785, 0.135, 0.15, 0.86); | ||
} | ||
.content #details #added { font-size: 12px; text-align: right; color: #a9a9a9; } | ||
|
||
#button { transition: all 1s cubic-bezier(0.075, 0.82, 0.165, 1); opacity: 0; transform: translateY(50px); transition-delay: 0.5s } | ||
.button { | ||
padding: 8px 20px; background-color: #FFF85F; border-bottom: 2px solid #CDBD1E; border-radius: 2px; | ||
text-decoration: none; transition: all 0.5s; background-position: left center; display: inline-block; margin-top: 10px; color: black; | ||
} | ||
.button:hover { background-color: #FFF400; border-bottom: 2px solid #4D4D4C; transition: none; } | ||
.button:active { position: relative; top: 1px; } | ||
.button:focus { outline: none; } | ||
|
||
</style> | ||
|
||
<div class="content"> | ||
<h1>Site blocked</h1> | ||
<h2>This site is on your blacklist:</h2> | ||
<div id="details"> | ||
<div id="reason">Too much image</div> | ||
<div id="added">on 2015-01-25 12:32:11</div> | ||
</div> | ||
<div><a href="#Visit+Site" class="button button-submit" id="button">Remove from blacklist</a></div> | ||
</div> | ||
|
||
<script type="text/javascript" src="js/ZeroFrame.js"></script> | ||
|
||
<script> | ||
class Page extends ZeroFrame { | ||
onOpenWebsocket () { | ||
this.cmd("wrapperSetTitle", "Blacklisted site - ZeroNet") | ||
this.cmd("siteInfo", {}, (site_info) => { | ||
this.site_info = site_info | ||
}) | ||
this.cmd("blacklistList", {}, (blacklists) => { | ||
this.blacklists = blacklists | ||
var address = document.location.search.match(/address=(.*?)[&\?]/)[1] | ||
var reason = blacklists[address]["reason"] | ||
if (!reason) reason = "Unknown reason" | ||
var date = new Date(blacklists[address]["date_added"] * 1000) | ||
document.getElementById("reason").innerText = reason | ||
document.getElementById("added").innerText = "at " + date.toLocaleDateString() + " " + date.toLocaleTimeString() | ||
document.getElementById("details").style.transform = "scale(1) rotateX(0deg)" | ||
document.getElementById("button").style.transform = "translateY(0)" | ||
document.getElementById("button").style.opacity = "1" | ||
document.getElementById("button").onclick = () => { | ||
this.cmd("blacklistRemove", address, () => { this.cmd("wrapperReload") }) | ||
} | ||
}); | ||
} | ||
} | ||
page = new Page() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
const CMD_INNER_READY = 'innerReady' | ||
const CMD_RESPONSE = 'response' | ||
const CMD_WRAPPER_READY = 'wrapperReady' | ||
const CMD_PING = 'ping' | ||
const CMD_PONG = 'pong' | ||
const CMD_WRAPPER_OPENED_WEBSOCKET = 'wrapperOpenedWebsocket' | ||
const CMD_WRAPPER_CLOSE_WEBSOCKET = 'wrapperClosedWebsocket' | ||
|
||
class ZeroFrame { | ||
constructor(url) { | ||
this.url = url | ||
this.waiting_cb = {} | ||
this.wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1") | ||
this.connect() | ||
this.next_message_id = 1 | ||
this.init() | ||
} | ||
|
||
init() { | ||
return this | ||
} | ||
|
||
connect() { | ||
this.target = window.parent | ||
window.addEventListener('message', e => this.onMessage(e), false) | ||
this.cmd(CMD_INNER_READY) | ||
} | ||
|
||
onMessage(e) { | ||
let message = e.data | ||
let cmd = message.cmd | ||
if (cmd === CMD_RESPONSE) { | ||
if (this.waiting_cb[message.to] !== undefined) { | ||
this.waiting_cb[message.to](message.result) | ||
} | ||
else { | ||
this.log("Websocket callback not found:", message) | ||
} | ||
} else if (cmd === CMD_WRAPPER_READY) { | ||
this.cmd(CMD_INNER_READY) | ||
} else if (cmd === CMD_PING) { | ||
this.response(message.id, CMD_PONG) | ||
} else if (cmd === CMD_WRAPPER_OPENED_WEBSOCKET) { | ||
this.onOpenWebsocket() | ||
} else if (cmd === CMD_WRAPPER_CLOSE_WEBSOCKET) { | ||
this.onCloseWebsocket() | ||
} else { | ||
this.onRequest(cmd, message) | ||
} | ||
} | ||
|
||
onRequest(cmd, message) { | ||
this.log("Unknown request", message) | ||
} | ||
|
||
response(to, result) { | ||
this.send({ | ||
cmd: CMD_RESPONSE, | ||
to: to, | ||
result: result | ||
}) | ||
} | ||
|
||
cmd(cmd, params={}, cb=null) { | ||
this.send({ | ||
cmd: cmd, | ||
params: params | ||
}, cb) | ||
} | ||
|
||
send(message, cb=null) { | ||
message.wrapper_nonce = this.wrapper_nonce | ||
message.id = this.next_message_id | ||
this.next_message_id++ | ||
this.target.postMessage(message, '*') | ||
if (cb) { | ||
this.waiting_cb[message.id] = cb | ||
} | ||
} | ||
|
||
log(...args) { | ||
console.log.apply(console, ['[ZeroFrame]'].concat(args)) | ||
} | ||
|
||
onOpenWebsocket() { | ||
this.log('Websocket open') | ||
} | ||
|
||
onCloseWebsocket() { | ||
this.log('Websocket close') | ||
} | ||
} | ||
|