Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 2 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,2 @@
# Mashup project

This project is open-ended!

* [AJAX demos](https://github.com/advanced-js/deck/tree/gh-pages/demos/ajax)
* [inspiration?](http://www.programmableweb.com/mashups)

## Requirements

* Build a site that uses data from at least one external API in an interesting, interactive way. (**80%**)
* HTML validation (using the [Nu HTML Checker](https://validator.w3.org/nu/)) must pass. (**10%**)
* JavaScript linting (using the configured [JSHint](http://jshint.com/about/)) must pass. (**10%**)
* Replace this README with a description of the project.

### Extra credit

Too easy?

* Build in an [object-oriented](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript) way (**10%**)
* Add fancy interactivity/animations (**10%**)

If you do either of these, please let Aidan know so he can take a look.

## Tips

* The JS code should be **non-trivial**. That being said... start simple! (Just get the data to show up on the page.)
* No server-side coding is required, but feel free to create a backend in whatever language if you like, if you need one.
* You are welcome to use any 3rd-party libraries/frameworks – just load them from a CDN (e.g. [cdnjs](http://cdnjs.com)), or put them under the [`vendor/`](vendor/) folder.
* **Do not commit the `client_secret` (or anything else from an API that says "token" or "secret")**, as a hacker could use this to make requests on behalf of you.

## Finding an API

A couple things to look for in an API (or at least the endpoints you're using) for this project:

* Make sure it doesn't require authentication/authorization (e.g. [OAuth](http://oauth.net/)) - at least for the endpoints that you want to use - so that you don't need a server.
* If the API doesn't support cross-domain requests (JSONP or CORS), you will need to use [JSONProxy](https://jsonp.afeld.me/).

Here is a [list of API suggestions](https://gist.github.com/afeld/4952991).

## Running tests locally

Within this repository directory in your [virtual machine](https://github.com/startup-systems/vm):

1. [Install Node.js 6.x.](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
1. Install the project dependencies.

```bash
npm install
```

1. Run the tests.

```bash
npm test -s
```
This is a simple stock price query tool.
Simply enter a company's name that you are interested in, and then click on search the last price of the company's stock will be displayed below
44 changes: 44 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,51 @@
<html>
<head>
<title>Mashup</title>
<style>
h1 {text-align: center; font-family: helvetica}
p {text-align: center; font-family: helvetica}
div {text-align: center;}
</style>
</head>
<body>
<h1>A Simple Stock Query Tool </h1>
<p>powered by Markit On Demand API</p>
<div class="wrapper">
<input type="text" id="symbolsearch" class="input- ui-autocomplete-input ui-autocomplete-loading" placeholder="Enter company name or symbol" autocomplete="off">
<button id="action-button">Search</button>
</div>
<p id="quote"></p>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.6.4.js"></script>
<script>
$('#action-button').click(function() {
$.ajax({
url: 'http://dev.markitondemand.com/Api/v2/Lookup/jsonp',
data: {
input: document.getElementById('symbolsearch').value
},
error: function() {
alert('An error has occurred');
},
dataType: 'jsonp',
success: function(data) {
$.ajax({
url: 'http://dev.markitondemand.com/Api/v2/Quote/jsonp',
data: {
symbol: data[0].Symbol,
},
error: function() {
alert('An error has occured');
},
dataType: 'jsonp',
success: function(result){
$('#quote').html(data[0].Name + "'s Last Price on ("+ data[0].Exchange + "): "+ result.LastPrice);
},
type: 'GET'
});
},
type: 'GET'
});
});
</script>
</body>
</html>
29 changes: 29 additions & 0 deletions query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$('#action-button').click(function() {
$.ajax({
url: 'http://dev.markitondemand.com/Api/v2/Lookup/jsonp',
data: {
input: document.getElementById('symbolsearch').value
},
error: function() {
alert('An error has occurred');
},
dataType: 'jsonp',
success: function(data) {
$.ajax({
url: 'http://dev.markitondemand.com/Api/v2/Quote/jsonp',
data: {
symbol: data[0].Symbol,
},
error: function() {
alert('An error has occured');
},
dataType: 'jsonp',
success: function(result){
$('#quote').html(data[0].Name + "'s Last Price on ("+ data[0].Exchange + "): "+ result.LastPrice);
},
type: 'GET'
});
},
type: 'GET'
});
});