Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
added option to put library in global scope immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
Youka committed Jan 17, 2015
1 parent 1944b09 commit 370bee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/content_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ window.addEventListener("load", function(evt){
// Add right space for vertical scrollbar (on appearance)
fixScrollBar(code, "vertical");
// Set code highlight
code.addEventListener("mouseover", function(){
numberBar.style.display = "table-cell";
code.addEventListener("mouseover", function(evt){
evt.currentTarget.childNodes[1].style.display = "table-cell";
})
code.addEventListener("mouseout", function(){
numberBar.style.display = "none";
code.addEventListener("mouseout", function(evt){
evt.currentTarget.childNodes[1].style.display = "none";
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ <h1>Yutils<span>An ASS typeset utilities library</span></h1>
local Ymath = Yutils.math

print(Ymath.distance(1,1))
-- 1.4142135623731</div>
-- 1.4142135623731</div><br>
It's also possible to load+execute the library script with the first argument as <b>true</b> to register Yutils to the global scope.<br>
<div class="code">loadfile("Yutils.lua")(true)
local Ymath = Yutils.math</div>
</div>
<div class="section" id="Functions">
<div class="function">
Expand Down
7 changes: 6 additions & 1 deletion src/Yutils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------------------------------------------
Version: 14th November 2014, 15:45 (GMT+1)
Version: 17th January 2015, 15:45 (GMT+1)
Yutils
table
Expand Down Expand Up @@ -3525,5 +3525,10 @@ Yutils = {
}
}

-- Put library in global scope (if first script argument is true)
if ({...})[1] then
_G.Yutils = Yutils
end

-- Return library to script loader
return Yutils

0 comments on commit 370bee4

Please sign in to comment.