");
$("#OJobs_slider").append("
Config
");
$("#OJobs_slider").append("
");
$("#OJobs_slider").append("
");
$("#OJobs_slider").slider();
$("#OJobs_config").append("
");
$("#OJobs_allyChat").append("
");
$("#OJobs_allyChat").children(0).css("height", "280px");
$("#OJobs_allyChat").append("
");
$("#OJobs_allyChat_input").css("width", "70%").css("height", "1.2em").css("min-height", "1.2em").css("max-height", "1.2em").css("top", "5px");
$("#OJobs_allyChat").append("
");
$("#OJobs_allyChat_log").css("overflow", "auto");
$("#OJobs_allyChat_log").click(function(event) {
OJAllyChatBlink(-1);
if(lastAllyMsg != 0)
{
lastAllyMsgRead = lastAllyMsg;
OJconfig["lastAllyMsgRead_" + OJconfig["uni"]] = lastAllyMsgRead;
GM_setValue("lastAllyMsgRead_" + OJconfig["uni"], lastAllyMsgRead);
}
});
$("#OJobs_allyChat_log").css("word-wrap", "break-word");
$("#OJobs_allyChat_header").click(function(event) {
OJAllyChatBlink(0);
$("#OJobs_allyChat_log").scrollTop($("#OJobs_allyChat_log")[0].scrollHeight);
if(lastAllyMsg != 0)
{
OJconfig["lastAllyMsgRead_" + OJconfig["uni"]] = lastAllyMsgRead;
GM_setValue("lastAllyMsgRead_" + OJconfig["uni"], lastAllyMsgRead);
}
});
$("#OJobs_allyChat_input").css("margin-left", "3px");
OJconfig["allyChat_continueLoading_" + OJconfig["uni"]] = OJconfig["allyChat_continueLoading_" + OJconfig["uni"]]%2;
allyChatContinueLoading = OJconfig["allyChat_continueLoading_" + OJconfig["uni"]];
if(allyChatContinueLoading == 1)
{
$("#OJobs_config_allyChat_continueLoading").attr("checked", "checked");
}
$("#OJobs_config_allyChat_continueLoading").change(function(event) {
if($("#OJobs_config_allyChat_continueLoading").is(":checked")){
allyChatContinueLoading = 1;
}
else
{
allyChatContinueLoading = 0;
}
OJconfig["allyChat_continueLoading_" + OJconfig["uni"]] = allyChatContinueLoading;
GM_setValue("allyChat_continueLoading_" + OJconfig["uni"], allyChatContinueLoading);
});
allyChatRate = OJconfig["allyChat_refresh_" + OJconfig["uni"]];
$("#OJobs_config_allyChat_refresh").val(allyChatRate);
$("#OJobs_config_allyChat_refresh").change(function(event) {
if($("#OJobs_config_allyChat_refresh").val() < 3)
{
$("#OJobs_config_allyChat_refresh").val("3");
}
allyChatRate = $("#OJobs_config_allyChat_refresh").val();
OJconfig["allyChat_refresh_" + OJconfig["uni"]] = allyChatRate;
GM_setValue("allyChat_refresh_" + OJconfig["uni"], allyChatRate);
}).css("height", "1.2em").css("min-height", "1.2em").css("max-height", "1.2em");
allyChatRate = OJconfig["allyChat_refresh_" + OJconfig["uni"]];
$("#OJobs_config_allyChat_refresh").val(allyChatRate);
$("#OJobs_config_allyChat_refresh").change(function(event) {
if($("#OJobs_config_allyChat_refresh").val() < 3)
{
$("#OJobs_config_allyChat_refresh").val("3");
}
allyChatRate = $("#OJobs_config_allyChat_refresh").val();
OJconfig["allyChat_refresh_" + OJconfig["uni"]] = allyChatRate;
GM_setValue("allyChat_refresh_" + OJconfig["uni"], allyChatRate);
}).css("height", "1.2em").css("min-height", "1.2em").css("max-height", "1.2em");
$("#OJobs_config_allyChat_fontSize").val(OJconfig["allyChat_fontSize_" + OJconfig["uni"]]);
$("#OJobs_allyChat").css("fontSize", OJconfig["allyChat_fontSize_" + OJconfig["uni"]] + "px");
$("#OJobs_config_allyChat_fontSize").change(function(event) {
OJconfig["allyChat_fontSize_" + OJconfig["uni"]] = $("#OJobs_config_allyChat_fontSize").val();
GM_setValue("allyChat_fontSize_" + OJconfig["uni"], $("#OJobs_config_allyChat_fontSize").val());
$("#OJobs_allyChat").css("fontSize", OJconfig["allyChat_fontSize_" + OJconfig["uni"]] + "px");
}).css("height", "1.2em").css("min-height", "1.2em").css("max-height", "1.2em");
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
if($("#OJobs_allyChat_input").hasClass("markItUpEditor"))
{
$("#OJobs_allyChat_input").parent().parent().parent()[0].outerHTML = $("#OJobs_allyChat_input")[0].outerHTML;
$("#OJobs_allyChat_input").next().remove();
$("#OJobs_allyChat_input").removeClass("markItUpEditor");
}
if($("#OJobs_config_allyChat_refresh").hasClass("markItUpEditor"))
{
$("#OJobs_config_allyChat_refresh").parent().parent().parent()[0].outerHTML = $("#OJobs_config_allyChat_refresh")[0].outerHTML;
$("#OJobs_config_allyChat_refresh").next().remove();
$("#OJobs_config_allyChat_refresh").removeClass("markItUpEditor");
$("#OJobs_config_allyChat_refresh").val(OJconfig["allyChat_refresh_" + OJconfig["uni"]]);
}
if($("#OJobs_config_allyChat_fontSize").hasClass("markItUpEditor"))
{
$("#OJobs_config_allyChat_fontSize").parent().parent().parent()[0].outerHTML = $("#OJobs_config_allyChat_fontSize")[0].outerHTML;
$("#OJobs_config_allyChat_fontSize").next().remove();
$("#OJobs_config_allyChat_fontSize").removeClass("markItUpEditor");
$("#OJobs_config_allyChat_fontSize").val(OJconfig["allyChat_fontSize_" + OJconfig["uni"]]);
}
observer.observe(document.getElementById("OJobs_allyChat_input"), {
attributes: true
});
});
observer.observe(document.getElementById("OJobs_allyChat_input"), {
attributes: true
});
var OJAllySend = function(event) {
event.preventDefault();
if($("#OJobs_allyChat_input").val() != "")
{
var result = OJobsAllyChatSend($("#OJobs_allyChat_input").val());
event.preventDefault();
}
};
$("#OJobs_allyChat_send").click(function(event) {
OJAllySend(event);
}).css("height", "25px").css("min-height", "25px").css("max-height", "25px");
$("#OJobs_allyChat_input").keydown(function(event) {
if(event.keyCode == 13)
{
OJAllySend(event);
}
});
$("#OJobs_allyChat").prev().click(function(event) {
allyChatIsOpen = (allyChatIsOpen+1)%2;
if(allyChatIsOpen == 1)
{
OJconfig["allyChatIsOpen_" +"uni"] = "1";
GM_setValue("allyChatIsOpen_" + OJconfig["uni"], "1");
OJobsAllyChatGetMessages(0);
OJobsAllyChatGetOnlineStatus(0);
}
else
{
OJconfig["allyChatIsOpen_" +"uni"] = "0";
GM_setValue("allyChatIsOpen_" + OJconfig["uni"], "0");
}
});
$("#OJobs_allyChat_whoIsOnline_header").click(function(event) {
onlineListIsOpen = (onlineListIsOpen+1)%2;
if(onlineListIsOpen == 1)
{
OJconfig["onlineListIsOpen_" +"uni"] = "1";
GM_setValue("onlineListIsOpen_" + OJconfig["uni"], "1");
OJobsAllyChatGetOnlineStatus(0);
}
else
{
OJconfig["onlineListIsOpen_" +"uni"] = "0";
GM_setValue("onlineListIsOpen_" + OJconfig["uni"], "0");
}
});
if(GM_getValue("allyChatIsOpen_" + OJconfig["uni"]) == 1 && GM_getValue("panelIsOpen_" + OJconfig["uni"]) == 1)
{
OJobsAllyChatGetMessages(1);
$("#OJobs_allyChat").toggle();
allyChatIsOpen = (allyChatIsOpen+1)%2;
}
else if(allyChatContinueLoading == 1)
{
OJobsAllyChatGetMessages(1);
}
if(GM_getValue("onlineListIsOpen_" + OJconfig["uni"]) == 1)
{
OJobsAllyChatGetOnlineStatus(1);
$("#OJobs_allyChat_whoIsOnline").toggle();
onlineListIsOpen = (onlineListIsOpen+1)%2;
}
else if(allyChatContinueLoading == 1)
{
OJobsAllyChatGetOnlineStatus(1);
}
}
function OJLogout()
{
clearTimeout(allyChatTimer);
var uni = OJgetCurrentUniverse();
GM_deleteValue("userName_" + uni);
GM_deleteValue("password_" + uni);
GM_deleteValue("hashed_" + uni);
delete OJconfig["userName_" + uni];
delete OJconfig["password_" + uni];
delete OJconfig["hashed_" + uni];
$("#OJUsernameSpan").remove();
$("#OJobs_slider").remove();
$("#OJobs_loginDiv").show();
allyChatIsOpen = 0;
OJconfig["allyChatIsOpen_" + OJconfig["uni"]] = 0;
GM_setValue("allyChatIsOpen_" + OJconfig["uni"], 0);
onlineListIsOpen = 0;
OJconfig["onlineListIsOpen_" + OJconfig["uni"]] = 0;
GM_setValue("onlineListIsOpen_" + OJconfig["uni"], 0);
allyChatContinueLoading = 0;
OJconfig["OJobs_deleteUserSpanallyChatContinueLoading_" + OJconfig["uni"]] = 0;
$("#OJobs_allyChat").hide();
}
function OJLogin(force, hidden)
{
var uni = OJgetCurrentUniverse();
var name;
var passHashed;
var hashed;
var hashed = 0;
if(typeof force === 'undefined')
{
force = 0;
}
if(force != 1 && typeof OJconfig["userName_" + uni] !== 'undefined' && OJconfig["userName_" + uni].length > 0)
{
name = OJconfig["userName_" + uni];
}
else
{
name = $("#OJobs_loginText").val();
}
if(force != 1 && typeof OJconfig["hashed_" + uni] !== 'undefined' && OJconfig["hashed_" + uni] == 1 && $("#OJobs_loginPass").val().length < 1)
{
passHashed = OJconfig["password_" + uni];
hashed = 1;
}
else
{
if(force != 1 && typeof OJconfig["password_" + uni] !== 'undefined' && OJconfig["password_" + uni].length > 0 && $("#OJobs_loginPass").val().length < 1)
{
passHashed = OJconfig["password_" + uni];
hashed = 0;
}
else
{
passHashed = $("#OJobs_loginPass").val();
}
}
var func = function(response) {
var result = JSON.parse(response.responseText);
if(result.status >= 1)
{
GM_setValue("userName_" + uni, result.name);
GM_setValue("password_" + uni, result.passHash);
GM_setValue("hashed_" + uni, "1");
OJconfig["userName_" + uni] = result.name;
OJconfig["password_" + uni] = result.passHash;
OJconfig["hashed_" + uni] = "1";
$("#OJobs_loginDiv").hide();
$("#OJobs_loginDiv").before("
Angemeldet: " + result.name + " LogoutDelete
\n");
$("#OJLogout").click(function (event) {
OJLogout();
}).css("cursor", "pointer");
$("#OJobs_deleteUserSpan").click(function (event) {
var ays = prompt("Soll der OChat-Account wircklich gelöscht weden?(\"YES\")");
if(ays == "YES")
{
OJDeleteUser(ays);
}
else
{
alert("Bitte auch auf Groß- und Kleinschreibung achten.");
}
}).css("cursor", "pointer");
OJCreateContent();
if(allyChatContinueLoading == 0 && OJconfig["allyChatContinueLoading_" + OJconfig["uni"]] == 1)
{
allyChatContinueLoading = OJconfig["allyChatContinueLoading_" + OJconfig["uni"]];
OJobsAllyChatGetMessages();
OJobsAllyChatGetOnlineStatus();
}
var version1 = OJVersion;
var version2;
if(OJIsBeta == 1)
{
version2 = result.betaVersion;
}
else
{
version2 = result.clientVersion;
}
if(version1 != version2)
{
version1 = version1.split(".");
version2 = version2.split(".");
var version2Old = 0;
var versionBigger = 0;
version2.forEach(function(element, index) {
if(typeof version1[index] === 'undefined')
{
version1[index] = 0;
}
});
version1.forEach(function(element, index) {
if(typeof version2[index] === 'undefined')
{
version2[index] = 0;
}
version1[index] = parseInt(version1[index]);
version2[index] = parseInt(version2[index]);
if(version2Old == 0 && versionBigger == 0 && version1[index] < version2[index])
{
version2Old = 1;
}
else if(version2Old != 1 && version1[index] > version2[index])
{
versionBigger = 1
}
});
if(version2Old == 1)
{
if(OJIsBeta != 1)
{
$("#OJobs_versionSpan").css("color", "#FF0000");
$("#OJobs_versionSpan").append("
Update");
$("#OJobs_versionSpan").click(function(event) {
window.location = "http://ochat.crypt-msg.de/OChat.user.js";
}).css("cursor", "pointer");
}
else
{
$("#OJobs_versionSpan").css("color", "#FF0000");
$("#OJobs_versionSpan").append("
Update");
$("#OJobs_versionSpan").click(function(event) {
window.location = "http://ochat.crypt-msg.de/OChat.beta.user.js";
}).css("cursor", "pointer");
}
}
}
}
else
{
if(typeof hidden === "undefined")
{
hidden = 0;
}
if(hidden != 1)
{
alert("Falsche Benutzerdaten!");
}
OJLogout();
}
};
var result = api("login", func, "&hashed=" + hashed + "&name=" + name + "&passHash=" + passHashed + "&uni=" + uni + "&version=" + OJVersion);
}
function OJDeleteUser(areYouSure)
{
var func = function(response) {
result = JSON.parse(response.responseText);
if(result.status >= 1)
{
alert("Erfolgreich gelöscht!");
}
else
{
alert("Fehlgeschlagen:\n" + result.message);
}
};
api("deleteUser", func, "&areYouSure=" + areYouSure);
}
function OJRegister()
{
if($("#OJobs_registerPass1").val() == $("#OJobs_registerPass2").val())
{
var passHash = $("#OJobs_registerPass1").val();
var func = function(response) {
result = JSON.parse(response.responseText);
if(result.status >= 1)
{
OJconfig["hashed_" + OJconfig["uni"]] = "1";
GM_setValue("hashed_" + OJconfig["uni"], "1");
OJconfig["password_" + OJconfig["uni"]] = result.passHash;
GM_setValue("password_" + OJconfig["uni"], result.passHash);
OJLogin(0,1);
$("#OJobs_registerPass1").val("");
$("#OJobs_registerPass2").val("");
}
else
{
alert("Anmeldung Fehlgeschlagen:\n" + result.message);
}
};
api("register", func, "&hashed=0&name=" + $("#OJobs_loginText").val() + "&passHash=" + passHash + "&uni=" + OJconfig["uni"]);
}
else
{
alert("Die Passwörter stimmen nicht überein.");
}
}
function OJcreateMenu(hidden, event)
{
var uni = OJgetCurrentUniverse();
$("#box").append("
");
$("#OJobs_panel").css("position", "absolute");
$("#OJobs_panel").width("300px");
$("#OJobs_panel").css("z-index", "3001").css("right", "-158px").css("height", "auto").css("background-color", "#192026");
//$("#OJobs_panel").css("margin-left", "133px");
$("#OJobs_panel").css("padding-top", "20px").css("padding-left", "5px").css("padding-right", "5px").css("padding-bottom", "20px");
$("#OJobs_panel").append("
Nur auf der Übersichtsseite einloggen und registrieren!
");
//$("#OJobs_loginDiv").append("
");
$("#OJobs_loginDiv").append("Register:
");
$("#OJobs_panel").append("");
$("#OJobs_header").append("
[-]");
$("#OJobs_minimizePanel").css("float", "right").css("cursor", "pointer");
$("#OJobs_minimizePanel").click(function (event) {
OJdisplayMenu();
});
$("#OJobs_minimizePanel").next().css("clear", "right");
$("#OJobs_panel").append("");
$("#OJobs_loginForm").submit(function(event){
event.preventDefault();
});
$("#OJobs_loginButton").click(function (event) {
OJLogin(1);
$("#OJobsloginPass").val("");
event.preventDefault();
});
$("#OJobs_loginPass").keydown(function(event)
{
if(event.keyCode == 13)
{
event.preventDefault();
}
});
$("#OJobs_footer").css("bottom", "0px").css("width", "100%").css("position", "absolute").css("left", "0px").css("background-color", "#222329");
$("#OJobs_header").css("top", "0px").css("width", "306px").css("position", "absolute").css("left", "0px").css("background-color", "#222329").css("padding", "2px");
$("#OJobs_header").css("cursor", "move");
if(typeof OJconfig["userName_" + OJconfig["uni"]] !== 'undefined' && OJconfig["userName_" + OJconfig["uni"]].length > 0)
{
$("#OJobs_loginText").val(OJconfig["userName_" + OJconfig["uni"]]);
if(OJconfig["hashed_" + OJconfig["uni"]] == 1)
{
if(typeof hidden === undefined)
{
OJLogin(0, 0);
}
else
{
OJLogin(0, hidden);
}
}
}
$("#OJobs_registerButton").click(function (event) {
OJRegister();
event.preventDefault();
});
var offLeft = GM_getValue("offsetLeft_" + OJconfig["uni"]);
var offTop = GM_getValue("offsetTop_" + OJconfig["uni"]);
if(offLeft != '0')
{
$("#OJobs_panel").offset({
top: offTop,
left: offLeft
});
}
$( document ).on("mousemove", function(e) {
if (mouseDragging == 1) {
$("#OJobs_panel").offset({
top: e.pageY-10,
left: e.pageX-100
});
}
});
$("#OJobs_header").mousedown(function(event) {
mouseDragging = 1;
});
$("#OJobs_header").on("mouseup", function(event) {
mouseDragging = 0;
GM_setValue("offsetTop_" + OJconfig["uni"], $("#OJobs_panel").offset().top);
GM_setValue("offsetLeft_" + OJconfig["uni"], $("#OJobs_panel").offset().left);
});
}
function OJdisplayMenu(hidden, event)
{
if($("#OJobs_panel").exists() )
{
if($("#OJobs_panel").is(":visible"))
{
$("#OJobs_panel").hide();
panelIsOpen = 0;
OJconfig["panelIsOpen_" + OJconfig["uni"]] = 0;
GM_setValue("panelIsOpen_" + OJconfig["uni"], 0);
}
else
{
$("#OJobs_panel").show();
panelIsOpen = 1;
OJconfig["panelIsOpen_" + OJconfig["uni"]] = 1;
GM_setValue("panelIsOpen_" + OJconfig["uni"], 1);
}
}
else
{
if(hidden == 1 && GM_getValue("panelIsOpen_" + OJconfig["uni"]) == 1)
{
panelIsOpen = 1;
OJconfig["panelIsOpen_" + OJconfig["uni"]] = 1;
GM_setValue("panelIsOpen_" + OJconfig["uni"], 1);
OJcreateMenu(1, null);
}
else
{
if(hidden == 0)
{
panelIsOpen = 1;
OJconfig["panelIsOpen_" + OJconfig["uni"]] = 1;
GM_setValue("panelIsOpen_" + OJconfig["uni"], 1);
OJcreateMenu(0, event);
}
else
{
panelIsOpen = 0;
OJconfig["panelIsOpen_" + OJconfig["uni"]] = 0;
GM_setValue("panelIsOpen_" + OJconfig["uni"], 0);
OJcreateMenu(1, event);
}
}
}
}
$( document ).ready(function() {
OJReadConfig();
panelIsOpen = OJconfig["panelIsOpen_" + OJconfig["uni"]];
allyChatIsOpen = OJconfig["allyChatIsOpen_" + OJconfig["uni"]];
onlineListIsOpen = OJconfig["onlineListIsOpen_" + OJconfig["uni"]];
allyChatContinueLoading = OJconfig["allyChatContinueLoading_" + OJconfig["uni"]];
lastAllyMsgRead = OJconfig["lastAllyMsgRead_" + OJconfig["uni"]];
var i = 0;
var list = $("#bar").children("ul");
var html = "
OChat";
list.append(html);
$("#OJobs_tb").click(function(event) {
OJdisplayMenu(0, event);
if(allyChatIsOpen == 1 && panelIsOpen == 1 && !$("#OJobs_allyChat_log").is(":visible"))
{
$("#OJobs_allyChat_header").click();
}
});
if(GM_getValue("panelIsOpen_" + OJconfig["uni"]) == "1")
{
OJdisplayMenu(1);
}
else if(OJconfig["allyChat_continueLoading_" + OJconfig["uni"]] == 1)
{
OJcreateMenu(1);
$("#OJobs_panel").hide();
}
});
function dAlert(text)
{
var arr = text.split(",");
var alertText ="";
arr.forEach(function(element, index) {
while(element.length > 45)
{
var t = element.substr(0, 45);
element = element.substr(45);
alertText = alertText + "\n" + t;
}
alertText = alertText + "\n" + element;
});
alert(alertText);
}