Skip to content

Commit

Permalink
Ajout du systeme de hashtag + quelques modif
Browse files Browse the repository at this point in the history
  • Loading branch information
atmoner committed Mar 29, 2020
1 parent 5b8ff81 commit 556ecbb
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 38 deletions.
Binary file added Genesis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 90 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
<link rel="stylesheet" href="css/uikit.min.css" />
<script src="js/uikit.min.js"></script>
<script src="js/uikit-icons.min.js"></script>

<script type="text/javascript" src="https://unpkg.com/moment@latest"></script>
<script type="text/javascript" src="https://unpkg.com/vis-data@latest"></script>
<script type="text/javascript" src="https://unpkg.com/vis-timeline@latest/peer/umd/vis-timeline-graph2d.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-timeline/styles/vis-timeline-graph2d.min.css" />
<style type="text/css">
#mynetwork {
width: 950px;
height: 370px;
height: 270px;

}
*:focus {
Expand Down Expand Up @@ -43,33 +48,81 @@
</div>
</div>
<div class="uk-container" id="all"><br />
<input class="uk-input uk-form-width-medium" type="text" placeholder="#hastag or @user" value="bfmtv" id="searchBox">
<input class="uk-input uk-form-width-medium" type="text" placeholder="#hastag or @user" value="macron" id="searchBox">
<button class="uk-button uk-button-primary " id="startStream" type="button"><span class="uk-margin-small-right" uk-icon="icon: play"></span> Start</button>
<button class="uk-button uk-button-danger" id="stopStream" type="button" style="display: none;"><span class="uk-margin-small-right" uk-icon="icon: ban"></span> Stop</button>
<button class="uk-button uk-button-primary " id="saveScreen" type="button"><span class="uk-margin-small-right" uk-icon="icon: copy"></span> Save screen</button>
<button class="uk-button uk-button-primary " id="clear" type="button"> <span class="uk-margin-small-right" uk-icon="icon: trash"></span> Clear</button>
<button class="uk-button uk-button-primary " id="stabilize" type="button"> <span class="uk-margin-small-right" uk-icon="icon: code"></span> stabilize</button>
<button class="uk-button uk-button-primary" id="options" type="button" uk-toggle="target: #toggle-usage">Options</button>
<!-- <button class="uk-button uk-button-primary" id="stabilize" type="button">Stabilize</button> -->
<button class="uk-button uk-button-primary" id="Output" type="button">Output</button>
<br /> <br />
<label>
<div uk-grid>
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='retweeted' checked></input>
Is <span style="color:red">retweeted</span>
</label>
<label id="toggle-usage" >
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='retweeted' checked></input>
Is <span style="color:red">retweeted</span> <span class="uk-badge" id="retweetStats">0</span>
</label>
</div>
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='quoted' checked></input>
Is <span style="color:green">quoted</span> <span class="uk-badge" id="quoteStats">0</span>
</label>
</div>
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='tweet' checked></input>
Is <span style="color:blue">tweet</span> <span class="uk-badge" id="tweetStats">0</span>
</label>
</div>

<!--<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='hashtag' checked></input>
Is <span style="color:yellow">hashtag</span> <span class="uk-badge" id="tweetStats">0</span>
</label>
</div> -->
</label>
</div>
<div>

</div>
</div>
<div uk-grid>
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='quoted' checked></input>
Is <span style="color:green">quoted</span>
</label>
<div id="mynetwork"></div>
</div>
<div>
<label>
<input class="uk-checkbox" type='checkbox' name='edgesFilter' value='tweet' checked></input>
Is <span style="color:blue">tweet</span>
</label>
<table class="uk-table uk-table-small ">
<caption>Stats</caption>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Node</td>
<td><div id="TwitNode"></div></td>
</tr>
<tr>
<td>Edge</td>
<td><div id="TwitEdge"></div></td>
</tr>
</tbody>
</table>

<button class="uk-button uk-button-primary uk-margin-small-right" type="button" uk-toggle="target: #ViewHashtag">View Hashtag</button>

<br />
</div>
</label>
<div id="mynetwork"></div>
</div>


<div id="detailNode" uk-modal>
<div class="uk-modal-dialog">
Expand All @@ -83,8 +136,9 @@ <h2 class="uk-modal-title">Detail node</h2>

</div>
</div>

</div>
<script src="./renderer.js"></script>


<!-- All modal -->
<div id="apiKeyModal" uk-modal>
Expand Down Expand Up @@ -120,10 +174,10 @@ <h2 class="uk-modal-title">Set your twitter api key</h2>
<div class="uk-form-controls">
<input class="uk-input" id="access_token_secret" type="password">
</div>
</div>
</div>
</div>
<div class="uk-modal-footer uk-text-right">
<button class="uk-button uk-button-primary" id="testapi" type="button">Save</button>
<button class="uk-button uk-button-primary" id="testapi" type="button">Save</button>
</div>
</div>
</div>
Expand All @@ -141,6 +195,22 @@ <h2 class="uk-modal-title">Settings</h2>
</div>
</div>
</div>
<div id="ViewHashtag" uk-modal>
<div class="uk-modal-dialog uk-modal-body">
<h2 class="uk-modal-title">Hashtag Stats</h2>
<table class="uk-table uk-table-divider uk-table-small">
<thead>
<tr>
<th>HashTag</th>
<th>Used</th>
</tr>
</thead>
<tbody id="returnHastag">
</tbody>
</table>
</div>
</div>
<script src="./renderer.js"></script>
</body>
</html>

109 changes: 105 additions & 4 deletions lib/network.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
function check(array, key, value) {
return array.some(object => object[key] === value);
}

exports.add_retweeted = function(tweet) {

try {
nodes.add({
id: tweet.id_str,
shape: 'circularImage',
label: tweet.screen_name,
image: tweet.profile_image,
relation: 'retweeted'
relation: 'retweeted'
});
var retweetStats = retweet++
$('#retweetStats').html(retweetStats)
$('#TwitNode').html(TwitNode++)

/*edges.add({
id: a++,
from: tweet.id_str,
to: tweet.sub_id_str,
color:{color:'yellow'},
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++) */

}
catch(error) {
console.error(error);
Expand All @@ -19,13 +37,18 @@ exports.add_retweeted = function(tweet) {
image: tweet.sub_profile_image,
relation: 'retweeted'
});
$('#TwitNode').html(TwitNode++)
var tweetStats = tweets++
$('#tweetStats').html(tweetStats)
//network.stabilize(tweet.id_str)
edges.add({
id: tweet.sub_id_str,
type: 'arrow',
from: 1, // TODO C'est ici qu'il y a quelque chose à faire pour ameliorer le programme!
to: tweet.sub_id_str,
arrows: 'from'
});
});
$('#TwitEdge').html(TwitEdge++)
}
catch(error) {
console.error(error);
Expand All @@ -37,11 +60,47 @@ exports.add_retweeted = function(tweet) {
to: tweet.sub_id_str,
color:{color:'red'},
arrows: 'from'
});
});
$('#TwitEdge').html(TwitEdge++)
}
catch(error) {
console.error(error);
}
}

