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
function searchLink(searchEngine, searchTerm){ | |
switch(searchEngine.toString().toLowerCase()){ | |
case 'google': return 'https://google.com/search?q=' + encodeURI(searchTerm); | |
case 'bing': return 'https://bing.com/search?q=' + encodeURI(searchTerm); | |
case 'duckduckgo': return 'https://duckduckgo.com/?q=' + encodeURI(searchTerm); | |
} | |
} |
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
<div class="container"> | |
<main role="main" class="pb-3"> | |
<environment include="Development"> | |
<style>#mocha { display: block; }</style> | |
<div id="mocha"></div> | |
</environment> | |
@RenderBody() | |
</main> | |
</div> |
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
<environment include="Development"> | |
<!-- Add Chai and Mocha --> | |
<link rel="stylesheet" href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script> | |
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script> | |
<!-- Add the test file --> | |
<script src="js/site.test.js"></script> | |
</environment> |
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
'user strict'; | |
const expect = chai.expect, | |
assert = chai.assert; | |
mocha.setup('bdd'); | |
describe('libraries',function(){ | |
it('should have jQuery',function(){ | |
expect($).to.not.be.null; | |
expect($).to.not.equal(undefined); |
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
<pre>{ | |
"glossary": { | |
"title": "example glossary", | |
"GlossDiv": { | |
"title": "S", | |
"GlossList": { | |
"GlossEntry": { | |
"ID": "SGML", | |
"SortAs": "SGML", | |
"GlossTerm": "Standard Generalized Markup Language", |
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
fetch('https://json.org/example.html') | |
.then( x => x.text()) | |
.then(function(html){ | |
var parser = new DOMParser(); | |
var doc = parser.parseFromString(html, "text/html"); | |
var pre = doc.querySelector('pre'); | |
var obj = JSON.parse(pre.innerHTML); | |
console.log(obj.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso[0]) | |
}); |
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
// Step 1: download chromedriver version 70-72 into the project root folder | |
// Step 2: include this in pom.xml | |
/* | |
<dependency> | |
<groupId>org.seleniumhq.selenium</groupId> | |
<artifactId>selenium-java</artifactId> | |
<version>3.141.59</version> | |
</dependency> | |
*/ |
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
var video = document.createElement('video'); | |
// internally console.log calls .toString() if the parameter is not a string. | |
console.log(video); | |
/* | |
output: | |
[object HTMLVideoElement] | |
*/ |
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
var input = document.createElement('input'); | |
input.type='password'; | |
input.name='p-word'; | |
console.log(input.outerHTML); // <input type="password" name="p-word"> |
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
var div = document.createElement('div'); | |
div.id = 'abc'; | |
div.className = 'col-md-5'; | |
console.log(div.outerHTML); // output: <div id="abc" class="col-md-5"></div> |
NewerOlder