Skip to main content

Questions tagged [coffeescript]

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.

Filter by
Sorted by
Tagged with
2 votes
1 answer
444 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. ...
Aravind's user avatar
  • 121
4 votes
0 answers
9k 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 ...
Blaiz's user avatar
  • 141
1 vote
2 answers
920 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 ...
user0103's user avatar
  • 176
7 votes
5 answers
568 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, it ...
Ecnalyr's user avatar
  • 413
1 vote
1 answer
100 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, ...
edi9999's user avatar
  • 183
10 votes
1 answer
302 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 ...
user1502223's user avatar
4 votes
1 answer
68 views

Refactor array for loop result

...
WaYdotNET's user avatar
8 votes
1 answer
472 views

Simple CoffeeScript navigation menu

I'm using simple script to handle tab menu like this: HTML: ...
Eternal1's user avatar
  • 286
2 votes
1 answer
123 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 ...
VLS's user avatar
  • 163
3 votes
1 answer
155 views

Paginating a Backbone collection

This is part of a class for paginating a Backbone collection. The paginateTo method is for paginating to a model id. It returns ...
meleyal's user avatar
  • 131
4 votes
0 answers
138 views

Core class of a JavaScript framework for Single-Page-Applications

A few years ago I started building a tiny (~300 SLOC) JavaScript framework for scalable and maintainable Single-Page-Applications written in CoffeeScript. GitHub www.scaleapp.org It's inspired by ...
flosse's user avatar
  • 121
5 votes
2 answers
780 views

isRTL.coffee library to determine if a text is of right-to-left direction

I just wrote this tiny library called isRTL.coffee to determine the direction of the text. Is there any better way of doing this? ...
dhilipsiva's user avatar
3 votes
2 answers
749 views

Fibonacci using cache

This is my simple Fibonacci implementation in CoffeeScript. What do you think? Using cache (fibResults), it's very very fast. ...
Daniele Vrut's user avatar
3 votes
2 answers
1k views

Getting the outliers of both dates and values

This is working now, but it looks very inelegant. I'm sure there is a nicer way of doing this. ...
Fresheyeball's user avatar
0 votes
1 answer
144 views

Coffeescript Review

...
thedev's user avatar
  • 827
1 vote
1 answer
263 views

Conditionally replacing an input field when submitting a form

