Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10799 closed defect (fixed)

Workflow macro generates invalid colors

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Milestone: 1.0
Component: ticket system Version:
Severity: minor Keywords: workflow macro
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When using the Workflow macro with more than five actions, invalid colors can be generated.

For example the above graph causes Firefox to log a warning Expected color but found '#3abb'. and use the same color twice.

The fix is simple:

  • trac/htdocs/js/workflow_graph.js

    diff -r 144933abd515 trac/htdocs/js/workflow_graph.js
    a b  
    172172  };
    173173
    174174  function hexColor(r, g, b) {
    175     return '#' +
    176       Math.floor(r).toString(16) +
    177       Math.floor(g).toString(16) +
    178       Math.floor(b).toString(16);
     175    r = (r < 16 ? '0' : '') + Math.floor(r).toString(16);
     176    g = (g < 16 ? '0' : '') + Math.floor(g).toString(16);
     177    b = (b < 16 ? '0' : '') + Math.floor(b).toString(16);
     178    return String.concat('#', r, g, b);
    179179  }
    180180
    181181  function saturatedColor(r, g, b) {

Attachments (0)

Change History (8)

comment:1 by Remy Blank, 12 years ago

If you have the fix already, feel free to apply it to 1.0dev.

comment:2 by Peter Suter, 12 years ago

Milestone: next-stable-1.0.x1.0
Resolution: fixed
Status: newclosed

OK, applied in [11196].

comment:3 by Peter Suter, 12 years ago

Owner: set to Peter Suter

comment:4 by Christian Boos, 12 years ago

Resolution: fixed
Status: closedreopened

Oops…

TypeError: Object function String() { [native code] } has no method 'concat' workflow_graph.js:178

comment:5 by Christian Boos, 12 years ago

-  return String.concat('#', r, g, b); 
+  return '#'.concat(r, g, b);

Works in Chrome at least.

comment:6 by Peter Suter, 12 years ago

Oops indeed! I'm not sure why I even switched away from +. (Apparently it's faster too.) Backed that out in [11199].

Thanks for noticing!

comment:7 by Peter Suter, 12 years ago

Resolution: fixed
Status: reopenedclosed

Hopefully that settles that. :)

comment:8 by Christian Boos, 12 years ago

Severity: normalminor

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Peter Suter to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.