-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
131 lines (101 loc) · 3.79 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
var title = '<h1><a href="/">minaizamina</a></h1>';
let md = window.markdownit({html: true});
var width;
$("document").ready(function(){
width = $(window).width();
displayText();
});
$("#handle").draggable({
grid: [50, 50],
axis: "x",
containment: "#container",
zIndex: 100,
drag: function(event, ui){
ui.position.left = Math.min(Math.max( 50, ui.position.left ), width - 100);
let x = ui.position.left + 12.5;
$("#left").css( "width", x );
$("#left")[ 0 ].style.setProperty( '--title-fontsize', x / window.innerWidth );
$("#right").css( "width", x );
$("#right")[ 0 ].style.setProperty( '--title-fontsize', x / window.innerWidth );
}
});
function displayText(){
$("#title").html(title);
$.ajax({
url: `md/projects.md`,
datatype: "html",
success: function(markdown){
let html = md.render(markdown);
$(`#right`).html(html);
const paragraphs = document.querySelectorAll( '#right p' );
const random_paragraph = paragraphs[ Math.floor( Math.random( ) * paragraphs.length ) ];
const sentences = random_paragraph.innerText.match( /[^\.!\?]+[\.!\?]+/g );
const random_index = Math.floor( Math.random( ) * sentences.length );
let random_sentence = sentences[ random_index ];
random_sentence = `<span class="inserted">${ random_sentence }</span>`;
paragraphs.forEach( paragraph => {
const amount = 3;
const add_sentence = ( Math.floor( Math.random( ) * amount ) % amount == 0 );
if ( add_sentence ) {
let sentences = paragraph.innerHTML.match( /[^\.!\?]+[\.!\?]+/g );
if ( sentences ) {
const insert_index = Math.floor( Math.random( ) * sentences.length );
sentences.splice( insert_index, 0, random_sentence );
// console.log( sentences );
paragraph.innerHTML = sentences.join( '' );
}
// console.log( paragraph.innerHTML );
}
} );
/* $( '#right a' ).click( function( event ) {
event.preventDefault( );
loadProject( $( this ).attr( 'href' ) );
} ); */
}
});
$.ajax({
url: `md/notes.md`,
datatype: "html",
success: function(markdown){
let html = md.render(markdown);
$(`#left`).append(html);
}
});
$.ajax({
url: `md/titlemain.md`,
datatype: "html",
success: function(markdown){
let html = md.render(markdown);
$(`#right`).append(html);
}
});
}
// Show the button when scrolling down
/*
const handle = document.getElementById( 'handle' );
handle.addEventListener( 'dragstart', event => {
handle.classList.add( 'dragging' );
//console.log( event.offsetX );
} );
handle.addEventListener( 'drag', event => {
handle.classList.add( 'dragging' );
//console.log( event );
} );
handle.addEventListener( 'dragend', event => {
handle.style.left = event.screenX + 'px';
} );
// document.addEventListener( 'mousemove', event => {
// // ABORT MISSION IF SLIDER IS NOT CLICKED
// if ( handle.classList.contains( 'dragging' ) == false ) return;
// // CODE ONLY GETS EXECUTED WHEN THE SLIDER IS CLICKED
// handle.style.left = event.clientX + 'px';
// } );
// document.addEventListener( 'mouseup', ( ) => {
// handle.classList.remove( 'dragging' );
// } );
console.log( handle )
*/
/*document.getElementById('right').addEventListener("scroll", (event) => {
console.log(event.target.scrollTop)
document.getElementById('alper').style.top = event.target.scrollTop + 'px'
}) */