Skip to content

Commit

Permalink
Api and popup pseudocode
Browse files Browse the repository at this point in the history
  • Loading branch information
pg013c committed May 31, 2017
1 parent a99a91f commit 250e3b9
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const folder = {
}

gulp.task('html', () => {
const out = folder.build + 'html/'
const out = folder.build
return gulp.src(folder.src + 'html/**/*')
.pipe(newer(out))
.pipe(htmlclean())
Expand Down
2 changes: 1 addition & 1 deletion src/html/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<script src="../js/main.js"></script>
<script src="/js/main.js"></script>
</head>
<body>
test
Expand Down
11 changes: 11 additions & 0 deletions src/js/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

import { get, post } from './apiInterface'

export function testGet() {
get('test')
}

export function testPost() {
post('test')
}
21 changes: 21 additions & 0 deletions src/js/apiInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

const fetch = window.fetch

function prepareUrl(url, params) {

}

function handleResponse() {

}

export function get(url, query) {
console.log('get')
// return fetch(prepareUrl(url)).then(handleResponse)
}

export function post(url, payload, query) {
console.log('post')
// return fetch(prepareUrl(url)).then(handleResponse)
}
4 changes: 4 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

import { myFunction3, config } from './config'
import * as api from './api'

window.MySpace = {
myFunction2: () => {
Expand All @@ -21,3 +22,6 @@ console.log(config)
MySpace.myFunction2()
let result = MySpace.myFunction(3)
console.log(result)

api.testGet()
api.testPost()
38 changes: 38 additions & 0 deletions src/js/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

class Popup {
constructor (title, content, buttons) {

}

on (event, callback) {
addCallbackToList()
}

trigger (event, ...args) {
if (exists) {
listeners.forEach(listener => listener(...args))
}
}

open() {
appendToDocument()

if (hasButtons) {
addButtonsToModal()
buttons.forEach(button => {
button.onCLick(() => {
this.trigger('button:' + button.id)
})
})
}

appendTitle()
appendContent()
showModal()
}

close() {
hideModal()
}
}

0 comments on commit 250e3b9

Please sign in to comment.