dhtml = function() {
this.alert_window_count = 0;
this.layer_list = new Array();
this.post_vars = new Array();
this.template_mappings = new Array();
this.current_url = window.location.href;
this.current_url = this.current_url.replace(/^[^\?]+\?/, "");
}
/*
This function will display a quick alert box
*/
dhtml.prototype.alert = function(data, single, options) {
if (this.alert_window_count < 0) {
this.alert_window_count = 0;
}
alert_layer_id = "common_alert_layer";
if ((single==undefined || single=="" ) && !document.getElementById(alert_layer_id+"_text")) {
alert_layer = document.createElement("div");
alert_layer.id = alert_layer_id;
alert_layer.style.position = "absolute";
start = this.alert_window_count;
alert_layer.style.top = start+"%";
alert_layer.style.left = start+"%";
str = "
";
str += "(Close | Close All)";
alert_layer.innerHTML = str;
document.body.appendChild(alert_layer);
this.layer_list.push(alert_layer);
this.alert_window_count += 15;
}
else {
textarea = document.getElementById(alert_layer_id+"_text");
}
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
textarea = document.getElementById(alert_layer_id+"_text");
d = month+"/"+day+"/"+year+" "+hours+":"+minutes+":"+seconds;
textarea.value = "*********"+d+"****************\n\n"+data + "\n\n\n\n\n\n\n\n" + textarea.value;
}
/*
function closes a single alert layer
*/
dhtml.prototype.close_alert_layer = function(layer) {
if (typeof(layer) == "string") {
layer = document.getElementById(layer);
}
this.remove_node(layer)
this.alert_window_count -= 2;
return false;
}
/*
function closes every layer that was generated from the alert
*/
dhtml.prototype.close_all_alert_layers = function() {
for (x in this.layer_list) {
this.remove_node(this.layer_list[x]);
}
this.layer_list = new Array();
this.alert_window_count = 0;
}
/*
This function will return the container as given from the php
template function. basically searches from the given node up the tree untill the
container is found. Returns a jquery object
*/
dhtml.prototype.get_container = function(node) {
//If this is a string get the html object
if (typeof(node) == "string") {
file_struct = node;
node = document.getElementById(node);
}
//is this a jquery object
else if (typeof(node) == "object" && node.length > 0) {
node = node.context;
}
p = node.parentNode;
for (x=0; x<100; x++) {
p = p.parentNode;
if ($(p).attr("container") != undefined) {
container = $(p);
break;
}
}
return container;
}
/*
This function returns the style from the array inline
*/
dhtml.prototype.get_inline_style = function(name, myStyles) {
style_str = "";
style_str += "";
return style_str;
}
/*
This function will show the page as loading
*/
dhtml.prototype.hide_loading = function() {
this.remove_node("dhtml_load_overlay");
this.remove_node("dhtml_load_box");
}
/*
This function will return the entries from a drop down list to a database
*/
dhtml.prototype.load_template_file_from_options = function(load_class, file_struct, container_id, options, callback) {
ajax_vals = new Object();
options = options.split(",");
for (x=0; x| "+content+" |
"
load_box.innerHTML += str;
container.appendChild(load_box);
}
/*
This function is used to submit form data
form_ob is an id or an html form object
class this is the class with process function that you are submitting to
*/
dhtml.prototype.submit_form = function(table, class_variables, form_ob, my_class, callback) {
if (typeof(form_ob) == "string") {
url = $('#'+form_ob+" :input:textarea").serialize();
}
else {
form = $(form_ob);
url = form.find(":input:textarea").serialize();
}
if (callback == "" || callback == undefined) {
callback = new Object();
callback.handleSuccess = function(xmlhttp) {
alert(xmlhttp.responseText);
}
}
url += "&my_action=submit_form&class="+my_class+"&table="+table+"&class_variables="+class_variables;
ajax.connect(callback, url);
return false;
}
/*
This function takes the given id and refreshes the data based on the db info
*/
dhtml.prototype.refresh_data = function(data_container, class_name, func_name, params, required, callback) {
if (callback == undefined) {
callback = {
handleSuccess:function(xmlhttp) {
if (document.getElementById(data_container)) {
document.getElementById(data_container).innerHTML = xmlhttp.responseText;
}
}
}
}
ajax.get_function_data(class_name, func_name, params, required, callback);
}
var dhtml = new dhtml();