Skip to content

Instantly share code, notes, and snippets.

View adamcjoiner's full-sized avatar

Adam C. Joiner adamcjoiner

View GitHub Profile
$(function() {
$('.login_button').click(function() {
doLogin();
});
$('#send_chat_form').submit(function() {
var message = $(this).find('.message').val();
sendMsg(message);
$('#chat').append('<div class="msg">me: ' + message + '</div>');
$(this).find(".message").val('');
@adamcjoiner
adamcjoiner / wp-admin-modal-dialog.php
Created June 6, 2018 20:38 — forked from anttiviljami/wp-admin-modal-dialog.php
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
@adamcjoiner
adamcjoiner / dom-to-json.js
Last active September 27, 2017 23:49 — forked from sstur/dom-to-json.js
Convert DOM Node ->JSON string format (and back again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@adamcjoiner
adamcjoiner / dom-to-object
Last active September 28, 2017 03:46 — forked from alain75007/elementToObject
DOM Node -> Object -> JSON
function elementToObject(element, o) {
var el = $(element);
var o = {
tagName: el.tagName
};
var i = 0;
for (i ; i < el.attributes.length; i++) {
o[el.attributes[i].name] = el.attributes[i].value;
}
@adamcjoiner
adamcjoiner / reddit.html
Created March 31, 2017 22:06 — forked from sente/reddit.html
An example of a retrieving data from reddit's JSON(p) api using jquery
<!DOCTYPE html>
<!--
Stuart Powers
http://sente.cc/
http://twitter.com/stuartpowers
-->
<html>
<head>