Skip to content

Commit

Permalink
Using ajax to download github release download count
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex authored and Jaex committed Nov 17, 2013
1 parent 5f93e4e commit d89712c
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 55 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
156 changes: 156 additions & 0 deletions .gitignore
@@ -0,0 +1,156 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf


#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store
14 changes: 14 additions & 0 deletions Web.config
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules>
<add name="FilterForBrowserLink"
type="Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.PageInspectorHttpModule,
Microsoft.VisualStudio.Web.PageInspector.Runtime, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
</configuration>
38 changes: 38 additions & 0 deletions Website.sln
@@ -0,0 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "sharex.github.io", "http://localhost:56650", "{9C3AC163-95E7-4C20-811C-440D3541C073}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
Debug.AspNetCompiler.VirtualPath = "/localhost_56650"
Debug.AspNetCompiler.PhysicalPath = "..\sharex.github.io\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_56650\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/localhost_56650"
Release.AspNetCompiler.PhysicalPath = "..\sharex.github.io\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_56650\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "..\sharex.github.io\"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C3AC163-95E7-4C20-811C-440D3541C073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C3AC163-95E7-4C20-811C-440D3541C073}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions css/sharex.css
Expand Up @@ -787,4 +787,9 @@ footer p {

a .img-thumbnail {
max-height: 150px;
}

.release-info {
display: none;
font-size: 8px;
}
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -72,7 +72,7 @@ <h2>Loading...</h2>

<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/sharex.js"></script>
<script src="../js/sharex_docs.js"></script>

<script>
(function (i, s, o, g, r, a, m) {
Expand Down
2 changes: 2 additions & 0 deletions index.html
Expand Up @@ -46,6 +46,7 @@ <h1>ShareX</h1>
<a href="https://sharex.googlecode.com/files/ShareX-8.3.0.747-setup.exe" class="btnd btnd-1 btnd-1d">Download ShareX</a>
<a href="https://github.com/ShareX/ShareX" class="btnd btnd-1 btnd-1d">View on Github</a>
</p>
<p class="release-info"></p>
</div>
</div>

Expand Down Expand Up @@ -130,6 +131,7 @@ <h1>ShareX</h1>

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/sharex.js"></script>

<script type="text/javascript">
(function () {
Expand Down
65 changes: 11 additions & 54 deletions js/sharex.js
@@ -1,55 +1,12 @@
$("#sidebar").affix({
offset: {
top: $('#top-navbar').height() + $('.jumbotron').height()
}
});

$(document).ready(function () {
var isLoading = false;
var hash = window.location.hash.substr(1) + ".html";
$("#sidebar a").each(function () {
var href = $(this).attr("href");
if (hash == href) {
LoadContent(href);
ToggleActive($(this));
isLoading = true;
return false;
}
$(document).ready(function () {
$.getJSON("https://api.github.com/repos/ShareX/ShareX/releases").done(function (json) {
var latestRelease = json[0];
var name = latestRelease.name;
var asset = latestRelease.assets[0];
var date = new Date(asset.updated_at);
var downloadCount = asset.download_count;
var text = name + " was last updated on " + date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " and has been downloaded " + downloadCount + " times.";
$(".release-info").text(text);
$(".release-info").slideDown("slow");
});

if (!isLoading) {
var href = $("#sidebar a").first().attr("href");
LoadContent(href);
}

$("#sidebar a").click(function () {
window.scrollTo(0, 0);
var href = $(this).attr("href");
LoadContent(href);
ToggleActive($(this));
return false;
});
});

function LoadContent(href) {
$("#content").fadeOut("fast", loadContent);
$("#loading").fadeIn("fast");

window.location.hash = href.substr(0, href.length - 5);

function loadContent() {
$("#content").load(href, "", showNewContent())
}

function showNewContent() {
$("#loading").hide();
$("#content").fadeIn("normal");
}
}

function ToggleActive(a) {
$("#sidebar a.active").removeClass("active");
if (!a.hasClass('active')) {
a.addClass('active');
}
}
});

0 comments on commit d89712c

Please sign in to comment.