diff --git a/common/img/boba.png b/common/img/boba.png new file mode 100755 index 0000000..e26faf9 Binary files /dev/null and b/common/img/boba.png differ diff --git a/index.html b/index.html index add59b4..be71f26 100644 --- a/index.html +++ b/index.html @@ -32,7 +32,7 @@

by Dan Wellman

  • Project One: Sliding Puzzle
  • Project Two: Fixed Sidebar
  • Project Three: Google Map
  • -
  • Project Four: Bounty Hunter
  • +
    diff --git a/proj4/about.html b/proj4/about.html new file mode 100644 index 0000000..60a7903 --- /dev/null +++ b/proj4/about.html @@ -0,0 +1,38 @@ + + + + Bounty Hunter + + + + + + + + + + + +
    +
    + +

    About Bounty Hunter

    +
    +
    +

    + Bounty Hunter is an educational app built for the jQuery Hotshots book by Dan Wellman +

    + danwellman.co.uk +
    +
    + © 2014 Denver Code Club + + About + +
    +
    + + + + \ No newline at end of file diff --git a/proj4/assets/css/style.css b/proj4/assets/css/style.css new file mode 100644 index 0000000..7ff212a --- /dev/null +++ b/proj4/assets/css/style.css @@ -0,0 +1,101 @@ +.filter-form .ui-btn { + margin:10px 0 0 0; + float:right; +} + +.ui-footer small { + display:block; + margin:10px; + float:left; +} + +.ui-footer .ui-btn { + margin:2px 10px 0 0; + float:right; +} + +.ui-bar { + margin:0 -15px 14px -15px; + text-align:center; +} + +.ui-bar a:first-child { + margin-left:-5px; + float:left; +} + +.ui-bar a:last-child { + margin-right:-5px; + float:right; +} + +.ui-bar h2 { + margin-top:10px; + font-size:14px; +} + +.footer-bar { + margin-top:14px; +} + +.bounty { + width:24%; + border-radius:3px; + margin-right:5%; + float:left; + text-align:center; + font-size:90%; + line-height:1.5em; + font-weight:bold; + color:#fff; + background-color:#07d; + text-shadow:none; +} + +.bounty span { + display:block; +} + +.expires { + font-size:70%; + font-weight:normal; + line-height:1em; +} + +.expires .value { + display:block; + font-size:110%; + font-weight:bold; + line-height:1.5em; +} + +.title { + width:70%; + margin-top:-.25em; + float:left; + white-space:normal; + font-size:80%; + line-height:1.25em; + color:#07d; +} + +.meta { + clear:both; +} + +.meta span { + width:24%; + margin-right:5%; + float:left; + font-size:70%; + font-weight:normal; + color:#999; +} + +.meta .value { + width:70%; + margin-right:0; + float:none; + font-size:90%; + font-weight:bold; +} \ No newline at end of file diff --git a/proj4/assets/js/script.js b/proj4/assets/js/script.js new file mode 100644 index 0000000..4e42071 --- /dev/null +++ b/proj4/assets/js/script.js @@ -0,0 +1,134 @@ +(function($) { + var tags = '', + getBounties = function(page, callback) { + // AJAX request to Stack Exchange API + $.ajax({ + url: 'http://api.stackexchange.com/2.0/questions/featured', + dataType: 'jsonp', + data: { + page: page, + pagesize: 10, + tagged: tags, + order: 'desc', + sort: 'activity', + site: 'stackoverflow', + filter: '!)4k2jB7EKv1OvDDyMLKT2zyrACssKmSCXeX5DeyrzmOdRu8sC5L8d7X3ZpseW5o_nLvVAFfUSf' + }, + beforeSend: function() { + // Before the data is retrieved... + // Show the spinner text + $.mobile.loadingMessageTextVisible = true; + // Show the spinner + $.mobile.showPageLoadingMsg('a', 'Searching'); + } + }).done(function(data) { + // When finished getting data, send it to the callback handler + callback(data); + }); + }; + + $(document) + // Use onpageinit instead of $(document).ready() because the AJAX calls used + // throughout jQuery Mobile may not be completed by the time the + // document is ready. onpageinit fires only once, when the page is + // first fully loaded. + .on('pageinit', '#welcome', function() { + // When search button is clicked... + $('#search').on('click', function() { + // Prevent the button from being clicked twice + $(this).closest('.ui-btn').addClass('ui-disabled'); + + // Pull in list of tags from the text input + tags = $('tags').val(); + + // Go get 'em! + getBounties(1, function(data) { + // This becomes the AJAX callback function + + // Cache the starting page number + data.currentPage = 1; + + // Data must be stringified because only arrays and + // primitive types can be saved in localStorage. + // Must convert to a JSON string + localStorage.setItem('res', JSON.stringify(data)); + + // Change the view to the list page + $.mobile.changePage('list.html', { + transition: 'slide' + }); + }); + }); + }) + // Whenever the welcome page is shown... + .on('pageshow', '#welcome', function() { + // Re-enable the search button + $('#search').closest('.ui-btn').removeClass('ui-disabled'); + }) + // + .on('pageinit', '#list', function() { + var data = JSON.parse(localStorage.getItem('res')), + total = parseInt(data.total, 10), + size = parseInt(data.page, 10), + totalPages = Math.ceil(total / size), + months = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dev' + ], + createData = function(date) { + var cDate = new Date(date * 1000), + fDate = [ + cDate.getDate(), + months[cDate.getMonth()], + cDate.getFullyYear() + ].join(' '); + + return fDate; + }; + + $.views.helpers({ + CreateDate: createDate + }); + + $('#results') + .append( + $('#listTemplate').render(data) + ) + .find('ul') + .listview(); + + var setClasses = function() { + if (data.currentPage > 1) { + $('a[data-icon="back"]').removeClass('ui-disabled'); + } + else { + $('a[data-icon="back"]').addClass('ui-disabled'); + } + + if (data.currentPage < totalPages) { + $('a[data-icon="forward"]').removeClass('ui-disabled'); + } + else { + $('a[data-icon="forward"]').addClass('ui-disabled'); + } + }; + + $('span.num').text(data.currentPage); + $('span.of').text(totalPages); + + if (totalPages > 1) { + $('a[data-icon="forward"]').removeClass('ui-disabled'); + } + + }); +})(jQuery); \ No newline at end of file diff --git a/proj4/index.html b/proj4/index.html new file mode 100644 index 0000000..65d92c5 --- /dev/null +++ b/proj4/index.html @@ -0,0 +1,48 @@ + + + + Bounty Hunter + + + + + + + + + + + +
    +
    +

    Bounty Hunter

    +
    + +
    +

    + Enter tag(s) to search for bounties on. + Separate tags with a semi-colon, or leave blank to get all bounties. +

    +
    + + + +
    +
    + Bounty Hunter +
    + © 2014 Denver Code Club + + About + +
    +
    + + + + \ No newline at end of file diff --git a/proj4/list.html b/proj4/list.html new file mode 100644 index 0000000..db593e8 --- /dev/null +++ b/proj4/list.html @@ -0,0 +1,100 @@ + + + + Active Bounties + + + + + + + + + + + +
    +
    +

    Active Bounties

    +
    + +
    +
    + + Prev + +

    + Page + + of + +

    + + Next + +
    + +
    + + +
    + Bounty Hunter +
    + © 2014 Denver Code Club + + About + +
    + +
    + + + + \ No newline at end of file diff --git a/proj4/readme.md b/proj4/readme.md new file mode 100644 index 0000000..38cc34d --- /dev/null +++ b/proj4/readme.md @@ -0,0 +1,8 @@ +# Notes: + +## Project 4 - Bounty Hunter +- Will need to use a web server, not a file +- Can't use the jQuery included with the book files (as with the previous projects) because jQuery Mobile isn't compitable w/ jQuery 1.9 and above +- Why not use chaining on the $(document) object? + +Progress: Stopped on page 104, Mini Debriefing \ No newline at end of file