Skip to content

Commit

Permalink
move function load_script to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-knoebl committed Oct 3, 2014
1 parent 8e13701 commit 1259d84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 16 additions & 0 deletions klib/load_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//from http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file
var loadScript = function(url, callback) {
// Adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;

// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;

// Fire the loading
head.appendChild(script);
};
18 changes: 1 addition & 17 deletions kubos_boxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,12 @@
<script type="text/javascript" src="lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="lib/Detector.js"></script>
<script type="text/javascript" src="klib/setStyle.js"></script>
<script type="text/javascript" src="klib/load_script.js"></script>
<script>
"use strict";

// generic helper functions

//from http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file
var loadScript = function(url, callback) {
// Adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;

// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;

// Fire the loading
head.appendChild(script);
};

var createButton = function(text, onclick) {
var button = document.createElement('button');
setStyle(button, {
Expand Down

0 comments on commit 1259d84

Please sign in to comment.