Permalink
Browse files

Worked on counting chars in level one

  • Loading branch information...
1 parent f40e7dd commit 3ffed7114b47afa087315a3a16b2f8fed8cdf478 @craigprotzel craigprotzel committed Apr 15, 2012
@@ -693,7 +693,9 @@ backToTheGame{
}
-
+#linkToStory {
+ color: @white;
+}
View
@@ -925,6 +925,9 @@ backToTheGame {
line-height: 26px;
margin: 20px 12% 10px 12%;
}
+#linkToStory {
+ color: #ffffff;
+}
/* forms */
/*
.main{
View
@@ -942,9 +942,17 @@ $('input#readStory').on('click', function(){
})
+$('#linkToStory').click(function() {
+
+ window.open($('#linkToStory').attr('title'));
+
+});
+
+
+//Character Word Counts
View
@@ -61,10 +61,10 @@
<footer>
- <!-- <form method="POST" action="/usaTodayAPIQuery"> -->
- <!-- <input type="submit" class="footerButtons" id="usaTodayCall" value="USA Today API" /> -->
- <input type="button" class="footerButtons" id="usaTodayCall" value="USA Today API" />
- <!-- </form> -->
+ <form method="POST" action="/usaTodayAPIQuery">
+ <input type="submit" class="footerButtons" id="usaTodayCall" value="USA Today API" />
+ <!-- <input type="button" class="footerButtons" id="usaTodayCall" value="USA Today API" /> -->
+ </form>
<a href="http://www.craigprotzel.com" class="footerButtons">By Craig Protzel</a>
@@ -179,7 +179,7 @@
<section id="showStory">
<section id="showStoryHeadline">
- "<%= masterHeadline %>"
+ <div title="<%= randomStory.link %>" id="linkToStory">"<%= masterHeadline %>"</div>
</section>
<section id="showStoryText">
@@ -9,6 +9,7 @@
<% var masterWords = masterHeadlineLower.split(" "); %>
<% var theTwoLongestIndex = longestTwo(masterWords); %>
+ <!-- <%= theTwoLongestIndex %> -->
<% var levelTwoIndex = 0 %>
<!-- save these values for the front end in a hidden div -->
@@ -185,7 +186,7 @@
<section id="showStory">
<section id="showStoryHeadline">
- "<%= masterHeadline %>"
+ <div title="<%= randomStory.link %>" id="linkToStory">"<%= masterHeadline %>"</div>
</section>
<section id="showStoryText">
@@ -7,7 +7,12 @@
<% var masterHeadline = randomStory.title; %>
<% var masterHeadlineLower = masterHeadline.toLowerCase(); %>
<% var masterWords = masterHeadlineLower.split(" "); %>
+
+ <% var wordsLevelOne = [] %>
+ <% var wordsLevelOne = countCharsLevelOne(masterWords); %>
+ <%= "Level One Words: " + wordsLevelOne %>
+
<!-- use the "longestOne" function to (1)sort the comma separated string and then (2)determine the index value of the longest word -->
<% var index = longestOne(masterWords); %>
@@ -153,7 +158,7 @@
<section id="showStory">
<section id="showStoryHeadline">
- "<%= masterHeadline %>"
+ <div title="<%= randomStory.link %>" id="linkToStory">"<%= masterHeadline %>"</div>
</section>
<section id="showStoryText">
View
44 web.js
@@ -78,6 +78,8 @@ app.configure(function() {
//usa today variables
var source = 'USA_Today';
+var topic = 'Weather';
+
var storyTopics = ['Offbeat','Travel','Weather'];
var requestedTopic = '';
@@ -148,7 +150,7 @@ app.get('/storyscramble_level_I', function(request, response) {
//sort by date in descending order
query.sort('date',-1);
- query.limit(50);
+ query.limit(150);
//run the query
query.exec({}, function(err, allStories){
@@ -186,7 +188,7 @@ app.get('/storyscramble_level_II', function(request, response) {
//sort by date in descending order
query.sort('date',-1);
- query.limit(50);
+ query.limit(150);
//run the query
query.exec({}, function(err, allStories){
@@ -227,7 +229,7 @@ app.get('/storyscramble_level_III', function(request, response) {
//sort by date in descending order
query.sort('date',-1);
- query.limit(50);
+ query.limit(150);
//run the query
query.exec({}, function(err, allStories){
@@ -252,7 +254,7 @@ app.get('/ajaxgetarticle', function(request, response){
articleURL = request.query.url;
articleURL = articleURL.replace(/apidata/g, "content");
- console.log("this is the CONSOLE LOG MUTHAFUCKER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " +articleURL);
+ console.log("this is the article!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " +articleURL);
if (articleURL) {
@@ -276,14 +278,14 @@ app.get('/ajaxgetarticle', function(request, response){
}
})
-/*
+
//USA Today API Query - click button on Main Page
app.post('/usaTodayAPIQuery', function (request,response) {
console.log("hit usaTodayAPIQuery");
// the url you need to request from USA Today
// this will return the 10 top news articles in json format
- var url = "http://api.usatoday.com/open/articles/offbeat?encoding=json&count=30&api_key=85gehs983tmqbwxz4uwk6ghv"
+ var url = "http://api.usatoday.com/open/articles/weather?encoding=json&count=30&api_key=85gehs983tmqbwxz4uwk6ghv"
// make the request to USA Today api
@@ -318,7 +320,7 @@ app.post('/usaTodayAPIQuery', function (request,response) {
response.redirect('/');
});
-*/
+
@@ -333,7 +335,24 @@ app.listen(port, function() {
app.helpers({
- longestOne: function(wordslist){
+ //function for Words Level I
+ countCharsLevelOne: function(wordsList){
+
+ var wordsSplit = [];
+ var levelOneWords = [];
+
+ for (var i = 0; i < wordsList.length; i++){
+ wordsSplit[i] = wordsList[i].split("");
+
+ if (wordsSplit[i].length == 4 || wordsSplit[i].length == 5 || wordsSplit[i].length == 6) {
+ levelOneWords.push(wordsList[i]);
+ }
+ }
+ return levelOneWords;
+ }
+
+ //function for Headlines Level I
+ , longestOne: function(wordslist){
var sortLongToShort = function(a,b) {
return(b.toString().length - a.toString().length);
@@ -349,6 +368,8 @@ app.helpers({
return -1
}
+
+ //function for Headlines Level II
, longestTwo: function(wordslist){
var sortLongToShort = function(a,b) {
@@ -367,6 +388,7 @@ app.helpers({
return twoLongest;
}
+
, cleanup : function(word) {
word = word.replace(/[^\w ]/, "");
return word.toLowerCase();
@@ -375,12 +397,16 @@ app.helpers({
, scramble : function (word){
//here we use regex to find punctuation and save it for adding it after scrambling.
+ //this strips out all the punctuation
+ //wordNew = word.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " ");
+ //wordNew = word.replace(/[^\w ]/, "");
var random = function() {
return (0.5 - Math.random());
};
- var characters = word.split("");
+ var characters = word.split("");
+ //var characters = wordNew.split("");
characters.sort(random);
//before returning you would add back the punctuation you removed at the beginning.

0 comments on commit 3ffed71

Please sign in to comment.