CoffeeScript is a little language that compiles into JavaScript. Underneath all of those embarrassing braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

learn more… | top users | synonyms

3
votes
0answers
27 views

Multiple select widget in CoffeeScript

I created a widget to handle multiple selections in CoffeeScript. There's a working attached snippet that uses the compiled JavaScript (Stack Snippets don't support CoffeeScript), which is available ...
2
votes
0answers
36 views
2
votes
0answers
54 views

Passing functions using higher order components in React

After reading this, I'm on board, however it doesn't get into passing methods from the parent class. In my mixins right now I have a lot of helper functions that are used across the various components ...
1
vote
1answer
32 views

Extracting a list of hyperlinks [closed]

I need to produce a list objCollector with some results: ...
2
votes
0answers
40 views

Correcting a quiz

I wrote this code that's supposed to correct quizzes on a webpage, but it feels bloated and I'm sure there's tons of ways to improve it. Any thoughts? ...
3
votes
2answers
169 views

HTML5 Video player

I do HTML5 Video player with some controls. I have a button, where I change classname for make play, pause or replay button. I have a mute/unmute button, volume range slider, timer and fullscreen mode ...
1
vote
0answers
12 views

Extend a rethinkdb query, with `if`s

I have something roughly like this: ...
2
votes
0answers
101 views

Click interceptor directive

I needed a simple way to add this test to certain click events: if isUser then fireClickEvent else openSignInModal So I made this directive: ...
2
votes
0answers
101 views

Resource that use two different services and query with pagination when resolved

I'm learning Angular and I don't like my current approach. The current controller uses first Geolocation service and when ...
2
votes
1answer
76 views

Wait for all resources to be loaded

In my application I need some resources to be loaded and I have services to load each of them and then I need some point to know that all requests finished. First thought was to use $q.all with array ...
3
votes
1answer
199 views

Regex for curly quotes and apostrophes

After years of fear and procrastination I decided to learn regular expressions. This is the result: CoffeScript: ...
5
votes
2answers
142 views

Periodic Table generator

I've been playing around with Jekyll and CoffeeScript the last few days and made a Periodic Table to learn those two. Now, to create the Periodic Table, I take an array of ...
1
vote
1answer
298 views

AngularJS Login Check

I have states that have a requiredlogin object set as true, then I have Angular listen on ...
4
votes
1answer
105 views

Flood game implementation

There is the implementation of flood game on my GitHub. The app.coffee is the main part of project: ...
1
vote
1answer
54 views

CSV lookup problem solved with CoffeeScript

Source code with some test: ...
1
vote
1answer
448 views

Cleaner way to map array of objects in CoffeeScript

Im wondering if there is a cleaner way to write this - map = (obj) -> $scope.data.push({name : obj.name, id : obj.id}) map obj for obj in objArr ...
4
votes
2answers
237 views

Get <TH> texts into a tab separated string

table_with_headers = $(this.dom.table).find("thead tr th").map(-> $(this).text() ).get().join("\t") Can one write it nicer? I especially dont like the inner ...
6
votes
1answer
121 views

English-Russian irregular words tester

Could you please offer some suggestions about my self learning project? It is really hard-coded, but I have no idea what to do next. I'm using angular (only few ...
2
votes
0answers
127 views

RESTful API parsing DBF data HSET in Redis

I have this working code, but would like your review: sync.coffe ...
1
vote
1answer
70 views

Conditional AND statement- which is more readable?