// Hastag part
if (tweet.streamHashtag.length > 0) {
//console.log(tweet.streamHashtag);


tweet.streamHashtag.forEach((item3, index) => {
//console.log(item.text);
//console.log(check(tweet.hashTagVar, 'name', item3.text));

if (!check(tweet.hashTagVar, 'name', item3.text)) {

} else {
tweet.hashTagVar.forEach((item4, index) => {
//console.log(item4);
//console.log(item3);
if (item4.name === item3.text) {
edges.add({
id: a++,
type: 'arrow',
from: tweet.id_str,
to: item4.idNode,
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++)
}

})


}
})
}
//network.stabilize()

}

exports.add_quoted = function(tweet) {
Expand All @@ -53,6 +112,9 @@ exports.add_quoted = function(tweet) {
image: tweet.profile_image,
relation: 'quoted'
});
$('#TwitNode').html(TwitNode++)
var quoteStats = quote++
$('#quoteStats').html(quoteStats)
}
catch(error) {
console.error(error);
Expand All @@ -66,13 +128,15 @@ exports.add_quoted = function(tweet) {
image: tweet.sub_profile_image,
relation: 'quoted'
});
$('#TwitNode').html(TwitNode++)
edges.add({
id: a++,
type: 'arrow',
from: 1,
to: tweet.sub_id_str,
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++)
}
catch(error) {
console.error(error);
Expand All @@ -86,11 +150,13 @@ exports.add_quoted = function(tweet) {
color:{color:'green'},
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++)
}
catch(error) {
console.log('quoted_status node ');
console.error(error);
}
//network.stabilize()
}

exports.add_twitted = function(tweet) {
Expand All @@ -102,6 +168,7 @@ exports.add_twitted = function(tweet) {
image: tweet.profile_image,
relation: 'tweet'
});
$('#TwitNode').html(TwitNode++)
} catch(error) {
console.error(error);
}
Expand All @@ -113,10 +180,44 @@ exports.add_twitted = function(tweet) {
to: tweet.id_str,
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++)
} catch(error) {
console.log('Main tweet ');
console.error(error);
}
// Hastag part
if (tweet.streamHashtag.length > 0) {
//console.log(tweet.streamHashtag);


tweet.streamHashtag.forEach((item3, index) => {
//console.log(item.text);
//console.log(check(tweet.hashTagVar, 'name', item3.text));

if (!check(tweet.hashTagVar, 'name', item3.text)) {

} else {
tweet.hashTagVar.forEach((item4, index) => {
console.log(item4);
console.log(item3);
if (item4.name === item3.text) {
edges.add({
id: a++,
type: 'arrow',
from: tweet.id_str,
to: item4.idNode,
arrows: 'from'
});
$('#TwitEdge').html(TwitEdge++)
}

})


}
})
}
//network.stabilize()
}
/*
exports.add_reply = function(tweet) {
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let mainWindow

function createWindow () {
mainWindow = new BrowserWindow({
width: 1100,
width: 1300,
height: 850,
//fullscreen:true,
webPreferences: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"jquery": "^3.4.1",
"openurl": "^1.1.1",
"twit": "^2.2.11",
"uniqid": "^5.2.0",
"vis-network": "=7.3.4"
}
}
Loading

0 comments on commit 556ecbb

Please sign in to comment.