Skip to content

Commit

Permalink
In local mode, the site loads individual JS files for more productive…
Browse files Browse the repository at this point in the history
… development. But in non-local mode, it loads the combined JS files.
  • Loading branch information
oazabir committed Aug 3, 2012
1 parent d83cf5e commit 1d14a0f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 19 deletions.
15 changes: 9 additions & 6 deletions Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

<asp:Content ContentPlaceHolderID="scripts" runat="server">
<!-- Copyright 2012 Omar AL Zabir -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>

<script type="text/javascript" src="js/CombinedDashboard.js?v=5"></script>
<% if (Request.IsLocal) { %>
<!--
If you change any of the below javascript files, make sure you run the Combine.bat
file in the /js folder to generate the CombinedDashboard.js file again. And then don't
forget to update the ?v=#. Otherwise user's will have cached copies in their browser
and won't get the newly deployed file. -->
<!--
<script type="text/javascript" src="js/TheCore.js?v=1"></script>
<script type="text/javascript" src="tiles/tiles.js?v=1"></script>
<script type="text/javascript" src="js/Dashboard.js?v=1"></script>
-->

<% } else { %>
<script type="text/javascript" src="js/CombinedDashboard.js?v=6"></script>
<% } %>

<script type="text/ecmascript">
Expand Down Expand Up @@ -99,7 +100,9 @@
<div id="CombinedScriptAlert" class="alert">
<button class="close" data-dismiss="alert">×</button>
<strong>Warning!</strong>
Combined javascript files are outdated. Please retun the js\Combine.bat file.
Combined javascript files are outdated.
Please retun the js\Combine.bat file.
Otherwise it won't work when you will deploy on a server.
</div>
<div id="metro-sections-container" class="metro">
<div id="trash" class="trashcan">
Expand Down Expand Up @@ -142,7 +145,7 @@
</div>
</div>
</div>
<div id="copyright">
<div id="copyright">
Copyright 2012 <a href="http://omaralzabir.com/">Omar AL Zabir</a>. This is Open Source.
For license details and to get the code, <a href="http://oazabir.github.com/Droptiles/">See Droptiles GitHub</a>
</div>
Expand Down
13 changes: 10 additions & 3 deletions Default.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@ protected void Page_Load(object sender, EventArgs e)
});
}

protected string GetAlerts()
private bool IsCombinedJSOlder(string path)
{
var jsPath = Server.MapPath("~/js");
var jsPath = Context.Server.MapPath(path);
string[] files = Directory.GetFiles(jsPath);

var combinedFileLastWrite = File.GetLastWriteTime(Server.MapPath("~/js/Combined.js"));

if (Array.Exists(files, file => (File.GetLastWriteTime(file) - combinedFileLastWrite).TotalSeconds > 5))
return Array.Exists(files, file => (File.GetLastWriteTime(file) - combinedFileLastWrite).TotalSeconds > 1);
}

protected string GetAlerts()
{
if (IsCombinedJSOlder("~/js/") || IsCombinedJSOlder("~/Tiles/"))
{
return "$('#CombinedScriptAlert').show();";
}
else
{
return string.Empty;
}

}
}
13 changes: 7 additions & 6 deletions Droptiles.master
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@
</asp:ContentPlaceHolder>
</body>


<script type="text/javascript" src="js/Combined.js?v=4"></script>
<!--
<% if (Request.IsLocal) { %>
<!--
If you change any of the below javascript files, make sure you run the Combine.bat
file in the /js folder to generate the CombinedDashboard.js file again. And then don't
forget to update the ?v=#. Otherwise user's will have cached copies in their browser
and won't get the newly deployed file. -->

<!--
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="js/jQueryEnhancement.js"></script>
Expand All @@ -53,8 +51,11 @@
<script type="text/javascript" src="js/Underscore.js"></script>
<script type="text/javascript" src="js/jQuery.hashchange.js"></script>
<script type="text/javascript" src="js/User.js"></script>
-->


<% } else { %>
<script type="text/javascript" src="js/Combined.js?v=4"></script>
<% } %>

<script type="text/javascript">
// Bootstrap initialization
$(document).ready(function () {
Expand Down
16 changes: 14 additions & 2 deletions Tiles/Tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ window.DefaultTiles = [
{ id: "amazon1", name:"amazon" },
{ id: "news1", name: "news" },
{ id: "weather1", name: "weather" },
{ id: "calendar1", name: "calendar" },
//{ id: "calendar1", name: "calendar" },
{ id: "video1", name: "video" },
{ id: "feature1", name: "feature" },
{ id: "facebook1", name: "facebook" }
]
Expand Down Expand Up @@ -105,6 +106,17 @@ window.TileBuilders = {
};
},

video: function (uniqueId) {
return {
uniqueId: uniqueId,
name: "ie",
size: "tile-double",
color: "bg-color-darken",
iconSrc: "img/Youtube.png",
slides: ['<iframe width="310" height="174" src="http://www.youtube.com/embed/IO45ZiGql8E" frameborder="0" allowfullscreen=""></iframe>']
};
},

facebook: function (uniqueId) {
return {
uniqueId: uniqueId,
Expand Down Expand Up @@ -186,7 +198,7 @@ window.TileBuilders = {
name: "email",
iconSrc: "img/Youtube.png",
label: "Youtube",
color: "bg-color-yellow",
color: "bg-color-darken",
appUrl: "http://www.youtube.com/",
appInNewWindow: true
};
Expand Down
16 changes: 14 additions & 2 deletions js/CombinedDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,8 @@ window.DefaultTiles = [
{ id: "amazon1", name:"amazon" },
{ id: "news1", name: "news" },
{ id: "weather1", name: "weather" },
{ id: "calendar1", name: "calendar" },
//{ id: "calendar1", name: "calendar" },
{ id: "video1", name: "video" },
{ id: "feature1", name: "feature" },
{ id: "facebook1", name: "facebook" }
]
Expand Down Expand Up @@ -845,6 +846,17 @@ window.TileBuilders = {
};
},

video: function (uniqueId) {
return {
uniqueId: uniqueId,
name: "ie",
size: "tile-double",
color: "bg-color-darken",
iconSrc: "img/Youtube.png",
slides: ['<iframe width="310" height="174" src="http://www.youtube.com/embed/IO45ZiGql8E" frameborder="0" allowfullscreen=""></iframe>']
};
},

facebook: function (uniqueId) {
return {
uniqueId: uniqueId,
Expand Down Expand Up @@ -926,7 +938,7 @@ window.TileBuilders = {
name: "email",
iconSrc: "img/Youtube.png",
label: "Youtube",
color: "bg-color-yellow",
color: "bg-color-darken",
appUrl: "http://www.youtube.com/",
appInNewWindow: true
};
Expand Down

0 comments on commit 1d14a0f

Please sign in to comment.