Does this function automationStatusIsSuccessful = (data) -> data.Automation.Status isnt "FAILED" and data.Automation.Status isnt "COMPLETEDWITHERROR"` ...
0
votes
1answer
56 views

Function with underscore overuse

The code below is converting: data from one format to another ...
1
vote
1answer
250 views

Refactor Coffee Script to fire on page load instead of change

I have a Rails app where I'm trying to select a list of facilities based on what region is selected in a form. So far, I've implemented group_collection_select to do this as well as a bit of ...
2
votes
1answer
141 views

NodeJS conditional request before the real request

In my code I have to login a user with username and password. But if the user sends his e-mail instead of his username, I have to resolve it with another request. This is what the code looks like: ...
1
vote
1answer
68 views

Generating Passwords with a Secure PRNG

What's the best way to approach generating a password using a secure prng? In Python, I could simply use os.urandom. Any suggestions on this? ...
5
votes
2answers
52 views

Mathematical boundaries (audio meter)

I've just been putting together an audio meter by stacking bootstrap progress bars, and thought there was probably a better way, mathematically / logically, of achieving this. ...
5
votes
1answer
54 views

Tick module for the game

I tried to look up and suck in most of the information about optimizing this operation and this is what I came up with. As it's pretty much core of the game, I really would like to have it performant ...
1
vote
1answer
67 views

Navigating around ul li and looking for the active state on the current slide

How can I rewrite this in a simpler way? ...
3
votes
1answer
81 views

Automatically gravitate popover towards page center

I've authored a couple of plugins which show popovers on a given element. One of the objectives for both was no specification of plugin direction. So instead of the implementing dev having to specify ...
3
votes
0answers
115 views

Create component with select+button

I'm new to ReactJs and trying to figure out the preferred style. I also have tried it enough to realize that I'm not a fan of jsx and prefer how React looks when written in coffeescript. This is a ...
3
votes
1answer
44 views

Set up event on class and initialize state [closed]

Very similar to this question, I'm curious about common patterns/best practices for handling events in coffeescript classes, particularly when you also need to call the event handlers immediately to ...
4
votes
1answer
183 views

Ruby on Rails text editor

I'm currently building a text editor using contenteditable and RoR back end. As the editor is WYSIWYG and trying to follow DRY, I used only one file to 3 actions: Show, Edit and New. Edit and new ...
4
votes
1answer
150 views

Resize renderer on browser window size change

For a game, there is some WebGLRenderer object that wraps around canvas element. There is need to update it's size when browser window size changes. Here goes my current code written using BaconJS. ...
4
votes
2answers
72 views

Initializing events on class

I wrote a simple class that substitutes all file inputs in an HTML for a more complex template and set some actions on it. The code is rather small, but I'm not used to write JavaScript. I wonder if ...
1
vote
1answer
38 views

Implementing a Simple “MoneyAccount” in CoffeeScript

Please critique this CoffeeScript code. Is it idiomatic? ...
2
votes
1answer
44 views

Cleaner Way to Test for Types? [closed]

I defined a function that multiplies its argument by 3: coffee> foo = (x) -> x * 3 [Function] We can call it with an input of 1: ...
6
votes
2answers
132 views

Optimize CoffeeScript comparison function

I've wrote this CoffeScript function to compare values in a table, but it turned out to be a HUGE function. Since the code is really really long, you can find it here as well. Code explanation: The ...
2
votes
1answer
270 views

Multiple search filter like the one in freshdesk

I have requirement to apply multiple filters on database. I will have multiple conditions in the front end where the user can select the conditions he wants to filter with and then see the output. ...
4
votes
0answers
4k views

An Object-Oriented Programming pattern for AngularJS models using CoffeeScript classes

Over the past week, we tried to make our AngularJS model layer more powerful and reduce complexity in our controllers and template by using the object-oriented programming pattern and the CoffeeScript ...
0
votes
2answers
521 views

Promises and chained calls

I've realized JS callback hell and I started looking into Promises libraries. After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because ...
7
votes
5answers
350 views

Avoiding nested conditionals and comparing strings

I have a web page with a set of icons that are grey by default: If a user clicks one, it toggles green (.toggleClass('green')): If a user clicks a green one, ...
1
vote
1answer
57 views

Remove nodejs/browser specific code in library

I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee I want to maintain a library that works on node and in the browser, ...
10
votes
1answer
208 views

Tabbed navigation to hide and show pages

I'm new to jQuery and trying to learn how to refactor my bloated code to make it nicer and better maintainable. I have a tabbed navigation which I'm using jQuery to hide and show pages depending on ...
4
votes
1answer
56 views

Refactor array for loop result

...
8
votes
1answer
237 views

Simple CoffeeScript navigation menu

I'm using simple script to handle tab menu like this: HTML: ...
1
vote
1answer
644 views

Inheritance in angular directive with coffeescript

Here is my solution: ...
2
votes
1answer
106 views

Backbone subviews with non-uniform layout

I have a “featured projects” view that requires its subviews conform to a non-uniform grid: one narrow column with 3 items, then one wide column with 2 items, followed by another narrow column with 3 ...
-1
votes
1answer
282 views

How to improve or refactor Backbone CoffeeScript code? [closed]

how can I improve the following code mainly regarding the router, when to initialize the and fetch the collection and how I can filter the models?= Thank you ...
3
votes
2answers
79 views

How can I remove DRY violations from this event handling code?

I've got a bunch of event handlers that follow this pattern: ...
3
votes
1answer
121 views

How to refactor this series of JavaScript promises?

This is part of a class for paginating a Backbone collection. The paginateTo method is for paginating to a model id. It returns the model if it's already in the ...
2
votes
0answers
108 views

node.js Review Core class of a Javascript framework for SPA's

A few years ago I started building a tiny (~300 SLOC) JavaScript framework for scalable and maintainable Single-Page-Applications written in CoffeeScript: https://github.com/flosse/scaleApp and ...