|
|
@ -15,40 +15,40 @@ var cardSettings = { |
|
|
|
|
|
|
|
function loadCard(type, apiurl, title) { |
|
|
|
$.get("cards/" + type + ".html", {}, function (html) { |
|
|
|
console.log(type + " " + apiurl + " " + title); |
|
|
|
var cardClasses = "col-sm-12 col-md-6 col-lg-6 col-xl-4 order-12"; |
|
|
|
if (cardSettings.hasOwnProperty(type) && cardSettings[type].hasOwnProperty("classes")) { |
|
|
|
cardClasses = cardSettings[type]["classes"]; |
|
|
|
} |
|
|
|
var box = $('<div class="col ' + cardClasses + '" id=""></div>'); |
|
|
|
var card = $('<div class="card card_app card_' + type + '" style="width: 100%;" data-title="' + title + '" data-apiurl="' + apiurl + '"></div>'); |
|
|
|
$(card).html(html); |
|
|
|
$(box).html(card); |
|
|
|
$("#card-box").append(box); |
|
|
|
if (loadedCardTypes.indexOf(type) == -1) { |
|
|
|
loadedCardTypes.push(type); |
|
|
|
} |
|
|
|
console.log(type + " " + apiurl + " " + title); |
|
|
|
var cardClasses = "col-sm-12 col-md-6 col-lg-6 col-xl-4 order-12"; |
|
|
|
if (cardSettings.hasOwnProperty(type) && cardSettings[type].hasOwnProperty("classes")) { |
|
|
|
cardClasses = cardSettings[type]["classes"]; |
|
|
|
} |
|
|
|
var box = $('<div class="col ' + cardClasses + '" id=""></div>'); |
|
|
|
var card = $('<div class="card card_app card_' + type + '" style="width: 100%;" data-title="' + title + '" data-apiurl="' + apiurl + '"></div>'); |
|
|
|
$(card).html(html); |
|
|
|
$(box).html(card); |
|
|
|
$("#card-box").append(box); |
|
|
|
if (loadedCardTypes.indexOf(type) == -1) { |
|
|
|
loadedCardTypes.push(type); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function applyCardTitles() { |
|
|
|
$(".card_app").each(function () { |
|
|
|
var title = $(this).data("title"); |
|
|
|
$(this).find(".card_title").text(title); |
|
|
|
var title = $(this).data("title"); |
|
|
|
$(this).find(".card_title").text(title); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function waitForCardsToLoadThenInjectScripts() { |
|
|
|
// How's *that* for self-documenting code?
|
|
|
|
for (var i = 0; i < totalCardTypes.length; i++) { |
|
|
|
if (loadedCardTypes.indexOf(totalCardTypes[i]) == -1) { |
|
|
|
setTimeout(waitForCardsToLoadThenInjectScripts, 50); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (loadedCardTypes.indexOf(totalCardTypes[i]) == -1) { |
|
|
|
setTimeout(waitForCardsToLoadThenInjectScripts, 50); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
applyCardTitles(); |
|
|
|
for (var i = 0; i < loadedCardTypes.length; i++) { |
|
|
|
$.getScript('cards/js/' + loadedCardTypes[i] + '.js'); |
|
|
|
$.getScript('cards/js/' + loadedCardTypes[i] + '.js'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -56,22 +56,22 @@ function waitForCardsToLoadThenInjectScripts() { |
|
|
|
getApps(function (apps) { |
|
|
|
console.log(apps); |
|
|
|
for (var appname in apps) { |
|
|
|
if (!apps.hasOwnProperty(appname)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
var app = apps[appname]; |
|
|
|
console.log(app); |
|
|
|
console.log(" " + app.url); |
|
|
|
console.log(" " + app.title); |
|
|
|
if (typeof app.station_features !== "undefined" && app.station_features.length > 0) { |
|
|
|
for (var type in app.station_features) { |
|
|
|
if (!app.station_features.hasOwnProperty(type)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
totalCardTypes.push(app.station_features[type]); |
|
|
|
loadCard(app.station_features[type], app.url + "/api.php", app.title); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!apps.hasOwnProperty(appname)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
var app = apps[appname]; |
|
|
|
console.log(app); |
|
|
|
console.log(" " + app.url); |
|
|
|
console.log(" " + app.title); |
|
|
|
if (typeof app.station_features !== "undefined" && app.station_features.length > 0) { |
|
|
|
for (var type in app.station_features) { |
|
|
|
if (!app.station_features.hasOwnProperty(type)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
totalCardTypes.push(app.station_features[type]); |
|
|
|
loadCard(app.station_features[type], app.url + "/api.php", app.title); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
waitForCardsToLoadThenInjectScripts(); |
|
|
|
}); |
|
|
|