var mydate = new Date() var DOW = mydate.getDate() var rndquote = new Array(31) //Random Quote List rndquote[5]="It wasn't a dream, it was a place, and you and you and you - and you were there!\"unquote\"
— Judy Garland, The Wizard of Oz" rndquote[6]="I believe in death, destruction, chaos, filth and greed\"unquote\"
— Edward Furlong, American History X" rndquote[7]="Your anger is shutting down the brain God gave you\"unquote\"
— Avery Brooks, American History X" rndquote[8]="Come on, Sweeney, it took me two weeks to read Mein Kampf\"unquote\"
— Edward Furlong, American History X" rndquote[9]="... decent, hard working Americans like my father are murdered by parasites\"unquote\"
— Edward Norton, American History X" rndquote[10]="Are you callin me a blimp, you fuckin Democrat?\"unquote\"
— [fat guy], American History X" rndquote[11]="Christ, Lincoln freed the slaves, what, 130 years ago? I mean how long does it take to get your act together?\"unquote\"
— Edward Norton, American History X" rndquote[12]="I'm ashamed that you came out of my body.\"unquote\"
— [Mom], American History X" rndquote[13]="I'm not scared. I don't want it anymore.\"unquote\"
— Edward Norton, American History X" rndquote[14]="All the wrong people knew who I was anyway so I figure I'm just gonna put up a flag and hope a friend sees it.\"unquote\"
— Edward Norton, American History X" rndquote[15]="In the joint, you the nigga, not me.\"unquote\"
— [laundry pal], American History X" rndquote[16]="Now we can ignore each other in peace\"unquote\"
— [laundry pal], American History X" rndquote[17]="Has anythihng you've done made your life better?\"unquote\"
— Edward Norton, American History X" rndquote[18]="I kept askin' myself how did I buy into this shit. It was because I was pissed off.\"unquote\"
— Edward Norton, American History X" rndquote[19]="Life's too short to be pissed off all the time.\"unquote\"
— Edward Norton, American History X" rndquote[20]="I want to use every means possible to get what I need\"unquote\"
— Jon Voight, Enemy of the State" rndquote[21]="Some people mediate, some people get messages, I blend\"unquote\"
— Will Smith, Enemy of the State" rndquote[22]="If you live another day, I'll be very impressed\"unquote\"
— Gene Hackman, Enemy of the State" rndquote[23]="Conspiracy theorists unite\"unquote\"
— Will Smith, Enemy of the State" rndquote[24]="No I don't want any coffee! I want to play with my dog!\"unquote\"
— Jason Robards, Enemy of the State" rndquote[25]="National security is not the only thing going on in this country\"unquote\"
— Jason Robards, Enemy of the State" rndquote[26]="I'm an attorney, I don't make video tapes\"unquote\"
— Will Smith, Enemy of the State" rndquote[27]="I don't want to come in here and look stupid... too late.\"unquote\"
— Will Smith, Enemy of the State" rndquote[28]="Oh! Well! There goes the fourth amendment -- what's left of it!\"unquote\"
— [wife], Enemy of the State" rndquote[29]="He didn't secrete it into any of my bodily orifices...\"unquote\"
— Will Smith, Enemy of the State" rndquote[30]="Right now you either shoot me or you tell me what the fuck is going on\"unquote\"
— Will Smith, Enemy of the State" rndquote[31]="It's a brave new world out there. At least it better be.\"unquote\"
— Gene Hackman, Enemy of the State" rndquote[1]="If this was somebody's personal wet dream, that somebody is going to prison\"unquote\"
— [head honcho], Enemy of the State" rndquote[2]="Who's going to monitor the monitors of the monitors\"unquote\"
— [wife], Enemy of the State" rndquote[3]="You got no right to come into my home\"unquote\"
— Larry King, Enemy of the State" rndquote[4]="I have a professional obligation to be malicious\"unquote\"
— [pit bull], Babe: Pig in the City" //Random Quote List End /* * Helper functions specific to Movie Habit */ if (!window.console) { function dn() { /* do nothing */ } window.console = { 'log': dn, 'debug': dn, 'info': dn, 'warn': dn, 'error': dn, 'assert': dn, 'dir': dn, 'dirxml': dn, 'trace': dn, 'group': dn, 'groupCollapsed': dn, 'groupEnd': dn, 'time': dn, 'timeEnd': dn, 'profile': dn, 'profileEnd': dn, 'count': dn }; } Function.prototype.hitch = function(context) { var fn = this; return function () { return fn.apply(context, arguments); }; }; function MovieHabit_Class(){ this.init(); } MovieHabit_Class.prototype.rValidRatings = ["0", "0.5", ".5", "1", "1.0", "1.5", "2", "2.0", "2.5", "3", "3.0", "3.5", "4", "4.0"]; MovieHabit_Class.prototype.init = function() { this.oValidRatings = {}; for (var i = 0; i < this.rValidRatings.length; i++) { var rating = this.rValidRatings[i]; this.oValidRatings[rating] = true; } }; MovieHabit_Class.prototype.getEssayFileName = function(title) { var title = String(title).substring(0, 45); title = title.toLowerCase(); return this.cleanFileName( title.replace(/ /g, "_") + "_" + this.get4Date() ); }; MovieHabit_Class.prototype.cleanFileName = function(filename) { return String(filename).replace(/[^0-9a-zA-Z\_\-]/g, ""); }; MovieHabit_Class.prototype.get4Date = function() { var rParts = []; // fir_ah09 - a var d = new Date(); var month = (d.getMonth()+1); rParts.push( String.fromCharCode((96 + month)) ); // fir_ah09 - h var dt = d.getDate(); if (dt < 27) { rParts.push( String.fromCharCode((96 + dt)) ); } else { rParts.push( String(dt).substr(1, 1) ); } // fir_ah09 - 09 rParts.push( String(d.getFullYear()).substr(2, 2) ); return rParts.join(""); }; MovieHabit_Class.prototype.getOldFileName = function(title) { var rParts = []; var titleNoArticle = this.getTitleNoArticle(title); titleNoArticle = titleNoArticle.replace(/[^\w]/g, ""); titleNoArticle = titleNoArticle.toLowerCase(); rParts.push( titleNoArticle.substr(0, 3) ); rParts.push("_"); rParts.push(this.get4Date()); return rParts.join(""); }; MovieHabit_Class.prototype.getSqlDate = function(jsDate) { var d = jsDate || new Date(); datePart = [ d.getFullYear(), ((d.getMonth() < 9 ? '0' : '') + (d.getMonth()+1)), ((d.getDate() < 10 ? '0' : '') + d.getDate()) ].join("-"); timePart = [ d.getHours(), d.getMinutes(), d.getSeconds() ].join(":"); return datePart + " " + timePart; }; MovieHabit_Class.prototype.getImdbLink = function(title) { return "http://imdb.com/find?s=tt&q=" + title.replace(/ /g,"+"); }; MovieHabit_Class.prototype.getAmazonLink = function(title) { return "http://www.amazon.com/exec/obidos/external-search?tag=moviehabit-20&keyword=" + encodeURIComponent(title) + "&mode=dvd"; }; MovieHabit_Class.prototype.getOutnowLink = function(title) { return "http://www.google.com/search?q=" + encodeURIComponent(title) + "+bilder+site%3Aoutnow.ch"; }; MovieHabit_Class.prototype.getTitleNoArticle = function(title) { var str = String(title); str = str.replace(/(^a\s|^an\s|^the\s)(.*$)/i, "$2, $1"); return this.trim(str); }; MovieHabit_Class.prototype.isValidRating = function(numStars) { return (numStars in this.oValidRatings); }; MovieHabit_Class.prototype.trim = function(strWithSpace) { var str = String(strWithSpace); return str.replace(/^\s+|\s+$/g, ""); }; // Convert "It's a Wonderful Life 2: The reckoning" into // its_a_wonderful_life_2 (suffix is like _78.jpg or _150.png) MovieHabit_Class.prototype.getPhotoTitle = function(title, suffix) { title = title.toLowerCase(); title = title.replace(/ /g, "_"); title = title.replace(/'|\-|,|\?|!|\./g, ""); title = title.replace(/_{2,}/, "_"); var posOfColon = title.indexOf(":"); if (posOfColon > -1) {title = title.substr(0, posOfColon); } if (suffix) { title = title + suffix; } return title; }; MovieHabit_Class.prototype.getInitials = function(nameOrNames) { rOut = []; if (nameOrNames.constructor == String) { var rNames = nameOrNames.split(","); } if (nameOrNames.constructor == Array) { var rNames = nameOrNames; } if (!rNames) { return false; } for (var i in rNames) { rOut.push(this._getInitials(rNames[i])); } return this.commatize(rOut); }; MovieHabit_Class.prototype._getInitials = function(singleName) { sOut = ""; rNames = singleName.match(/[^\s]+/g); for (var i in rNames) { sOut += rNames[i].substr(0, 1); } return sOut; }; MovieHabit_Class.prototype.commatize = function(rArray, glue1, glue2) { var glue1 = glue1 || ", "; var glue2 = glue2 || " and "; var last = rArray.pop(); var first = rArray.join(glue1); if (first == "") { return last; } return first + glue2 + last; }; var MovieHabit = new MovieHabit_Class(); jQuery.valt = function () { alert ("testing 3902"); }; (function($) { $.fn.labelInput = function(label) { var label = label || ""; function init () { var j = $(this); if ("" == j.val() || label == j.val()) { j.addClass("empty"); j.val(label); } j.bind("focus", this, inputFocus); j.bind("blur", this, inputBlur); j.bind("beforeSubmit", this, beforeSubmit); // custom event j.attr({title: label}); j.attr({"labeledInput": label}); j.valt = function(){alert (2392)}; } function beforeSubmit() { revertValue.apply(this); } function revertValue() { var el = $(this); if (el.val() == label) { el.val(""); } } function inputFocus (e) { // assert e.data == this var el = $(this); if (el.hasClass("empty")) { el.removeClass("empty"); revertValue.apply(this); } } function inputBlur (e) { var el = $(this); if (el.val() == "") { el.addClass("empty"); el.val(label); } } this.filter('textarea, :text').each(init); return this; }; $.fn.VAL = function () { var j = $(this); if ( j.hasClass("empty") ) { return ""; } return j.val(); }; })(jQuery); if (!window.console) { function dn() { /* do nothing */ } window.console = { 'log': dn, 'debug': dn, 'info': dn, 'warn': dn, 'error': dn, 'assert': dn, 'dir': dn, 'dirxml': dn, 'trace': dn, 'group': dn, 'groupCollapsed': dn, 'groupEnd': dn, 'time': dn, 'timeEnd': dn, 'profile': dn, 'profileEnd': dn, 'count': dn }; } Function.prototype.hitch = function(context) { var fn = this; return function () { return fn.apply(context, arguments); }; }; Common = function() {}; Common.prototype.init = function() { this.labelInputs(); this.bindEvents(); }; Common.prototype.bindEvents = function() { $("a[target=_blank]").bind("click", this, this.openPop); $("a[target=contact]").bind("click", this, this.openPop); $("form[target=_blank]").bind("submit", this, this.openPop); $(".expandable h3").bind("click", this, function() { // jQuery(this).toggleClass("collapsed", 100); // only works on FF, not IE8, safari... jQuery(this.parentNode).toggleClass("collapsed"); } ); }; Common.prototype.labelInputs = function() { $('input.search').labelInput("Search Movie Habit"); }; Common.prototype.openPop = function(e) { // var self = e.data; var el = this; e.preventDefault(); var location = el.href || el.action; if (el.tagName.toLowerCase()=="form") { var sUrlParams = "?"; var rUrlParams = []; $(":input", el).each( function() { if ($(this).attr("name") != "") { rUrlParams.push( $(this).attr("name") + "=" + $(this).val() ); } } ); location += sUrlParams + rUrlParams.join("&"); } var w = window.open(location, $(el).attr('target'), "width=609, height=703, status=no, resizable=yes, toolbar=no, menubar=no, scrollbars=yes"); w.focus(); }; Common.prototype.skippableKeyCodes = { "9": "tab" , "13": "enter" , "16": "shift" , "17": "ctrl" , "18": "alt" , "27": "esc" , "35": "end" , "36": "home" , "37": "left" , "38": "up" , "39": "right" , "40": "down" }; var oCommon = new Common(); $(document).ready(function(){ oCommon.init(); });var whitespace = " \t\n\r"; function isEmpty(s) { return ((s == null) || (s.length == 0)); } function isWhitespace(s) { var i; if (isEmpty(s)) return true; for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } return true; } function isEmail (s) { if (isEmpty(s)) return false; // is s whitespace? if (isWhitespace(s)) return false; // there must be >= 1 character before @, so we // start looking at character position 1 // (i.e. second character) var i = 1; var sLength = s.length; // look for @ while ((i < sLength) && (s.charAt(i) != "@")) { i++; } if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; // look for . while ((i < sLength) && (s.charAt(i) != ".")) { i++; } // there must be at least one character after the . if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false; else return true; } Newsletter = function(){ this.init(); }; Newsletter.prototype.init = function() { this.labelInputs(); this.initEvents(); $('form').bind("submit", this, this.beforeSubmit); }; Newsletter.prototype.beforeSubmit = function(e) { var self = e.data; $('input').filter('textarea, :text').trigger('beforeSubmit'); } Newsletter.prototype.prefillEmail = function() { // pull the n/v pairs off the URL var srch = document.location.search; // parse them // if one is email="blah" then fill the form with "blah" if (srch.indexOf("email=") == 1) { document.Subscribe.email.value = srch.substr(7); } }; Newsletter.prototype.labelInputs = function() { jQuery('input[name="subscribername"]').labelInput("Your name"); jQuery('input[name="email"]').labelInput("Your e-mail address"); jQuery('input[name="favemovie"]').labelInput("Your favorite movie"); }; Newsletter.prototype.initEvents = function() { jQuery('#Subscribe').bind('submit', this, this.handleSubmit); }; Newsletter.prototype.validateEmail = function(strEmail) { if (!isEmail(strEmail)) { alert ("Your e-mail address appears to be incorrectly formatted. Please check it and try again."); return false; } return true; }; Newsletter.prototype.getDefaultAjaxParams = function() { return { dataType: "json", type: "POST", url: "do_action.php", error: this.ajaxError }; }; Newsletter.prototype.handleSaveClick = function(e) { var self = e.data; e.preventDefault(); self.insertMovie(); self.insertStory(); // need to do this only after we have an idStory // call after story with race-condition check // self.insertStoryHasWriter(); // need to wait until movie and story are done // so do this after each with a race-condition check // self.insertReviewOfMovie(); }; Newsletter.prototype.handleBodyBlur = function(e) { var self = e.data; self.drawBody(); }; Newsletter.prototype.drawBody = function() { var body = jQuery('#story_Body').val(); var preview = jQuery('#preview')[0]; preview.innerHTML = body; }; Newsletter.prototype.getTitle = function() { var fTitle = $('#story_Title'); return fTitle.val(); }; // ****************** Inserts ************************* Newsletter.prototype.insertMovie = function() { var title = this.getTitle(); var titleNoArticle = MovieHabit.getTitleNoArticle(title); var ajaxParams = this.getDefaultAjaxParams(); ajaxParams.success = this.handleInsertedMovie.hitch(this); ajaxParams.data = { Title:title, TitleNoArticle: titleNoArticle, "do": "movie", "action": "insert" }; if (this.idMovie && isFinite(this.idMovie)) { ajaxParams.data.idMovie = this.idMovie; ajaxParams.data.action = "updatePartial"; } jQuery.ajax(ajaxParams); }; Newsletter.prototype.insertStory = function() { var fBody = $('#story_Body'); var body = fBody.val(); var dateAdded = MovieHabit.getSqlDate(); var fileName = MovieHabit.getOldFileName( this.getTitle() ); var discriminator = 1; var ajaxParams = this.getDefaultAjaxParams(); ajaxParams.success = this.handleInsertedStory.hitch(this); ajaxParams.data = { Body: body, DateAdded: dateAdded, DateUpdated: dateAdded, Discriminator: discriminator, FileName: fileName, "do": "story", "action": "insert" }; if (this.idStory && isFinite(this.idStory)) { ajaxParams.data.idStory = this.idStory; ajaxParams.data.action = "updatePartial"; } jQuery.ajax(ajaxParams); }; Newsletter.prototype.insertStoryHasWriter = function() { console.log(arguments, this); var fWriters = $('input[name="story_idWriter"]'); for (var i = 0; i < fWriters.length; i++) { var fWriter = fWriters[i]; this._insertStoryHasWriter(fWriter.value); } }; // ****************** Response Handlers ************************* Newsletter.prototype.handleSubmit = function(e) { var self = e.data; var email = jQuery('p.email input[name]="email"').val(); if (!self.validateEmail(email)) { e.preventDefault(); return false; } return true; }; Newsletter.prototype.handleInsertedMovie = function(serverData, success) { this.idMovie = null; if (serverData && serverData.id && serverData.id.idMovie) { this.setIdMovie(serverData.id.idMovie); } this.insertReviewOfMovie(); return this.idMovie; }; Newsletter.prototype.setIdMovie = function(idMovie) { this.idMovie = idMovie; var movieLinks = jQuery('a.movie'); for (var i = 0; i < movieLinks.length; i++) { var href= movieLinks[i].getAttribute("href"); if (/idMovie=/.test(href)) { href = href.replace(/idMovie=[^&]*/, ("idMovie=" + this.idMovie)); } else { href = href + "&idMovie=" + this.idMovie; } movieLinks[i].setAttribute("href", href); } }; Newsletter.prototype.setIdStory = function(idStory) { this.idStory = idStory; var storyLinks = jQuery('a.story'); for (var i = 0; i < storyLinks.length; i++) { var href= storyLinks[i].getAttribute("href"); if (/idStory=/.test(href)) { href = href.replace(/idStory=[^&]*/, ("idStory=" + this.idStory)); } else { href = href + "&idStory=" + this.idStory; } storyLinks[i].setAttribute("href", href); } }; Newsletter.prototype.handleInsertedStory = function(serverData, success) { this.idStory = null; if (serverData && serverData.id && serverData.id.idStory) { this.setIdStory(serverData.id.idStory); } this.insertReviewOfMovie(); this.insertStoryHasWriter(); return this.idStory; }; Newsletter.prototype.handleInsertedReviewOfMovie = function(serverData, success) { console.log(serverData, success, arguments); }; Newsletter.prototype.ajaxError = function() { console.log("ajaxError args: ", arguments); }; $(document).ready(function(){ oNewsletter = new Newsletter(); });