Skip to content

Instantly share code, notes, and snippets.

@jamiefolsom
jamiefolsom / Store.coffee
Created September 5, 2012 17:24
Adding events to the Store plugin
# Public: Callback method for annotationCreated event. Receives an annotation
# and sends a POST request to the sever using the URI for the "create" action.
#
# annotation - An annotation Object that was created.
#
# Examples
#
# store.annotationCreated({text: "my new annotation comment"})
# # => Results in an HTTP POST request to the server containing the
# # annotation as serialised JSON.
jQuery(function ($) {
// Get a reference to the Annotator for event callback subscriptions //
var studio = $('#textcontent').annotator();
studio.annotator('addPlugin','Auth', {
token: '<%= @jwt %>'
});
studio.annotator('addPlugin','Store', {
prefix: 'http://localhost:5000/api',
@jamiefolsom
jamiefolsom / jquery.ba-tinypubsub.js
Created August 14, 2012 16:33 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@jamiefolsom
jamiefolsom / demo.htm
Created June 8, 2012 16:42 — forked from bennadel/demo.htm
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
<!DOCTYPE html>
<html>
<head>
<title>Cross-Origin Resource Sharing (CORS) With jQuery And Node.js</title>
</head>
<body>
<h1>
Cross-Origin Resource Sharing (CORS) With jQuery And Node.js
</h1>
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');