function edbrl(key, options) {
//this.resultbox = 'resultbox';
this.lang = 'eng';
this.key = 'kla';
this.options = {
};
//ini value
//if (resultbox) { this.resultbox = resultbox;}
if (key) { this.key = key;}
if (options) { this.options = options;}
}
edbrl.prototype.init = function () {
var thisobj = this;
}
edbrl.prototype.get_latest_res = function () {
var thisobj = this;
var post_query = null;
var post_sort = "uploaded_date";
var lang = this.lang;
var key = this.key;
$.post("/hkecmodule/APIs/res/handler.php?action=search_resources",{'key':this.key, 'query':post_query, 'sort':post_sort},function (data){
if (data != 'null') {
var ids = eval('(' + data + ')');
$.each(ids, function(idx, val) {
if (idx > 2) return;
var index = idx+1;
$.post("/hkecmodule/APIs/res/handler.php?action=get_resources",
{
'rid':val,
'lang':lang,
'key':key
},
function(data){
$("#new_resource_title_"+index).html("" + data.title + "");
$resource_type_array = data.resource_type.split(",", 5);
$("#new_resource_type_"+index).html($resource_type_array.join(" | "));
//$("#new_resource_type_"+index).html(data.resource_type.replace(/,/gi, " | "));
},"json");
});
for (i = ids.length+1; i <=3 ; i++)
{
$("#new_resource_title_" + i).html("No resource");
$("#new_resource_type_" + i).html("");
}
}
else
{
$("#new_resource_title_1").html("No resource");
$("#new_resource_type_1").html("");
$("#new_resource_title_2").html("No resource");
$("#new_resource_type_2").html("");
$("#new_resource_title_3").html("No resource");
$("#new_resource_type_3").html("");
}
}, "html");
}
edbrl.prototype.get_popular_res = function () {
var thisobj = this;
var lang = this.lang;
var key = this.key;
$.post("/hkecmodule/APIs/res/handler.php?action=get_most_popular_resources",{'key':this.key},function (data){
if (data != 'null') {
var ids = eval('(' + data + ')');
$.each(ids, function(idx, val) {
if (idx > 2) return;
var index = idx+1;
$.post("/hkecmodule/APIs/res/handler.php?action=get_resources",
{
'rid':val,
'lang':lang,
'key':key
},
function(data){
$("#most_popular_title_"+index).html("" + data.title + "");
$resource_type_array = data.resource_type.split(",", 5);
$("#most_popular_type_"+index).html($resource_type_array.join(" | "));
//$("#most_popular_type_"+index).html(data.resource_type.replace(/,/gi, " | "));
},"json");
});
for (i = ids.length+1; i <=3 ; i++)
{
$("#most_popular_title_" + i).html("No resource");
$("#most_popular_type_" + i).html("");
}
}
else
{
$("#most_popular_title_1").html("No resource");
$("#most_popular_type_1").html("");
$("#most_popular_title_2").html("No resource");
$("#most_popular_type_2").html("");
$("#most_popular_title_3").html("No resource");
$("#most_popular_type_3").html("");
}
}, "html");
}