Skip to content
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
4 changes: 4 additions & 0 deletions public/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
<meta charset="utf-8">
<title>Sprinkle's Q&A Blockchain Site</title>

<script src="https://dapps.stanford.edu/web3/web3-1.0.0-beta.34.min.js"></script>


<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/style.css">

<style>
.modal {
display: none; /* Hidden by default */
Expand Down
26 changes: 24 additions & 2 deletions public/app/js/main-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,28 @@
//SearchView.render($body.find('#search'));
};

window.MainView = MainView;

if (typeof web3 == 'undefined') throw 'No web3 detected. Is Metamask/Mist being used?';

web3 = new Web3(web3.currentProvider);
console.log("Using web3 version: " + Web3.version);

var contract;
var userAccount;

//var contractDataPromise = $.getJSON('CardinalToken.json');
var networkIdPromise = web3.eth.net.getId();
var accountsPromise = web3.eth.getAccounts();

Promise.all([networkIdPromise, accountsPromise])
.then(function initApp(results){
var accounts = results[1];
var userAccount = accounts[0];
MainView.user_id = userAccount;
console.log("accounts: " + accounts)
})

window.MainView = MainView;
})();

function openModal() {
Expand All @@ -17,4 +38,5 @@ function openModal() {

function closeModal() {
$("#add_container").css("display", "none");
}
}

6 changes: 6 additions & 0 deletions public/app/js/newsfeed-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function submitQuestion() {
var q_details = $("textarea").val()
var q_bounty = $('#bounty_amount').val()

if (MainView.user_id == null) {
return
} else {
console.log("Ethereum: " + MainView.user_id)
}

$("#question_title").val("");
$("textarea").val("")
$('#bounty_amount').val(null)
Expand Down
5 changes: 3 additions & 2 deletions public/app/js/question-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ function upvoteClicked(element) {
function submitAnswer() {
console.log('omg')
var box_text = document.getElementById("answer_input").value
console.log("answer_submission " + box_text)


answer_data = {
question_id: QuestionView.question_id,
user_id: "chachang",
user_id: MainView.user_id,
text: box_text
}
PostModel.addAnswer(answer_data)
Expand Down