Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
socekt
  • Loading branch information
Lauren McCarthy committed Mar 23, 2016
1 parent a2dc9ce commit e311aff
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 40 deletions.
1 change: 1 addition & 0 deletions ChromeExtensionExamples/BrowserAction+PageAction/inject.js
Expand Up @@ -21,6 +21,7 @@ $('.js-tweet-text').each(function(){

// put the modified text back into the element on the page
$(this).html(text);
$('body').css('background', 'red');
});


Expand Down
Expand Up @@ -13,7 +13,6 @@
"https://*/*"
],
"web_accessible_resources": [
"manifest.json",
"data/new_lines.txt"
]
}
Expand Up @@ -19,6 +19,6 @@
<script src="popup.js"></script>
</head>
<body>
Emotional labor performed!
something different
</body>
</html>
3 changes: 1 addition & 2 deletions ChromeExtensionExamples/BrowserAction_Popup/manifest.json
Expand Up @@ -10,7 +10,6 @@
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/"
"activeTab"
]
}
2 changes: 1 addition & 1 deletion ChromeExtensionExamples/BrowserAction_Popup/popup.js
Expand Up @@ -19,5 +19,5 @@ $(document).ready(function() {
$('#status').text('url = '+url);

});

});
17 changes: 8 additions & 9 deletions ChromeExtensionExamples/PageAction_Replace/content_script.js
Expand Up @@ -12,8 +12,14 @@ $(document).ready(function(){


function changeText() {
$('a, p').each(function(){
$(this).html(getRandom(new_lines))
$('.js-tweet-text').each(function(){

var text = $(this).html();
text = text.replace('. ', '!!!! ');
$(this).html(text);
// if (Math.random() < 0.25) {
// $(this).html(getRandom(new_lines))
// }
//$(this).hide();
});
}
Expand All @@ -40,10 +46,3 @@ function getRandom(array){
var value = array[index];
return value;
}


//returns true if string contains searched character
function contains(string, searchChar){
if(string.indexOf(searchChar) != -1) return true;
else return false;
}
3 changes: 1 addition & 2 deletions ChromeExtensionExamples/PageAction_Replace/manifest.json
Expand Up @@ -6,8 +6,7 @@
"content_scripts": [
{
"matches": [
"http://www.nytimes.com/*",
"http://processing.org/*"
"https://twitter.com/*"
],
"js": [
"jquery.js",
Expand Down
48 changes: 24 additions & 24 deletions SocketExamples/chat/public/index.html
@@ -1,36 +1,36 @@
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.23/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.23/addons/p5.dom.js"></script>
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
</style>
</head>
<body>
<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off" /><button>Send</button>
</form>

<script>
var socket = io();
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
createDiv(msg);
});

$('form').submit(function(){
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
var input;
var button;

function setup() {
noCanvas();
input = createInput();
button = createButton('send');
button.mousePressed(send);
}

function send() {
var val = input.value();
input.value('');
socket.emit('chat message', val);
}

</script>
<style>
body { margin: 0; padding: 0; }
</style>
</head>
<body>
</body>
</html>

0 comments on commit e311aff

Please sign in to comment.