I have the following working sample application that display typing text in a terminal window:
Step 1 - working sample which has no problem (3 files in one folder: index.php, style.css and typed-custom.js)
I have the following content for style.css:
.terminal-window {
text-align: left;
width: 620px;
height: 650px;
border-radius: 10px;
margin: auto;
position: relative;
}
.terminal-window section.terminal {
color: white;
font-family: Menlo, Monaco, "Consolas", "Courier New", "Courier";
font-size: 11pt;
background: black;
padding: 10px;
box-sizing: border-box;
position: absolute;
width: 100%;
top: 30px;
bottom: 0;
overflow: auto;
}
.term-home{color: #0095ff;}
I have the following content for typed-custom.js
$(function() {
var data = [
{
action: 'type',
strings: ["typing-1:"],
output: '<span class="green"><small> This is first typing</small></span> ',
postDelay: 1000,
},
{
action: 'type',
strings: ["typing-2:"],
output: '<span class="green"><small>This is second typing</small></span> ',
postDelay: 1000
},
];
runScripts(data, 0);
});
function runScripts(data, pos) {
var prompt = $('.prompt'),
script = data[pos];
if(script.clear === true) {
$('.history').html('');
}
switch(script.action) {
case 'type':
// cleanup for next execution
prompt.removeData();
$('.typed-cursor').text('');
prompt.typed({
strings: script.strings,
typeSpeed: 10,
callback: function() {
var history = $('.history').html();
history = history ? [history] : [];
history.push('<span class="term-home">root:~$</span> ' + prompt.text());
if(script.output) {
history.push(script.output);
prompt.html('');
$('.history').html(history.join('<br>'));
}
// scroll to bottom of screen
$('section.terminal').scrollTop($('section.terminal').height());
// Run next script
pos++;
if(pos < data.length) {
setTimeout(function() {
runScripts(data, pos);
}, script.postDelay || 1000);
}
}
});
break;
case 'view':
break;
}
}
//Note: `typed-custom.js` depends on the library from `https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js` which I have included in index.php:
For displaying, I have the following content for index.php
<?php
?>
<!doctype html>
<html lang="en">
<head>
<title>Test load (load.php)</title>
<!-- Get jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
<script src="typed-custom.js"></script>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<!-- terminal -->
<div class="wrap">
<div class="title-head"> <h5><font color="white">Test</font></h5></div>
<div class="type-wrap">
<div class="terminal-window">
<header>
<div class="button green"></div>
<div class="button yellow"></div>
<div class="button red"></div>
<div class="button black"></div>
</header>
<section class="terminal">
<div class="history"></div>
<span class="term-home">root:~$</span> <span class="prompt"></span>
<span class="typed-cursor"></span>
</section>
<!-- data -->
</div>
</div>
</div>
</body>
</html>
The above is working perfectly with no error.
Step 2 - the problem when loaded external php load.php file into index.php
but now I want to add another display from a php page, so I created a php file call load.php with the following content:
<!DOCTYPE html>
<html>
<head>
<title>load.php show data</title>
<style>
.loadData div {display:none;}
.loadData div.display {display: block;}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
</head>
<body>
<div class="loadData">
<div>Content 1</div>
<div>Content 2</div>
<div>Content 3</div>
<div>Content 4</div>
<div>Content 5</div>
</div>
<a href="#" id="loadMore">Load More</a>
<script>
// this code is used to reduce long div display. example 5 div, reduce it to 3 and when click Load More, it will show all.
$(function () {
$(".loadData div").slice(0, 3).addClass('display');
$("#loadMore").on('click', function (e) {
e.preventDefault();
$(".loadData div:hidden").addClass('display');
if ($(".loadData div:hidden").length == 0) {
$("#loadMore").remove();
} else {
$('html,body').animate({
scrollTop: $(this).offset().top
}, 1500);
}
});
});
</script>
</body>
</html>
Then, I updated my index.php just to load the file load.php at the bottom like this:
index.php
<?php
?>
<!doctype html>
<html lang="en">
<head>
<title>Test Terminal with another php file load at the bottom (load.php)</title>
<!-- Get jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
<script src="typed-custom.js"></script>
<link href="style.css" rel="stylesheet" />
<style>
<!-- internal style -->
</style>
</head>
<body>
<!-- terminal -->
<div class="wrap">
<div class="title-head"> <h5><font color="white">Test</font></h5></div>
<div class="type-wrap">
<div class="terminal-window">
<header>
<div class="button green"></div>
<div class="button yellow"></div>
<div class="button red"></div>
<div class="button black"></div>
</header>
<section class="terminal">
<div class="history"></div>
<span class="term-home">root:~$</span> <span class="prompt"></span>
<span class="typed-cursor"></span>
</section>
<!-- data -->
</div>
</div>
</div>
<!-- NEW CODE HERE WHICH HAS ERROR: try to load an external file using js -->
<div class="container"></div>
<div> This index.php loads "load.php" below</div>
<div id="contents"></div>
<div> ----------------------- </div>
<script>
$().ready(function() {
$("#contents").load("load.php");
});
</script>
</body>
</html>
but, when I run the above code, I got an error saying:
typed-custom.js:39 Uncaught TypeError: prompt.typed is not a function
at runScripts (typed-custom.js:39)
at typed-custom.js:57
and my terminal window stopped typing for the 2nd text (which I suspect is js conflict) but there is no problem clicking the 'Load More' button which also uses js to call.
I searched this error and it said that I might have jquery conflict, but I'm not sure which part is the conflict. Any idea?

step 2. thestep 1is only for demonstration a working sample application.typed-custom.jsso where is the code from this file?