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
document.addEventListener('DOMContentLoaded', initPage, false); | |
function initPage() { | |
if (!('Notification' in window)) { | |
// this browser does not support notifications | |
} else if (Notification.permission === 'denied') { | |
// the user denied notification permission! | |
else if (Notification.permission === 'granted') { | |
pirateManager.subscribeToPush(); | |
} ... | |
function enableNotifications() { |
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.fn.println = function() { | |
// Join all the arguments into a space-separated string | |
var msg = Array.prototype.join.call(arguments, " "); | |
// Loop through each element in the jQuery object | |
this.each(function() { | |
// For each one, append the string as plain text, then append a <br/>. | |
jQuery(this).append(document.createTextNode(msg)).append("<br/>"); | |
}); | |
// Return the unmodified jQuery object for method chaining | |
return this; |
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
// Issue an HTTP GET request for the contents of the specified URL. | |
// When the response arrives, pass it to the callback function as a | |
// parsed XML Document object, a JSON-parsed object, or a string. | |
function get(url, callback) { | |
var request = new XMLHttpRequest(); // Create new request | |
request.open("GET", url); // Specify URL to fetch | |
request.onreadystatechange = function() { // Define event listener | |
// If the request is compete and was successful | |
if (request.readyState === 4 && request.status === 200) { | |
// Get the type of the response |
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
// Issue an HTTP GET request for the contents of the specified URL. | |
// When the response arrives successfully, verify that it is plain text | |
// and if so, pass it to the specified callback function | |
function getText(url, callback) { | |
var request = new XMLHttpRequest(); // Create new request | |
request.open("GET", url); // Specify URL to fetch | |
request.onreadystatechange = function() { // Define event listener | |
// If the request is compete and was successful | |
if (request.readyState === 4 && request.status === 200) { | |
var type = request.getResponseHeader("Content-Type"); |
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
function postMessage(msg) { | |
var request = new XMLHttpRequest(); // New request | |
request.open("POST", "/log.php"); // POST to a server-side script | |
// Send the message, in plain-text, as the request body | |
request.setRequestHeader("Content-Type", // Request body will be plain text | |
"text/plain;charset=UTF-8"); | |
request.send(msg); // Send msg as the request body | |
// The request is done. We ignore any response or any error. | |
} |
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
var request; | |
if (window.XMLHttpRequest) { | |
request = new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { | |
try { | |
request = new ActiveXObject('Msxml2.XMLHTTP'); | |
} catch (e) { | |
try { | |
request = new ActiveXObject('Microsoft.XMLHTTP'); | |
} catch (e) {} |
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
'use strict'; | |
var request = require('request'); | |
var dbSession = require('../../src/backend/dbSession.js'); | |
var resetDatabase = require('../resetDatabase.js'); | |
var async = require('async'); | |
describe('The API', function () { | |
it('should respond to a GET request at /api/keywords/', function (done) { | |
var expected = { | |
"_items": [ | |
{'id': 1, 'value': 'Aubergine', 'categoryID': 1}, |
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
import React, { Component } from 'react'; | |
class RepeatComponent extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
lenguajes: ['Javascript', 'JSX', 'Typescript', 'NodeJS'] | |
} | |
} | |
render() { |
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
import React, { Component } from 'react' | |
import FeedbackMessage from './FeedbackMessage' | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<FeedbackMessage name="SoyLuisCorona" app="My App React" /> | |
</div> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Test React from a blank page</title> | |
</head> | |
<body> | |
<div id="anchorage"></div> | |