Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #116 from Idrinth/idrinth
Browse files Browse the repository at this point in the history
Mentions - simple version; Cleanups, reparing registration
  • Loading branch information
Idrinth authored Sep 6, 2016
2 parents db6e6b6 + 695a572 commit 79d8f8b
Show file tree
Hide file tree
Showing 8 changed files with 1,361 additions and 1,347 deletions.
235 changes: 229 additions & 6 deletions mods/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,22 @@ idrinth.chat = {
addZero ( d.getSeconds (), 2 ) +
addZero ( d.getMilliseconds (), 3 );
};
var own = parseInt ( message.user, 10 ) === parseInt ( idrinth.chat.self, 10 );
if ( !own ) {
try {
idrinth.core.sendNotification (
message.time.split ( ' ' )[1] + ' ' + document.getElementById ( 'idrinth-chat-tab-click-' + chatId ).innerHTML + ':',
idrinth.chat.users[message.user].name + ': ' + message.text
);
} catch ( exception ) {
idrinth.core.log ( exception.getMessage () );
}
}
chat.appendChild ( idrinth.ui.buildElement (
{
type: 'li',
id: 'idrinth-single-chat-message-' + messageId + ( parseInt ( messageId, 10 ) < 1 ? '-' + getfullDateInt () : '' ),
css: ( parseInt ( message.user, 10 ) === parseInt ( idrinth.chat.self, 10 ) ? 'self-written ' : '' ),
css: own ? 'self-written ' : '',
children: [
{
type: 'span',
Expand Down Expand Up @@ -460,11 +471,223 @@ idrinth.chat = {
},
emotes: { },
start: function () {
var build = function () {
var makeInput = function ( label ) {
return {
type: 'li',
children: [
{
type: 'label',
content: label
},
{
type: 'input',
attributes: [
{
name: 'type',
value: 'text'
},
{
name: 'onchange',
value: 'this.setAttribute(\'value\',this.value);'
}
]
}
]
};
};
var makeButton = function ( label, onclick ) {
return {
type: 'li',
children: [
{
type: 'button',
attributes: [
{
name: 'type',
value: 'button'
},
{
name: 'onclick',
value: onclick
}
],
content: label
}
]
};
};
return idrinth.ui.buildElement ( {
id: 'idrinth-chat',
css: 'idrinth-hovering-box' + ( !idrinth.settings.chatHiddenOnStart ? ' active' : '' ) + ( idrinth.settings.moveLeft ? ' left-sided' : '' ),
children: [
{
type: 'button',
content: ( idrinth.settings.chatHiddenOnStart ? '<<' : '>>' ),
attributes: [ {
name: 'onclick',
value: 'idrinth.chat.openCloseChat(this);'
} ]
}, {
type: 'ul',
css: 'styles-scrollbar chat-labels',
children: [ {
type: 'li',
css: 'active',
content: "\u2699",
attributes: [
{
name: 'onclick',
value: 'idrinth.chat.enableChat(this);'
},
{
name: 'data-id',
value: '0'
}
]
} ]
}, {
type: 'ul',
css: 'chat-tabs',
children: [ {
type: 'li',
css: 'styles-scrollbar active',
attributes: [
{
name: 'data-id',
value: '0'
}
],
children: [
{
type: 'h1',
content: 'Chat'
},
{
type: 'p',
content: 'This part of the script is optional, so logging in is unneeded for raid catching etc.'
}, {
id: 'idrinth-chat-login',
children: [
{
type: 'h2',
content: 'Account'
},
{
type: 'p',
content: 'This should not be the data for logging in on the related gaming site and the login does not need to match your ingame name - you can set a display name after the registration.'
},
{
type: 'ul',
css: 'settings',
children: [
makeInput ( 'Username' ),
makeInput ( 'Password' ),
makeButton ( "Not logged in, click to login/register", "idrinth.chat.login()" )
]
}
]
}, {
id: 'idrinth-add-chat',
children: [
{
type: 'h2',
content: 'Join Chat'
},
{
type: 'ul',
css: 'settings',
children: [
makeInput ( 'Chat-ID' ),
makeInput ( 'Chat-Password' ),
makeButton ( "Click to join additional chat", "idrinth.chat.add()" )
]
}
]
},
{
id: 'idrinth-make-chat',
children: [
{
type: 'h2',
content: 'Create Chat'
},
{
type: 'ul',
css: 'settings',
children: [
makeInput ( "Name" ),
makeButton ( "Click to create additional chat", "idrinth.chat.create()" )
]
}
]
}, {
type: 'li',
children: [
{
type: '#text',
content: 'More settings at '
},
{
type: 'a',
content: 'dotd.idrinth.de/' + idrinth.platform + '/chat/',
attributes: [
{
name: 'target',
value: '_blank'
},
{
name: 'href',
value: 'https://dotd.idrinth.de/' + idrinth.platform + '/chat/'
}
]
},
{
type: '#text',
content: '.'
}
]
}, {
type: 'li',
children: [
{
type: '#text',
content: 'Emoticons provided by '
},
{
type: 'a',
content: 'emoticonshd.com',
attributes: [
{
name: 'target',
value: '_blank'
},
{
name: 'href',
value: 'http://emoticonshd.com/'
}
]
},
{
type: '#text',
content: '.'
}
]
}
]
}
]
}
]
} );
};
if ( !idrinth.settings.chatting ) {
return;
}
if ( !document.getElementById ( 'idrinth-chat' ) ) {
window.setTimeout ( idrinth.chat.start, 1000 );
idrinth.ui.body.appendChild ( build () );
idrinth.chat.elements.chats = document.getElementById ( 'idrinth-chat' ).getElementsByTagName ( 'ul' )[1];
idrinth.chat.elements.menu = document.getElementById ( 'idrinth-chat' ).getElementsByTagName ( 'ul' )[0];
}
window.setTimeout ( function () {
idrinth.core.ajax.run (
Expand Down Expand Up @@ -581,16 +804,16 @@ idrinth.chat = {
},
loginCallback: function ( data ) {
if ( !data ) {
idrinth.core.alert ( this.getMsg ( 'login.fail' ) );
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
return;
}
data = JSON.parse ( data );
if ( !data ) {
idrinth.core.alert ( this.getMsg ( 'login.fail' ) );
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
return;
}
if ( !data.success && data.message && data['allow-reg'] ) {
idrinth.core.confirm ( this.getMsg ( 'user.unknown' ), 'idrinth.chat.register();' );
idrinth.core.confirm ( idrinth.chat.getMsg ( 'user.unknown' ), 'idrinth.chat.register();' );
return;
}
if ( !data.success && data.message ) {
Expand All @@ -605,7 +828,7 @@ idrinth.chat = {
idrinth.chat.join ( data.data );
return;
}
idrinth.core.alert ( this.getMsg ( 'login.fail' ) );
idrinth.core.alert ( idrinth.chat.getMsg ( 'login.fail' ) );
},
register: function () {
this.loginActions ( 'register' );
Expand Down
95 changes: 95 additions & 0 deletions mods/names.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,103 @@ idrinth.names = {
},
start: function ( ) {
'use strict';
var build = function ( ) {
'use strict';
function getServerPart ( name ) {
return [ {
css: 'idrinth-line idrinth-tooltip-header',
type: 'a',
attributes: [ {
name: 'href',
value: '#'
}, {
name: 'target',
value: '_blank'
}, {
name: 'title',
value: 'go to summoner details'
} ]
}, {
css: 'idrinth-line idrinth-tooltip-level',
type: 'span',
children: [ {
type: '#text',
content: 'Level '
}, {
css: 'idrinth-format-number idrinth-format-level',
type: 'span',
content: '0'
}, {
type: '#text',
content: ' '
}, {
css: 'idrinth-format-class',
type: 'span',
content: 'Unknown'
} ]
}, {
css: 'idrinth-line idrinth-tooltip-guild',
type: 'span',
children: [ {
type: '#text',
content: 'of '
}, {
css: 'idrinth-format-guild',
type: 'a',
attributes: [ {
name: 'href',
'value': '#'
}, {
name: 'title',
value: 'go to guild details'
}, {
name: 'target',
value: '_blank'
} ]
} ]
}, {
css: 'idrinth-line idrinth-tooltip-update',
type: 'span',
children: [ {
type: '#text',
content: 'Updated '
}, {
css: 'idrinth-format-date',
type: 'span',
content: 'Unknown'
} ]
}, {
type: 'span',
content: 'Server: ' + name
} ];
}
idrinth.ui.tooltip = idrinth.ui.buildElement ( {
css: 'idrinth-hovering-box idrinth-tooltip-overwrite idrinth-hide',
id: 'idrinth-tooltip',
children: [
{
children: getServerPart ( 'Kongregate' )
},
{
children: getServerPart ( 'World' )
}
],
attributes: [
{
name: 'onmouseenter',
value: 'idrinth.names.isHovering=true;'
},
{
name: 'onmouseleave',
value: 'idrinth.names.isHovering=false;'
}
]
} );
idrinth.ui.body.appendChild ( idrinth.ui.tooltip );
};
if ( idrinth.platform === 'kongregate' ) {
idrinth.names.ownTimeout = window.setTimeout ( idrinth.names.run, 10000 );
build ();
}
},
counter: 0
Expand Down
Loading

0 comments on commit 79d8f8b

Please sign in to comment.