mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-22 02:57:25 -07:00
Added Username Export Function
This commit is contained in:
parent
528a2f8b05
commit
e42fd11694
3 changed files with 51 additions and 9 deletions
|
@ -26,6 +26,8 @@ function circle_main() {
|
|||
function formatedUserHandle(mastodon_handle) {
|
||||
// Remove leading @
|
||||
if (mastodon_handle.charAt(0) === '@') mastodon_handle = mastodon_handle.substr(1);
|
||||
// Remove Spaces
|
||||
mastodon_handle = mastodon_handle.replaceAll(" ","");
|
||||
// Split handle into name and instance
|
||||
mastodon_handle = mastodon_handle.split("@");
|
||||
// Return the array (fetch user ID with getIdFromName)
|
||||
|
@ -141,12 +143,24 @@ function showConnections() {
|
|||
(first, second) => { return second[1]["conStrength"] - first[1]["conStrength"] }
|
||||
);
|
||||
|
||||
// Export Item List for Further usage
|
||||
// Also export the Username List
|
||||
let userDataExport = {};
|
||||
let usersDivs = [document.getElementById("ud1"), document.getElementById("ud2"), document.getElementById("ud3")];
|
||||
for (var i=0; i<items.length; i++) {
|
||||
userDataExport[items[i][0]] = items[i][1]["conStrength"].toFixed(1);
|
||||
// Create a new html Element
|
||||
let newUser = document.createElement("p");
|
||||
newUser.innerText = items[i][1]["acct"];
|
||||
|
||||
// Determine the column for the data
|
||||
let udNum = 0;
|
||||
if (i > numb[0]) udNum = 1;
|
||||
if (i > numb[0]+numb[1]) udNum = 2;
|
||||
usersDivs[udNum].appendChild(newUser);
|
||||
|
||||
// Belongs to the hidden Export - Maybe for further Projects
|
||||
// userDataExport[items[i][0]] = items[i][1]["conStrength"].toFixed(1);
|
||||
}
|
||||
document.getElementById("outDiv").innerText = JSON.stringify(userDataExport);
|
||||
//document.getElementById("outDiv").innerText = JSON.stringify(userDataExport);
|
||||
|
||||
// Render the Objects
|
||||
document.getElementById("btn_download").style.display = "inline";
|
||||
|
@ -177,7 +191,9 @@ function httpRequest(url, callback, callbackVal=null)
|
|||
xmlHttp.send(null);
|
||||
}
|
||||
|
||||
function downloadImage() {
|
||||
var canvas = document.getElementById("canvas");
|
||||
window.open(canvas.toDataURL('image/png'));
|
||||
}
|
||||
function downloadImage(){
|
||||
var link = document.createElement('a');
|
||||
link.download = 'mastodon-circle.png';
|
||||
link.href = document.getElementById('canvas').toDataURL()
|
||||
link.click();
|
||||
}
|
14
index.html
14
index.html
|
@ -22,8 +22,18 @@
|
|||
<br><br>
|
||||
<!-- Canvas for the final Image -->
|
||||
<canvas id="canvas" width="1000" height="1000"></canvas>
|
||||
<br><br><br><br>
|
||||
<div id="credits">Thanks to <a href="https://twitter.com/duiker101">Duiker101</a> for creating chirpty for Twitter</div>
|
||||
<br>
|
||||
<!-- List of all people in Circle -->
|
||||
<div id="usersDiv">
|
||||
<div id="ud1" class="userSubDiv"></div>
|
||||
<div id="ud2" class="userSubDiv"></div>
|
||||
<div id="ud3" class="userSubDiv"></div>
|
||||
</div>
|
||||
<br><br><br>
|
||||
<div id="credits">
|
||||
<p>Thanks to <a href="https://twitter.com/duiker101">Duiker101</a> for creating chirpty for Twitter</p>
|
||||
<p>Contribute on <a href="https://github.com/andigandhi/Mastodon-Circles">Github</a> </p>
|
||||
</div>
|
||||
<!-- output for further projects ;) -->
|
||||
<div id="outDiv" style="display: none;"></div>
|
||||
<!-- Preload the background image -->
|
||||
|
|
16
style.css
16
style.css
|
@ -17,6 +17,11 @@ button {
|
|||
font-size: 110%;
|
||||
}
|
||||
|
||||
canvas {
|
||||
max-width: 1000px;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #AAAAAA;
|
||||
|
@ -25,3 +30,14 @@ a {
|
|||
#outDiv {
|
||||
font-size: 20%;
|
||||
}
|
||||
|
||||
#usersDiv {
|
||||
margin-top: 30px;
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
.userSubDiv {
|
||||
width: 30%;
|
||||
float: left;
|
||||
padding: 20px;
|
||||
}
|
Loading…
Reference in a new issue