# HG changeset patch # User Robert McIntyre # Date 1280283793 14400 # Node ID 8ed3394e6b73a16d162e0704dfed3b165f1e4c19 # Parent 2bec541ef58fd8cb23ef89993eb4fe713a1703ce wrote comment-killer diff -r 2bec541ef58f -r 8ed3394e6b73 js-lib/buy3.js --- a/js-lib/buy3.js Tue Jul 27 08:39:43 2010 -0400 +++ b/js-lib/buy3.js Tue Jul 27 22:23:13 2010 -0400 @@ -15,16 +15,23 @@ var h = paper.height; var w = paper.width; + var standard = (function (text, x, y, pt, font){ + if (!font) {font = helvetica;} + var scale_x = 0.00030*h*pt/20; + var scale_y = 0.00025*w*pt/20; + return paper.print(h*x, w*y,text, font).scale( + scale_x,scale_y,h*x,w*y);}); + + var bold = { + "name" :(function (text){ + return standard(text, 0.2,0.1,20).attr({"fill" : "red"});}), + "email" : (function (text){ + return standard(text, 0.2,0.4,20,helveticaI).attr( + {"fill" : "red"});})}; + + return { - "bold" : { - "name" :(function (text){ - var x = w*0.1; var y = h*0.2; - return paper.print(x,y,text,helvetica).attr( - {"fill" : "red"}).scale(0.0002*h,0.00025*w,x,y);}), - "email" : (function (text){ - var x = w*0.1; var y = h*0.4; - return paper.print(x,y,text,helveticaI).attr( - {"fill" : "red"}).scale(0.0002*h,0.00025*w,x,y);})} + "bold" : bold }; }); diff -r 2bec541ef58f -r 8ed3394e6b73 kill-comments --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kill-comments Tue Jul 27 22:23:13 2010 -0400 @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import subprocess +import sys + +target_file = sys.argv[1] + +command = "emacs -batch " + \ + target_file + \ + " --eval '(kill-comment (point-min) (point-max) nil)' -f save-buffer" + +print command +subprocess.call(command, shell=True) diff -r 2bec541ef58f -r 8ed3394e6b73 temp342423/buy3.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/temp342423/buy3.css Tue Jul 27 22:23:13 2010 -0400 @@ -0,0 +1,28 @@ +div#debug { + position: absolute; + top:5%; + right:10%; + width: 450px; + border-color:#DD7777; + border-width:2px; + background-color:#bf3f9b; + font: bold 15px "helvetica","arial", "sans-serif"; + color: white; + height: 200px; + display : none; +} + +div#text-entry { + position : absolute; + top : 15%; + left : 25%; + width : 150px; +} + +.hidden { + display : none; +} + +input.exampleText { + color: #aaa; +} diff -r 2bec541ef58f -r 8ed3394e6b73 temp342423/buy3.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/temp342423/buy3.js Tue Jul 27 22:23:13 2010 -0400 @@ -0,0 +1,310 @@ + +Buy = (function (){ + + + + var magic_font_ratio = 318; + var mfg = magic_font_ratio; + + + + var draw_card = (function (paper){ + + var helvetica = paper.getFont('HelveticaNeue', 700); + var helveticaI = paper.getFont('HelveticaNeue', 800); + var h = paper.height; + var w = paper.width; + + var standard = (function (text, x, y, pt, font){ + if (!font) {font = helvetica;} + var scale_x = 0.00030*h*pt/20; + var scale_y = 0.00025*w*pt/20; + return paper.print(h*x, w*y,text, font).scale( + scale_x,scale_y,h*x,w*y);}); + + var bold = { + "name" :(function (text){ + return standard(text, 0.2,0.1,20).attr({"fill" : "red"});}), + "email" : (function (text){ + return standard(text, 0.2,0.4,20,helveticaI).attr( + {"fill" : "red"});})}; + + + return { + "bold" : bold + }; + + }); + + + + + + + + + + + + + + + + var switchText = (function (){ + if ($(this).val() == $(this).attr('title')) + $(this).val('').removeClass('exampleText'); + else if ($.trim($(this).val()) == '') + $(this).addClass('exampleText').val($(this).attr('title'));}); + + + var deref = (function (var_name){return var_name;}); + + + + + + var card; + + var card_init = (function () { + + card = { + name : {text: "Robert McIntyre", ref: display.set()}, + company : {text: "", ref: display.set()}, + occupation : {text: "", ref: display.set()}, + phone : {text: "", ref: display.set()}, + email : {text: "rlm@mit.edu", ref: display.set()}, + website : {text: "", ref: display.set()}, + decoration : {text: "", ref: display.set()}}; + }); + + + var order = + {color : "blue", + style : "bold", + quantity : 30, + content : undefined, + info : undefined, + name : "Robert McIntyre", + occupation : "AI Researcher", + phone : "617.821.9129", + email : "rlm@mit.edu", + website : "www.rlmcintyre.com", + company : "LaserKard LLC." + }; + + var display; + var color; + var style = {}; + var helvetica; + var helvetica_I; + + var state_map = { + bold : null, + classic : null, + + green : {ref : null, + offState : {"fill" : "#030", "scale": 1} , + onState : {"fill" : "#0F0", "scale": 1}}, + red : {ref : null, + offState: {"fill" : "#300", "scale" : 1}, + onState : {"fill" : "#F00" ,"scale" : 1}}, + blue : {ref : null, + offState : {"fill" : "#003", "scale": 1}, + onState : {"fill" : "#00F", "scale": 1}, + ref : null}, + black : {offState : null, onState : null, ref : null}, + display : {ref : null, state : {"fill" : "black"}}}; + + var color_select_init = (function (){ + state_map["red"].ref = + color.rect(160, 1, 70, 50, 10).attr(state_map["red"].offState); + state_map["red"].ref.node.onclick = + (function (){order.color= "red"; update();}); + state_map["green"].ref = + color.rect(1, 1, 70, 50, 10).attr(state_map["green"].offState); + state_map["green"].ref.node.onclick = + (function (){order.color= "green"; update();}); + state_map["blue"].ref = + color.rect(80, 1, 70, 50, 10).attr(state_map["blue"].offState); + state_map["blue"].ref.node.onclick = + (function (){order.color= "blue"; update();}); + + toggle_on(state_map[order.color]); + }); + + var display_init = (function (){ + state_map["display"].ref = + display.rect(1, 1 , display.width - 1, display.height - 2, 20).attr( + state_map["display"].state); + }); + + var text_entry_init = (function (){ + $('input[type=text][title!=""]').each(function() { + if ($.trim($(this).val()) == ''){ + $(this).val($(this).attr('title'));} + if ($(this).val() == $(this).attr('title')){ + $(this).addClass('exampleText');} + }).focus(switchText).blur(switchText); + + $('form').submit(function() { + $(this).find('input[type=text][title!=""]').each(function() { + if ($(this).val() == $(this).attr('title')){ + $(this).val('');}})})}); + + var style_text = { + phone : "617.821.9129", + email : "rlm@mit.edu", + website : "www.rlmcintyre.com", + name : "Robert McIntyre", + company : "LaserKard LLC.", + occupation : "AI Researcher"} + + + var style_init = (function (){ + var draw = draw_card(style.bold); + draw.bold.name(style_text.name); + style.bold.rect(1, 1 ,style.bold.width - 1, style.bold.height - 2, 10); + draw.bold.email(style_text.email); + + + + + + + + }); + + + + + var init = (function () { + display = Raphael("card-display", 340 ,215); + color = Raphael("color-select", 300, 100); + + style.bold = Raphael("bold", 170, 107); + + style.classic = Raphael("classic", 170 , 107); + + helvetica = display.getFont('HelveticaNeue', 700); + helvetica_I = display.getFont('HelveticaNeue', 800); + color_select_init(); + display_init(); + card_init(); + text_entry_init(); + key_handling(); + style_init(); + update(); + }); + + + + + var toggle_on = (function (button){ + button.ref.animate(button.onState, 2000); + }); + + var toggle_off = (function (button){ + button.ref.animate(button.offState, 2000); + }); + + var color_select_update = (function (){ + var color = order.color; + return (function (){ + if (order.color === color){} + else { + toggle_off(state_map[color]); + toggle_on(state_map[(order.color)]); + color = order.color;} + });})(); + + var display_color_update = (function (){ + var color = state_map.display.state.fill + + return (function (){ + if (order.color === color){} + else { + state_map["display"].ref.animate( + {"fill" : state_map[order.color].onState.fill}, 2000); + color = order.color;}})})(); + + var display_style_update = (function (){ + var style = null; + return (function (){ + if (style !== order.style){ + ""; }}); + }); + + var key_handling = (function (){ + var assoc = (function (target, field) { + $(target).keyup(function() { + field.text = $(target).val(); + update();})}); + assoc('#user-name', card.name); + assoc('#user-phone', card.phone); + assoc('#user-email', card.email); + assoc('#user-company', card.company); + assoc('#user-occupation', card.occupation); + assoc('#user-website', card.website); + }); + + var display_style_update = (function (){ + var style = null; + + return (function () { + var draw = draw_card(display); + if (style !== order.style){ + for ( var property in card ){ + if (!draw[order.style][(deref(property))]){ + $("#user" + "-" + property).toggle(400);}} + style = order.style;} + });})(); + + var display_text_update = (function (){ + var state = {name : "nothing", + phone: "nothing", + email: "nothing", + occupation: "nothing", + company : "nothing", + website : "nothing" }; + + var check_text = (function (var_name) { + var draw = draw_card(display); + if (state[deref(var_name)] !== (card[deref(var_name)]).text){ + if (draw[order.style][deref(var_name)]) { + card[deref(var_name)].ref.remove(); + card[var_name].ref = + draw[order.style][deref(var_name)]( + card[deref(var_name)].text,display); + state[deref(var_name)] = card[deref(var_name)].text; + }}}); + + return (function (){ + check_text("name"); + check_text("phone"); + check_text("email"); + check_text("occupation"); + check_text("company"); + check_text("website"); + + $("#debug").html(JSON.stringify(state)); + }); + + })(); + + var update = (function (){ + color_select_update(); + display_color_update(); + display_text_update(); + display_style_update(); + }); + + + return {init : init, + update : update};})(); + + + +$(document).ready(function() { + Buy.init(); + Buy.update(); + }); diff -r 2bec541ef58f -r 8ed3394e6b73 temp342423/kill-comments --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/temp342423/kill-comments Tue Jul 27 22:23:13 2010 -0400 @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import subprocess +import sys +import os + +target_file = sys.argv[1] + +command = "emacs -batch -l ~/.emacs-bash " + \ + target_file + \ + " --eval '(kill-comment (count-lines (point-min) (point-max)))'" + +#to load a custom .emacs script (for more syntax support), +#use -l in the above command + +#print command + +fnull = open(os.devnull, 'w') +result = subprocess.call(command, shell = True, stdout = fnull, stderr = fnull) +fnull.close() + + + + + + + + diff -r 2bec541ef58f -r 8ed3394e6b73 temp342423/server.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/temp342423/server.clj Tue Jul 27 22:23:13 2010 -0400 @@ -0,0 +1,27 @@ +(ns laserkard.server + (:use (compojure.http request servlet session routes) + (compojure.server jetty) + (compojure control) + (laserkard buy-temp faq) + +)) + +(defroutes example + (GET "/index.clj" [] "

hello, connie, good to meet you

") + (GET "/buy-temp.clj" [] (buy-gen)) + (GET "/faq.clj" [] (faq)) +) + + + +(defserver laserkard-server + {:port 9000 :host "localhost"} + "/*" (servlet example)) + + + ;adasdas + +;asdas + + +