diff --git a/src/AboutMe.Mvc.Web/AboutMe.Mvc.Web.csproj b/src/AboutMe.Mvc.Web/AboutMe.Mvc.Web.csproj
index b9fbb92..ab28b13 100644
--- a/src/AboutMe.Mvc.Web/AboutMe.Mvc.Web.csproj
+++ b/src/AboutMe.Mvc.Web/AboutMe.Mvc.Web.csproj
@@ -227,6 +227,7 @@
+
main.js
diff --git a/src/AboutMe.Mvc.Web/App_Start/BundleConfig.cs b/src/AboutMe.Mvc.Web/App_Start/BundleConfig.cs
index 2b3bac7..550ed76 100644
--- a/src/AboutMe.Mvc.Web/App_Start/BundleConfig.cs
+++ b/src/AboutMe.Mvc.Web/App_Start/BundleConfig.cs
@@ -21,9 +21,10 @@ namespace AboutMe.Mvc.Web
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/site").Include(
- "~/Scripts/main.js",
"~/Scripts/Mustache.js",
- "~/Scripts/GithubActivity.js"));
+ "~/Scripts/GithubActivity.js",
+ "~/Scripts/lodestoneapi.js",
+ "~/Scripts/main.js"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
diff --git a/src/AboutMe.Mvc.Web/Scripts/_references.js b/src/AboutMe.Mvc.Web/Scripts/_references.js
index 5408a1e..35fdcb6 100644
Binary files a/src/AboutMe.Mvc.Web/Scripts/_references.js and b/src/AboutMe.Mvc.Web/Scripts/_references.js differ
diff --git a/src/AboutMe.Mvc.Web/Scripts/lodestoneapi.js b/src/AboutMe.Mvc.Web/Scripts/lodestoneapi.js
new file mode 100644
index 0000000..2039bdf
--- /dev/null
+++ b/src/AboutMe.Mvc.Web/Scripts/lodestoneapi.js
@@ -0,0 +1,150 @@
+/* --------------------------------------------------
+ * XIVPads.com (v5) - Lodestone API (Javascript)
+ * This runs off: XIVSync.com
+ *
+ * > requires jquery.
+ * --------------------------------------------------
+ * API calls will match those of the PHP API, so for
+ * example, you can do:
+ *
+ * LodestoneAPI.Search.Character(Name, Server);
+ * LodestoneAPI.Search.Character(123456);
+ */
+var LodestoneAPI =
+{
+ logEnabled: false,
+
+ paths:
+ {
+ sync: 'http://xivsync.com',
+ search: '/search/character',
+ character: '/character/get',
+ },
+
+ // Initialize
+ init: function()
+ {
+ LodestoneAPI.log('init()');
+
+ // check for jquery.
+ if (typeof window.jQuery == 'undefined') {
+ console.error('Please include https://jquery.com/, this API requires it.');
+ }
+ },
+
+ // wrapper for ajaxing
+ get: function(url, data, callback)
+ {
+ LodestoneAPI.log('get', url);
+ LodestoneAPI.log('get', data);
+
+ $.ajax({
+ url: url,
+ data: data,
+ crossDomain: true,
+ dataType: 'json',
+ success: function(data)
+ {
+ LodestoneAPI.log('get > return', data);
+ if (data.ok) {
+ return callback(data.data);
+ }
+
+ console.error('XIVSync API Error: '+ data.msg);
+ return callback(false);
+ },
+ error: function(data, status, error)
+ {
+ console.error('Error attempting to ajax to: ' + url);
+ console.error(status);
+ console.error(error);
+ console.error('Please open an issue on Github: https://github.com/viion/XIVPads-LodestoneAPI');
+ return callback(false);
+ },
+ })
+ },
+
+ // Logging
+ log: function(text, data)
+ {
+ if (LodestoneAPI.logEnabled) {
+ if (data) {
+ console.log('[LODESTONE-API]', text, data);
+ return;
+ }
+
+ console.log('[LODESTONE-API]', text);
+ }
+ },
+
+ // Search for thingz
+ Search:
+ {
+ Character: function(nameOrId, server, callback, recurrsive)
+ {
+ if (!callback || typeof callback !== 'function') {
+ console.error('Callback function not defined.');
+ return;
+ }
+
+ if (!nameOrId) {
+ console.error('Name or ID is empty');
+ return callback(false);
+ }
+
+ // if numeric, can just get character
+ // else we have to search!
+ if ($.isNumeric(nameOrId))
+ {
+ LodestoneAPI.log('search > character > isNumeric = true =', nameOrId);
+
+ var url = LodestoneAPI.paths.sync + LodestoneAPI.paths.character,
+ data = { lodestone: nameOrId }
+
+ LodestoneAPI.get(url, data, function(data)
+ {
+ // if empty
+ if (data.length == 0) {
+ return callback(false);
+ }
+
+ return callback(data);
+ });
+ }
+ else if (!recurrsive)
+ {
+ LodestoneAPI.log('search > character > isNumeric = false =', nameOrId);
+
+ var url = LodestoneAPI.paths.sync + LodestoneAPI.paths.search,
+ data = { name: nameOrId, server: server }
+
+ // get
+ LodestoneAPI.get(url, data, function(data)
+ {
+ // if empty
+ if (data.length == 0) {
+ return callback(false);
+ }
+
+
+ // Try match server and name
+ for (var i in data)
+ {
+ var c = data[i];
+ if (c.name == nameOrId && c.world == server && $.isNumeric(c.i));
+ {
+ // recurrsive callback on character using id
+ LodestoneAPI.log('search > character > recurrsion with id:', c.id);
+ LodestoneAPI.Search.Character(c.id, null, callback, true);
+ return;
+ }
+ }
+
+ LodestoneAPI.log('search > character > no results for: ', nameOrId);
+ return callback(false);
+ });
+ }
+ },
+ },
+}
+LodestoneAPI.init();
\ No newline at end of file
diff --git a/src/AboutMe.Mvc.Web/Scripts/main.js b/src/AboutMe.Mvc.Web/Scripts/main.js
index d2c4754..e1ccd77 100644
--- a/src/AboutMe.Mvc.Web/Scripts/main.js
+++ b/src/AboutMe.Mvc.Web/Scripts/main.js
@@ -49,4 +49,30 @@ jQuery(document).ready(function ($) {
limit: 20 // optional
});
+ var buildFinalFantasy = function (data) {
+ return "";
+ };
+
+ LodestoneAPI.Search.Character(8696200, null, function (data) {
+ if (data !== undefined && data !== null) {
+ $('.secondary').append(buildFinalFantasy(data));
+ }
+ });
+
+
+
});