Aralot (aralot) wrote in changelog,
Aralot
aralot
changelog

[livejournal] r19507: LJSUP-8714: New Photo-hosting (User Inte...

Committer: szhirkov
LJSUP-8714: New Photo-hosting (User Interface) - Client Side
A   branches/fotki/htdocs/js/ck/
A   branches/fotki/htdocs/js/ck/plugins/
A   branches/fotki/htdocs/js/ck/plugins/livejournal/
A   branches/fotki/htdocs/js/ck/plugins/livejournal/plugin.js
U   branches/fotki/htdocs/js/entry.js
U   branches/fotki/htdocs/js/jquery.js
U   branches/fotki/htdocs/js/rte.js
Added: branches/fotki/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- branches/fotki/htdocs/js/ck/plugins/livejournal/plugin.js	                        (rev 0)
+++ branches/fotki/htdocs/js/ck/plugins/livejournal/plugin.js	2011-07-22 07:56:21 UTC (rev 19507)
@@ -0,0 +1,748 @@
+(function(){
+
+	var likeButtons = [
+		{
+			label: top.CKLang.LJLike_button_google,
+			id: 'google',
+			abbr: 'go',
+			html: '<div class="lj-like-item lj-like-gag">' + top.CKLang.LJLike_button_google + '</div>'
+		},
+		{
+			label: top.CKLang.LJLike_button_facebook,
+			id: 'facebook',
+			abbr: 'fb',
+			html: '<div class="lj-like-item lj-like-gag">' + top.CKLang.LJLike_button_facebook + '</div>'
+		},
+		{
+			label: top.CKLang.LJLike_button_vkontakte,
+			id: 'vkontakte',
+			abbr: 'vk',
+			html: '<div class="lj-like-item lj-like-gag">' + top.CKLang.LJLike_button_vkontakte + '</div>'
+		},
+		{
+			label: top.CKLang.LJLike_button_twitter,
+			id: 'twitter',
+			abbr: 'tw',
+			html: '<div class="lj-like-item lj-like-gag">' + top.CKLang.LJLike_button_twitter + '</div>'
+		},
+		{
+			label: top.CKLang.LJLike_button_give,
+			id: 'livejournal',
+			abbr: 'lj',
+			html: '<div class="lj-like-item lj-like-gag">' + top.CKLang.LJLike_button_give + '</div>'
+		}
+	];
+
+	var ljUsers = {};
+
+	CKEDITOR.plugins.add('livejournal', {
+		init: function(editor){
+			editor.dataProcessor.toHtml = function(html, fixForBody){
+				html = html
+					.replace(/<lj-template name=['"]video['"]>(\S+?)<\/lj-template>/g, '<div class="ljvideo" url="$1"><img src="' + Site
+					.statprefix + '/fck/editor/plugins/livejournal/ljvideo.gif" /></div>')
+					.replace(/<lj-embed\s*(?:id="(\d*)")?\s*>([\s\S]*?)<\/lj-embed>/gi, '<div class="ljembed" embedid="$1">$2</div>')
+					.replace(/<lj-poll .*?>[^b]*?<\/lj-poll>/gm,
+					function(ljtags){
+						return new Poll(ljtags).outputHTML();
+					}).replace(/<lj-template(.*?)><\/lj-template>/g, "<lj-template$1 />");
+
+				html = html.replace(/<lj-cut([^>]*)><\/lj-cut>/g, '<lj-cut$1>\ufeff</lj-cut>')
+					.replace(/(<lj-cut[^>]*>)/g, '\ufeff$1').replace(/(<\/lj-cut>)/g, '$1\ufeff');
+
+				// IE custom tags. http://msdn.microsoft.com/en-us/library/ms531076%28VS.85%29.aspx
+				if(CKEDITOR.env.ie){
+					html = html.replace(/<lj-cut([^>]*)>/g, '<lj:cut$1>').replace(/<\/lj-cut>/g, '</lj:cut>')
+						.replace(/<([\/])?lj-raw>/g, '<$1lj:raw>').replace(/<([\/])?lj-wishlist>/g, '<$1lj:wishlist>')
+						.replace(/(<lj [^>]*)> /g, '$1> '); // IE merge spaces
+				} else {
+					// close <lj user> tags
+					html = html.replace(/(<lj [^>]*[^\/])>/g, '$1/> ');
+				}
+				if(!$('event_format').checked){
+					html = '<pre>' + html + '</pre>';
+				}
+
+				html = html.replace(/<br\s*\/?>/g, '');
+				html = CKEDITOR.htmlDataProcessor.prototype.toHtml.call(this, html, fixForBody);
+
+				if(!$('event_format').checked){
+					html = html.replace(/<\/?pre>/g, '');
+					html = html.replace(/\n/g, '<br\/>');
+				}
+
+				return html;
+			};
+
+			editor.dataProcessor.toDataFormat = function(html, fixForBody){
+				// DOM methods are used for detection of node opening/closing
+				/*var document = editor.document.$;
+				 var newBody = document.createElement('div'),
+				 copyNode = document.body.firstChild;
+				 if(copyNode){
+				 newBody.appendChild(copyNode.cloneNode(true));
+				 while(copyNode = copyNode.nextSibling){
+				 newBody.appendChild(copyNode.cloneNode(true));
+				 }
+				 var divs = newBody.getElementsByTagName('div'),
+				 i = divs.length;
+				 while(i--){
+				 var div = divs[i];
+				 switch(div.className){
+				 // lj-template any name: <lj-template name="" value="" alt="html code"/>
+				 case 'lj-template':
+				 var name = div.getAttribute('name'),
+				 value = div.getAttribute('value'),
+				 alt = div.getAttribute('alt');
+				 if(!name || !value || !alt){
+				 break;
+				 }
+				 var ljtag = FCK.EditorDocument.createElement('lj-template');
+				 ljtag.setAttribute('name', name);
+				 ljtag.setAttribute('value', value);
+				 ljtag.setAttribute('alt', alt);
+				 div.parentNode.replaceChild(ljtag, div);
+				 }
+
+				 }
+				 }*/
+				html = html.replace(/^<pre>\n*([\s\S]*?)\n*<\/pre>\n*$/, '$1');
+
+				html = CKEDITOR.htmlDataProcessor.prototype.toDataFormat.call(this, html, fixForBody);
+
+				html = html.replace(/\t/g, ' ');
+				html = html.replace(/>\n\s*(?!\s)([^<]+)</g, '>$1<');
+				// rte fix, http://dev.fckeditor.net/ticket/3023
+				// type="_moz" for Safari 4.0.11
+				if(!CKEDITOR.env.ie){
+					html = html.replace(/<br (type="_moz" )? ?\/>$/, '');
+					if(CKEDITOR.env.webkit){
+						html = html.replace(/<br type="_moz" \/>/, '');
+					}
+				}
+
+				html = html.replace(/<form.*?class="ljpoll" data="([^"]*)"[\s\S]*?<\/form>/gi, function(form, data){
+					return unescape(data);
+				}).replace(/<\/lj>/g, '');
+
+				html = html
+					.replace(/<div(?=[^>]*class="ljvideo")[^>]*url="(\S+)"[^>]*><img.+?\/><\/div>/g, '<lj-template name="video">$1</lj-template>')
+					.replace(/<div(?=[^>]*class="ljvideo")[^>]*url="\S+"[^>]*>([\s\S]+?)<\/div>/g, '<p>$1</p>')
+					.replace(/<div class=['"]ljembed['"](\s*embedid="(\d*)")?\s*>([\s\S]*?)<\/div>/gi, '<lj-embed id="$2">$3</lj-embed>')
+					.replace(/<div\s*(embedid="(\d*)")?\s*class=['"]ljembed['"]\s*>([\s\S]*?)<\/div>/gi, '<lj-embed id="$2">$3</lj-embed>')// convert qotd
+					.replace(/<div([^>]*)qotdid="(\d+)"([^>]*)>[^\b]*<\/div>(<br \/>)*/g, '<lj-template id="$2"$1$3 /><br />')// div tag and qotdid attrib
+					.replace(/(<lj-template id="\d+" )([^>]*)class="ljqotd"?([^>]*\/>)/g, '$1name="qotd" $2$3')// class attrib
+					.replace(/(<lj-template id="\d+" name="qotd" )[^>]*(lang="\w+")[^>]*\/>/g, '$1$2 \/>'); // lang attrib
+
+				if(!$('event_format').checked && !top.switchedRteOn){
+					html = html.replace(/\n?\s*<br \/>\n?/g, '\n');
+				}
+
+				// IE custom tags
+				if(CKEDITOR.env.ie){
+					html = html.replace(/<lj:cut([^>]*)>/g, '<lj-cut$1>').replace(/<\/lj:cut>/g, '</lj-cut>')
+						.replace(/<([\/])?lj:wishlist>/g, '<$1lj-wishlist>').replace(/<([\/])?lj:raw>/g, '<$1lj-raw>');
+				}
+
+				html = html.replace(/><\/lj-template>/g, '/>');// remove null pointer.replace(/\ufeff/g, '');
+
+				return html;
+			};
+
+			//////////  LJ User Button //////////////
+			var url = top.Site.siteroot + '/tools/endpoints/ljuser.bml',
+				LJUserNode;
+
+			editor.attachStyleStateChange(new CKEDITOR.style({
+				element: 'span'
+			}), function(){
+				var selectNode = editor.getSelection().getStartElement().getAscendant('span', true);
+				var isUserLink = selectNode && selectNode.hasClass('ljuser');
+				LJUserNode = isUserLink ? selectNode : null;
+				editor.getCommand('LJUserLink').setState(isUserLink ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
+			});
+
+			editor.on('doubleclick', function(evt){
+				var command = editor.getCommand('LJUserLink');
+				LJUserNode = evt.data.element.getAscendant('span', true);
+				if(LJUserNode && LJUserNode.hasClass('ljuser')){
+					command.setState(CKEDITOR.TRISTATE_ON);
+					command.exec();
+					evt.data.dialog = '';
+				} else {
+					command.setState(CKEDITOR.TRISTATE_OFF);
+				}
+			});
+
+			editor.addCommand('LJUserLink', {
+				exec : function(editor){
+					var userName = '',
+						selection = editor.getSelection(),
+						LJUser = LJUserNode;
+
+					if(this.state == CKEDITOR.TRISTATE_ON && LJUserNode){
+						userName = prompt(top.CKLang.UserPrompt, LJUserNode.getElementsByTag('b').getItem(0).getText());
+					} else if(selection.getType() == 2){
+						userName = selection.getSelectedText();
+					}
+
+					if(userName == ''){
+						userName = prompt(top.CKLang.UserPrompt, userName);
+					}
+
+					if(!userName){
+						return;
+					}
+
+					parent.HTTPReq.getJSON({
+						data: parent.HTTPReq.formEncoded({
+							username : userName
+						}),
+						method: 'POST',
+						url: url,
+						onData: function(data){
+							if(data.error){
+								alert(data.error);
+								return;
+							}
+							if(!data.success){
+								return;
+							}
+							data.ljuser = data.ljuser.replace('<span class="useralias-value">*</span>', '');
+
+							if(LJUser){
+								LJUser.setHtml(data.ljuser);
+								LJUser.insertBeforeMe(LJUser.getFirst());
+								LJUser.remove();
+							} else {
+								editor.insertHtml(data.ljuser);
+							}
+						}
+					});
+				}
+			});
+
+			editor.ui.addButton('LJUserLink', {
+				label: top.CKLang.LJUser,
+				command: 'LJUserLink'
+			});
+
+			//////////  LJ Image Button //////////////
+			editor.addCommand('LJImage', {
+				exec : function(editor){
+					jQuery('#content')
+						.photouploader({
+							type: 'upload'
+						})
+						.photouploader('show')
+							.bind('htmlready', function (event, html) {
+								editor.insertHtml(html);
+							});
+				}
+			});
+
+			editor.ui.addButton('LJImage', {
+				label: 'Add Image',
+				command: 'LJImage'
+			});
+
+			//////////  LJ Embed Media Button //////////////
+			editor.addCommand('LJEmbedLink', {
+				exec: function(){
+					top.LJ_IPPU.textPrompt(top.CKLang.LJEmbedPromptTitle, top.CKLang.LJEmbedPrompt, doEmbed);
+				}
+			});
+
+			editor.ui.addButton('LJEmbedLink', {
+				label: top.CKLang.LJEmbed,
+				command: 'LJEmbedLink'
+			});
+
+			editor.addCss('img.lj-embed' + '{' + 'background-image: url(' + CKEDITOR.getUrl(this
+				.path + 'images/placeholder_flash.png') + ');' + 'background-position: center center;' + 'background-repeat: no-repeat;' + 'border: 1px solid #a9a9a9;' + 'width: 80px;' + 'height: 80px;' + '}');
+
+			function doEmbed(content){
+				if(content && content.length){
+					editor.insertHtml('<div class="ljembed">' + content + '</div><br/>');
+					editor.focus();
+				}
+			}
+
+			//////////  LJ Cut Button //////////////
+			var ljCutNode;
+
+			editor.attachStyleStateChange(new CKEDITOR.style({
+				element: 'lj-cut'
+			}), function(state){
+				var command = editor.getCommand('LJCut');
+				command.setState(state);
+				if(state == CKEDITOR.TRISTATE_ON){
+					ljCutNode = this.getSelection().getStartElement().getAscendant('lj-cut', true);
+				} else {
+					ljCutNode = null;
+				}
+			});
+
+			editor.on('doubleclick', function(evt){
+				var command = editor.getCommand('LJCut');
+				ljCutNode = evt.data.element.getAscendant('lj-cut', true);
+				if(ljCutNode){
+					command.setState(CKEDITOR.TRISTATE_ON);
+					command.exec();
+				} else {
+					command.setState(CKEDITOR.TRISTATE_OFF);
+				}
+			});
+
+			editor.addCommand('LJCut', {
+				exec: function(){
+					var text;
+					if(this.state == CKEDITOR.TRISTATE_ON){
+						text = prompt(top.CKLang.CutPrompt, ljCutNode.getAttribute('text') || top.CKLang.ReadMore);
+						if(text){
+							if(text == top.CKLang.ReadMore){
+								ljCutNode.removeAttribute('text');
+							} else {
+								ljCutNode.setAttribute('text', text);
+							}
+						}
+					} else {
+						text = prompt(top.CKLang.CutPrompt, top.CKLang.ReadMore);
+						if(text){
+							ljCutNode = editor.document.createElement('lj-cut');
+							if(text != top.CKLang.ReadMore){
+								ljCutNode.setAttribute('text', text);
+							}
+							editor.getSelection().getRanges()[0].extractContents().appendTo(ljCutNode);
+							editor.insertElement(ljCutNode);
+						}
+					}
+				}
+			});
+
+			editor.ui.addButton('LJCut', {
+				label: top.CKLang.LJCut,
+				command: 'LJCut'
+			});
+
+			//////////  LJ Poll Button //////////////
+			if(top.canmakepoll){
+				var currentPollForm, currentPoll;
+				var noticeHtml = top.CKLang
+					.Poll_PollWizardNotice + '<br /><a href="#" onclick="CKEDITOR.instances.draft.getCommand(\'LJPollLink\').exec(); return false;">' + window
+					.parent.CKLang.Poll_PollWizardNoticeLink + '</a>';
+
+				editor.attachStyleStateChange(new CKEDITOR.style({
+					element: 'form',
+					attributes: {
+						'class': 'ljpoll'
+					}
+				}), function(state){
+					var command = editor.getCommand('LJPollLink');
+					command.setState(state);
+					currentPollForm = this.getSelection().getStartElement().getAscendant('form', true);
+					currentPollForm = currentPollForm && currentPollForm.hasClass('ljpoll') ? currentPollForm.$ : null;
+					if(state == CKEDITOR.TRISTATE_ON){
+						parent.LJ_IPPU.showNote(noticeHtml, editor.container.$).centerOnWidget(editor.container.$);
+					}
+				});
+
+				editor.on('doubleclick', function(evt){
+					var command = editor.getCommand('LJPollLink');
+					currentPollForm = evt.data.element.getAscendant('form', true);
+					if(currentPollForm && currentPollForm.hasClass('ljpoll')){
+						command.setState(CKEDITOR.TRISTATE_ON);
+						command.exec();
+						evt.data.dialog = '';
+					} else {
+						command.setState(CKEDITOR.TRISTATE_OFF);
+					}
+				});
+
+				CKEDITOR.dialog.add('LJPollDialog', function(){
+					var isAllFrameLoad = 0, okButtonNode, questionsWindow, setupWindow;
+
+					var onLoadPollPage = function(){
+						if(this.removeListener){
+							this.removeListener('load', onLoadPollPage);
+						}
+						if(isAllFrameLoad && okButtonNode){
+							currentPoll = new Poll(currentPollForm && unescape(currentPollForm.getAttribute('data')), questionsWindow
+								.document, setupWindow.document, questionsWindow.Questions);
+
+							questionsWindow.ready(currentPoll);
+							setupWindow.ready(currentPoll);
+
+							okButtonNode.style.display = 'block';
+						} else {
+							isAllFrameLoad++;
+						}
+					};
+
+					return {
+						title : top.CKLang.Poll_PollWizardTitle,
+						width : 420,
+						height : 270,
+						onShow: function(){
+							if(isAllFrameLoad){
+								currentPoll = new Poll(currentPollForm && unescape(currentPollForm
+									.getAttribute('data')), questionsWindow.document, setupWindow.document, questionsWindow.Questions);
+
+								questionsWindow.ready(currentPoll);
+								setupWindow.ready(currentPoll);
+							}
+						},
+						contents : [
+							{
+								id : 'LJPool_Setup',
+								label : 'Setup',
+								padding: 0,
+								elements :[
+									{
+										type : 'html',
+										html : '<iframe src="/tools/ck_poll_setup.bml" frameborder="0" style="width:100%; height:370px"></iframe>',
+										onShow: function(data){
+											if(!okButtonNode){
+												(okButtonNode = document.getElementById(data.sender.getButton('LJPool_Ok').domId).parentNode)
+													.style.display = 'none';
+											}
+											var iframe = this.getElement('iframe');
+											setupWindow = iframe.$.contentWindow;
+											if(setupWindow.ready){
+												onLoadPollPage();
+											} else {
+												iframe.on('load', onLoadPollPage);
+											}
+										}
+									}
+								]
+							},
+							{
+								id : 'LJPool_Questions',
+								label : 'Questions',
+								padding: 0,
+								elements:[
+									{
+										type : 'html',
+										html : '<iframe src="/tools/ck_poll_questions.bml" frameborder="0" style="width:100%; height:370px"></iframe>',
+										onShow: function(){
+											var iframe = this.getElement('iframe');
+											questionsWindow = iframe.$.contentWindow;
+											if(questionsWindow.ready){
+												onLoadPollPage();
+											} else {
+												iframe.on('load', onLoadPollPage);
+											}
+										}
+									}
+								]
+							}
+						],
+						buttons : [new CKEDITOR.ui.button({
+							type : 'button',
+							id : 'LJPool_Ok',
+							label : editor.lang.common.ok,
+							onClick : function(evt){
+								evt.data.dialog.hide();
+								var pollSource = new Poll(currentPoll, questionsWindow.document, setupWindow.document, questionsWindow
+									.Questions).outputHTML();
+								if(pollSource.length > 0){
+									if(currentPollForm){
+										var node = document.createElement('div');
+										node.innerHTML = pollSource;
+										currentPollForm.$.parentNode.insertBefore(node.firstChild, currentPollForm.$);
+										currentPollForm.remove();
+									} else {
+										editor.insertHtml(pollSource);
+									}
+									currentPollForm = null;
+								}
+							}
+						}), CKEDITOR.dialog.cancelButton]
+					};
+				});
+
+				editor.addCommand('LJPollLink', new CKEDITOR.dialogCommand('LJPollDialog'));
+			} else {
+				editor.addCommand('LJPollLink', {
+					exec: function(editor){
+						var notice = top.LJ_IPPU.showNote(top.CKLang.Poll_AccountLevelNotice, editor.container.$);
+						notice.centerOnWidget(editor.container.$);
+					}
+				});
+
+				editor.getCommand('LJPollLink').setState(CKEDITOR.TRISTATE_DISABLED);
+			}
+
+			editor.ui.addButton('LJPollLink', {
+				label: top.CKLang.Poll,
+				command: 'LJPollLink'
+			});
+
+			//////////  LJ Like Button //////////////
+			var buttonsLength = likeButtons.length;
+			var dialogContents = [];
+			var currentLjLikeNode;
+			likeButtons.defaultButtons = [];
+
+			for(var i = 0; i < buttonsLength; i++){
+				var button = likeButtons[i];
+				likeButtons[button.id] = likeButtons[button.abbr] = button;
+				likeButtons.defaultButtons.push(button.abbr);
+				dialogContents.push({
+					type: 'checkbox',
+					label: button.label,
+					id: 'LJLike_' + button.id
+				});
+			}
+
+			dialogContents.unshift({
+				type: 'html',
+				html: top.CKLang.LJLike_dialogText
+			});
+
+			CKEDITOR.dialog.add('LJLikeDialog', function(){
+				return {
+					title : top.CKLang.LJLike_name,
+					width : 200,
+					height : 150,
+					resizable: false,
+					contents : [
+						{
+							id: 'LJLike_Options',
+							elements: dialogContents
+						}
+					],
+					buttons : [new CKEDITOR.ui.button({
+						type : 'button',
+						id : 'LJLike_Ok',
+						label : editor.lang.common.ok,
+						onClick : function(evt){
+							var dialog = evt.data.dialog, attr = [];
+							var likeNode = currentLjLikeNode || new CKEDITOR.dom.element('div');
+							likeNode.setHtml('');
+
+							for(var i = 0; i < buttonsLength; i++){
+								var button = likeButtons[i];
+								var buttonNode = dialog.getContentElement('LJLike_Options', 'LJLike_' + button.id);
+								if(buttonNode.getValue('checked')){
+									attr.push(button.abbr);
+									likeNode.appendHtml(button.html);
+								}
+							}
+
+							likeNode.setAttribute('buttons', attr.join(','));
+
+							if(!currentLjLikeNode){
+								likeNode.setAttribute('class', 'lj-like');
+								editor.insertElement(likeNode);
+							}
+
+							dialog.hide();
+						}
+					}), CKEDITOR.dialog.cancelButton],
+					onShow: function(){
+						var command = editor.getCommand('LJLikeCommand');
+						var i = 0;
+						if(command.state == CKEDITOR.TRISTATE_ON){
+							var buttons = currentLjLikeNode.getAttribute('buttons').split(',');
+							for(var l = buttons.length; i < l; i++){
+								this.getContentElement('LJLike_Options', 'LJLike_' + likeButtons[buttons[i]].id)
+									.setValue('checked', true);
+							}
+						} else {
+							for(i; i < buttonsLength; i++){
+								this.getContentElement('LJLike_Options', 'LJLike_' + likeButtons[i].id).setValue('checked', false);
+							}
+						}
+					}
+				}
+			});
+
+			editor.attachStyleStateChange(new CKEDITOR.style({
+				element: 'div'
+			}), function(){
+				currentLjLikeNode = editor.getSelection().getStartElement().getAscendant('div', true);
+				while(currentLjLikeNode){
+					if(currentLjLikeNode.hasClass('lj-like')){
+						break;
+					}
+					currentLjLikeNode = currentLjLikeNode.getParent();
+				}
+				editor.getCommand('LJLikeCommand').setState(currentLjLikeNode ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
+			});
+
+			editor.on('doubleclick', function(){
+				var command = editor.getCommand('LJLikeCommand');
+				if(command.state == CKEDITOR.TRISTATE_ON){
+					command.exec();
+				}
+			});
+
+			editor.addCommand('LJLikeCommand', new CKEDITOR.dialogCommand('LJLikeDialog'));
+
+			editor.ui.addButton('LJLike', {
+				label: top.CKLang.LJLike_name,
+				command: 'LJLikeCommand'
+			});
+		},
+		afterInit : function(editor){
+			var flashFilenameRegex = /\.swf(?:$|\?)/i;
+
+			function isFlashEmbed(element){
+				var attributes = element.attributes;
+
+				return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test(attributes.src || '') );
+			}
+
+			function createFakeElement(editor, realElement){
+				return editor.createFakeParserElement(realElement, 'lj-embed', 'flash', false);
+			}
+
+			var dataProcessor = editor.dataProcessor;
+
+			dataProcessor.dataFilter.addRules({
+				elements: {
+					'cke:object' : function(element){
+						//////////  LJ Embed Media Button //////////////
+						var attributes = element.attributes,
+							classId = attributes.classid && String(attributes.classid).toLowerCase();
+
+						if(!classId && !isFlashEmbed(element)){
+							for(var i = 0; i < element.children.length; i++){
+								if(element.children[i].name == 'cke:embed'){
+									return isFlashEmbed(element.children[i]) ? createFakeElement(editor, element) : null;
+								}
+							}
+							return null;
+						}
+
+						return createFakeElement(editor, element);
+					},
+					'cke:embed' : function(element){
+						return isFlashEmbed(element) ? createFakeElement(editor, element) : null;
+					},
+					'lj-like': function(element){
+						var html = '', attr = [];
+
+						var fakeElement = new CKEDITOR.htmlParser.element('div');
+						fakeElement.attributes['class'] = 'lj-like';
+
+						var currentButtons = element.attributes.buttons && element.attributes.buttons.split(',') || likeButtons
+							.defaultButtons;
+
+						var length = currentButtons.length;
+						for(var i = 0; i < length; i++){
+							var buttonName = currentButtons[i].replace(/^\s*([a-z]{2,})\s*$/i, '$1');
+							var button = likeButtons[buttonName];
+							if(button){
+								html += button.html;
+								attr.push(buttonName);
+							}
+						}
+
+						fakeElement.attributes.buttons = attr.join(',');
+						fakeElement.add(new CKEDITOR.htmlParser.fragment.fromHtml(html));
+						return fakeElement;
+					},
+					'lj': function(element){
+						var ljUserName = element.attributes.user;
+						if(!ljUserName || !ljUserName.length){
+							return;
+						}
+						
+						var ljUserTitle = element.attributes.title;
+						var cacheName = ljUserTitle ? ljUserName + ':' + ljUserTitle : ljUserName;
+						
+						if(ljUsers.hasOwnProperty(cacheName)){
+							return (new CKEDITOR.htmlParser.fragment.fromHtml(ljUsers[cacheName])).children[0];
+						} else {
+							var onSuccess = function(data){
+								ljUsers[cacheName] = data.ljuser;
+
+								if(data.error){
+									return alert(data.error + ' "' + username + '"');
+								}
+								if(!data.success){
+									return;
+								}
+
+								data.ljuser = data.ljuser.replace("<span class='useralias-value'>*</span>", '');
+
+								var ljTags = editor.document.getElementsByTag('lj');
+
+								for(var i = 0, l = ljTags.count(); i < l; i++){
+									var ljTag = ljTags.getItem(i);
+
+									var userName = ljTag.getAttribute('user');
+									var userTitle = ljTag.getAttribute('title');
+									if(cacheName == userTitle ? userName + ':' + userTitle : userName){
+										ljTag.setHtml(ljUsers[cacheName]);
+										ljTag.insertBeforeMe(ljTag.getFirst());
+										ljTag.remove();
+									}
+								}
+							};
+
+							var onError = function(err){
+								alert(err + ' "' + ljUserName + '"');
+							};
+
+							var postData = {
+								username: ljUserName
+							};
+
+							if(ljUserTitle){
+								postData.usertitle = ljUserTitle;
+							}
+
+							HTTPReq.getJSON({
+								data: HTTPReq.formEncoded(postData),
+								method: 'POST',
+								url: Site.siteroot + '/tools/endpoints/ljuser.bml',
+								onError: onError,
+								onData: onSuccess
+							});
+						}
+					}
+				}
+			}, 5);
+
+			dataProcessor.htmlFilter.addRules({
+				elements: {
+					'div': function(element){
+						if(element.attributes['class'] == 'lj-like'){
+							var ljLikeNode = new CKEDITOR.htmlParser.element('lj-like');
+							if(element.attributes.buttons && element.attributes.buttons.length){
+								ljLikeNode.attributes.buttons = element.attributes.buttons;
+							}
+							ljLikeNode.isEmpty = true;
+							ljLikeNode.isOptionalClose = true;
+							return ljLikeNode;
+						}
+					},
+					span: function(element){
+						var userName = element.attributes['lj:user'];
+						if(userName){
+							var ljUserNode = new CKEDITOR.htmlParser.element('lj');
+							ljUserNode.attributes.user = userName;
+							var userTitle = element.children[1].children[0].children[0].value;
+
+							if(userTitle && userTitle != userName){
+								ljUserNode.attributes.title = userTitle;
+							}
+
+							ljUserNode.isEmpty = true;
+							ljUserNode.isOptionalClose = true;
+							return ljUserNode;
+						}
+					}
+				}
+			});
+
+		},
+
+		requires : [ 'fakeobjects' ]
+	});
+
+})();
\ No newline at end of file

Modified: branches/fotki/htdocs/js/entry.js
===================================================================
--- branches/fotki/htdocs/js/entry.js	2011-07-22 07:04:00 UTC (rev 19506)
+++ branches/fotki/htdocs/js/entry.js	2011-07-22 07:56:21 UTC (rev 19507)
@@ -2,1334 +2,1481 @@
 var sc_old_border_style;
 var shift_init = "true";
 
-if (! ("$" in window))
-    $ = function(id) {
-        if (document.getElementById)
-           return document.getElementById(id);
-        return null;
-    };
+if(! ("$" in window)){
+	$ = function(id){
+		if(document.getElementById){
+			return document.getElementById(id);
+		}
+		return null;
+	};
+}
 
-function editdate() {
+function editdate(){
 	clearInterval(settime.interval);
 	$('currentdate').style.display = 'none';
 	$('modifydate').style.display = 'inline';
 }
 
-function showEntryTabs() {
-	if (FCKeditor_IsCompatibleBrowser()) {
-		document.getElementById('entry-tabs').style.visibility = 'visible';
-	}
+function showEntryTabs(){
+	document.getElementById('entry-tabs').style.visibility = 'visible';
 }
 
-function changeSubmit(prefix, defaultjournal, defPrefix ) {
-    if (document.getElementById) {
-        var usejournal = document.getElementById('usejournal');
-        var formsubmit = document.getElementById('formsubmit');
-        var newvalue, commname;
-        if (!defaultjournal) {
-            newvalue = prefix;
-        } else if (!usejournal || usejournal.value == '') {
-            newvalue = prefix + ' ' + defaultjournal;
-            commname = defaultjournal;
-        } else {
-            if( usejournal.value === '[none]' ) {
-                newvalue = defPrefix;
-            } else {
-                newvalue = prefix + ' ' + usejournal.value;
-            }
-            commname = usejournal.value;
-        }
-        formsubmit.disabled = ( /\[none\]/.test( commname ) || /^ext_/.test( commname ) );
-        formsubmit.value = newvalue;
-    }
+function changeSubmit(prefix, defaultjournal, defPrefix){
+	if(document.getElementById){
+		var usejournal = document.getElementById('usejournal');
+		var formsubmit = document.getElementById('formsubmit');
+		var newvalue, commname;
+		if(!defaultjournal){
+			newvalue = prefix;
+		} else if(!usejournal || usejournal.value == ''){
+			newvalue = prefix + ' ' + defaultjournal;
+			commname = defaultjournal;
+		} else {
+			if(usejournal.value === '[none]'){
+				newvalue = defPrefix;
+			} else {
+				newvalue = prefix + ' ' + usejournal.value;
+			}
+			commname = usejournal.value;
+		}
+		formsubmit.disabled = ( /\[none\]/.test(commname) || /^ext_/.test(commname) );
+		formsubmit.value = newvalue;
+	}
 }
 
-function new_post_load(dotime) {
-	if (dotime) {
-		settime.interval = setInterval(settime, 1000)
+function new_post_load(dotime){
+	if(dotime){
+		settime.interval = setInterval(settime, 1000);
 		settime();
 	}
-	
-    var remotelogin = $('remotelogin');
-    if (! remotelogin) return;
-    var remotelogin_content = $('remotelogin_content');
-    if (! remotelogin_content) return;
-    remotelogin_content.onclick = altlogin;
-    f = document.updateForm;
-    if (! f) return false;
-	
-    var userbox = f.user;
-    if (! userbox) return false;
-    if (! Site.has_remote && userbox.value) altlogin();
 
-    return false;
+	var remotelogin = $('remotelogin');
+	if(! remotelogin){
+		return;
+	}
+	var remotelogin_content = $('remotelogin_content');
+	if(! remotelogin_content){
+		return;
+	}
+	remotelogin_content.onclick = altlogin;
+	f = document.updateForm;
+	if(! f){
+		return false;
+	}
+
+	var userbox = f.user;
+	if(! userbox){
+		return false;
+	}
+	if(! Site.has_remote && userbox.value){
+		altlogin();
+	}
+
+	return false;
 }
 
-function updateRepostButtons(stateIndex)
-{
-    var boxes = ['facebook', 'twitter'],
-        input, label, parentNode,
-        parentDisableClass = 'b-repost-item-disabled',
+function updateRepostButtons(stateIndex){
+	var boxes = ['facebook', 'twitter'],
+		input, label, parentNode,
+		parentDisableClass = 'b-repost-item-disabled',
 		linkDisclass = 'b-repost-item-dis';
 
-    for(var i in boxes)
-    {
-        input = $('repost_' + boxes[i]);
-        if(!input) continue;
+	for(var i in boxes){
+		input = $('repost_' + boxes[i]);
+		if(!input){
+			continue;
+		}
 
-        parentNode = input.parentNode;
-        label = parentNode.getElementsByTagName('label')[0];
+		parentNode = input.parentNode;
+		label = parentNode.getElementsByTagName('label')[0];
 
-        if(stateIndex > 0 || parentNode.className.indexOf(parentDisableClass) != -1)
-        {
-            input.setAttribute('disabled', 'disabled');
-            label.className = "repost_disabled";
-            input.checked = false;
-			if(parentNode.className.indexOf(linkDisclass) == -1) {
+		if(stateIndex > 0 || parentNode.className.indexOf(parentDisableClass) != -1){
+			input.setAttribute('disabled', 'disabled');
+			label.className = "repost_disabled";
+			input.checked = false;
+			if(parentNode.className.indexOf(linkDisclass) == -1){
 				parentNode.className += " " + linkDisclass;
 			}
-        }
-        else {
-            input.removeAttribute('disabled');
-            label.className = "repost_" + boxes[i];
+		} else {
+			input.removeAttribute('disabled');
+			label.className = "repost_" + boxes[i];
 			parentNode.className = parentNode.className.replace(" " + linkDisclass, "");
-        }
-    }
+		}
+	}
 
 }
 
-function customboxes (e) {
-    if (! e) var e = window.event;
-    if (! document.getElementById) return false;
+function customboxes(e){
+	if(! e){
+		e = window.event;
+	}
+	if(! document.getElementById){
+		return false;
+	}
 
-    
-    f = document.updateForm;
-    if (! f) return false;
-    
-    var custom_boxes = $('custom_boxes');
-    if (! custom_boxes) return false;
+	var f = document.updateForm;
+	if(! f){
+		return false;
+	}
 
-    updateRepostButtons(f.security.selectedIndex);
-    
-    if (f.security.selectedIndex != 3) {
-        custom_boxes.style.display = 'none';
-        return false;
-    }
-    
-    var altlogin_username = $('altlogin_username');    
-    if (altlogin_username != undefined && (altlogin_username.style.display == 'table-row' ||
-                                           altlogin_username.style.display == 'block')) {
-        f.security.selectedIndex = 0;
-        custom_boxes.style.display = 'none';
-        alert("Custom security is only available when posting as the logged in user.");
-    } else {
-        custom_boxes.style.display = 'block';
-    }
-    
-    if (e) {
-        e.cancelBubble = true;
-        if (e.stopPropagation) e.stopPropagation();
-    }
-    return false;
+	var security = $('security');
+
+	var custom_boxes = $('custom_boxes');
+	if(! custom_boxes){
+		return false;
+	}
+
+	updateRepostButtons(security.selectedIndex);
+
+	if(security.selectedIndex != 3){
+		custom_boxes.style.display = 'none';
+		return false;
+	}
+
+	var altlogin_username = $('altlogin_username');
+	if(altlogin_username != undefined && (altlogin_username.style.display == 'table-row' || altlogin_username.style
+		.display == 'block')){
+		security.selectedIndex = 0;
+		custom_boxes.style.display = 'none';
+		alert("Custom security is only available when posting as the logged in user.");
+	} else {
+		custom_boxes.style.display = 'block';
+	}
+
+	if(e){
+		e.cancelBubble = true;
+		if(e.stopPropagation){
+			e.stopPropagation();
+		}
+	}
+	return false;
 }
 
-function setCopyrightUpdate() {
-    if ($('prop_copyright') && Site.default_copyright == "P") {
-        $('prop_copyright').checked = 1;
-    }
+function setCopyrightUpdate(){
+	if($('prop_copyright') && Site.default_copyright == "P"){
+		$('prop_copyright').checked = 1;
+	}
 }
 
-
 function detectLocation(){
 
-	function myFunctionForLoadDistr(url)
-	{
-	 //alert('Magic Scanner is not installed, download it at '+url);
-	 wi2Geo.response=true;
+	function myFunctionForLoadDistr(url){
+		//alert('Magic Scanner is not installed, download it at '+url);
+		wi2Geo.response = true;
 	}
-	
-	var wi2Geo={};
-	var gGears={};
 
-	wi2Geo.response=false;
-	gGears.response=false;
+	var wi2Geo = {};
+	var gGears = {};
 
-	function updateWi2GeoPosition(q)
-	{
-	          if(q){		
-		  	wi2Geo.country=q.city.country;
-		  	wi2Geo.city=q.city.name;
-			wi2Geo.type=q.type;
-			if(wi2Geo.type!='IP'){
-		  		wi2Geo.street=q.building.street;
-		  		wi2Geo.building=q.building.address;
-				wi2Geo.metro=q.metro.name;
+	wi2Geo.response = false;
+	gGears.response = false;
+
+	function updateWi2GeoPosition(q){
+		if(q){
+			wi2Geo.country = q.city.country;
+			wi2Geo.city = q.city.name;
+			wi2Geo.type = q.type;
+			if(wi2Geo.type != 'IP'){
+				wi2Geo.street = q.building.street;
+				wi2Geo.building = q.building.address;
+				wi2Geo.metro = q.metro.name;
 			}
-		  	wi2Geo.lat=q.lat;
-		  	wi2Geo.lng=q.lng;
-		  }
-		  wi2Geo.response=true;
-	 }
-	
-	function updateGearsPosition(p) {
+			wi2Geo.lat = q.lat;
+			wi2Geo.lng = q.lng;
+		}
+		wi2Geo.response = true;
+	}
+
+	function updateGearsPosition(p){
 		if(p){
-		  gGears.country=(!p.gearsAddress.country.match(/\?\?/gi)?(p.gearsAddress.country):(""));
-		  gGears.city=(!p.gearsAddress.city.match(/\?\?/gi)?(p.gearsAddress.city):(""));
-		  if(gGears.country=='USA') gGears.region=p.gearsAddress.region;
-		  gGears.lat=p.coords.latitude;
-		  gGears.lng=p.coords.longitude;
-		  gGears.type=(p.accuracy<1000&&p.accuracy>0)?("nonIP"):("IP");
-		  if(gGears.type!='IP' && !p.gearsAddress.street.match(/\?\?/gi)){
-		  	gGears.street=p.gearsAddress.street;
-		  	gGears.building=p.gearsAddress.streetNumber;
-		  }
-		  
+			gGears.country = (!p.gearsAddress.country.match(/\?\?/gi) ? (p.gearsAddress.country) : (""));
+			gGears.city = (!p.gearsAddress.city.match(/\?\?/gi) ? (p.gearsAddress.city) : (""));
+			if(gGears.country == 'USA'){
+				gGears.region = p.gearsAddress.region;
+			}
+			gGears.lat = p.coords.latitude;
+			gGears.lng = p.coords.longitude;
+			gGears.type = (p.accuracy < 1000 && p.accuracy > 0) ? ("nonIP") : ("IP");
+			if(gGears.type != 'IP' && !p.gearsAddress.street.match(/\?\?/gi)){
+				gGears.street = p.gearsAddress.street;
+				gGears.building = p.gearsAddress.streetNumber;
+			}
+
 		}
-		gGears.response=true;
-		wi2Geo.response=true;
+		gGears.response = true;
+		wi2Geo.response = true;
 	}
 
 	try{
-		var geo = google.gears.factory.create('beta.geolocation');	
+		var geo = google.gears.factory.create('beta.geolocation');
 		geo.getCurrentPosition(updateGearsPosition, handleError, {enableHighAccuracy: true, gearsRequestAddress: true});
-	}catch(e){
-		gGears.response=true;
+	} catch(e){
+		gGears.response = true;
 		try{
 			var myWi2GeoScanner = new Wi2GeoScanner('AQIAAKxzJUlHmzaMvzei5+vo3XLHJIdR', myFunctionForLoadDistr);
 			myWi2GeoScanner.scan(updateWi2GeoPosition);
-			if(window.opera) wi2Geo.response=true;
-		}catch(e){
-			wi2Geo.response=true;
+			if(window.opera){
+				wi2Geo.response = true;
+			}
+		} catch(e){
+			wi2Geo.response = true;
 		}
 
 	}
-	
-	function handleError(positionError) {
-		  gGears.response=true;
+
+	function handleError(positionError){
+		gGears.response = true;
 	}
 
-	var si=window.setInterval(function getLocation(){
-			if(wi2Geo.response==true && gGears.response==true){
-				window.clearInterval(si);
-				var fCountry=(gGears.country||wi2Geo.country)?((gGears.country||wi2Geo.country)+", "):("");
-				var fRegion=(gGears.region||wi2Geo.region)?((gGears.region||wi2Geo.region)+", "):("");
-				var fCity=(gGears.city||wi2Geo.city)?((gGears.city||wi2Geo.city)+", "):("");
-				if (fRegion==fCity) fRegion="";
-				var fStreet=(gGears.street||wi2Geo.street)?((gGears.street||wi2Geo.street)+", "):("");
-				if(fStreet=="") fCity=fCity.replace(/,/,"");
-				var fBuilding=gGears.building||wi2Geo.building||"";
-				var fMetro=(wi2Geo.metro)||"";
-				var fLat=(gGears.lat||wi2Geo.lat)?((gGears.lat||wi2Geo.lat)+", "):("");
-				var fLng=gGears.lng||wi2Geo.lng||"";
-				if(!fCountry || !fCity || !fLat || !fLng){
-					HTTPReq.getJSON({url:'/tools/endpoints/geo_location.bml',
-						onData:function(data){
-							if(data.data){
-								fCountry=(data.data.country_rus_name)?(data.data.country_rus_name+", "):(data.data.country_name+", ");
-								fCity=data.data.city_rus_name||data.data.city_name;
-								if(data.data.country_short=='US') fRegion=data.data.region_name+", ";
-								fLat=data.data.latitude+", ";
-								fLng=data.data.longitude;
-								$('prop_current_location').value=fCountry+fRegion+fCity;
-							}else{
-								$('prop_current_location').value="Can't Detect";
-								window.setTimeout(function(){$('prop_current_location').value=" "},3000);
+	var si = window.setInterval(function getLocation(){
+		if(wi2Geo.response && gGears.response){
+			window.clearInterval(si);
+			var fCountry = (gGears.country || wi2Geo.country) ? ((gGears.country || wi2Geo.country) + ", ") : ("");
+			var fRegion = (gGears.region || wi2Geo.region) ? ((gGears.region || wi2Geo.region) + ", ") : ("");
+			var fCity = (gGears.city || wi2Geo.city) ? ((gGears.city || wi2Geo.city) + ", ") : ("");
+			if(fRegion == fCity){
+				fRegion = "";
+			}
+			var fStreet = (gGears.street || wi2Geo.street) ? ((gGears.street || wi2Geo.street) + ", ") : ("");
+			if(fStreet == ""){
+				fCity = fCity.replace(/,/, "");
+			}
+			var fBuilding = gGears.building || wi2Geo.building || "";
+			var fMetro = (wi2Geo.metro) || "";
+			var fLat = (gGears.lat || wi2Geo.lat) ? ((gGears.lat || wi2Geo.lat) + ", ") : ("");
+			var fLng = gGears.lng || wi2Geo.lng || "";
+			if(!fCountry || !fCity || !fLat || !fLng){
+				HTTPReq.getJSON({url:'/tools/endpoints/geo_location.bml',
+					onData:function(data){
+						if(data.data){
+							fCountry = (data.data.country_rus_name) ? (data.data.country_rus_name + ", ") : (data.data
+								.country_name + ", ");
+							fCity = data.data.city_rus_name || data.data.city_name;
+							if(data.data.country_short == 'US'){
+								fRegion = data.data.region_name + ", ";
 							}
-						},
-						onError:LiveJournal.ajaxError
-						});
-				}
-				else{
-					$('prop_current_location').value=fCountry+fRegion+fCity+fStreet+fBuilding;
-				}
-				
+							fLat = data.data.latitude + ", ";
+							fLng = data.data.longitude;
+							$('prop_current_location').value = fCountry + fRegion + fCity;
+						} else {
+							$('prop_current_location').value = "Can't Detect";
+							window.setTimeout(function(){
+								$('prop_current_location').value = " "
+							}, 3000);
+						}
+					},
+					onError:LiveJournal.ajaxError
+				});
+			} else {
+				$('prop_current_location').value = fCountry + fRegion + fCity + fStreet + fBuilding;
 			}
-			else{
-				$('prop_current_location').value='detecting...';
-			}
-	},100);
-	
-	
+
+		} else {
+			$('prop_current_location').value = 'detecting...';
+		}
+	}, 100);
+
 }
 
-function setCopyrightEdit() {
-    if ($('security') && $('prop_copyright')) {
-	var copyright_flag=$('prop_copyright').checked;
-	if($('security').value!='public'){
-		$('prop_copyright').checked=false;
-            	$('prop_copyright').disabled = true;
-	}		
-	$('security').onchange=function(){
-		copyright(copyright_flag);
-		customboxes();
+function setCopyrightEdit(){
+	if($('security') && $('prop_copyright')){
+		var copyright_flag = $('prop_copyright').checked;
+		if($('security').value != 'public'){
+			$('prop_copyright').checked = false;
+			$('prop_copyright').disabled = true;
+		}
+		$('security').onchange = function(){
+			copyright(copyright_flag);
+			customboxes();
+		};
+		$('prop_copyright').onchange = function(){
+			copyright_flag = $('prop_copyright').checked;
+		}
 	}
-	$('prop_copyright').onchange=function(){
-		copyright_flag=$('prop_copyright').checked;
-	}
-     }
 }
 
-function copyright(copyright_flag) {
-    if ($('security') && $('prop_copyright')) {
-        if ($('security').value != "public") {
-            $('prop_copyright').checked = 0;
-            $('prop_copyright').disabled = true;
-	    $('defined_copyright').value = '0';
-        } else {
-            if (Site.default_copyright == "P") {
-                $('prop_copyright').checked = 1;
-            }
-            $('prop_copyright').disabled = false;
-	    $('prop_copyright').checked=copyright_flag;
-	    
-	    $('defined_copyright').value = '1';
-	   
-     	}
+function copyright(copyright_flag){
+	if($('security') && $('prop_copyright')){
+		if($('security').value != "public"){
+			$('prop_copyright').checked = 0;
+			$('prop_copyright').disabled = true;
+			$('defined_copyright').value = '0';
+		} else {
+			if(Site.default_copyright == "P"){
+				$('prop_copyright').checked = 1;
+			}
+			$('prop_copyright').disabled = false;
+			$('prop_copyright').checked = copyright_flag;
 
-    }
+			$('defined_copyright').value = '1';
+
+		}
+
+	}
 }
 
-function altlogin (e) {
-    var agt   = navigator.userAgent.toLowerCase();
-    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
+function altlogin(e){
+	var agt = navigator.userAgent.toLowerCase();
+	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
 
-    if (! e) var e = window.event;
-    if (! document.getElementById) return false;
-    
-    var altlogin_wrapper = $('altlogin_wrapper');
-    if (! altlogin_wrapper) return false;
-    altlogin_wrapper.style.display = 'block';
-   
-    var remotelogin = $('remotelogin');
-    if (! remotelogin) return false;
-    remotelogin.style.display = 'none';
-    
-    var usejournal_list = $('usejournal_list');
-    if (usejournal_list) {
-        usejournal_list.style.display = 'none';
-    }
+	if(! e){
+		e = window.event;
+	}
+	if(! document.getElementById){
+		return false;
+	}
 
-    var readonly = $('readonly');
-    var userbox = f.user;
-    if (!userbox.value && readonly) {
-        readonly.style.display = 'none';
-    }
+	var altlogin_wrapper = $('altlogin_wrapper');
+	if(! altlogin_wrapper){
+		return false;
+	}
+	altlogin_wrapper.style.display = 'block';
 
-    var userpic_list = $('userpic_select_wrapper');
-    if (userpic_list) {
-        userpic_list.style.display = 'none';
-    }
+	var remotelogin = $('remotelogin');
+	if(! remotelogin){
+		return false;
+	}
+	remotelogin.style.display = 'none';
 
-    var userpic_preview = $('userpic_preview');
-    if (userpic_preview) {
-        userpic_preview.className = "";
-        userpic_preview.innerHTML = "<img src='/img/userpic_loggedout.gif' alt='selected userpic' id='userpic_preview_image' class='userpic_loggedout' />";
-    }
+	var usejournal_list = $('usejournal_list');
+	if(usejournal_list){
+		usejournal_list.style.display = 'none';
+	}
 
-    var mood_preview = $('mood_preview');
-    mood_preview.style.display = 'none';
+	var readonly = $('readonly');
+	var userbox = f.user;
+	if(!userbox.value && readonly){
+		readonly.style.display = 'none';
+	}
 
-    f = document.updateForm;
-    if (! f) return false;
-    f.action = 'update.bml?altlogin=1';
-    
-    var custom_boxes = $('custom_boxes');
-    if (! custom_boxes) return false;
-    custom_boxes.style.display = 'none';
-    if (f.security) {
-        f.security.options[3] = null;
-    }
-    
-    f.security.selectedIndex = 0;
+	var userpic_list = $('userpic_select_wrapper');
+	if(userpic_list){
+		userpic_list.style.display = 'none';
+	}
 
-    if (e) {
-        e.cancelBubble = true;
-        if (e.stopPropagation) e.stopPropagation();
-    }
+	var userpic_preview = $('userpic_preview');
+	if(userpic_preview){
+		userpic_preview.className = "";
+		userpic_preview
+			.innerHTML = "<img src='/img/userpic_loggedout.gif' alt='selected userpic' id='userpic_preview_image' class='userpic_loggedout' />";
+	}
 
-    changeSubmit('Post to Journal', null, 'Post to Journal');
+	var mood_preview = $('mood_preview');
+	mood_preview.style.display = 'none';
 
-    if ($('usejournal_username')) {
-        changeSecurityOptions($('usejournal_username').value);
-    } else {
-        changeSecurityOptions('');
-    }
+	f = document.updateForm;
+	if(! f){
+		return false;
+	}
+	f.action = 'update.bml?altlogin=1';
 
-    return false;    
+	var custom_boxes = $('custom_boxes');
+	if(! custom_boxes){
+		return false;
+	}
+	custom_boxes.style.display = 'none';
+	if(f.security){
+		f.security.options[3] = null;
+	}
+
+	f.security.selectedIndex = 0;
+
+	if(e){
+		e.cancelBubble = true;
+		if(e.stopPropagation){
+			e.stopPropagation();
+		}
+	}
+
+	changeSubmit('Post to Journal', null, 'Post to Journal');
+
+	if($('usejournal_username')){
+		changeSecurityOptions($('usejournal_username').value);
+	} else {
+		changeSecurityOptions('');
+	}
+
+	return false;
 }
 
-function insertFormHints() {
-    return;
-    // remove this function after changes to weblib.pl go live
+function insertFormHints(){
+	return;
+	// remove this function after changes to weblib.pl go live
 }
 
-function defaultDate() {
-    $('currentdate').style.display = 'block';
-    $('modifydate').style.display = 'none';
+function defaultDate(){
+	$('currentdate').style.display = 'block';
+	$('modifydate').style.display = 'none';
 }
 
-function insertViewThumbs() {
-    var lj_userpicselect = $('lj_userpicselect');
-    lj_userpicselect.innerHTML = 'View Thumbnails';
+function insertViewThumbs(){
+	var lj_userpicselect = $('lj_userpicselect');
+	lj_userpicselect.innerHTML = 'View Thumbnails';
 }
 
-function mood_preview() {
-    if (! document.getElementById) return false;
-    var mood_list  = document.getElementById('prop_current_moodid'); // get select
-    var moodid = mood_list[mood_list.selectedIndex].value; // get value of select
-    var moodPreview;
+function mood_preview(){
+	if(! document.getElementById){
+		return false;
+	}
+	var mood_list = document.getElementById('prop_current_moodid'); // get select
+	var moodid = mood_list[mood_list.selectedIndex].value; // get value of select
+	var moodPreview;
 
-    if (moodid == "") {
-        if ($('mood_preview')) {
-            moodPreview = $('mood_preview');
-            moodPreview.innerHTML = '';         
-        }
-        return false
-    } else {
-        var wrapper = $('entryform-mood-wrapper');
-        if ($('mood_preview')) {
-            moodPreview = $('mood_preview');
-            moodPreview.innerHTML = '';
-        } else {
-            moodPreview = document.createElement('span');
-            moodPreview.id = 'mood_preview';
-            wrapper.appendChild(moodPreview);
-        } 
-        var moodPreviewImage = document.createElement('img');
-        moodPreviewImage.id = 'mood_image_preview';
-        moodPreviewImage.src = moodpics[moodid];
-        var moodPreviewText = document.createElement('span');
-        moodPreviewText.id = 'mood_text_preview';
-        var mood_custom_text  = $('prop_current_mood').value;
-        moodPreviewText.innerHTML = mood_custom_text == "" ? moods[moodid] : mood_custom_text;
-        moodPreview.appendChild(moodPreviewImage);
-        moodPreview.appendChild(moodPreviewText);
-        if (moodPreview.style.display != 'none') {
-            $('prop_current_music').className = $('prop_current_music').className + ' narrow';
-            $('prop_current_location').className = $('prop_current_location').className + ' narrow';
-        }
-    }
+	if(moodid == ""){
+		if($('mood_preview')){
+			moodPreview = $('mood_preview');
+			moodPreview.innerHTML = '';
+		}
+		return false
+	} else {
+		var wrapper = $('entryform-mood-wrapper');
+		if($('mood_preview')){
+			moodPreview = $('mood_preview');
+			moodPreview.innerHTML = '';
+		} else {
+			moodPreview = document.createElement('span');
+			moodPreview.id = 'mood_preview';
+			wrapper.appendChild(moodPreview);
+		}
+		var moodPreviewImage = document.createElement('img');
+		moodPreviewImage.id = 'mood_image_preview';
+		moodPreviewImage.src = moodpics[moodid];
+		var moodPreviewText = document.createElement('span');
+		moodPreviewText.id = 'mood_text_preview';
+		var mood_custom_text = $('prop_current_mood').value;
+		moodPreviewText.innerHTML = mood_custom_text == "" ? moods[moodid] : mood_custom_text;
+		moodPreview.appendChild(moodPreviewImage);
+		moodPreview.appendChild(moodPreviewText);
+		if(moodPreview.style.display != 'none'){
+			$('prop_current_music').className = $('prop_current_music').className + ' narrow';
+			$('prop_current_location').className = $('prop_current_location').className + ' narrow';
+		}
+	}
 }
 
-function entryPreview(entryForm) {
-    var f=entryForm,
-		action=f.action;
-	f.onsubmit && f.onsubmit(); // for rich editor, syn content
-    f.action='/preview/entry.bml'; 
-    f.target='preview';
-    window.open('','preview','width=760,height=600,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes');
-    f.submit(); 
-    f.action=action; 
-    f.target='_self'; 
-    return false;
+function entryPreview(entryForm){
+	var action = entryForm.action;
+	entryForm.onsubmit && entryForm.onsubmit(); // for rich editor, syn content
+	entryForm.action = '/preview/entry.bml';
+	entryForm.target = 'preview';
+	window
+		.open('', 'preview', 'width=760,height=600,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes');
+	entryForm.submit();
+	entryForm.action = action;
+	entryForm.target = '_self';
+	return false;
 }
 
-function numberOfColumns(items) {
-    if (items <= 6) { return 1 }
-    else if (items >= 7 && items <= 12) { return 2 }
-    else if (items >= 13 && items <= 18) { return 3 }
-    else { return 4 }
+function numberOfColumns(items){
+	if(items <= 6){
+		return 1
+	} else if(items >= 7 && items <= 12){
+		return 2
+	} else if(items >= 13 && items <= 18){
+		return 3
+	} else {
+		return 4
+	}
 }
-function setColumns(number) {
-    // we'll create all our variables here
-    // if you want to change the names of any of the ids, change them here
-    var listObj = document.getElementById('custom_boxes_list');                  // the actual ul
-    var listWrapper = document.getElementById('custom_boxes');      // ul wrapper
-    var listContainer = document.getElementById('list-container');  // container for dynamic content
+function setColumns(number){
+	// we'll create all our variables here
+	// if you want to change the names of any of the ids, change them here
+	var listObj = document.getElementById('custom_boxes_list');                  // the actual ul
+	var listWrapper = document.getElementById('custom_boxes');      // ul wrapper
+	var listContainer = document.getElementById('list-container');  // container for dynamic content
 
-    // create an array of all the LIs in the UL
-    // or return if we have no custom groups
-    if (listObj) {
-        var theList = listObj.getElementsByTagName('LI');
-    } else {
-        return;
-    }
+	// create an array of all the LIs in the UL
+	// or return if we have no custom groups
+	if(listObj){
+		var theList = listObj.getElementsByTagName('LI');
+	} else {
+		return;
+	}
 
-    if (!listContainer) {   // if div#list-container doesn't exist create it
-        var listContainer = document.createElement('div');
-        listContainer.setAttribute('id','list-container');
-        listWrapper.appendChild(listContainer);
-    } else {                // if it does exist, clear out any content
-        listContainer.innerHTML = '';
-    }
+	if(!listContainer){	 // if div#list-container doesn't exist create it
+		var listContainer = document.createElement('div');
+		listContainer.setAttribute('id', 'list-container');
+		listWrapper.appendChild(listContainer);
+	} else {								// if it does exist, clear out any content
+		listContainer.innerHTML = '';
+	}
 
-    // create and populate content arrays based on ul#list
-    var content = new Array();
-    var contentClass = new Array();
-    var contentId = new Array();
-    for (i=0;i<theList.length;i++) {
-        content[i] = theList[i].innerHTML;
-        contentClass[i] = theList[i].className;
-        contentId[i] = theList[i].id;
-    }
+	// create and populate content arrays based on ul#list
+	var content = new Array();
+	var contentClass = new Array();
+	var contentId = new Array();
+	for(i = 0; i < theList.length; i++){
+		content[i] = theList[i].innerHTML;
+		contentClass[i] = theList[i].className;
+		contentId[i] = theList[i].id;
+	}
 
-    // hide original list
-    listObj.style.display = 'none';
-    
-    // determine number of columns
-    if (number) {   // if it's passed as an argument
-        var columns = number;
-    } else {        // or use the numberOfColumns function to set it
-        var columns = numberOfColumns(content.length);
-    }
+	// hide original list
+	listObj.style.display = 'none';
 
-    // divide number of items by columns and round up to get the number of items per column
-    var perColumn = Math.ceil(content.length / columns);
+	// determine number of columns
+	if(number){	 // if it's passed as an argument
+		var columns = number;
+	} else {				// or use the numberOfColumns function to set it
+		var columns = numberOfColumns(content.length);
+	}
 
-    // set the class of list-wrapper to reflect the number of columns
-    if ((theList.length / perColumn) <= (columns - 1)) {
-        // If the number of items divided by the calculated items per column is less than 
-        // the number of columns minus one, the number of columns will be adjusted down by one. 
-        // In other words, if you have 9 items and try to break them into 4 columns, the last 
-        // column would be empty, so I've made the adjustment automatic.
-        columns = columns - 1;
-    }
-    listWrapper.className = 'columns' + columns;
+	// divide number of items by columns and round up to get the number of items per column
+	var perColumn = Math.ceil(content.length / columns);
 
-    for (j=0;j<columns;j++) { // insert columns into list-container
-        if ((perColumn * j) >= theList.length) return false;
+	// set the class of list-wrapper to reflect the number of columns
+	if((theList.length / perColumn) <= (columns - 1)){
+		// If the number of items divided by the calculated items per column is less than
+		// the number of columns minus one, the number of columns will be adjusted down by one.
+		// In other words, if you have 9 items and try to break them into 4 columns, the last
+		// column would be empty, so I've made the adjustment automatic.
+		columns = columns - 1;
+	}
+	listWrapper.className = 'columns' + columns;
 
-        var columnCounter = j + 1; // add 1 to give logical ids to ULs
-        var ulist = document.createElement('ul');
-        // ulist.setAttribute('class','column');
-        // ulist.setAttribute('id','column-' + columnCounter);
-        listContainer.appendChild(ulist);
-        var start = perColumn * j;      // set where the for loop will start
-        var end = perColumn * (j+1);    // set where the for loop will end
-        for (k=start;k<end;k++) {
-            if (content[k]) {
-                var listitem = document.createElement('li');
-                listitem.setAttribute('class', contentClass[k]);
-                listitem.setAttribute('id', contentId[k]);
-                listitem.innerHTML = content[k];
-                ulist.appendChild(listitem);
-            }
-        }
-    }
-    listWrapper.removeChild(listObj);
+	for(j = 0; j < columns; j++){ // insert columns into list-container
+		if((perColumn * j) >= theList.length){
+			return false;
+		}
+
+		var columnCounter = j + 1; // add 1 to give logical ids to ULs
+		var ulist = document.createElement('ul');
+		// ulist.setAttribute('class','column');
+		// ulist.setAttribute('id','column-' + columnCounter);
+		listContainer.appendChild(ulist);
+		var start = perColumn * j;      // set where the for loop will start
+		var end = perColumn * (j + 1);    // set where the for loop will end
+		for(k = start; k < end; k++){
+			if(content[k]){
+				var listitem = document.createElement('li');
+				listitem.setAttribute('class', contentClass[k]);
+				listitem.setAttribute('id', contentId[k]);
+				listitem.innerHTML = content[k];
+				ulist.appendChild(listitem);
+			}
+		}
+	}
+	listWrapper.removeChild(listObj);
 }
 
-function settime() {
-    function twodigit (n) {
-        if (n < 10) { return "0" + n; }
-        else { return n; }
-    }
-    
-    now = new Date();
-    if (! now) return false;
-    f = document.updateForm;
-    if (! f) return false;
-    
-    f.date_ymd_yyyy.value = now.getYear() < 1900 ? now.getYear() + 1900 : now.getYear();
-    f.date_ymd_mm.selectedIndex = twodigit(now.getMonth());
-    f.date_ymd_dd.value = twodigit(now.getDate());
-    f.hour.value = twodigit(now.getHours());
-    f.min.value = twodigit(now.getMinutes());
+function settime(){
+	function twodigit(n){
+		if(n < 10){
+			return "0" + n;
+		} else {
+			return n;
+		}
+	}
 
-    f.date_diff.value = 1;
+	now = new Date();
+	if(! now){
+		return false;
+	}
+	f = document.updateForm;
+	if(! f){
+		return false;
+	}
 
-    var mNames = new Array("January", "February", "March", 
-        "April", "May", "June", "July", "August", "September", 
-        "October", "November", "December");
-    var currentdate = document.getElementById('currentdate-date');
-    var cMonth = now.getMonth();
-    var cDay = now.getDate();
-    var cYear = now.getYear() < 1900 ? now.getYear() + 1900 : now.getYear();
-    var cHour = now.getHours();
-    var cMinute = twodigit(now.getMinutes());
-    currentdate.innerHTML = mNames[cMonth] + " " + cDay + ", " + cYear + ", " + cHour + ":" + cMinute;
-    
-    return false;
+	f.date_ymd_yyyy.value = now.getYear() < 1900 ? now.getYear() + 1900 : now.getYear();
+	f.date_ymd_mm.selectedIndex = twodigit(now.getMonth());
+	f.date_ymd_dd.value = twodigit(now.getDate());
+	f.hour.value = twodigit(now.getHours());
+	f.min.value = twodigit(now.getMinutes());
+
+	f.date_diff.value = 1;
+
+	var mNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
+	var currentdate = document.getElementById('currentdate-date');
+	var cMonth = now.getMonth();
+	var cDay = now.getDate();
+	var cYear = now.getYear() < 1900 ? now.getYear() + 1900 : now.getYear();
+	var cHour = now.getHours();
+	var cMinute = twodigit(now.getMinutes());
+	currentdate.innerHTML = mNames[cMonth] + " " + cDay + ", " + cYear + ", " + cHour + ":" + cMinute;
+
+	return false;
 }
 
-function tagAutocomplete(node, tags)
-{
+function tagAutocomplete(node, tags){
 	var searched;
-	
+
 	jQuery(node).autocomplete({
 		minLength: 1,
-		source: function(request, response) {
+		source: function(request, response){
 			var val = this.element.context.value,
 				range = DOM.getSelectedRange(this.element.context);
-			
-			if (!val || range.start != range.end) {
+
+			if(!val || range.start != range.end){
 				response([]);
 				return;
 			}
-			
+
 			// search one tag
-			searched = val.match(new RegExp('(^.{0,'+(range.start - 1)+'},|^)([^,]*),?(.*)'))
+			searched = val.match(new RegExp('(^.{0,' + (range.start - 1) + '},|^)([^,]*),?(.*)'));
 			var tag = searched[2].replace(/^ +/, '');
 			// delegate back to autocomplete, but extract term
-			if (!tag) {
+			if(!tag){
 				response([]);
 				return;
 			}
 			var resp_ary = [], i = -1;
-			while (tags[++i]) {
-				if (tags[i].indexOf(tag) === 0) {
+			while(tags[++i]){
+				if(tags[i].indexOf(tag) === 0){
 			...
 (truncated)
Tags: aralot, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments