how to move the dotted line from the middle of a “alt” sequence diagram - gliffy

I'm using the UML sequence diagram in gliffy for Jira and I can't seem to move the dotted line to the middle of the alt box - it stays stuck to the top and I don't see a handle for it. How do I move it to the middle?

It's really fiddly but it possible.
1) Double click the top guard condition [If] to go into text edit mode.
2) Add some carriage returns (new lines) at the end - the idea is to move the cursor down to where you want the line to go
If the line doesn't move when you insert the new lines (it's a bit flaky) then click outside the box (to save) and wait a few seconds for it to catch up.
If it still doesn't move the line, then move the shape a little to get it to redraw.
Finally, delete the shape and start again if it still won't move it.
As I said, it's a bit flaky.


HTML Element Divided in Half by Horizontal Line (at its waist)

Long-time lurker here. This is my first post (and I'm an electrical engineer, not a programmer).
I would like to have an element in HTML for which I can detect a click on its upper-half and its lower-half. Specifically, suppose I have a large numeric digit, and if you click above its "waist" it increments, and if you click below its waist it decrements. I then need to put several of these next to one another, like a "split-flap display" at a train station.
I already have all the javascript working for increment-only, but I want to make it easier to decrement instead of having to wrap all the way around with many clicks. I have so far avoided using jquery, so if you can think of an HTML-only way to do this I would love to hear about it.
I realize I will probably have to wrap two smaller containers (an upper and a lower one) into a larger container, but how do I get the text to cover the height of both internal containers? I probably want to avoid cutting a font in half and updating upper and lower separately.
This should work:
//here's the bounding rect
var bound=element.getBoundingClientRect();
var height=bound.height;
var mid=bound.bottom-(height/2);
//if we're above the middle increment, below decrement
;//we're above the middle, so put some code here that increments
;//we're below the middle, so put some code here that decrements
element is the element that you wish to apply this effect on

How to Make Canvas Text Selectable?

Any suggestion is highly appreciated.
Text selection has many components to it some visual, some non-visual.
First, make text selectable you must keep an array, of where the text is, what the text is, and what font was used. You will use this information with the Canvas function measureText.
By using measureText, with your text string, you can identify what letter the cursor should land on when you click on an image.
ctx.fillText("My String", 100, 100);
textWidth = ctx.measureText("My String").width;
You will still have to parse the font height from the "font" property,
as it is not currently included in text metrics. Canvas text is aligned
to the baseline by default.
With this information, you now have a bounding box, which you can check against.
If the cursor is inside of the bounding box, you now have the unfortunate task of deducing
which letter was intentionally selected; where the start of your cursor should be placed. This may involve calling measureText several times.
At that point you know where the cursor should go; you will need to store your
text string as a text string, in a variable, of course.
Once you have defined the start and stop points of your range, you have to draw
a selection indicator. This can be done in a new layer (a second canvas element),
or by drawing a rectangle using the XOR composition mode. It can also be done by
simply clearing and redrawing the text on top of a filled rectangle.
All told, text selection, text editing in Canvas are quite laborious to program, and it would be wise to re-use components already written, Bespin being an excellent example.
I'll edit my post should I come across other public examples. I believe that Bespin uses a grid-based selection method, possibly requiring a monospaced font. Ligatures, kerning, bi-directionality and other advanced features of font rendering require additional programming; it's a complex problem.
the text drawn in canvas elements cannot be selected, because of the nature of the canvas tag. But there are a few workarounds, like the one used in typefaceJS.
Another solution would be to add text with positioned div elements instead of useing strokeText or fillText.
If you need to have selectable text it would be a lot easier to just create a div or whatever, and position it on top of the canvas where you want the text to show.
canvas does not have any built-in mechanism for selecting text, so you would have to roll out your own text rendering and selecting code - which can be rather tricky to get right.
You may get some ideas from Bespin.
They implemented a text editor in javascript using canvas with text selection, scroll bars, cursor blinking, etc.
Source Code
I would suggest using EaselJS library, you can add each letter as a child and even add mouse events to that object, its an amazing library, go check it out!
TextInput controls are complicated
Let me begin by saying I am not an expert in text controls, but by now I'm sure that this doesn't matter, because I can help you get into the woods and out safely. These things are complicated in nature and require plenty of intuition and knowledge of how things work. However, you can inspect the code that runs in the senpai-js/senpai-stage repository here.
We should define a few things up front:
Text can be any valid unicode character. You can parse that using this regex: /^.$/u
You need to keep track of three different sorts of text editing modes: Insert, Selection, Basic (I use the SelectionState enum in my library and inspect the insertMode property on stage)
You should implement sanity checks at every turn, or you will have undefined and unexpected behavior
Most people expect text inputs to be sizable by width, so make sure you use a pattern for the innards of the text box if you plan on using a texture
mouse/touch point collision detection is complicated unless you guarantee that the text input control won't rotate
The text should scroll when it's larger than the textbox in the horizontal direction. We will refer to this as textScroll which is always a negative number
Now I will go over each function to describe it's behavior to describe exactly how a textbox control should work.
Collision (broadPhase, and narrowPhase)
Collision detection is a monster. Normalizing point movement between mouse and touch events is a complicated beast not covered in this text. Once you handle point events, you have to perform some sort of general collision detection for a rectangle. This means doing AABB collision. If the textbox sprite itself is rotated, you will have to "un-rotate" the point itself. However, we bypass this check if the mouse/touch point is already down over the textbox. This is because once you start selecting text, you want this function to always return true. Then we move to narrowPhase collision, which actually checks to see if the "un-transformed" mouse/touch point is within the padding of the textbox. If it is, or the textbox is active, we return a truthy value here.
Once we know that the mouse/touch point is within the bounds of our textbox, we change the css of the canvas to cursor: text; visually.
When we press the mouse button down over the textbox, we need to calculate where to move the caret. The caret can exist in a range from 0 to text.length inclusive. Note that this isn't exactly right because unicode characters can have a length of 2. You must keep track of each character added to your text inside an array to assert that you aren't measuring faulty unicode characters. Calculating the target index means looping over each character of the current text and appending it to a temporary string, measuring each time until the measured width is greater than the current textScroll + the measured textWidth.
Once we have garunteed that the point has gone down on top of the textbox and the starting point is set, we can start the "selection" mode. Dragging the point should move the selection from the starting caretIndex to the new calculated end index. This goes in both directions.
An example of this is shown here.
The solution for web key presses is to inspect the key property on the KeyEvent. Despite a lot of what everyone says, it's possible to test that text property by testing it against the aforementioned unicode regex. If it matches, chances are that key has actually been pressed on the keyboard. This doesn't account for key combinations like ctrl + c and ctrl + v for copy and pasting. These features are trivial and are left up to the reader to decide how to implement these.
The few exceptions are the arrow keys: "ArrowLeft", "ArrowRight" etc. These keys actually modify the state of your control, and change how it functions. It's important to remember that key events should only be handled by the currently focused control. This means you should check and make sure the control is focused during text input. This of course happens at a higher level than I have coded in my library, so this is trivial.
The next problem that needs to be solved is how each character input should modify the state of your control. The keyDown method discerns the selectionState and calls a different function based on it's state. This is not optimized pseudo-code, but is used for clarity, and is perfect for our purposes in describing the behavior.
keydown on a selection
Normal key presses replace the content of the selected text
Splice out from selectionStart, and insert the new key into the text array
if "delete" or "backspace" is pressed, splice out the selection and return the selection mode to Normal or Caret
if the "left" or "right" key is pressed, move the cursor to the beginning or the end respectively and return the selection mode to Normal unless the shift key is pressed
if the shift key is pressed, then we actually want to extend the selection further
selection start will always be at the caretIndex, and we essentially move the selection end point left or right with this key combination
if selection end returns back to the caret index, we return the selectionState to Normal again
the "home" and "end" keys work the same way, only the caret is moved to 0 and text.length indexes respectively
also note that holding down the shift key extends selection from the caretIndex once again
keydown on normal mode (caret mode)
in caret mode, we don't replace any text, just insert new characters at the current position
keydowns that match the unicode regex are inserted using the splice method
move the caret to the right after splicing the text in (check and make sure that you don't go over text length)
Backspace removes one character before the index at caretIndex - 1
Delete removes one character after the index at caretIndex
text selection applies for left and right keys while the shift key is pressed
when shift isn't pressed, left and right move the caret to the left and right respectively
the home key sets the caretIndex to 0
the end key sets the caretIndex to text.length
keyDown on insert mode
in insert mode, we replace the currently selected character at caretIndex
keydowns that match the unicode regex are inserted using the splice method
move the caret to the right after splicing the text in (check and make sure that you don't go over text length)
the backspace remove the character BEFORE the current selection
delete removes the currently selected character
the arrow keys work as expected and described in normal mode
the home and end keys work as expected and described in normal mode
updating the textbox every frame
If the textbox is focused, you should start flashing the caret to let the user know they are editing text in the textbox
when moving the caret left or right in Caret mode, you should restart the flash mechanism so that it shows exactly where they are each time the caret moves
Flash the caret about once every 30 frames, or half a second
measure how far the caret is along the text by using ctx.measureText to the caret index by slicing the text to the caret position unless the mode is Selection
It's still useful to measure how far along the text is in selection mode Selection, because we always want the end of the text selection to be visible to the user
Make sure that the caret is always visible within the visible bounds of the textbox, taking into account the current textScroll
rendering the textbox
save the context first (basic canvas)
if you are not drawing the textbox with paths, draw the left cap of the textbox, draw the middle pattern, and the right cap respectively on the first layer
use a path defined by the padding and the size of the textbox to clip out a square to prevent the text from bleeding out
translate to the x textScroll value which should be a negative number
translate to the y midline value which should be the middle of the textbox vertically
set the font property
set the text baseline to middle and fill the text by calling text.join("") on your text array
if there is a selection, or insert mode, make sure to draw a "blue" square behind the selected text and invert the font color of the selected text (this is non-trivial and left to the reader as an exercise)
Final notes
Yeah the task is monstrous, but sometimes you just want to give the world a visual novel engine, or a sprite stage with all sorts of features. Please visit the senpai-stage repo and submit a pull request if you feel like you want senpai to notice you. Good luck on your endeavors!
~devil senpai
FabricJS now has the ability to interact with objects outside the canvas element - eg this demo shows a button that is linked to an image loaded in a canvas element.
The same approach can be used in other libs such as Raphael by hooking any move event, getting the bounding box of the element and re-positioning the HTML element.
canvas is just a drawing surface. You render and the result is pixels. So, you'd need to track the positions of all text you have rendered to the canvas in a some kind of data structure which you'd process during mouse events.
A simple answer would be: either use HTML or SVG instead of canvas. Unless you really need the degree of lowlevel control canvas offers.

Avoid visual movement of word when showing sentence dynamicaly

On cocos creator, I want to show the dialog, in a way like Typed.js. Basically showing the letters as if someone is typing them.
The problem is that I have a Label of a determined width, and, when there is a word near the end of the size of the Label, it starts writing on a line, and finishes writing on another line.
I would like that word to start writing it at the start of the next line, but I don't know how to do it.
The thing that I have tried:
RichText for Cocos creator, to make the part of the sentence that stills needs to be written transparent, but RichText on cocos creator cannot be transparent.
Try to write the word before rendering it, and then check the size of the Label, to see if the dimension has changed, so I will have to set the last word on a new line, but the Label size is not updated until rendered, and I want it before rendering.
Any idea on how to accomplish this?
found a solution, and it's to first put all the words on the scene, without showing them, and then calculate the size of every word, then, calculate at witch word the sentence would break, and add a line break before that word. I don't know if it's the most optimized approach, but it works and I don't know any other way to do it.

jquery countdown/timer line script needed

I'd like to put a countdown/timer script in my page which visually warns a user how much time is left to perform a certain action (i.e. edit a post) - I'd like the user to see a line that gets smaller by the second, indicating that an action can no longer be performed when the line is not visible.
Ideally, as inputs, the script would take the number of time units remaining, the units in which time is measured, the color and initial width of the line, and whether the line should be vertical or horizontal. It would be ideal if the line could be placed so that it overlays the edge of DIV.
Does anyone have a script which fulfills most or all of the functionality specified above? Thanks.

Adding a completion point for a maze in JS

Alright so I made a maze with JS and HTML5, and it works well and all, but now I want to add a completion point (at the end of the maze) so that when it's reached, a congratulations message pops up erasing the canvas and a link to the second maze with it.
Here is the link to it (check code by doing view source):
Reference link
controls are WASD and the arrow keys.
Like this is a quick implementation.
But you do want to optimize the code.
First of all, keyboard events should be quicker.
I mean... when you press a key, you should activate a timer that triggers the key event.
The first time you press a key, you have the key delay which takes place.You don't want that in games with arrows. Take a look into that if you want to expand the functionality and optimize gameplay.
Second you must get rid of the flickerring.
Third your alignment on the maze is not 100% good.
Here you have the solution.
But there are other ways to achieve this.
you could set up an endpoint.
Once that is matched with the moving square you completed the maze.