This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.toJson = function(name, value = name) { | |
| return this.reduce((acc, cur) => { | |
| acc[cur[name]] = cur[value]; | |
| return acc; | |
| }, {}); | |
| } | |
| /** Test **/ | |
| const form = [ | |
| { name: 'firstname', flex: 1, value: 'test1' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).ready(function() { | |
| jQuery('video').each(function() { | |
| const sourceDom = jQuery(this).find('source'); | |
| if(sourceDom.length === 1) { | |
| const src = jQuery(sourceDom[0]).attr('src'), | |
| indexVimeo = src.indexOf('vimeo.com'); | |
| if(indexVimeo !== -1) { | |
| const split = src.split('/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| onRotateImage(file, checkError = true) { | |
| const promise = new Promise((resolve, reject) => { | |
| const reader = new FileReader(); | |
| reader.onload = (e) => { | |
| this.getOrientation(file, (orientation) => { | |
| if (orientation > 0) { | |
| const image = new Image(); | |
| image.src = e.target['result']; | |
| image.onload = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const editor = new Quill(...); | |
| // defined method insert html | |
| editor.insertHTML = (html) => { | |
| const range = this.editor.getSelection(true), | |
| date = Date.now(); | |
| editor.insertEmbed(range.index, 'div', { id: date }, 'user'); | |
| editor.setSelection(range.index + 1, Quill.sources.SILENT); | |
| $(html).insertAfter('#' + date); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const editor = $('.editor'); | |
| const quill = new Quill(editor); | |
| // set html content | |
| quill.setHTML = (html) => { | |
| editor.root.innerHTML = html; | |
| }; | |
| // get html content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cleanObject = (object) => { | |
| if (object !== null) { | |
| switch (typeof object) { | |
| case 'string' : | |
| const regex = new RegExp('your regex', 'gm'); | |
| object = object.replace(regex, 'your new string'); | |
| break; | |
| case 'object': | |
| if (object instanceof Array) { | |
| const length = object.length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| npm install | |
| ng build -prod | |
| cp src/.htaccess dist/ | |
| find dist/assets -type f \( -name '*.js' -o -name '*.css' \) -exec gzip -k -f "{}" \; #every js and css files you cannot add to angular-cli.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| find . -iname "*.ts" -exec grep -vE '^#' {} \; | wc -l |