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.
93 questions
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. ...
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 ...
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 ...
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 ...
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, ...
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 ...
4
votes
1
answer
68
views
8
votes
1
answer
472
views
Simple CoffeeScript navigation menu
I'm using simple script to handle tab menu like this:
HTML:
...
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 ...
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 ...
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 ...
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?
...
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.
...
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.
...
0
votes
1
answer
144
views
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 ...
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:
...
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.
...
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.
...
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:
...
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. ...
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 :
...
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:
...
6
votes
1
answer
194
views
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 ...
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 ...
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:
...
4
votes
2
answers
11k
views
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 ...
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 ...
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
...
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 - ...
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 ...
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.
...
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 ...
4
votes
1
answer
226
views
Searching an object tree structure
I have this recursive function that searches an object tree structure:
...
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 ...
1
vote
2
answers
176
views
Similar but slightly different JavaScript functions
I have two very similar functions that exist mainly for syntactic sugar.
...
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 ...
4
votes
3
answers
155
views
Adding push to array inside the class that is being pushed
I used to mostly do this:
...
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 ...
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:
...
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 ...