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
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popover | |
{ | |
if (!self.adaptivePresentationStyleAsked) { | |
popover.overrideTraitCollection = [popover.presentingViewController.traitCollection copy]; | |
} | |
} | |
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)popover | |
traitCollection:(UITraitCollection *)traitCollection | |
{ |
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
window.addEventListener("message", receiveMessage, false); | |
function receiveMessage(event){ | |
// make sure the message is sent from your minipush server | |
if(event.origin !== "http://127.0.0.1:8000"){ return; } | |
// when connection is established / disconnected | |
// you will be notified with the following messages | |
if(event.data = "connected"){ return; } |
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
<?php | |
if(!isset($_POST['message'])){ exit(); } | |
$host = "127.0.0.1:8001"; | |
$channel = "chat"; | |
$message = '"'.$_POST['message'].'"'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "http://$host/channels/$channel"); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
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
<html> | |
<head> | |
<script type="text/javascript" src="jquery.js"></script> | |
<script type="text/javascript" src="form.js"></script> | |
<script type="text/javascript"> | |
function receiveMessage(event){ | |
if(event.origin !== "http://127.0.0.1:8000"){ return; } | |
if(event.data === "connected"){ return; } | |
if(event.data === "disconnected"){ return; } |
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
<?php | |
if(!isset($_POST['message'])){ exit(); } | |
$host = "127.0.0.1:8001"; | |
$channel = "chat"; | |
$message = '"'.$_POST['message'].'"'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "http://$host/channels/$channel"); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
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
$("#msg_form").ajaxForm(function(){ | |
//clear the message input field after sending a message | |
$("#msg_form input[name='message']").attr("value", ""); | |
//focus to the message input field again | |
$("#msg_form input[name='message']").focus(); | |
}); |
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
<script type="text/javascript" src="jquery.js"></script> | |
<script type="text/javascript" src="form.js"></script> | |
<script type="text/javascript"> | |
function receiveMessage(event){ | |
if(event.origin !== "http://127.0.0.1:8000"){ return; } | |
if(event.data === "connected"){ return; } | |
if(event.data === "disconnected"){ return; } | |
$("#msg_textarea").get(0).value += event.data + "\n"; | |
//scroll to the bottom |
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
<iframe style="position:absolute;top:-500px;left:-500px;" src="http://127.0.0.1:8000/iframe?channel=chat"></iframe> |
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
<html> | |
<head> | |
<title>Chatroom</title> | |
</head> | |
<body> | |
<textarea id="msg_textarea" | |
rows="10" | |
cols="10" | |
readonly="readyonly" | |
style="width:500px;height:400px;"></textarea> |