/**
*
* matrix.js is a standalone javascript software
* Add entries to the page of the month and save the page with CTRL+S
* Use with Firefox - Mozilla Foundation
*
* @author: Fabrice Morisseau
* @version: 6.0
* @date: March 20, 2016
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org
**/
/**
*
* load_menu: Load the menu
*
**/
function load_menu() {
document.getElementById("menu_top").innerHTML = "";
}
/**
*
* add_div: Generate timestamp of the div
*
**/
function add_div() {
var today = new Date();
var y = today.getFullYear();
var M = today.getMonth()+1;
var d = today.getDate();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
return "" + y + M + d + h + m + s;
}
/**
*
* model: Matrix Reloaded Core Engine repository
*
**/
function model() {
this.model = {};
this.add = function (prettyname,form) {
this.model[prettyname] = form;
}
this.get = function (prettyname) {
return this.model[prettyname];
}
}
/**
*
* form: Matrix Reloaded Core Engine form
*
**/
function form(prettyname) {
this.name = prettyname;
this.content = "";
this.set = function (content) {
this.content = content;
}
this.display = function() {
return this.content;
}
}
// Create timestamp
var item = add_div();
// Create Core Engine repository
var breeze = new model();
/**
*
* evolution: Add an entry to the main div
*
**/
function evolution() {
// Create Breeze Evolution Core Engine Forms
var main_evolution = new form("evolution");
main_evolution.set("<div id='item" + item + "' class='item" + item + "'></br></br><h2><div id='date" + item + "' class='date" + item + "'>" + document.getElementById('date').value + "</div></h2></br><div id='entry" + item + "' class='entry" + item + "'>" + document.getElementById('entry').value + "</div> <a href=javascript:update_item('"+ item +"');><img src='css/icon_edit.png' border='0'></a> <a href=javascript:delete_item('"+ item +"');><img src='css/icon_delete.png' border='0' height='18px'></a></div>");
// Add Breeze Evolution Core Engine Forms to Core Engine repository
breeze.add("evolution",main_evolution);
var main = document.getElementById('main').innerHTML;
var str = breeze.get("evolution").display();
while (str.search("\n") != -1)
str = str.replace("\n","<br>");
document.getElementById('main').innerHTML = str + main;
clear_passwd();
}
/**
*
* editor_display: Display Editor
*
**/
function editor_display() {
if (check_passwd())
document.getElementById("editor").innerHTML = "<br><input value='' class='date' id='date' type='text'><br><textarea value='' class='entry' id='entry' cols='60' rows='10'></textarea> <input name='Valid' value='Valid' onclick='javascript:evolution();return false;' type='button'>";
else
document.getElementById("editor").innerHTML = "You must set the password first";
}
/**
*
* editor_close: Close Editor
*
**/
function editor_close() {
document.getElementById("editor").innerHTML = "";
}
/**
*
* update_item: Change the entry displayer from text to update
*
* @param item: timestamp of the entry
*
**/
function update_item(item) {
if (check_passwd()) {
var date = document.getElementById('date' + item).innerHTML;
var entry = document.getElementById('entry' + item).innerHTML;
while (entry.search("\n") != -1)
entry = entry.replace("\n","");
while (entry.search("<br>") != -1)
entry = entry.replace("<br>","\n");
document.getElementById('date' + item).innerHTML = "<input value='" + date + "' class=update_date" + item + " id=update_date" + item + " type=text>";
document.getElementById('entry' + item).innerHTML = "<textarea class=update_entry" + item + " id=update_entry" + item + " cols=60 rows=10>" + entry + "</textarea> <input name=valid_update value=Valid onclick=javascript:valid_update('" + item + "');return false; type=button>";
}
}
/**
*
* valide_update: Update the entry of the main div
*
* @param item: timestamp of the entry
*
**/
function valid_update(item) {
var date = document.getElementById('update_date' + item).value;
var entry = document.getElementById('update_entry' + item).value;
while (entry.search("\n") != -1)
entry = entry.replace("\n","<br>");
document.getElementById('date' + item).innerHTML = date;
document.getElementById('entry' + item).innerHTML = entry;
clear_passwd();
}
/**
*
* delete_item: Delete an entry of the main div
*
* @param item: timestamp of the entry
*
**/
function delete_item(item) {
if (check_passwd())
document.getElementById('item' + item).innerHTML = "";
clear_passwd();
}
/**
*
* start_time: Display time every 10000ms
*
**/
function start_time() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
m = check_time(m);
document.getElementById('clock').innerHTML = "<center>"+h+":"+m+"</center>";
var t = setTimeout(function(){start_time()},10000);
}
/**
*
* check_time: Add zero in front of numbers if < 10
*
* @param i: Minutes
*
**/
function check_time(i) {
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
/**
*
* update_menu: Change the menu displayer from text to update
*
**/
function update_menu() {
var menu = document.getElementById('menu').innerHTML;
if (check_passwd())
document.getElementById('menu').innerHTML = "<textarea class=entry_menu id=entry_menu cols=50 rows=5>" + menu + "</textarea> <input name=valid_menu value=Valid onclick=javascript:valid_menu();return false; type=button>";
}
/**
*
* valide_menu: Update the entry of the menu
*
**/
function valid_menu() {
var menu = document.getElementById('entry_menu').value;
document.getElementById('menu').innerHTML = menu;
clear_passwd();
}
/**
*
* update_about: Change the about displayer from text to update
*
**/
function update_about() {
var about = document.getElementById('about').innerHTML;
if (check_passwd())
document.getElementById('about').innerHTML = "<textarea class=entry_about id=entry_about cols=50 rows=5>" + about + "</textarea> <input name=valid_about value=Valid onclick=javascript:valid_about();return false; type=button>";
}
/**
*
* valide_about: Update the entry of the about
*
**/
function valid_about() {
var about = document.getElementById('entry_about').value;
document.getElementById('about').innerHTML = about;
clear_passwd();
}
/**
*
* clear_passwd: Clear password hidden input
*
**/
function clear_passwd() {
document.getElementById('set_password_value').value = "";
}
/**
*
* check_passwd: check password hidden input
*
**/
function check_passwd() {
var str = document.getElementById('set_password_value').value;
if (str.hashCode() == "-1025043652")
return true;
else
return false;
}
/**
*
* hashCode: return hashCode of any String
*
**/
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash;
}
return hash;
}
Sunday, February 28, 2016
Matrix 6.0 Javascript Source Code
Subscribe to:
Post Comments (Atom)
-
You can easily build a web application with an Object Relational Bridge (O.R.B). The O.R.B should handle the connection and transformation o...
-
There is a saying in information technology that says "If you have a computer, don't use it" and this sound weird. Both my com...
-
Matrix 6.0 source code with Matrix Reloaded Core Engine. The first Matrix was written in 2000 for NetValue Online. Matrix 6.0 is a s...
No comments:
Post a Comment