Repository: alyssaxuu/flowy
Branch: master
Commit: e977380e3a84
Files: 9
Total size: 83.2 KB
Directory structure:
gitextract_biqyvohl/
├── .gitattributes
├── .github/
│ └── FUNDING.yml
├── LICENSE
├── README.md
├── demo/
│ ├── index.html
│ ├── main.js
│ └── styles.css
└── engine/
├── flowy.css
└── flowy.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: alyssaxuu
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2019 Alyssa X
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Flowy

<br>A javascript library to create pretty flowcharts with ease ✨
[Dribbble](https://dribbble.com/shots/8576286-Flowy-Flowchart-Engine) | [Twitter](https://twitter.com/alyssaxuu/status/1199724989353730048) | [Live demo](https://alyssax.com/x/flowy)
Flowy makes creating WebApps with flowchart functionality an incredibly simple task. Build automation software, mind mapping tools, or simple programming platforms in minutes by implementing the library into your project.
> You can support this project (and many others) through [GitHub Sponsors](https://github.com/sponsors/alyssaxuu)! ❤️
Made by [Alyssa X](https://alyssax.com)
## Table of contents
- [Features](#features)
- [Installation](#installation)
- [Running Flowy](#running-flowy)
- [Initialization](#initialization)
- [Example](#example)
- [Callbacks](#callbacks)
- [On grab](#on-grab)
- [On release](#on-release)
- [On snap](#on-snap)
- [On rearrange](#on-rearrange)
- [Methods](#methods)
- [Get the flowchart data](#get-the-flowchart-data)
- [Import the flowchart data](#import-the-flowchart-data)
- [Delete all blocks](#delete-all-blocks)
## Features
Currently, Flowy supports the following:
- [x] Responsive drag and drop
- [x] Automatic snapping
- [x] Automatic scrolling
- [x] Block rearrangement
- [x] Delete blocks
- [x] Automatic block centering
- [x] Conditional snapping
- [x] Conditional block removal
- [x] Import saved files
- [x] Mobile support
- [x] Vanilla javascript (no dependencies)
- [ ] [npm install](https://github.com/alyssaxuu/flowy/issues/10)
You can suggest new features [here](https://github.com/alyssaxuu/flowy/issues)
## Installation
Adding Flowy to your WebApp is incredibly simple:
1. Link `flowy.min.js` and `flowy.min.css` to your project. Through jsDelivr:
```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/alyssaxuu/flowy/flowy.min.css">
<script src="https://cdn.jsdelivr.net/gh/alyssaxuu/flowy/flowy.min.js"></script>
```
2. Create a canvas element that will contain the flowchart (for example, `<div id="canvas"></div>`)
3. Create the draggable blocks with the `.create-flowy` class (for example, `<div class="create-flowy">Grab me</div>`)
## Running Flowy
### Initialization
```javascript
flowy(canvas, ongrab, onrelease, onsnap, onrearrange, spacing_x, spacing_y);
```
Parameter | Type | Description
--- | --- | ---
`canvas` | *javascript DOM element* | The element that will contain the blocks
`ongrab` | *function* (optional) | Function that gets triggered when a block is dragged
`onrelease` | *function* (optional) | Function that gets triggered when a block is released
`onsnap` | *function* (optional) | Function that gets triggered when a block snaps with another one
`onrearrange` | *function* (optional) | Function that gets triggered when blocks are rearranged
`spacing_x` | *integer* (optional) | Horizontal spacing between blocks (default 20px)
`spacing_y` | *integer* (optional) | Vertical spacing between blocks (default 80px)
To define the blocks that can be dragged, you need to add the class `.create-flowy`
### Example
**HTML**
```html
<div class="create-flowy">The block to be dragged</div>
<div id="canvas"></div>
```
**Javascript**
```javascript
var spacing_x = 40;
var spacing_y = 100;
// Initialize Flowy
flowy(document.getElementById("canvas"), onGrab, onRelease, onSnap, onRearrange, spacing_x, spacing_y);
function onGrab(block){
// When the user grabs a block
}
function onRelease(){
// When the user releases a block
}
function onSnap(block, first, parent){
// When a block snaps with another one
}
function onRearrange(block, parent){
// When a block is rearranged
}
```
## Callbacks
In order to use callbacks, you need to add the functions when initializing Flowy, as explained before.
### On grab
```javascript
function onGrab(block){
// When the user grabs a block
}
```
Gets triggered when a user grabs a block with the class `create-flowy`
Parameter | Type | Description
--- | --- | ---
`block` | *javascript DOM element* | The block that has been grabbed
### On release
```javascript
function onRelease(){
// When the user lets go of a block
}
```
Gets triggered when a user lets go of a block, regardless of whether it attaches or even gets released in the canvas.
### On snap
```javascript
function onSnap(block, first, parent){
// When a block can attach to a parent
return true;
}
```
Gets triggered when a block can attach to another parent block. You can either prevent the attachment, or allow it by using `return true;`
Parameter | Type | Description
--- | --- | ---
`block` | *javascript DOM element* | The block that has been grabbed
`first` | *boolean* | If true, the block that has been dragged is the first one in the canvas
`parent` | *javascript DOM element* | The parent the block can attach to
### On rearrange
```javascript
function onRearrange(block, parent){
// When a block is rearranged
return true;
}
```
Gets triggered when blocks are rearranged and are dropped anywhere in the canvas, without a parent to attach to. You can either allow the blocks to be deleted, or prevent it and thus have them re-attach to their previous parent using `return true;`
Parameter | Type | Description
--- | --- | ---
`block` | *javascript DOM element* | The block that has been grabbed
`parent` | *javascript DOM element* | The parent the block can attach to
## Methods
### Get the flowchart data
```javascript
// As an object
flowy.output();
// As a JSON string
JSON.stringify(flowy.output());
```
The JSON object that gets outputted looks like this:
```json
{
"html": "",
"blockarr": [],
"blocks": [
{
"id": 1,
"parent": 0,
"data": [
{
"name": "blockid",
"value": "1"
}
],
"attr": [
{
"id": "block-id",
"class": "block-class"
}
]
}
]
}
```
Here's what each property means:
Key | Value type | Description
--- | --- | ---
`html` | *string* | Contains the canvas data
`blockarr` | *array* | Contains the block array generated by the library (for import purposes)
`blocks` | *array* | Contains the readable block array
`id` | *integer* | Unique value that identifies a block
`parent` | *integer* | The `id` of the parent a block is attached to (-1 means the block has no parent)
`data` | *array of objects* | An array of all the inputs within a certain block
`name` | *string* | The name attribute of the input
`value` | *string* | The value attribute of the input
`attr` | *array of objects* | Contains all the data attributes of a certain block
### Import the flowchart data
```javascript
flowy.import(output)
```
Allows you to import entire flowcharts initially exported using the previous method, `flowy.output()`
Parameter | Type | Description
--- | --- | ---
`output` | *javascript DOM element* | The data from `flowy.output()`
#### Warning
This method accepts raw HTML and does **not** sanitize it, therefore this method is vulnerable to [XSS](https://owasp.org/www-community/attacks/DOM_Based_XSS). The _only_ safe use for this method is when the input is **absolutely** trusted, if the input is _not_ to be trusted the use this method can introduce a vulnerability in your system.
### Delete all blocks
To remove all blocks at once use:
```javascript
flowy.deleteBlocks()
```
Currently there is no method to individually remove blocks. The only way to go about it is by splitting branches manually.
#
Feel free to reach out to me through email at hi@alyssax.com or [on Twitter](https://twitter.com/alyssaxuu) if you have any questions or feedback! Hope you find this useful 💜
================================================
FILE: demo/index.html
================================================
<!DOCTYPE html>
<html>
<head>
<!-- Primary Meta Tags -->
<title>Flowy - The simple flowchart engine</title>
<meta name="title" content="Flowy - The simple flowchart engine">
<meta name="description" content="Flowy is a minimal javascript library to create flowcharts. Use it for automation software, mind mapping tools, programming platforms, and more. Made by Alyssa X.">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://alyssax.com/x/flowy">
<meta property="og:title" content="Flowy - The simple flowchart engine">
<meta property="og:description" content="Flowy is a minimal javascript library to create flowcharts. Use it for automation software, mind mapping tools, programming platforms, and more. Made by Alyssa X.">
<meta property="og:image" content="https://alyssax.com/x/assets/meta.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://alyssax.com/x/flowy">
<meta property="twitter:site" content="alyssaxuu">
<meta property="twitter:title" content="Flowy - The simple flowchart engine">
<meta property="twitter:description" content="Flowy is a minimal javascript library to create flowcharts. Use it for automation software, mind mapping tools, programming platforms, and more. Made by Alyssa X.">
<meta property="twitter:image" content="https://alyssax.com/x/assets/meta.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap" rel="stylesheet">
<link href='styles.css' rel='stylesheet' type='text/css'>
<link href='flowy.min.css' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script src="flowy.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="navigation">
<div id="leftside">
<div id="details">
<div id="back"><img src="assets/arrow.svg"></div>
<div id="names">
<p id="title">Your automation pipeline</p>
<p id="subtitle">Marketing automation</p>
</div>
</div>
</div>
<div id="centerswitch">
<div id="leftswitch">Diagram view</div>
<div id="rightswitch">Code editor</div>
</div>
<div id="buttonsright">
<div id="discard">Discard</div>
<div id="publish">Publish to site</div>
</div>
</div>
<div id="leftcard">
<div id="closecard">
<img src="assets/closeleft.svg">
</div>
<p id="header">Blocks</p>
<div id="search">
<img src="assets/search.svg">
<input type="text" placeholder="Search blocks">
</div>
<div id="subnav">
<div id="triggers" class="navactive side">Triggers</div>
<div id="actions" class="navdisabled side">Actions</div>
<div id="loggers" class="navdisabled side">Loggers</div>
</div>
<div id="blocklist">
<div class="blockelem create-flowy noselect">
<input type="hidden" name='blockelemtype' class="blockelemtype" value="1">
<div class="grabme">
<img src="assets/grabme.svg">
</div>
<div class="blockin">
<div class="blockico">
<span></span>
<img src="assets/eye.svg">
</div>
<div class="blocktext">
<p class="blocktitle">New visitor</p>
<p class="blockdesc">Triggers when somebody visits a specified page</p>
</div>
</div>
</div>
<div class="blockelem create-flowy noselect">
<input type="hidden" name='blockelemtype' class="blockelemtype" value="2">
<div class="grabme">
<img src="assets/grabme.svg">
</div>
<div class="blockin">
<div class="blockico">
<span></span>
<img src="assets/action.svg">
</div>
<div class="blocktext">
<p class="blocktitle">Action is performed</p>
<p class="blockdesc">Triggers when somebody performs a specified action</p>
</div>
</div>
</div>
<div class="blockelem create-flowy noselect">
<input type="hidden" name='blockelemtype' class="blockelemtype" value="3">
<div class="grabme">
<img src="assets/grabme.svg">
</div>
<div class="blockin">
<div class="blockico">
<span></span>
<img src="assets/time.svg">
</div>
<div class="blocktext">
<p class="blocktitle">Time has passed</p>
<p class="blockdesc">Triggers after a specified amount of time</p>
</div>
</div>
</div>
<div class="blockelem create-flowy noselect">
<input type="hidden" name='blockelemtype' class="blockelemtype" value="4">
<div class="grabme">
<img src="assets/grabme.svg">
</div>
<div class="blockin">
<div class="blockico">
<span></span>
<img src="assets/error.svg">
</div>
<div class="blocktext">
<p class="blocktitle">Error prompt</p>
<p class="blockdesc">Triggers when a specified error happens</p>
</div>
</div>
</div>
</div>
<div id="footer">
<a href="https://github.com/alyssaxuu/flowy/" target="_blank">GitHub</a>
<span>·</span>
<a href="https://twitter.com/alyssaxuu/status/1199724989353730048" target="_blank">Twitter</a>
<span>·</span>
<a href="https://alyssax.com" target="_blank"><p>Made with</p><img src="assets/heart.svg"><p>by</p> Alyssa X</a>
</div>
</div>
<div id="propwrap">
<div id="properties">
<div id="close">
<img src="assets/close.svg">
</div>
<p id="header2">Properties</p>
<div id="propswitch">
<div id="dataprop">Data</div>
<div id="alertprop">Alerts</div>
<div id="logsprop">Logs</div>
</div>
<div id="proplist">
<p class="inputlabel">Select database</p>
<div class="dropme">Database 1 <img src="assets/dropdown.svg"></div>
<p class="inputlabel">Check properties</p>
<div class="dropme">All<img src="assets/dropdown.svg"></div>
<div class="checkus"><img src="assets/checkon.svg"><p>Log on successful performance</p></div>
<div class="checkus"><img src="assets/checkoff.svg"><p>Give priority to this block</p></div>
</div>
<div id="divisionthing"></div>
<div id="removeblock">Delete blocks</div>
</div>
</div>
<div id="canvas">
</div>
</body>
</html>
================================================
FILE: demo/main.js
================================================
document.addEventListener("DOMContentLoaded", function(){
var rightcard = false;
var tempblock;
var tempblock2;
document.getElementById("blocklist").innerHTML = '<div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="1"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/eye.svg"></div><div class="blocktext"> <p class="blocktitle">New visitor</p><p class="blockdesc">Triggers when somebody visits a specified page</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="2"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/action.svg"></div><div class="blocktext"> <p class="blocktitle">Action is performed</p><p class="blockdesc">Triggers when somebody performs a specified action</p></div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="3"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/time.svg"></div><div class="blocktext"> <p class="blocktitle">Time has passed</p><p class="blockdesc">Triggers after a specified amount of time</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="4"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/error.svg"></div><div class="blocktext"> <p class="blocktitle">Error prompt</p><p class="blockdesc">Triggers when a specified error happens</p> </div></div></div>';
flowy(document.getElementById("canvas"), drag, release, snapping);
function addEventListenerMulti(type, listener, capture, selector) {
var nodes = document.querySelectorAll(selector);
for (var i = 0; i < nodes.length; i++) {
nodes[i].addEventListener(type, listener, capture);
}
}
function snapping(drag, first) {
var grab = drag.querySelector(".grabme");
grab.parentNode.removeChild(grab);
var blockin = drag.querySelector(".blockin");
blockin.parentNode.removeChild(blockin);
if (drag.querySelector(".blockelemtype").value == "1") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/eyeblue.svg'><p class='blockyname'>New visitor</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>When a <span>new visitor</span> goes to <span>Site 1</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "2") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/actionblue.svg'><p class='blockyname'>Action is performed</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>When <span>Action 1</span> is performed</div>";
} else if (drag.querySelector(".blockelemtype").value == "3") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/timeblue.svg'><p class='blockyname'>Time has passed</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>When <span>10 seconds</span> have passed</div>";
} else if (drag.querySelector(".blockelemtype").value == "4") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/errorblue.svg'><p class='blockyname'>Error prompt</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>When <span>Error 1</span> is triggered</div>";
} else if (drag.querySelector(".blockelemtype").value == "5") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/databaseorange.svg'><p class='blockyname'>New database entry</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Add <span>Data object</span> to <span>Database 1</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "6") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/databaseorange.svg'><p class='blockyname'>Update database</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Update <span>Database 1</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "7") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/actionorange.svg'><p class='blockyname'>Perform an action</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Perform <span>Action 1</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "8") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/twitterorange.svg'><p class='blockyname'>Make a tweet</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Tweet <span>Query 1</span> with the account <span>@alyssaxuu</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "9") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/logred.svg'><p class='blockyname'>Add new log entry</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Add new <span>success</span> log entry</div>";
} else if (drag.querySelector(".blockelemtype").value == "10") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/logred.svg'><p class='blockyname'>Update logs</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Edit <span>Log Entry 1</span></div>";
} else if (drag.querySelector(".blockelemtype").value == "11") {
drag.innerHTML += "<div class='blockyleft'><img src='assets/errorred.svg'><p class='blockyname'>Prompt an error</p></div><div class='blockyright'><img src='assets/more.svg'></div><div class='blockydiv'></div><div class='blockyinfo'>Trigger <span>Error 1</span></div>";
}
return true;
}
function drag(block) {
block.classList.add("blockdisabled");
tempblock2 = block;
}
function release() {
if (tempblock2) {
tempblock2.classList.remove("blockdisabled");
}
}
var disabledClick = function(){
document.querySelector(".navactive").classList.add("navdisabled");
document.querySelector(".navactive").classList.remove("navactive");
this.classList.add("navactive");
this.classList.remove("navdisabled");
if (this.getAttribute("id") == "triggers") {
document.getElementById("blocklist").innerHTML = '<div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="1"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/eye.svg"></div><div class="blocktext"> <p class="blocktitle">New visitor</p><p class="blockdesc">Triggers when somebody visits a specified page</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="2"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/action.svg"></div><div class="blocktext"> <p class="blocktitle">Action is performed</p><p class="blockdesc">Triggers when somebody performs a specified action</p></div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="3"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/time.svg"></div><div class="blocktext"> <p class="blocktitle">Time has passed</p><p class="blockdesc">Triggers after a specified amount of time</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="4"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/error.svg"></div><div class="blocktext"> <p class="blocktitle">Error prompt</p><p class="blockdesc">Triggers when a specified error happens</p> </div></div></div>';
} else if (this.getAttribute("id") == "actions") {
document.getElementById("blocklist").innerHTML = '<div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="5"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/database.svg"></div><div class="blocktext"> <p class="blocktitle">New database entry</p><p class="blockdesc">Adds a new entry to a specified database</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="6"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/database.svg"></div><div class="blocktext"> <p class="blocktitle">Update database</p><p class="blockdesc">Edits and deletes database entries and properties</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="7"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/action.svg"></div><div class="blocktext"> <p class="blocktitle">Perform an action</p><p class="blockdesc">Performs or edits a specified action</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="8"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/twitter.svg"></div><div class="blocktext"> <p class="blocktitle">Make a tweet</p><p class="blockdesc">Makes a tweet with a specified query</p> </div></div></div>';
} else if (this.getAttribute("id") == "loggers") {
document.getElementById("blocklist").innerHTML = '<div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="9"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/log.svg"></div><div class="blocktext"> <p class="blocktitle">Add new log entry</p><p class="blockdesc">Adds a new log entry to this project</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="10"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/log.svg"></div><div class="blocktext"> <p class="blocktitle">Update logs</p><p class="blockdesc">Edits and deletes log entries in this project</p> </div></div></div><div class="blockelem create-flowy noselect"><input type="hidden" name="blockelemtype" class="blockelemtype" value="11"><div class="grabme"><img src="assets/grabme.svg"></div><div class="blockin"> <div class="blockico"><span></span><img src="assets/error.svg"></div><div class="blocktext"> <p class="blocktitle">Prompt an error</p><p class="blockdesc">Triggers a specified error</p> </div></div></div>';
}
}
addEventListenerMulti("click", disabledClick, false, ".side");
document.getElementById("close").addEventListener("click", function(){
if (rightcard) {
rightcard = false;
document.getElementById("properties").classList.remove("expanded");
setTimeout(function(){
document.getElementById("propwrap").classList.remove("itson");
}, 300);
tempblock.classList.remove("selectedblock");
}
});
document.getElementById("removeblock").addEventListener("click", function(){
flowy.deleteBlocks();
});
var aclick = false;
var noinfo = false;
var beginTouch = function (event) {
aclick = true;
noinfo = false;
if (event.target.closest(".create-flowy")) {
noinfo = true;
}
}
var checkTouch = function (event) {
aclick = false;
}
var doneTouch = function (event) {
if (event.type === "mouseup" && aclick && !noinfo) {
if (!rightcard && event.target.closest(".block") && !event.target.closest(".block").classList.contains("dragging")) {
tempblock = event.target.closest(".block");
rightcard = true;
document.getElementById("properties").classList.add("expanded");
document.getElementById("propwrap").classList.add("itson");
tempblock.classList.add("selectedblock");
}
}
}
addEventListener("mousedown", beginTouch, false);
addEventListener("mousemove", checkTouch, false);
addEventListener("mouseup", doneTouch, false);
addEventListenerMulti("touchstart", beginTouch, false, ".block");
});
================================================
FILE: demo/styles.css
================================================
body, html {
margin: 0px;
padding: 0px;
overflow: hidden;
background-image: url(assets/tile.png);
background-repeat: repeat;
background-size: 30px 30px;
background-color: #FBFBFB;
height: 100%;
}
#navigation {
height: 71px;
background-color: #FFF;
border: 1px solid #E8E8EF;
width: 100%;
display: table;
box-sizing: border-box;
position: fixed;
top: 0;
z-index: 9
}
#back {
width: 40px;
height: 40px;
border-radius: 100px;
background-color: #F1F4FC;
text-align: center;
display: inline-block;
vertical-align: top;
margin-top: 12px;
margin-right: 10px
}
#back img {
margin-top: 13px;
}
#names {
display: inline-block;
vertical-align: top;
}
#title {
font-family: Roboto;
font-weight: 500;
font-size: 16px;
color: #393C44;
margin-bottom: 0px;
}
#subtitle {
font-family: Roboto;
color: #808292;
font-size: 14px;
margin-top: 5px;
}
#leftside {
display: inline-block;
vertical-align: middle;
margin-left: 20px;
}
#centerswitch {
position: absolute;
width: 222px;
left: 50%;
margin-left: -111px;
top: 15px;
}
#leftswitch {
border: 1px solid #E8E8EF;
background-color: #FBFBFB;
width: 111px;
height: 39px;
line-height: 39px;
border-radius: 5px 0px 0px 5px;
font-family: Roboto;
color: #393C44;
display: inline-block;
font-size: 14px;
text-align: center;
}
#rightswitch {
font-family: Roboto;
color: #808292;
border-radius: 0px 5px 5px 0px;
border: 1px solid #E8E8EF;
height: 39px;
width: 102px;
display: inline-block;
font-size: 14px;
line-height: 39px;
text-align: center;
margin-left: -5px;
}
#discard {
font-family: Roboto;
font-weight: 500;
font-size: 14px;
color: #A6A6B3;
width: 95px;
height: 38px;
border: 1px solid #E8E8EF;
border-radius: 5px;
text-align: center;
line-height: 38px;
display: inline-block;
vertical-align: top;
transition: all .2s cubic-bezier(.05,.03,.35,1);
}
#discard:hover {
cursor: pointer;
opacity: .7;
}
#publish {
font-family: Roboto;
font-weight: 500;
font-size: 14px;
color: #FFF;
background-color: #217CE8;
border-radius: 5px;
width: 143px;
height: 38px;
margin-left: 10px;
display: inline-block;
vertical-align: top;
text-align: center;
line-height: 38px;
margin-right: 20px;
transition: all .2s cubic-bezier(.05,.03,.35,1);
}
#publish:hover {
cursor: pointer;
opacity: .7;
}
#buttonsright {
float: right;
margin-top: 15px;
}
#leftcard {
width: 363px;
background-color: #FFF;
border: 1px solid #E8E8EF;
box-sizing: border-box;
padding-top: 85px;
padding-left: 20px;
height: 100%;
position: absolute;
z-index: 2;
}
#search input {
width: 318px;
height: 40px;
background-color: #FFF;
border: 1px solid #E8E8EF;
box-sizing: border-box;
box-shadow: 0px 2px 8px rgba(34,34,87,0.05);
border-radius: 5px;
text-indent: 35px;
font-family: Roboto;
font-size: 16px;
}
::-webkit-input-placeholder { /* Edge */
color: #C9C9D5;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: #C9C9D5
}
::placeholder {
color: #C9C9D5;
}
#search img {
position: absolute;
margin-top: 10px;
width: 18px;
margin-left: 12px;
}
#header {
font-size: 20px;
font-family: Roboto;
font-weight: bold;
color: #393C44;
}
#subnav {
border-bottom: 1px solid #E8E8EF;
width: calc(100% + 20px);
margin-left: -20px;
margin-top: 10px;
}
.navdisabled {
transition: all .3s cubic-bezier(.05,.03,.35,1);
}
.navdisabled:hover {
cursor: pointer;
opacity: .5;
}
.navactive {
color: #393C44!important;
}
#triggers {
margin-left: 20px;
font-family: Roboto;
font-weight: 500;
font-size: 14px;
text-align: center;
color: #808292;
width: calc(88% / 3);
height: 48px;
line-height: 48px;
display: inline-block;
float: left;
}
.navactive:after {
display: block;
content: "";
width: 100%;
height: 4px;
background-color: #217CE8;
margin-top: -4px;
}
#actions {
display: inline-block;
font-family: Roboto;
font-weight: 500;
color: #808292;
font-size: 14px;
height: 48px;
line-height: 48px;
width: calc(88% / 3);
text-align: center;
float: left;
}
#loggers {
width: calc(88% / 3);
display: inline-block;
font-family: Roboto;
font-weight: 500;
color: #808292;
font-size: 14px;
height: 48px;
line-height: 48px;
text-align: center;
}
#footer {
position: absolute;
left: 0;
padding-left: 20px;
line-height: 40px;
bottom: 0;
width: 362px;
border: 1px solid #E8E8EF;
height: 67px;
box-sizing: border-box;
background-color: #FFF;
font-family: Roboto;
font-size: 14px;
}
#footer a {
text-decoration: none;
color: #393C44;
transition: all .2s cubic-bezier(.05,.03,.35,1);
}
#footer a:hover {
opacity: .5;
}
#footer span {
color: #808292;
}
#footer p {
display: inline-block;
color: #808292;
}
#footer img {
margin-left: 5px;
margin-right: 5px;
}
.blockelem:first-child {
margin-top: 20px
}
.blockelem {
padding-top: 10px;
width: 318px;
border: 1px solid transparent;
transition-property: box-shadow, height;
transition-duration: .2s;
transition-timing-function: cubic-bezier(.05,.03,.35,1);
border-radius: 5px;
box-shadow: 0px 0px 30px rgba(22, 33, 74, 0);
box-sizing: border-box;
}
.blockelem:hover {
box-shadow: 0px 4px 30px rgba(22, 33, 74, 0.08);
border-radius: 5px;
background-color: #FFF;
cursor: pointer;
}
.grabme, .blockico {
display: inline-block;
}
.grabme {
margin-top: 10px;
margin-left: 10px;
margin-bottom: -14px;
width: 15px;
}
#blocklist {
height: calc(100% - 220px);
overflow: auto;
}
#proplist {
height: calc(100% - 305px);
overflow: auto;
margin-top: -30px;
padding-top: 30px;
}
.blockin {
display: inline-block;
vertical-align: top;
margin-left: 12px;
}
.blockico {
width: 36px;
height: 36px;
background-color: #F1F4FC;
border-radius: 5px;
text-align: center;
white-space: nowrap;
}
.blockico span {
height: 100%;
width: 0px;
display: inline-block;
vertical-align: middle;
}
.blockico img {
vertical-align: middle;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
.blocktext {
display: inline-block;
width: 220px;
vertical-align: top;
margin-left: 12px
}
.blocktitle {
margin: 0px!important;
padding: 0px!important;
font-family: Roboto;
font-weight: 500;
font-size: 16px;
color: #393C44;
}
.blockdesc {
margin-top: 5px;
font-family: Roboto;
color: #808292;
font-size: 14px;
line-height: 21px;
}
.blockdisabled {
background-color: #F0F2F9;
opacity: .5;
}
#closecard {
position: absolute;
margin-left: 340px;
background-color: #FFF;
border-radius: 0px 5px 5px 0px;
border-bottom: 1px solid #E8E8EF;
border-right: 1px solid #E8E8EF;
border-top: 1px solid #E8E8EF;
width: 53px;
height: 53px;
text-align: center;
z-index: 10;
}
#closecard img {
margin-top: 15px
}
#canvas {
position: absolute;
width: calc(100% - 361px);
height: calc(100% - 71px);
top: 71px;
left: 361px;
z-index: 0;
overflow: auto;
}
#propwrap {
position: absolute;
right: 0;
top: 0;
width: 311px;
height: 100%;
padding-left: 20px;
overflow: hidden;
z-index: -2;
}
#properties {
position: absolute;
height: 100%;
width: 311px;
background-color: #FFF;
right: -150px;
opacity: 0;
z-index: 2;
top: 0px;
box-shadow: -4px 0px 40px rgba(26, 26, 73, 0);
padding-left: 20px;
transition: all .25s cubic-bezier(.05,.03,.35,1);
}
.itson {
z-index: 2!important;
}
.expanded {
right: 0!important;
opacity: 1!important;
box-shadow: -4px 0px 40px rgba(26, 26, 73, 0.05);
z-index: 2;
}
#header2 {
font-size: 20px;
font-family: Roboto;
font-weight: bold;
color: #393C44;
margin-top: 101px;
}
#close {
margin-top: 100px;
position: absolute;
right: 20px;
z-index: 9999;
transition: all .25s cubic-bezier(.05,.03,.35,1);
}
#close:hover {
cursor: pointer;
opacity: .7;
}
#propswitch {
border-bottom: 1px solid #E8E8EF;
width: 331px;
margin-top: 10px;
margin-left: -20px;
margin-bottom: 30px;
}
#dataprop {
font-family: Roboto;
font-weight: 500;
font-size: 14px;
text-align: center;
color: #393C44;
width: calc(88% / 3);
height: 48px;
line-height: 48px;
display: inline-block;
float: left;
margin-left: 20px;
}
#dataprop:after {
display: block;
content: "";
width: 100%;
height: 4px;
background-color: #217CE8;
margin-top: -4px;
}
#alertprop {
display: inline-block;
font-family: Roboto;
font-weight: 500;
color: #808292;
font-size: 14px;
height: 48px;
line-height: 48px;
width: calc(88% / 3);
text-align: center;
float: left;
}
#logsprop {
width: calc(88% / 3);
display: inline-block;
font-family: Roboto;
font-weight: 500;
color: #808292;
font-size: 14px;
height: 48px;
line-height: 48px;
text-align: center;
}
.inputlabel {
font-family: Roboto;
font-size: 14px;
color: #253134;
}
.dropme {
background-color: #FFF;
border-radius: 5px;
border: 1px solid #E8E8EF;
box-shadow: 0px 2px 8px rgba(34, 34, 87, 0.05);
font-family: Roboto;
font-size: 14px;
color: #253134;
text-indent: 20px;
height: 40px;
line-height: 40px;
width: 287px;
margin-bottom: 25px;
}
.dropme img {
margin-top: 17px;
float: right;
margin-right: 15px;
}
.checkus {
margin-bottom: 10px;
}
.checkus img {
display: inline-block;
vertical-align: middle;
}
.checkus p {
display: inline-block;
font-family: Roboto;
font-size: 14px;
vertical-align: middle;
margin-left: 10px;
}
#divisionthing {
height: 1px;
width: 100%;
background-color: #E8E8EF;
position: absolute;
right: 0px;
bottom: 80;
}
#removeblock {
border-radius: 5px;
position: absolute;
bottom: 20px;
font-family: Roboto;
font-size: 14px;
text-align: center;
width: 287px;
height: 38px;
line-height: 38px;
color: #253134;
border: 1px solid #E8E8EF;
transition: all .3s cubic-bezier(.05,.03,.35,1);
}
#removeblock:hover {
cursor: pointer;
opacity: .5;
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Opera and Firefox */
}
.blockyname {
font-family: Roboto;
font-weight: 500;
color: #253134;
display: inline-block;
vertical-align: middle;
margin-left: 8px;
font-size: 16px;
}
.blockyleft img {
display: inline-block;
vertical-align: middle;
}
.blockyright {
display: inline-block;
float: right;
vertical-align: middle;
margin-right: 20px;
margin-top: 10px;
width: 28px;
height: 28px;
border-radius: 5px;
text-align: center;
background-color: #FFF;
transition: all .3s cubic-bezier(.05,.03,.35,1);
z-index: 10;
}
.blockyright:hover {
background-color: #F1F4FC;
cursor: pointer;
}
.blockyright img {
margin-top: 12px;
}
.blockyleft {
display: inline-block;
margin-left: 20px;
}
.blockydiv {
width: 100%;
height: 1px;
background-color: #E9E9EF;
}
.blockyinfo {
font-family: Roboto;
font-size: 14px;
color: #808292;
margin-top: 15px;
text-indent: 20px;
margin-bottom: 20px;
}
.blockyinfo span {
color: #253134;
font-weight: 500;
display: inline-block;
border-bottom: 1px solid #D3DCEA;
line-height: 20px;
text-indent: 0px;
}
.block {
background-color: #FFF;
margin-top: 0px!important;
box-shadow: 0px 4px 30px rgba(22, 33, 74, 0.05);
}
.selectedblock {
border: 2px solid #217CE8;
box-shadow: 0px 4px 30px rgba(22, 33, 74, 0.08);
}
@media only screen and (max-width: 832px) {
#centerswitch {
display: none;
}
}
@media only screen and (max-width: 560px) {
#names {
display: none;
}
}
================================================
FILE: engine/flowy.css
================================================
.dragging{z-index:111!important}.block{position:absolute;z-index:9}.indicator{width:12px;height:12px;border-radius:60px;background-color:#217ce8;margin-top:-5px;opacity:1;transition:all .3s cubic-bezier(.05,.03,.35,1);transform:scale(1);position:absolute;z-index:2}.invisible{opacity:0!important;transform:scale(0)}.indicator:after{content:"";display:block;width:12px;height:12px;background-color:#217ce8;transform:scale(1.7);opacity:.2;border-radius:60px}.arrowblock{position:absolute;width:100%;overflow:visible;pointer-events:none}.arrowblock svg{width: -webkit-fill-available;overflow: visible;}
================================================
FILE: engine/flowy.js
================================================
var flowy = function(canvas, grab, release, snapping, rearrange, spacing_x, spacing_y) {
if (!grab) {
grab = function() {};
}
if (!release) {
release = function() {};
}
if (!snapping) {
snapping = function() {
return true;
}
}
if (!rearrange) {
rearrange = function() {
return false;
}
}
if (!spacing_x) {
spacing_x = 20;
}
if (!spacing_y) {
spacing_y = 80;
}
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
var el = this;
do {
if (Element.prototype.matches.call(el, s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
var loaded = false;
flowy.load = function() {
if (!loaded)
loaded = true;
else
return;
var blocks = [];
var blockstemp = [];
var canvas_div = canvas;
var absx = 0;
var absy = 0;
if (window.getComputedStyle(canvas_div).position == "absolute" || window.getComputedStyle(canvas_div).position == "fixed") {
absx = canvas_div.getBoundingClientRect().left;
absy = canvas_div.getBoundingClientRect().top;
}
var active = false;
var paddingx = spacing_x;
var paddingy = spacing_y;
var offsetleft = 0;
var rearrange = false;
var drag, dragx, dragy, original;
var mouse_x, mouse_y;
var dragblock = false;
var prevblock = 0;
var el = document.createElement("DIV");
el.classList.add('indicator');
el.classList.add('invisible');
canvas_div.appendChild(el);
flowy.import = function(output) {
canvas_div.innerHTML = output.html;
for (var a = 0; a < output.blockarr.length; a++) {
blocks.push({
childwidth: parseFloat(output.blockarr[a].childwidth),
parent: parseFloat(output.blockarr[a].parent),
id: parseFloat(output.blockarr[a].id),
x: parseFloat(output.blockarr[a].x),
y: parseFloat(output.blockarr[a].y),
width: parseFloat(output.blockarr[a].width),
height: parseFloat(output.blockarr[a].height)
})
}
if (blocks.length > 1) {
rearrangeMe();
checkOffset();
}
}
flowy.output = function() {
var html_ser = canvas_div.innerHTML;
var json_data = {
html: html_ser,
blockarr: blocks,
blocks: []
};
if (blocks.length > 0) {
for (var i = 0; i < blocks.length; i++) {
json_data.blocks.push({
id: blocks[i].id,
parent: blocks[i].parent,
data: [],
attr: []
});
var blockParent = document.querySelector(".blockid[value='" + blocks[i].id + "']").parentNode;
blockParent.querySelectorAll("input").forEach(function(block) {
var json_name = block.getAttribute("name");
var json_value = block.value;
json_data.blocks[i].data.push({
name: json_name,
value: json_value
});
});
Array.prototype.slice.call(blockParent.attributes).forEach(function(attribute) {
var jsonobj = {};
jsonobj[attribute.name] = attribute.value;
json_data.blocks[i].attr.push(jsonobj);
});
}
return json_data;
}
}
flowy.deleteBlocks = function() {
blocks = [];
canvas_div.innerHTML = "<div class='indicator invisible'></div>";
}
flowy.beginDrag = function(event) {
if (window.getComputedStyle(canvas_div).position == "absolute" || window.getComputedStyle(canvas_div).position == "fixed") {
absx = canvas_div.getBoundingClientRect().left;
absy = canvas_div.getBoundingClientRect().top;
}
if (event.targetTouches) {
mouse_x = event.changedTouches[0].clientX;
mouse_y = event.changedTouches[0].clientY;
} else {
mouse_x = event.clientX;
mouse_y = event.clientY;
}
if (event.which != 3 && event.target.closest(".create-flowy")) {
original = event.target.closest(".create-flowy");
var newNode = event.target.closest(".create-flowy").cloneNode(true);
event.target.closest(".create-flowy").classList.add("dragnow");
newNode.classList.add("block");
newNode.classList.remove("create-flowy");
if (blocks.length === 0) {
newNode.innerHTML += "<input type='hidden' name='blockid' class='blockid' value='" + blocks.length + "'>";
document.body.appendChild(newNode);
drag = document.querySelector(".blockid[value='" + blocks.length + "']").parentNode;
} else {
newNode.innerHTML += "<input type='hidden' name='blockid' class='blockid' value='" + (Math.max.apply(Math, blocks.map(a => a.id)) + 1) + "'>";
document.body.appendChild(newNode);
drag = document.querySelector(".blockid[value='" + (parseInt(Math.max.apply(Math, blocks.map(a => a.id))) + 1) + "']").parentNode;
}
blockGrabbed(event.target.closest(".create-flowy"));
drag.classList.add("dragging");
active = true;
dragx = mouse_x - (event.target.closest(".create-flowy").getBoundingClientRect().left);
dragy = mouse_y - (event.target.closest(".create-flowy").getBoundingClientRect().top);
drag.style.left = mouse_x - dragx + "px";
drag.style.top = mouse_y - dragy + "px";
}
}
flowy.endDrag = function(event) {
if (event.which != 3 && (active || rearrange)) {
dragblock = false;
blockReleased();
if (!document.querySelector(".indicator").classList.contains("invisible")) {
document.querySelector(".indicator").classList.add("invisible");
}
if (active) {
original.classList.remove("dragnow");
drag.classList.remove("dragging");
}
if (parseInt(drag.querySelector(".blockid").value) === 0 && rearrange) {
firstBlock("rearrange")
} else if (active && blocks.length == 0 && (drag.getBoundingClientRect().top + window.scrollY) > (canvas_div.getBoundingClientRect().top + window.scrollY) && (drag.getBoundingClientRect().left + window.scrollX) > (canvas_div.getBoundingClientRect().left + window.scrollX)) {
firstBlock("drop");
} else if (active && blocks.length == 0) {
removeSelection();
} else if (active) {
var blocko = blocks.map(a => a.id);
for (var i = 0; i < blocks.length; i++) {
if (checkAttach(blocko[i])) {
active = false;
if (blockSnap(drag, false, document.querySelector(".blockid[value='" + blocko[i] + "']").parentNode)) {
snap(drag, i, blocko);
} else {
active = false;
removeSelection();
}
break;
} else if (i == blocks.length - 1) {
active = false;
removeSelection();
}
}
} else if (rearrange) {
var blocko = blocks.map(a => a.id);
for (var i = 0; i < blocks.length; i++) {
if (checkAttach(blocko[i])) {
active = false;
drag.classList.remove("dragging");
snap(drag, i, blocko);
break;
} else if (i == blocks.length - 1) {
if (beforeDelete(drag, blocks.filter(id => id.id == blocko[i])[0])) {
active = false;
drag.classList.remove("dragging");
snap(drag, blocko.indexOf(prevblock), blocko);
break;
} else {
rearrange = false;
blockstemp = [];
active = false;
removeSelection();
break;
}
}
}
}
}
}
function checkAttach(id) {
const xpos = (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left;
const ypos = (drag.getBoundingClientRect().top + window.scrollY) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top;
if (xpos >= blocks.filter(a => a.id == id)[0].x - (blocks.filter(a => a.id == id)[0].width / 2) - paddingx && xpos <= blocks.filter(a => a.id == id)[0].x + (blocks.filter(a => a.id == id)[0].width / 2) + paddingx && ypos >= blocks.filter(a => a.id == id)[0].y - (blocks.filter(a => a.id == id)[0].height / 2) && ypos <= blocks.filter(a => a.id == id)[0].y + blocks.filter(a => a.id == id)[0].height) {
return true;
} else {
return false;
}
}
function removeSelection() {
canvas_div.appendChild(document.querySelector(".indicator"));
drag.parentNode.removeChild(drag);
}
function firstBlock(type) {
if (type == "drop") {
blockSnap(drag, true, undefined);
active = false;
drag.style.top = (drag.getBoundingClientRect().top + window.scrollY) - (absy + window.scrollY) + canvas_div.scrollTop + "px";
drag.style.left = (drag.getBoundingClientRect().left + window.scrollX) - (absx + window.scrollX) + canvas_div.scrollLeft + "px";
canvas_div.appendChild(drag);
blocks.push({
parent: -1,
childwidth: 0,
id: parseInt(drag.querySelector(".blockid").value),
x: (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left,
y: (drag.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(drag).height) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top,
width: parseInt(window.getComputedStyle(drag).width),
height: parseInt(window.getComputedStyle(drag).height)
});
} else if (type == "rearrange") {
drag.classList.remove("dragging");
rearrange = false;
for (var w = 0; w < blockstemp.length; w++) {
if (blockstemp[w].id != parseInt(drag.querySelector(".blockid").value)) {
const blockParent = document.querySelector(".blockid[value='" + blockstemp[w].id + "']").parentNode;
const arrowParent = document.querySelector(".arrowid[value='" + blockstemp[w].id + "']").parentNode;
blockParent.style.left = (blockParent.getBoundingClientRect().left + window.scrollX) - (window.scrollX) + canvas_div.scrollLeft - 1 - absx + "px";
blockParent.style.top = (blockParent.getBoundingClientRect().top + window.scrollY) - (window.scrollY) + canvas_div.scrollTop - absy - 1 + "px";
arrowParent.style.left = (arrowParent.getBoundingClientRect().left + window.scrollX) - (window.scrollX) + canvas_div.scrollLeft - absx - 1 + "px";
arrowParent.style.top = (arrowParent.getBoundingClientRect().top + window.scrollY) + canvas_div.scrollTop - 1 - absy + "px";
canvas_div.appendChild(blockParent);
canvas_div.appendChild(arrowParent);
blockstemp[w].x = (blockParent.getBoundingClientRect().left + window.scrollX) + (parseInt(blockParent.offsetWidth) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left - 1;
blockstemp[w].y = (blockParent.getBoundingClientRect().top + window.scrollY) + (parseInt(blockParent.offsetHeight) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top - 1;
}
}
blockstemp.filter(a => a.id == 0)[0].x = (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left;
blockstemp.filter(a => a.id == 0)[0].y = (drag.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(drag).height) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top;
blocks = blocks.concat(blockstemp);
blockstemp = [];
}
}
function drawArrow(arrow, x, y, id) {
if (x < 0) {
canvas_div.innerHTML += '<div class="arrowblock"><input type="hidden" class="arrowid" value="' + drag.querySelector(".blockid").value + '"><svg preserveaspectratio="none" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M' + (blocks.filter(a => a.id == id)[0].x - arrow.x + 5) + ' 0L' + (blocks.filter(a => a.id == id)[0].x - arrow.x + 5) + ' ' + (paddingy / 2) + 'L5 ' + (paddingy / 2) + 'L5 ' + y + '" stroke="#C5CCD0" stroke-width="2px"/><path d="M0 ' + (y - 5) + 'H10L5 ' + y + 'L0 ' + (y - 5) + 'Z" fill="#C5CCD0"/></svg></div>';
document.querySelector('.arrowid[value="' + drag.querySelector(".blockid").value + '"]').parentNode.style.left = (arrow.x - 5) - (absx + window.scrollX) + canvas_div.scrollLeft + canvas_div.getBoundingClientRect().left + "px";
} else {
canvas_div.innerHTML += '<div class="arrowblock"><input type="hidden" class="arrowid" value="' + drag.querySelector(".blockid").value + '"><svg preserveaspectratio="none" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 0L20 ' + (paddingy / 2) + 'L' + (x) + ' ' + (paddingy / 2) + 'L' + x + ' ' + y + '" stroke="#C5CCD0" stroke-width="2px"/><path d="M' + (x - 5) + ' ' + (y - 5) + 'H' + (x + 5) + 'L' + x + ' ' + y + 'L' + (x - 5) + ' ' + (y - 5) + 'Z" fill="#C5CCD0"/></svg></div>';
document.querySelector('.arrowid[value="' + parseInt(drag.querySelector(".blockid").value) + '"]').parentNode.style.left = blocks.filter(a => a.id == id)[0].x - 20 - (absx + window.scrollX) + canvas_div.scrollLeft + canvas_div.getBoundingClientRect().left + "px";
}
document.querySelector('.arrowid[value="' + parseInt(drag.querySelector(".blockid").value) + '"]').parentNode.style.top = blocks.filter(a => a.id == id)[0].y + (blocks.filter(a => a.id == id)[0].height / 2) + canvas_div.getBoundingClientRect().top - absy + "px";
}
function updateArrow(arrow, x, y, children) {
if (x < 0) {
document.querySelector('.arrowid[value="' + children.id + '"]').parentNode.style.left = (arrow.x - 5) - (absx + window.scrollX) + canvas_div.getBoundingClientRect().left + "px";
document.querySelector('.arrowid[value="' + children.id + '"]').parentNode.innerHTML = '<input type="hidden" class="arrowid" value="' + children.id + '"><svg preserveaspectratio="none" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M' + (blocks.filter(id => id.id == children.parent)[0].x - arrow.x + 5) + ' 0L' + (blocks.filter(id => id.id == children.parent)[0].x - arrow.x + 5) + ' ' + (paddingy / 2) + 'L5 ' + (paddingy / 2) + 'L5 ' + y + '" stroke="#C5CCD0" stroke-width="2px"/><path d="M0 ' + (y - 5) + 'H10L5 ' + y + 'L0 ' + (y - 5) + 'Z" fill="#C5CCD0"/></svg>';
} else {
document.querySelector('.arrowid[value="' + children.id + '"]').parentNode.style.left = blocks.filter(id => id.id == children.parent)[0].x - 20 - (absx + window.scrollX) + canvas_div.getBoundingClientRect().left + "px";
document.querySelector('.arrowid[value="' + children.id + '"]').parentNode.innerHTML = '<input type="hidden" class="arrowid" value="' + children.id + '"><svg preserveaspectratio="none" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 0L20 ' + (paddingy / 2) + 'L' + (x) + ' ' + (paddingy / 2) + 'L' + x + ' ' + y + '" stroke="#C5CCD0" stroke-width="2px"/><path d="M' + (x - 5) + ' ' + (y - 5) + 'H' + (x + 5) + 'L' + x + ' ' + y + 'L' + (x - 5) + ' ' + (y - 5) + 'Z" fill="#C5CCD0"/></svg>';
}
}
function snap(drag, i, blocko) {
if (!rearrange) {
canvas_div.appendChild(drag);
}
var totalwidth = 0;
var totalremove = 0;
var maxheight = 0;
for (var w = 0; w < blocks.filter(id => id.parent == blocko[i]).length; w++) {
var children = blocks.filter(id => id.parent == blocko[i])[w];
if (children.childwidth > children.width) {
totalwidth += children.childwidth + paddingx;
} else {
totalwidth += children.width + paddingx;
}
}
totalwidth += parseInt(window.getComputedStyle(drag).width);
for (var w = 0; w < blocks.filter(id => id.parent == blocko[i]).length; w++) {
var children = blocks.filter(id => id.parent == blocko[i])[w];
if (children.childwidth > children.width) {
document.querySelector(".blockid[value='" + children.id + "']").parentNode.style.left = blocks.filter(a => a.id == blocko[i])[0].x - (totalwidth / 2) + totalremove + (children.childwidth / 2) - (children.width / 2) + "px";
children.x = blocks.filter(id => id.parent == blocko[i])[0].x - (totalwidth / 2) + totalremove + (children.childwidth / 2);
totalremove += children.childwidth + paddingx;
} else {
document.querySelector(".blockid[value='" + children.id + "']").parentNode.style.left = blocks.filter(a => a.id == blocko[i])[0].x - (totalwidth / 2) + totalremove + "px";
children.x = blocks.filter(id => id.parent == blocko[i])[0].x - (totalwidth / 2) + totalremove + (children.width / 2);
totalremove += children.width + paddingx;
}
}
drag.style.left = blocks.filter(id => id.id == blocko[i])[0].x - (totalwidth / 2) + totalremove - (window.scrollX + absx) + canvas_div.scrollLeft + canvas_div.getBoundingClientRect().left + "px";
drag.style.top = blocks.filter(id => id.id == blocko[i])[0].y + (blocks.filter(id => id.id == blocko[i])[0].height / 2) + paddingy - (window.scrollY + absy) + canvas_div.getBoundingClientRect().top + "px";
if (rearrange) {
blockstemp.filter(a => a.id == parseInt(drag.querySelector(".blockid").value))[0].x = (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left;
blockstemp.filter(a => a.id == parseInt(drag.querySelector(".blockid").value))[0].y = (drag.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(drag).height) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top;
blockstemp.filter(a => a.id == drag.querySelector(".blockid").value)[0].parent = blocko[i];
for (var w = 0; w < blockstemp.length; w++) {
if (blockstemp[w].id != parseInt(drag.querySelector(".blockid").value)) {
const blockParent = document.querySelector(".blockid[value='" + blockstemp[w].id + "']").parentNode;
const arrowParent = document.querySelector(".arrowid[value='" + blockstemp[w].id + "']").parentNode;
blockParent.style.left = (blockParent.getBoundingClientRect().left + window.scrollX) - (window.scrollX + canvas_div.getBoundingClientRect().left) + canvas_div.scrollLeft + "px";
blockParent.style.top = (blockParent.getBoundingClientRect().top + window.scrollY) - (window.scrollY + canvas_div.getBoundingClientRect().top) + canvas_div.scrollTop + "px";
arrowParent.style.left = (arrowParent.getBoundingClientRect().left + window.scrollX) - (window.scrollX + canvas_div.getBoundingClientRect().left) + canvas_div.scrollLeft + 20 + "px";
arrowParent.style.top = (arrowParent.getBoundingClientRect().top + window.scrollY) - (window.scrollY + canvas_div.getBoundingClientRect().top) + canvas_div.scrollTop + "px";
canvas_div.appendChild(blockParent);
canvas_div.appendChild(arrowParent);
blockstemp[w].x = (blockParent.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(blockParent).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left;
blockstemp[w].y = (blockParent.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(blockParent).height) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top;
}
}
blocks = blocks.concat(blockstemp);
blockstemp = [];
} else {
blocks.push({
childwidth: 0,
parent: blocko[i],
id: parseInt(drag.querySelector(".blockid").value),
x: (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left,
y: (drag.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(drag).height) / 2) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top,
width: parseInt(window.getComputedStyle(drag).width),
height: parseInt(window.getComputedStyle(drag).height)
});
}
var arrowblock = blocks.filter(a => a.id == parseInt(drag.querySelector(".blockid").value))[0];
var arrowx = arrowblock.x - blocks.filter(a => a.id == blocko[i])[0].x + 20;
var arrowy = paddingy;
drawArrow(arrowblock, arrowx, arrowy, blocko[i]);
if (blocks.filter(a => a.id == blocko[i])[0].parent != -1) {
var flag = false;
var idval = blocko[i];
while (!flag) {
if (blocks.filter(a => a.id == idval)[0].parent == -1) {
flag = true;
} else {
var zwidth = 0;
for (var w = 0; w < blocks.filter(id => id.parent == idval).length; w++) {
var children = blocks.filter(id => id.parent == idval)[w];
if (children.childwidth > children.width) {
if (w == blocks.filter(id => id.parent == idval).length - 1) {
zwidth += children.childwidth;
} else {
zwidth += children.childwidth + paddingx;
}
} else {
if (w == blocks.filter(id => id.parent == idval).length - 1) {
zwidth += children.width;
} else {
zwidth += children.width + paddingx;
}
}
}
blocks.filter(a => a.id == idval)[0].childwidth = zwidth;
idval = blocks.filter(a => a.id == idval)[0].parent;
}
}
blocks.filter(id => id.id == idval)[0].childwidth = totalwidth;
}
if (rearrange) {
rearrange = false;
drag.classList.remove("dragging");
}
rearrangeMe();
checkOffset();
}
function touchblock(event) {
dragblock = false;
if (hasParentClass(event.target, "block")) {
var theblock = event.target.closest(".block");
if (event.targetTouches) {
mouse_x = event.targetTouches[0].clientX;
mouse_y = event.targetTouches[0].clientY;
} else {
mouse_x = event.clientX;
mouse_y = event.clientY;
}
if (event.type !== "mouseup" && hasParentClass(event.target, "block")) {
if (event.which != 3) {
if (!active && !rearrange) {
dragblock = true;
drag = theblock;
dragx = mouse_x - (drag.getBoundingClientRect().left + window.scrollX);
dragy = mouse_y - (drag.getBoundingClientRect().top + window.scrollY);
}
}
}
}
}
function hasParentClass(element, classname) {
if (element.className) {
if (element.className.split(' ').indexOf(classname) >= 0) return true;
}
return element.parentNode && hasParentClass(element.parentNode, classname);
}
flowy.moveBlock = function(event) {
if (event.targetTouches) {
mouse_x = event.targetTouches[0].clientX;
mouse_y = event.targetTouches[0].clientY;
} else {
mouse_x = event.clientX;
mouse_y = event.clientY;
}
if (dragblock) {
rearrange = true;
drag.classList.add("dragging");
var blockid = parseInt(drag.querySelector(".blockid").value);
prevblock = blocks.filter(a => a.id == blockid)[0].parent;
blockstemp.push(blocks.filter(a => a.id == blockid)[0]);
blocks = blocks.filter(function(e) {
return e.id != blockid
});
if (blockid != 0) {
document.querySelector(".arrowid[value='" + blockid + "']").parentNode.remove();
}
var layer = blocks.filter(a => a.parent == blockid);
var flag = false;
var foundids = [];
var allids = [];
while (!flag) {
for (var i = 0; i < layer.length; i++) {
if (layer[i] != blockid) {
blockstemp.push(blocks.filter(a => a.id == layer[i].id)[0]);
const blockParent = document.querySelector(".blockid[value='" + layer[i].id + "']").parentNode;
const arrowParent = document.querySelector(".arrowid[value='" + layer[i].id + "']").parentNode;
blockParent.style.left = (blockParent.getBoundingClientRect().left + window.scrollX) - (drag.getBoundingClientRect().left + window.scrollX) + "px";
blockParent.style.top = (blockParent.getBoundingClientRect().top + window.scrollY) - (drag.getBoundingClientRect().top + window.scrollY) + "px";
arrowParent.style.left = (arrowParent.getBoundingClientRect().left + window.scrollX) - (drag.getBoundingClientRect().left + window.scrollX) + "px";
arrowParent.style.top = (arrowParent.getBoundingClientRect().top + window.scrollY) - (drag.getBoundingClientRect().top + window.scrollY) + "px";
drag.appendChild(blockParent);
drag.appendChild(arrowParent);
foundids.push(layer[i].id);
allids.push(layer[i].id);
}
}
if (foundids.length == 0) {
flag = true;
} else {
layer = blocks.filter(a => foundids.includes(a.parent));
foundids = [];
}
}
for (var i = 0; i < blocks.filter(a => a.parent == blockid).length; i++) {
var blocknumber = blocks.filter(a => a.parent == blockid)[i];
blocks = blocks.filter(function(e) {
return e.id != blocknumber
});
}
for (var i = 0; i < allids.length; i++) {
var blocknumber = allids[i];
blocks = blocks.filter(function(e) {
return e.id != blocknumber
});
}
if (blocks.length > 1) {
rearrangeMe();
}
dragblock = false;
}
if (active) {
drag.style.left = mouse_x - dragx + "px";
drag.style.top = mouse_y - dragy + "px";
} else if (rearrange) {
drag.style.left = mouse_x - dragx - (window.scrollX + absx) + canvas_div.scrollLeft + "px";
drag.style.top = mouse_y - dragy - (window.scrollY + absy) + canvas_div.scrollTop + "px";
blockstemp.filter(a => a.id == parseInt(drag.querySelector(".blockid").value)).x = (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft;
blockstemp.filter(a => a.id == parseInt(drag.querySelector(".blockid").value)).y = (drag.getBoundingClientRect().top + window.scrollY) + (parseInt(window.getComputedStyle(drag).height) / 2) + canvas_div.scrollTop;
}
if (active || rearrange) {
if (mouse_x > canvas_div.getBoundingClientRect().width + canvas_div.getBoundingClientRect().left - 10 && mouse_x < canvas_div.getBoundingClientRect().width + canvas_div.getBoundingClientRect().left + 10) {
canvas_div.scrollLeft += 10;
} else if (mouse_x < canvas_div.getBoundingClientRect().left + 10 && mouse_x > canvas_div.getBoundingClientRect().left - 10) {
canvas_div.scrollLeft -= 10;
} else if (mouse_y > canvas_div.getBoundingClientRect().height + canvas_div.getBoundingClientRect().top - 10 && mouse_y < canvas_div.getBoundingClientRect().height + canvas_div.getBoundingClientRect().top + 10) {
canvas_div.scrollTop += 10;
} else if (mouse_y < canvas_div.getBoundingClientRect().top + 10 && mouse_y > canvas_div.getBoundingClientRect().top - 10) {
canvas_div.scrollLeft -= 10;
}
var xpos = (drag.getBoundingClientRect().left + window.scrollX) + (parseInt(window.getComputedStyle(drag).width) / 2) + canvas_div.scrollLeft - canvas_div.getBoundingClientRect().left;
var ypos = (drag.getBoundingClientRect().top + window.scrollY) + canvas_div.scrollTop - canvas_div.getBoundingClientRect().top;
var blocko = blocks.map(a => a.id);
for (var i = 0; i < blocks.length; i++) {
if (checkAttach(blocko[i])) {
document.querySelector(".blockid[value='" + blocko[i] + "']").parentNode.appendChild(document.querySelector(".indicator"));
document.querySelector(".indicator").style.left = (document.querySelector(".blockid[value='" + blocko[i] + "']").parentNode.offsetWidth / 2) - 5 + "px";
document.querySelector(".indicator").style.top = document.querySelector(".blockid[value='" + blocko[i] + "']").parentNode.offsetHeight + "px";
document.querySelector(".indicator").classList.remove("invisible");
break;
} else if (i == blocks.length - 1) {
if (!document.querySelector(".indicator").classList.contains("invisible")) {
document.querySelector(".indicator").classList.add("invisible");
}
}
}
}
}
function checkOffset() {
offsetleft = blocks.map(a => a.x);
var widths = blocks.map(a => a.width);
var mathmin = offsetleft.map(function(item, index) {
return item - (widths[index] / 2);
})
offsetleft = Math.min.apply(Math, mathmin);
if (offsetleft < (canvas_div.getBoundingClientRect().left + window.scrollX - absx)) {
var blocko = blocks.map(a => a.id);
for (var w = 0; w < blocks.length; w++) {
document.querySelector(".blockid[value='" + blocks.filter(a => a.id == blocko[w])[0].id + "']").parentNode.style.left = blocks.filter(a => a.id == blocko[w])[0].x - (blocks.filter(a => a.id == blocko[w])[0].width / 2) - offsetleft + canvas_div.getBoundingClientRect().left - absx + 20 + "px";
if (blocks.filter(a => a.id == blocko[w])[0].parent != -1) {
var arrowblock = blocks.filter(a => a.id == blocko[w])[0];
var arrowx = arrowblock.x - blocks.filter(a => a.id == blocks.filter(a => a.id == blocko[w])[0].parent)[0].x;
if (arrowx < 0) {
document.querySelector('.arrowid[value="' + blocko[w] + '"]').parentNode.style.left = (arrowblock.x - offsetleft + 20 - 5) + canvas_div.getBoundingClientRect().left - absx + "px";
} else {
document.querySelector('.arrowid[value="' + blocko[w] + '"]').parentNode.style.left = blocks.filter(id => id.id == blocks.filter(a => a.id == blocko[w])[0].parent)[0].x - 20 - offsetleft + canvas_div.getBoundingClientRect().left - absx + 20 + "px";
}
}
}
for (var w = 0; w < blocks.length; w++) {
blocks[w].x = (document.querySelector(".blockid[value='" + blocks[w].id + "']").parentNode.getBoundingClientRect().left + window.scrollX) + (canvas_div.scrollLeft) + (parseInt(window.getComputedStyle(document.querySelector(".blockid[value='" + blocks[w].id + "']").parentNode).width) / 2) - 20 - canvas_div.getBoundingClientRect().left;
}
}
}
function rearrangeMe() {
var result = blocks.map(a => a.parent);
for (var z = 0; z < result.length; z++) {
if (result[z] == -1) {
z++;
}
var totalwidth = 0;
var totalremove = 0;
var maxheight = 0;
for (var w = 0; w < blocks.filter(id => id.parent == result[z]).length; w++) {
var children = blocks.filter(id => id.parent == result[z])[w];
if (blocks.filter(id => id.parent == children.id).length == 0) {
children.childwidth = 0;
}
if (children.childwidth > children.width) {
if (w == blocks.filter(id => id.parent == result[z]).length - 1) {
totalwidth += children.childwidth;
} else {
totalwidth += children.childwidth + paddingx;
}
} else {
if (w == blocks.filter(id => id.parent == result[z]).length - 1) {
totalwidth += children.width;
} else {
totalwidth += children.width + paddingx;
}
}
}
if (result[z] != -1) {
blocks.filter(a => a.id == result[z])[0].childwidth = totalwidth;
}
for (var w = 0; w < blocks.filter(id => id.parent == result[z]).length; w++) {
var children = blocks.filter(id => id.parent == result[z])[w];
const r_block = document.querySelector(".blockid[value='" + children.id + "']").parentNode;
const r_array = blocks.filter(id => id.id == result[z]);
r_block.style.top = r_array.y + paddingy + canvas_div.getBoundingClientRect().top - absy + "px";
r_array.y = r_array.y + paddingy;
if (children.childwidth > children.width) {
r_block.style.left = r_array[0].x - (totalwidth / 2) + totalremove + (children.childwidth / 2) - (children.width / 2) - (absx + window.scrollX) + canvas_div.getBoundingClientRect().left + "px";
children.x = r_array[0].x - (totalwidth / 2) + totalremove + (children.childwidth / 2);
totalremove += children.childwidth + paddingx;
} else {
r_block.style.left = r_array[0].x - (totalwidth / 2) + totalremove - (absx + window.scrollX) + canvas_div.getBoundingClientRect().left + "px";
children.x = r_array[0].x - (totalwidth / 2) + totalremove + (children.width / 2);
totalremove += children.width + paddingx;
}
var arrowblock = blocks.filter(a => a.id == children.id)[0];
var arrowx = arrowblock.x - blocks.filter(a => a.id == children.parent)[0].x + 20;
var arrowy = paddingy;
updateArrow(arrowblock, arrowx, arrowy, children);
}
}
}
document.addEventListener("mousedown", flowy.beginDrag);
document.addEventListener("mousedown", touchblock, false);
document.addEventListener("touchstart", flowy.beginDrag);
document.addEventListener("touchstart", touchblock, false);
document.addEventListener("mouseup", touchblock, false);
document.addEventListener("mousemove", flowy.moveBlock, false);
document.addEventListener("touchmove", flowy.moveBlock, false);
document.addEventListener("mouseup", flowy.endDrag, false);
document.addEventListener("touchend", flowy.endDrag, false);
}
function blockGrabbed(block) {
grab(block);
}
function blockReleased() {
release();
}
function blockSnap(drag, first, parent) {
return snapping(drag, first, parent);
}
function beforeDelete(drag, parent) {
return rearrange(drag, parent);
}
function addEventListenerMulti(type, listener, capture, selector) {
var nodes = document.querySelectorAll(selector);
for (var i = 0; i < nodes.length; i++) {
nodes[i].addEventListener(type, listener, capture);
}
}
function removeEventListenerMulti(type, listener, capture, selector) {
var nodes = document.querySelectorAll(selector);
for (var i = 0; i < nodes.length; i++) {
nodes[i].removeEventListener(type, listener, capture);
}
}
flowy.load();
}
gitextract_biqyvohl/
├── .gitattributes
├── .github/
│ └── FUNDING.yml
├── LICENSE
├── README.md
├── demo/
│ ├── index.html
│ ├── main.js
│ └── styles.css
└── engine/
├── flowy.css
└── flowy.js
SYMBOL INDEX (20 symbols across 2 files)
FILE: demo/main.js
function addEventListenerMulti (line 7) | function addEventListenerMulti(type, listener, capture, selector) {
function snapping (line 13) | function snapping(drag, first) {
function drag (line 43) | function drag(block) {
function release (line 47) | function release() {
FILE: engine/flowy.js
function checkAttach (line 220) | function checkAttach(id) {
function removeSelection (line 230) | function removeSelection() {
function firstBlock (line 235) | function firstBlock(type) {
function drawArrow (line 275) | function drawArrow(arrow, x, y, id) {
function updateArrow (line 286) | function updateArrow(arrow, x, y, children) {
function snap (line 296) | function snap(drag, i, blocko) {
function touchblock (line 402) | function touchblock(event) {
function hasParentClass (line 426) | function hasParentClass(element, classname) {
function checkOffset (line 535) | function checkOffset() {
function rearrangeMe (line 562) | function rearrangeMe() {
function blockGrabbed (line 631) | function blockGrabbed(block) {
function blockReleased (line 635) | function blockReleased() {
function blockSnap (line 639) | function blockSnap(drag, first, parent) {
function beforeDelete (line 643) | function beforeDelete(drag, parent) {
function addEventListenerMulti (line 647) | function addEventListenerMulti(type, listener, capture, selector) {
function removeEventListenerMulti (line 654) | function removeEventListenerMulti(type, listener, capture, selector) {
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (89K chars).
[
{
"path": ".gitattributes",
"chars": 66,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n"
},
{
"path": ".github/FUNDING.yml",
"chars": 65,
"preview": "# These are supported funding model platforms\n\ngithub: alyssaxuu\n"
},
{
"path": "LICENSE",
"chars": 1065,
"preview": "MIT License\n\nCopyright (c) 2019 Alyssa X\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\no"
},
{
"path": "README.md",
"chars": 7766,
"preview": "\n# Flowy\n\n\n\n<br>A javascript library to create pretty"
},
{
"path": "demo/index.html",
"chars": 7590,
"preview": " <!DOCTYPE html>\n<html>\n<head>\n <!-- Primary Meta Tags -->\n<title>Flowy - The simple flowchart engine</title>\n<meta n"
},
{
"path": "demo/main.js",
"chars": 14236,
"preview": "document.addEventListener(\"DOMContentLoaded\", function(){\n var rightcard = false;\n var tempblock;\n var tempbloc"
},
{
"path": "demo/styles.css",
"chars": 12814,
"preview": "body, html {\n margin: 0px;\n padding: 0px;\n overflow: hidden;\n background-image: url(assets/tile.png);\n ba"
},
{
"path": "engine/flowy.css",
"chars": 599,
"preview": ".dragging{z-index:111!important}.block{position:absolute;z-index:9}.indicator{width:12px;height:12px;border-radius:60px;"
},
{
"path": "engine/flowy.js",
"chars": 41041,
"preview": "var flowy = function(canvas, grab, release, snapping, rearrange, spacing_x, spacing_y) {\n if (!grab) {\n grab ="
}
]
About this extraction
This page contains the full source code of the alyssaxuu/flowy GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (83.2 KB), approximately 21.5k tokens, and a symbol index with 20 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.