I just wrote this, and cleaned it up as much as I could. A couple things worry me: I change the scope of $(this) twice (and apparently don't know how to use ...
nickcoxdotme's user avatar
3 votes
4 answers
8k views

Determining if a target string is found in an array of strings

I wrote this simple function in CoffeeScript to see if elements are found in an array: ...
JAMESSTONEco's user avatar
1 vote
1 answer
786 views

Express, blade with connect-assets

I have this CoffeeScript code running here (with TZM-Blade) and would like to have your opinion on how to better optimize it. ...
khinester's user avatar
  • 277
0 votes
1 answer
1k views

coffeescript and angular directive

I feel this is deeply inelegant, but I really want the option of classical inheritance in the future. How could this be written better. FYI animation here is from GSAP if you are curious. ...
Fresheyeball's user avatar
1 vote
3 answers
512 views

Cleanest way to close over a counter in CoffeeScript

I haven't spent too much time with CoffeeScript and am trying to have a simple counter: ...
speg's user avatar
  • 111
1 vote
1 answer
722 views

Dynamic dropdown update for site reuse

This is based (somewhat loosely) on the code written in this railscast. I'm planning to re-use it in different places throughout the site, so I made it a bit more generic rather than based on IDs. ...
Drew's user avatar
  • 113
3 votes
2 answers
811 views

Passing Context in CoffeeScript

I'm trying to migrate from JavaScript to CoffeeScript. However I'm not sure about the best way to optimize the code generated by js2coffee. Below is the original JavaScript source : ...
uyetch's user avatar
  • 133
3 votes
1 answer
375 views

Functional Sundaram's sieve

I wrote this Sundaram's sieve in Coffeescript to quickly generate prime numbers up to limit: ...
Mirzhan Irkegulov's user avatar
6 votes
1 answer
194 views

CoffeeScript implementation of A* algorithm

...
pathikrit's user avatar
  • 205
2 votes
2 answers
1k views

Simple form validation

I would really like to hear how I can improve my form validator. Next, I want to refactor it into OO and learn a testing framework like Jasmine. Some things I know I could improve: Don't make it ...
SkinnyGeek1010's user avatar
2 votes
1 answer
380 views

Refactor jquery (coffescript) code with checkboxes

I have two different set of checkboxes. With the coffescript code below I set the maximum amount of checkable items at 3. I would like to refactor this code, to be cleaner and compact, but I can't get ...
framomo86's user avatar
  • 123
4 votes
2 answers
2k views

Altering input field width

This gets every form element and calculates its width, then changes the input fields depending on the parent-form width: ...
Rockbot's user avatar
  • 143
4 votes
2 answers
11k views

CoffeeScript date formatting

...
Vinko Vrsalovic's user avatar
3 votes
1 answer
328 views

Object wrapper/parameter injection module

I made an object wrapper/parameter injector and I hope it will be useful. I made it for a project I am working on but then decided to try polishing it a bit. The use case is for wrapping objects such ...
KGZM's user avatar
  • 133
1 vote
2 answers
93 views

Is there any way to make this CoffeScript code simpler / smaller

I've just started with coffeescript, and I saw http://blog.8thlight.com/uncle-bob/2012/04/20/Why-Is-Estimating-So-Hard.html which has a little programming problem, so I figured I'd do it in ...
Keith Nicholas's user avatar
3 votes
3 answers
174 views

Can this coffeescripts method be simplified?

I'm new to coffeescripts. Can the getSum method be simplified more? Thanks ...
Kuntau's user avatar
  • 141
2 votes
1 answer
839 views

PageObject implementation (CoffeeScript, CasperJS)

I'm using CasperJS and CoffeeScript for integration testing of a hobby project. Page Objects seem to be a useful abstraction. I had two major requirements: Support for node.js style callbacks - ...
abesto's user avatar
  • 123
0 votes
1 answer
349 views

Count non-transparent pixels in a canvas

I need to count non-transparent pixels in a canvas. I am pretty sure there is a nice and elegant syntax for doing this. Note that the data returned by getImageData ...
akonsu's user avatar
  • 273
4 votes
1 answer
514 views

Project Euler question 2 in CoffeeScript

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ...
crocaduck81's user avatar
3 votes
1 answer
910 views

Memory leak in a scraper [closed]

This is a scraper written in CoffeeScript for NodeJS. It is run in an interval (set to 5 seconds here to dramtically show the leak). Somewhere this code leaks memory. I already tried nulling a few ...
Lincoln's user avatar
  • 139
4 votes
1 answer
226 views

Searching an object tree structure

I have this recursive function that searches an object tree structure: ...
Matthew Nichols's user avatar
0 votes
1 answer
160 views

Model with complex/simple properties

I have a model with a number of complex/simple properties that has a corresponding strongly typed view, that calls EditorFor to a custom editor template view for ...
asawyer's user avatar
  • 291
1 vote
2 answers
176 views

Similar but slightly different JavaScript functions

I have two very similar functions that exist mainly for syntactic sugar. ...
Toast's user avatar
  • 21
2 votes
2 answers
140 views

Writing binding providers in CoffeeScript?

In his KnockoutJs 1.3 beta post, Steve Sanderson has an example of using Binding providers ("5. Binding providers (and hence external bindings)") where he makes a comment in the JSFiddle JavaScript ...
fordareh's user avatar
  • 145
4 votes
3 answers
155 views

Adding push to array inside the class that is being pushed

I used to mostly do this: ...
Pickels's user avatar
  • 143
3 votes
1 answer
770 views

A library written in CoffeeScript

So, I wrote this small library for fast DOM building with API tailored for CoffeeScript I feel like the code overall can be made better/smaller/faster. I am also not particularly happy about a few ...
glebm's user avatar
  • 665
4 votes
3 answers
847 views

Converting a string to coordinates

I'm going through the CoffeeScript book by Trevor Burnham, and I was curious as to what the best style is for a function I was writing. In the book the author writes the function like so: ...
Acorn's user avatar
  • 285
12 votes
3 answers
4k views

Coffeescript beautification and refactoring

As much as I try, I cannot seem to get this Coffeescript code to look beautiful (I'd like to think it is possible). I have tried both Javascript and Coffeescript. Just to be clear, this code works ...
S W's user avatar
  • 131

1
2