This file contains 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
/** | |
* Flattens an array of arbitrarily nested arrays into | |
* a flat array. e.g. [[1,2,[3]],4] -> [1,2,3,4] | |
* | |
* @param items - source array | |
* @return - flat array | |
*/ | |
function flatten(items) { | |
const flat = []; |
This file contains 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
Windows Registry Editor Version 5.00 | |
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll] | |
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell] | |
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open] | |
"MuiVerb"="@photoviewer.dll,-3043" | |
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command] |
This file contains 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
import { Pipe, PipeTransform } from '@angular/core'; | |
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; | |
@Pipe({ | |
name: 'sanitizeHtml' | |
}) | |
export class HtmlSanitizerPipe implements PipeTransform { | |
constructor(private sanitizer: DomSanitizer) { | |
} |
This file contains 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
import {Component, ViewChild, AfterViewInit} from '@angular/core'; | |
import {WpEndpoint, CollectionDirective, CollectionResponse} from '../../core/wordpress'; | |
@Component({ | |
selector: 'feed-page', | |
templateUrl: ` | |
<div class="feed" #feed [wpCollection]="postsEndpoint" [wpArgs]="postsArgs"> | |
<ul> | |
<li *ngFor="let post of posts">{{post.title()}}</li> |
This file contains 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
/* | |
* In this example, we display a collection of posts, pagination and a button to load the next page. | |
* we also set the QueryArgs for the request to get embedded posts and filter the results to 6 posts per page | |
* | |
* get pagination properties from `wpCollection.service` | |
*/ | |
import { Component, OnInit } from '@angular/core'; | |
import {WpEndpoint, WpService, CollectionResponse} from 'ng2-wp-api'; | |
@Component({ |
This file contains 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
/* | |
* This example demonstrates how to get a single post by id | |
*/ | |
import { Component } from '@angular/core'; | |
import { WpModel, WpPost } from "ng2-wp-api"; | |
@Component({ | |
selector: 'test-model', | |
template: ` |
This file contains 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
import {Directive, ElementRef, HostListener, Renderer2} from '@angular/core'; | |
@Directive({ | |
selector: '[ripple]' | |
}) | |
export class RippleDirective { | |
hostEl; | |
constructor(private renderer: Renderer2, el: ElementRef) { |
This file contains 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
import {Directive, Input, ElementRef, Renderer} from '@angular/core'; | |
import {WindowService} from "../../window/window.service"; | |
@Directive({ | |
selector: '[affix]' | |
}) | |
export class AffixDirective { | |
@Input() affix: any; | |
parent: HTMLElement; |
This file contains 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
//using your function (passing in date) | |
function formatAMPM(date) { | |
let days = date.getUTCDate(); | |
let month = date.getUTCMonth() + 1; | |
const year = date.getUTCFullYear(); | |
let hours = date.getHours(); | |
let minutes = date.getMinutes(); | |
const ampm = hours >= 12 ? 'pm' : 'am'; | |
// converts hours to 12 hour instead of 24 hour | |
hours = hours % 12; |
This file contains 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
import { existsSync, mkdirSync } from 'fs'; | |
import { dirname } from 'path'; | |
function makeDirectory(target: string) { | |
// check if parent directory exists | |
const parentDir = dirname(target); | |
if (!existsSync(parentDir)) { | |
makeDirectory(parentDir); |
OlderNewer