OSDN Git Service

fix many bug and use jwysiwyg.
authorelixirel <elixirel@users.sourceforge.jp>
Thu, 4 Jun 2009 14:51:10 +0000 (23:51 +0900)
committerelixirel <elixirel@users.sourceforge.jp>
Thu, 4 Jun 2009 14:51:10 +0000 (23:51 +0900)
generator.html
js/jwysiwyg/jquery.wysiwyg.css [new file with mode: 0644]
js/jwysiwyg/jquery.wysiwyg.gif [new file with mode: 0644]
js/jwysiwyg/jquery.wysiwyg.js [new file with mode: 0644]
js/lunardial/feedblog_gen.js
xml/diary.xml

index b0154fa..b59faa3 100644 (file)
@@ -3,12 +3,19 @@
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title>日記設置サンプル</title>
-        <link rel="stylesheet" href="./js/ext/resources/css/ext-all.css" type="text/css"/>
+               <link rel="stylesheet" href="./js/jwysiwyg/jquery.wysiwyg.css" type="text/css">
         <link rel="alternate" type="application/atom+xml" title="Atom" href="./xml/diary.xml"/>
         <script type="text/javascript" src="./js/jquery/jquery-1.3.2.min.js">
         </script>
         <script type="text/javascript" src="./js/lunardial/feedblog_gen.js">
         </script>
+        <script type="text/javascript" src="./js/jwysiwyg/jquery.wysiwyg.js">
+        </script>
+        <script type="text/javascript">
+            $(function(){
+                $('#stdin').wysiwyg();
+            });
+        </script>
         <style type="text/css">
             body {
                 font-size: 12px;
@@ -65,7 +72,7 @@
                             <br>
                             <input type="text" id="title" style="width: 100%">
                             <br>
-                            <textarea id="content" rows="10" style="width: 100%">
+                            <textarea id="stdin" rows="10" style="width: 100%">
                             </textarea>
                             <br>
                             <input type="button" value="CONVERT" onclick="javascript:applyChange();"><input type="button" value="DELETE" onclick="javascript:removeEntry()"><input type="button" value="RESET" onclick="javascript:initLoad()"
diff --git a/js/jwysiwyg/jquery.wysiwyg.css b/js/jwysiwyg/jquery.wysiwyg.css
new file mode 100644 (file)
index 0000000..b6a226e
--- /dev/null
@@ -0,0 +1,57 @@
+
+div.wysiwyg { border: 1px solid #cccccc; padding: 5px; background-color: #ffffff; }
+div.wysiwyg * { margin: 0; padding: 0; }
+
+div.wysiwyg ul.panel { border-bottom: 1px solid #cccccc; float: left; width: 100%; padding: 0 0 4px 0; }
+div.wysiwyg ul.panel li { list-style-type: none; float: left; margin: 0 2px;  background: #ffffff;}
+div.wysiwyg ul.panel li.separator { height: 16px; margin: 0 4px; border-left: 1px solid #cccccc; }
+div.wysiwyg ul.panel li a { opacity: 0.6; display: block; width: 16px; height: 16px; background: url('jquery.wysiwyg.gif') no-repeat -64px -80px; border: 0; cursor: pointer; padding: 1px; }
+div.wysiwyg ul.panel li a:hover, div.wysiwyg ul.panel li a.active { opacity: 0.99; }
+div.wysiwyg ul.panel li a.active { background-color: #f9f9f9; border: 1px solid #cccccc; border-left-color: #aaaaaa; border-top-color: #aaaaaa; padding: 0; }
+
+div.wysiwyg ul.panel li a.bold { background-position: 0 -16px; }
+div.wysiwyg ul.panel li a.italic { background-position: -16px -16px; }
+div.wysiwyg ul.panel li a.strikeThrough { background-position: -32px -16px; }
+div.wysiwyg ul.panel li a.underline { background-position: -48px -16px; }
+
+div.wysiwyg ul.panel li a.justifyLeft { background-position: 0 0; }
+div.wysiwyg ul.panel li a.justifyCenter { background-position: -16px 0; }
+div.wysiwyg ul.panel li a.justifyRight { background-position: -32px 0; }
+div.wysiwyg ul.panel li a.justifyFull { background-position: -48px 0; }
+
+div.wysiwyg ul.panel li a.indent { background-position: -64px 0; }
+div.wysiwyg ul.panel li a.outdent { background-position: -80px 0; }
+
+div.wysiwyg ul.panel li a.subscript { background-position: -64px -16px; }
+div.wysiwyg ul.panel li a.superscript { background-position: -80px -16px; }
+
+div.wysiwyg ul.panel li a.undo { background-position: 0 -64px; }
+div.wysiwyg ul.panel li a.redo { background-position: -16px -64px; }
+
+div.wysiwyg ul.panel li a.insertOrderedList { background-position: -32px -48px; }
+div.wysiwyg ul.panel li a.insertUnorderedList { background-position: -16px -48px; }
+div.wysiwyg ul.panel li a.insertHorizontalRule { background-position: 0 -48px; }
+
+div.wysiwyg ul.panel li a.h1 { background-position: 0 -32px; }
+div.wysiwyg ul.panel li a.h2 { background-position: -16px -32px; }
+div.wysiwyg ul.panel li a.h3 { background-position: -32px -32px; }
+div.wysiwyg ul.panel li a.h4 { background-position: -48px -32px; }
+div.wysiwyg ul.panel li a.h5 { background-position: -64px -32px; }
+div.wysiwyg ul.panel li a.h6 { background-position: -80px -32px; }
+
+div.wysiwyg ul.panel li a.cut { background-position: -32px -64px; }
+div.wysiwyg ul.panel li a.copy { background-position: -48px -64px; }
+div.wysiwyg ul.panel li a.paste { background-position: -64px -64px; }
+
+div.wysiwyg ul.panel li a.increaseFontSize { background-position: -16px -80px; }
+div.wysiwyg ul.panel li a.decreaseFontSize { background-position: -32px -80px; }
+
+div.wysiwyg ul.panel li a.createLink { background-position: -80px -48px; }
+div.wysiwyg ul.panel li a.insertImage { background-position: -80px -80px; }
+
+div.wysiwyg ul.panel li a.html { background-position: -48px -48px; }
+div.wysiwyg ul.panel li a.removeFormat { background-position: -80px -64px; }
+
+div.wysiwyg ul.panel li a.empty { background-position: -64px -80px; }
+
+div.wysiwyg iframe { border: 0; margin: 5px 0 0 0; clear: left; }
\ No newline at end of file
diff --git a/js/jwysiwyg/jquery.wysiwyg.gif b/js/jwysiwyg/jquery.wysiwyg.gif
new file mode 100644 (file)
index 0000000..fd64e36
Binary files /dev/null and b/js/jwysiwyg/jquery.wysiwyg.gif differ
diff --git a/js/jwysiwyg/jquery.wysiwyg.js b/js/jwysiwyg/jquery.wysiwyg.js
new file mode 100644 (file)
index 0000000..db278fc
--- /dev/null
@@ -0,0 +1,652 @@
+/**
+ * WYSIWYG - jQuery plugin 0.5
+ *
+ * Copyright (c) 2008-2009 Juan M Martinez
+ * http://plugins.jquery.com/project/jWYSIWYG
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ *
+ * $Id: $
+ */
+(function( $ )
+{
+    $.fn.document = function()
+    {
+        var element = this[0];
+
+        if ( element.nodeName.toLowerCase() == 'iframe' )
+            return element.contentWindow.document;
+            /*
+            return ( $.browser.msie )
+                ? document.frames[element.id].document
+                : element.contentWindow.document // contentDocument;
+             */
+        else
+            return $(this);
+    };
+
+    $.fn.documentSelection = function()
+    {
+        var element = this[0];
+
+        if ( element.contentWindow.document.selection )
+            return element.contentWindow.document.selection.createRange().text;
+        else
+            return element.contentWindow.getSelection().toString();
+    };
+
+    $.fn.wysiwyg = function( options )
+    {
+        if ( arguments.length > 0 && arguments[0].constructor == String )
+        {
+            var action = arguments[0].toString();
+            var params = [];
+
+            for ( var i = 1; i < arguments.length; i++ )
+                params[i - 1] = arguments[i];
+
+            if ( action in Wysiwyg )
+            {
+                return this.each(function()
+                {
+                    $.data(this, 'wysiwyg')
+                     .designMode();
+
+                    Wysiwyg[action].apply(this, params);
+                });
+            }
+            else return this;
+        }
+
+        var controls = {};
+
+        /**
+         * If the user set custom controls, we catch it, and merge with the
+         * defaults controls later.
+         */
+        if ( options && options.controls )
+        {
+            var controls = options.controls;
+            delete options.controls;
+        }
+
+        var options = $.extend({
+            html : '<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body>INITIAL_CONTENT</body></html>',
+            css  : {},
+
+            debug        : false,
+
+            autoSave     : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=11
+            rmUnwantedBr : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=15
+            brIE         : true,
+
+            controls : {},
+            messages : {}
+        }, options);
+
+        options.messages = $.extend(true, options.messages, Wysiwyg.MSGS_EN);
+        options.controls = $.extend(true, options.controls, Wysiwyg.TOOLBAR);
+
+        for ( var control in controls )
+        {
+            if ( control in options.controls )
+                $.extend(options.controls[control], controls[control]);
+            else
+                options.controls[control] = controls[control];
+        }
+
+        // not break the chain
+        return this.each(function()
+        {
+            Wysiwyg(this, options);
+        });
+    };
+
+    function Wysiwyg( element, options )
+    {
+        return this instanceof Wysiwyg
+            ? this.init(element, options)
+            : new Wysiwyg(element, options);
+    }
+
+    $.extend(Wysiwyg, {
+        insertImage : function( szURL, attributes )
+        {
+            var self = $.data(this, 'wysiwyg');
+
+            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
+            {
+                if ( attributes )
+                {
+                    self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
+                    var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');
+
+                    if ( img )
+                    {
+                        img.src = szURL;
+
+                        for ( var attribute in attributes )
+                        {
+                            img.setAttribute(attribute, attributes[attribute]);
+                        }
+                    }
+                }
+                else
+                {
+                    self.editorDoc.execCommand('insertImage', false, szURL);
+                }
+            }
+        },
+
+        createLink : function( szURL )
+        {
+            var self = $.data(this, 'wysiwyg');
+
+            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
+            {
+                var selection = $(self.editor).documentSelection();
+
+                if ( selection.length > 0 )
+                {
+                    self.editorDoc.execCommand('unlink', false, []);
+                    self.editorDoc.execCommand('createLink', false, szURL);
+                }
+                else if ( self.options.messages.nonSelection )
+                    alert(self.options.messages.nonSelection);
+            }
+        },
+
+        setContent : function( newContent )
+        {
+            var self = $.data(this, 'wysiwyg');
+                self.setContent( newContent );
+                self.saveContent();
+        },
+
+        clear : function()
+        {
+            var self = $.data(this, 'wysiwyg');
+                self.setContent('');
+                self.saveContent();
+        },
+
+        MSGS_EN : {
+            nonSelection : 'select the text you wish to link'
+        },
+
+        TOOLBAR : {
+            bold          : { visible : true, tags : ['b', 'strong'], css : { fontWeight : 'bold' } },
+            italic        : { visible : true, tags : ['i', 'em'], css : { fontStyle : 'italic' } },
+            strikeThrough : { visible : false, tags : ['s', 'strike'], css : { textDecoration : 'line-through' } },
+            underline     : { visible : false, tags : ['u'], css : { textDecoration : 'underline' } },
+
+            separator00 : { visible : false, separator : true },
+
+            justifyLeft   : { visible : false, css : { textAlign : 'left' } },
+            justifyCenter : { visible : false, tags : ['center'], css : { textAlign : 'center' } },
+            justifyRight  : { visible : false, css : { textAlign : 'right' } },
+            justifyFull   : { visible : false, css : { textAlign : 'justify' } },
+
+            separator01 : { visible : false, separator : true },
+
+            indent  : { visible : false },
+            outdent : { visible : false },
+
+            separator02 : { visible : false, separator : true },
+
+            subscript   : { visible : false, tags : ['sub'] },
+            superscript : { visible : false, tags : ['sup'] },
+
+            separator03 : { visible : false, separator : true },
+
+            undo : { visible : false },
+            redo : { visible : false },
+
+            separator04 : { visible : false, separator : true },
+
+            insertOrderedList    : { visible : false, tags : ['ol'] },
+            insertUnorderedList  : { visible : false, tags : ['ul'] },
+            insertHorizontalRule : { visible : false, tags : ['hr'] },
+
+            separator05 : { separator : true },
+
+            createLink : {
+                visible : true,
+                exec    : function()
+                {
+                    var selection = $(this.editor).documentSelection();
+
+                    if ( selection.length > 0 )
+                    {
+                        if ( $.browser.msie )
+                            this.editorDoc.execCommand('createLink', true, null);
+                        else
+                        {
+                            var szURL = prompt('URL', 'http://');
+
+                            if ( szURL && szURL.length > 0 )
+                            {
+                                this.editorDoc.execCommand('unlink', false, []);
+                                this.editorDoc.execCommand('createLink', false, szURL);
+                            }
+                        }
+                    }
+                    else if ( this.options.messages.nonSelection )
+                        alert(this.options.messages.nonSelection);
+                },
+
+                tags : ['a']
+            },
+
+            insertImage : {
+                visible : true,
+                exec    : function()
+                {
+                    if ( $.browser.msie )
+                        this.editorDoc.execCommand('insertImage', true, null);
+                    else
+                    {
+                        var szURL = prompt('URL', 'http://');
+
+                        if ( szURL && szURL.length > 0 )
+                            this.editorDoc.execCommand('insertImage', false, szURL);
+                    }
+                },
+
+                tags : ['img']
+            },
+
+            separator06 : { separator : true },
+
+            h1mozilla : { visible : true && $.browser.mozilla, className : 'h1', command : 'heading', arguments : ['h1'], tags : ['h1'] },
+            h2mozilla : { visible : true && $.browser.mozilla, className : 'h2', command : 'heading', arguments : ['h2'], tags : ['h2'] },
+            h3mozilla : { visible : true && $.browser.mozilla, className : 'h3', command : 'heading', arguments : ['h3'], tags : ['h3'] },
+
+            h1 : { visible : true && !( $.browser.mozilla ), className : 'h1', command : 'formatBlock', arguments : ['Heading 1'], tags : ['h1'] },
+            h2 : { visible : true && !( $.browser.mozilla ), className : 'h2', command : 'formatBlock', arguments : ['Heading 2'], tags : ['h2'] },
+            h3 : { visible : true && !( $.browser.mozilla ), className : 'h3', command : 'formatBlock', arguments : ['Heading 3'], tags : ['h3'] },
+
+            separator07 : { visible : false, separator : true },
+
+            cut   : { visible : false },
+            copy  : { visible : false },
+            paste : { visible : false },
+
+            separator08 : { separator : true && !( $.browser.msie ) },
+
+            increaseFontSize : { visible : true && !( $.browser.msie ), tags : ['big'] },
+            decreaseFontSize : { visible : true && !( $.browser.msie ), tags : ['small'] },
+
+            separator09 : { separator : true },
+
+            html : {
+                visible : false,
+                exec    : function()
+                {
+                    if ( this.viewHTML )
+                    {
+                        this.setContent( $(this.original).val() );
+                        $(this.original).hide();
+                    }
+                    else
+                    {
+                        this.saveContent();
+                        $(this.original).show();
+                    }
+
+                    this.viewHTML = !( this.viewHTML );
+                }
+            },
+
+            removeFormat : {
+                visible : true,
+                exec    : function()
+                {
+                    this.editorDoc.execCommand('removeFormat', false, []);
+                    this.editorDoc.execCommand('unlink', false, []);
+                }
+            }
+        }
+    });
+
+    $.extend(Wysiwyg.prototype,
+    {
+        original : null,
+        options  : {},
+
+        element  : null,
+        editor   : null,
+
+        init : function( element, options )
+        {
+            var self = this;
+
+            this.editor = element;
+            this.options = options || {};
+
+            $.data(element, 'wysiwyg', this);
+
+            var newX = element.width || element.clientWidth;
+            var newY = element.height || element.clientHeight;
+
+            if ( element.nodeName.toLowerCase() == 'textarea' )
+            {
+                this.original = element;
+
+                if ( newX == 0 && element.cols )
+                    newX = ( element.cols * 8 ) + 21;
+
+                if ( newY == 0 && element.rows )
+                    newY = ( element.rows * 16 ) + 16;
+
+                var editor = this.editor = $('<iframe></iframe>').css({
+                    minHeight : ( newY - 6 ).toString() + 'px',
+                    width     : ( newX - 8 ).toString() + 'px'
+                }).attr('id', $(element).attr('id') + 'IFrame');
+
+                if ( $.browser.msie )
+                {
+                    this.editor
+                        .css('height', ( newY ).toString() + 'px');
+
+                    /**
+                    var editor = $('<span></span>').css({
+                        width     : ( newX - 6 ).toString() + 'px',
+                        height    : ( newY - 8 ).toString() + 'px'
+                    }).attr('id', $(element).attr('id') + 'IFrame');
+
+                    editor.outerHTML = this.editor.outerHTML;
+                     */
+                }
+            }
+
+            var panel = this.panel = $('<ul></ul>').addClass('panel');
+
+            this.appendControls();
+            this.element = $('<div></div>').css({
+                width : ( newX > 0 ) ? ( newX ).toString() + 'px' : '100%'
+            }).addClass('wysiwyg')
+              .append(panel)
+              .append( $('<div><!-- --></div>').css({ clear : 'both' }) )
+              .append(editor);
+
+            $(element)
+            // .css('display', 'none')
+            .hide()
+            .before(this.element);
+
+            this.viewHTML = false;
+
+            this.initialHeight = newY - 8;
+
+            /**
+             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=52
+             */
+            this.initialContent = $(element).val();
+
+            this.initFrame();
+
+            if ( this.initialContent.length == 0 )
+                this.setContent('');
+
+            if ( this.options.autoSave )
+                $('form').submit(function() { self.saveContent(); });
+
+            $('form').bind('reset', function()
+            {
+                self.setContent( self.initialContent );
+                self.saveContent();
+            });
+        },
+
+        initFrame : function()
+        {
+            var self = this;
+            var style = '';
+
+            /**
+             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=14
+             */
+            if ( this.options.css && this.options.css.constructor == String )
+                style = '<link rel="stylesheet" type="text/css" media="screen" href="' + this.options.css + '" />';
+
+            this.editorDoc = $(this.editor).document();
+            this.editorDoc_designMode = false;
+
+            try {
+                this.editorDoc.designMode = 'on';
+                this.editorDoc_designMode = true;
+            } catch ( e ) {
+                // Will fail on Gecko if the editor is placed in an hidden container element
+                // The design mode will be set ones the editor is focused
+
+                $(this.editorDoc).focus(function()
+                {
+                    self.designMode();
+                });
+            }
+
+            this.editorDoc.open();
+            this.editorDoc.write(
+                this.options.html
+                    .replace(/INITIAL_CONTENT/, this.initialContent)
+                    .replace(/STYLE_SHEET/, style)
+            );
+            this.editorDoc.close();
+            this.editorDoc.contentEditable = 'true';
+
+            if ( $.browser.msie )
+            {
+                /**
+                 * Remove the horrible border it has on IE.
+                 */
+                setTimeout(function() { $(self.editorDoc.body).css('border', 'none'); }, 0);
+            }
+
+            $(this.editorDoc).click(function( event )
+            {
+                self.checkTargets( event.target ? event.target : event.srcElement);
+            });
+
+            /**
+             * @link http://code.google.com/p/jwysiwyg/issues/detail?id=20
+             */
+            $(this.original).focus(function()
+            {
+                $(self.editorDoc.body).focus();
+            });
+
+            if ( this.options.autoSave )
+            {
+                /**
+                 * @link http://code.google.com/p/jwysiwyg/issues/detail?id=11
+                 */
+                $(this.editorDoc).keydown(function() { self.saveContent(); })
+                                 .keyup(function() { self.saveContent(); })
+                                 .mousedown(function() { self.saveContent(); });
+            }
+
+            if ( this.options.css )
+            {
+                setTimeout(function()
+                {
+                    if ( self.options.css.constructor == String )
+                    {
+                        /**
+                         * $(self.editorDoc)
+                         * .find('head')
+                         * .append(
+                         *     $('<link rel="stylesheet" type="text/css" media="screen" />')
+                         *     .attr('href', self.options.css)
+                         * );
+                         */
+                    }
+                    else
+                        $(self.editorDoc).find('body').css(self.options.css);
+                }, 0);
+            }
+
+            $(this.editorDoc).keydown(function( event )
+            {
+                if ( $.browser.msie && self.options.brIE && event.keyCode == 13 )
+                {
+                    var rng = self.getRange();
+                        rng.pasteHTML('<br />');
+                        rng.collapse(false);
+                        rng.select();
+
+                               return false;
+                }
+            });
+        },
+
+        designMode : function()
+        {
+            if ( !( this.editorDoc_designMode ) )
+            {
+                try {
+                    this.editorDoc.designMode = 'on';
+                    this.editorDoc_designMode = true;
+                } catch ( e ) {}
+            }
+        },
+
+        getSelection : function()
+        {
+            return ( window.getSelection ) ? window.getSelection() : document.selection;
+        },
+
+        getRange : function()
+        {
+            var selection = this.getSelection();
+
+            if ( !( selection ) )
+                return null;
+
+            return ( selection.rangeCount > 0 ) ? selection.getRangeAt(0) : selection.createRange();
+        },
+
+        getContent : function()
+        {
+            return $( $(this.editor).document() ).find('body').html();
+        },
+
+        setContent : function( newContent )
+        {
+            $( $(this.editor).document() ).find('body').html(newContent);
+        },
+
+        saveContent : function()
+        {
+            if ( this.original )
+            {
+                var content = this.getContent();
+
+                if ( this.options.rmUnwantedBr )
+                    content = ( content.substr(-4) == '<br>' ) ? content.substr(0, content.length - 4) : content;
+
+                $(this.original).val(content);
+            }
+        },
+
+        appendMenu : function( cmd, args, className, fn )
+        {
+            var self = this;
+            var args = args || [];
+
+            $('<li></li>').append(
+                $('<a><!-- --></a>').addClass(className || cmd)
+            ).mousedown(function() {
+                if ( fn ) fn.apply(self); else self.editorDoc.execCommand(cmd, false, args);
+                if ( self.options.autoSave ) self.saveContent();
+            }).appendTo( this.panel );
+        },
+
+        appendMenuSeparator : function()
+        {
+            $('<li class="separator"></li>').appendTo( this.panel );
+        },
+
+        appendControls : function()
+        {
+            for ( var name in this.options.controls )
+            {
+                var control = this.options.controls[name];
+
+                if ( control.separator )
+                {
+                    if ( control.visible !== false )
+                        this.appendMenuSeparator();
+                }
+                else if ( control.visible )
+                {
+                    this.appendMenu(
+                        control.command || name, control.arguments || [],
+                        control.className || control.command || name || 'empty', control.exec
+                    );
+                }
+            }
+        },
+
+        checkTargets : function( element )
+        {
+            for ( var name in this.options.controls )
+            {
+                var control = this.options.controls[name];
+                var className = control.className || control.command || name || 'empty';
+
+                $('.' + className, this.panel).removeClass('active');
+
+                if ( control.tags )
+                {
+                    var elm = element;
+
+                    do {
+                        if ( elm.nodeType != 1 )
+                            break;
+
+                        if ( $.inArray(elm.tagName.toLowerCase(), control.tags) != -1 )
+                            $('.' + className, this.panel).addClass('active');
+                    } while ( elm = elm.parentNode );
+                }
+
+                if ( control.css )
+                {
+                    var elm = $(element);
+
+                    do {
+                        if ( elm[0].nodeType != 1 )
+                            break;
+
+                        for ( var cssProperty in control.css )
+                            if ( elm.css(cssProperty).toString().toLowerCase() == control.css[cssProperty] )
+                                $('.' + className, this.panel).addClass('active');
+                    } while ( elm = elm.parent() );
+                }
+            }
+        },
+
+        getElementByAttributeValue : function( tagName, attributeName, attributeValue )
+        {
+            var elements = this.editorDoc.getElementsByTagName(tagName);
+
+            for ( var i = 0; i < elements.length; i++ )
+            {
+                var value = elements[i].getAttribute(attributeName);
+
+                if ( $.browser.msie )
+                {
+                    /** IE add full path, so I check by the last chars. */
+                    value = value.substr(value.length - attributeValue.length);
+                }
+
+                if ( value == attributeValue )
+                    return elements[i];
+            }
+
+            return false;
+        }
+    });
+})(jQuery);
\ No newline at end of file
index eb7ebdf..3b27319 100644 (file)
@@ -33,14 +33,14 @@ function applyChange(){
         entry.published = dateRfc3339;
         entry.updated = dateRfc3339;
         entry.link = pageAddr + entry.id;
-        entry.content = xmlAttrContentEscape(document.getElementById("content").value);
+        entry.content = xmlAttrContentEscape(convertContent(document.getElementById("stdin").value));
         
         entryList.unshift(entry);
     }
     else {
         entryList[editIndex].title = xmlAttrContentEscape(document.getElementById("title").value);
         entryList[editIndex].updated = getDate();
-        entryList[editIndex].content = xmlAttrContentEscape(convertContent(document.getElementById("content").value));
+        entryList[editIndex].content = xmlAttrContentEscape(convertContent(document.getElementById("stdin").value));
     }
     
     refleshComboBox();
@@ -54,7 +54,7 @@ function removeEntry(index){
         
         document.getElementById("stdout").value = ""
         document.getElementById("title").value = "";
-        document.getElementById("content").value = "";
+        document.getElementById("stdin").value = "";
     }
 }
 
@@ -90,20 +90,20 @@ function analyzeTargetXml(xmlData){
     
     refleshComboBox();
     document.getElementById("title").value = "";
-    document.getElementById("content").value = "";
-       document.getElementById("stdout").value = "";
+    document.getElementById("stdin").value = "";
+    document.getElementById("stdout").value = "";
     editIndex = -1;
 }
 
 function entryLoader(index){
     if (index < 0) {
         document.getElementById("title").value = "";
-        document.getElementById("content").value = "";
+        document.getElementById("stdin").value = "";
         editIndex = -1;
     }
     else {
         document.getElementById("title").value = entryList[index].title;
-        document.getElementById("content").value = entryList[index].content;
+        document.getElementById("stdin").value = entryList[index].content;
         editIndex = index;
     }
 }
@@ -117,7 +117,7 @@ function refleshComboBox(){
     }
     stringBuffer.push("</select></form>");
     // コンボボックス要素を生成
-       editIndex = -1;
+    editIndex = -1;
     document.getElementById("entrySelect").innerHTML = stringBuffer.join("");
 }
 
@@ -126,15 +126,15 @@ function refleshComboBox(){
  * @param {Object} obj
  */
 function FeedInfo(obj){
-    this.title = $("title:first", obj).text();
-    this.subtitle = $("subtitle:first", obj).text();
-    this.self = $("link[rel=self]", obj).attr("href")
-    this.alternate = $("link[rel=alternate]", obj).attr("href")
-    this.updated = $("updated:first", obj).text();
-    this.id = $("id:first", obj).text();
-    this.rights = $("rights:first", obj).text();
-    this.authorname = $("author>name", obj).text();
-    this.authoremail = $("author>email", obj).text();
+    this.title = xmlAttrContentEscape($("title:first", obj).text());
+    this.subtitle = xmlAttrContentEscape($("subtitle:first", obj).text());
+    this.self = xmlAttrContentEscape($("link[rel=self]", obj).attr("href"));
+    this.alternate = xmlAttrContentEscape($("link[rel=alternate]", obj).attr("href"));
+    this.updated = xmlAttrContentEscape($("updated:first", obj).text());
+    this.id = xmlAttrContentEscape($("id:first", obj).text());
+    this.rights = xmlAttrContentEscape($("rights:first", obj).text());
+    this.authorname = xmlAttrContentEscape($("author>name", obj).text());
+    this.authoremail = xmlAttrContentEscape($("author>email", obj).text());
 }
 
 /**
@@ -142,13 +142,13 @@ function FeedInfo(obj){
  * @param {Object} obj entry 要素の DOM オブジェクト
  */
 function Entry(obj){
-    this.id = $("id:first", obj).text();
-    this.title = $("title:first", obj).text();
-    this.summary = $("summary:first", obj).text();
-    this.published = $("published:first", obj).text();
-    this.updated = $("updated:first", obj).text();
-    this.link = $("link:first", obj).attr("href");
-    this.content = $("content:first", obj).text();
+    this.id = xmlAttrContentEscape($("id:first", obj).text());
+    this.title = xmlAttrContentEscape($("title:first", obj).text());
+    this.summary = xmlAttrContentEscape($("summary:first", obj).text());
+    this.published = xmlAttrContentEscape($("published:first", obj).text());
+    this.updated = xmlAttrContentEscape($("updated:first", obj).text());
+    this.link = xmlAttrContentEscape($("link:first", obj).attr("href"));
+    this.content = xmlAttrContentEscape($("content:first", obj).text());
 }
 
 /**
@@ -199,9 +199,13 @@ function toXml(finfo, elist){
  * @param {Object} content
  */
 function convertContent(content){
+    if (!jQuery.browser.msie) {
+        content = content.replace(/[ ]*$/g, "");
+    }
+    
     if (validateMode == 0) {
-        content = content.replace(/(\r\n|\n)/g, "");
-        content = content.replace(/(<br>|<\/p>|<\/h\d>|<\/div>)(?=[^\n])/i, "$1\n");
+        content = content.replace(/[\n\r]|\r\n/g, "");
+        content = content.replace(/(<br>|<\/p>|<\/h\d>|<\/div>)(?=[^\n])/ig, "$1\n");
     }
     else {
         content = content.replace(/<br>/ig, "\n");
index dbc2865..56708b2 100644 (file)
@@ -1,44 +1,70 @@
 <?xml version="1.0" encoding="utf-8"?>
-<feed xml:lang="ja-jp" xmlns="http://www.w3.org/2005/Atom">
-
-<title type="text">さんぷる</title>
-<subtitle type="text">このファイルはサンプルのファイルです。</subtitle>
-<link rel="self" type="application/atom+xml" href="" />
-<link rel="alternate" type="text/html" href="http://www.yourdomain.com/index.html" />
-<updated>2009-01-27T22:07:10+09:00</updated>
-<id>urn:uuid:sample</id>
-<rights type="text">Copyright (c) YYYY, [Please input your name.]</rights>
+<feed xml:lang='ja-jp' 
+xmlns='http://www.w3.org/2005/Atom'>
+<title type="text">風雅</title>
+<subtitle type="text">壁紙と日記のウェブサイトです。</subtitle>
+<link rel="self" type="application/atom+xml" href="http://lunardial.sakura.ne.jp/xml/diary.xml" />
+<link rel="alternate" type="text/html" href="http://lunardial.sakura.ne.jp/index.html" />
+<updated>2009-06-02T22:07:07+09:00</updated>
+<id>http://lunardial.sakura.ne.jp/index.html</id>
+<rights type="text">Copyright (c) 2008, K.Hisame</rights>
 <author>
-       <name>Please input your name.</name>
-       <email>Please input your e-mail.</email>
+       <name>K.Hisame</name>
+       <email>luanrdial@hotmail.com</email>
 </author>
 
 <entry>
-<id>urn:uuid:sample;2009-01-27T22:03:57+09:00</id>
-<title>ã\82¿ã\82°ã\81®å\8f\96ã\82\8aæ\89±ã\81\84ã\81«ã\81¤ã\81\84ã\81¦</title>
+<id>http://lunardial.sakura.ne.jp/index.html?2009-06-02T21:53:44+09:00</id>
+<title>ã\82µã\82¯ã\83©ã\81¡ã\82\83ã\82\93æ´\97濯æ©\9f(横)ã\81«è² ã\81\91ã\81\9a</title>
 <summary></summary>
-<published>2009-01-27T22:03:57+09:00</published>
-<updated>2009-01-27T22:03:57+09:00</updated>
-<link href="../index.html#urn:uuid:sample;2009-01-27T22:03:57+09:00" />
-<content type="html"> FeedBlog Scriptでは&lt;span style=&quot;font-weight: bold;&quot;&gt;このように&lt;/span&gt;、タグを扱うことも可能です。
- ただしその際はエンティティ参照でタグを書く必要があります。
- 詳しくはXML標準のエンティティ参照に関するドキュメントか、ウェブページをご覧下さい。
-
-・&lt;a href=&quot;http://msdn.microsoft.com/ja-jp/library/ms256190(VS.80).aspx&quot; target=&quot;_blank&quot; &gt;文字参照とエンティティ参照[XMl標準]&lt;/a&gt; (MSDN)
-・&lt;a href=&quot;http://gogodiet.net/z/xml/3_10.htm&quot; target=&quot;_blank&quot; &gt;XML エンティティ参照(エスケープ文字)&lt;/a&gt; 
-</content>
+<published>2009-06-02T21:53:44+09:00</published>
+<updated>2009-06-02T21:53:44+09:00</updated>
+<link href="http://lunardial.sakura.ne.jp/index.html#http://lunardial.sakura.ne.jp/index.html?2009-06-02T21:53:44+09:00" />
+<content type="html">&amp;nbsp;&lt;iframe src=&quot;http://ext.nicovideo.jp/thumb/sm7205037&quot; style=&quot;border: 1px solid #CCCCCC;&quot; scrolling=&quot;no&quot; width=&quot;312&quot; frameborder=&quot;0&quot; height=&quot;176&quot;&gt;&amp;amp;lt;a href=&quot;http://www.nicovideo.jp/watch/sm7205037&quot;&amp;amp;gt;【ニコニコ動画】Xbox360版デススマイルズMBL 『ブラッディージルバ』(5/5)&amp;amp;lt;/a&amp;amp;gt;&lt;/iframe&gt;&lt;br&gt;
+&lt;br&gt;
+ 「リスタートを駆使しても出る(が、実績は解除されない)」という情報があったので、もしかすると誰かがやってくれるかもしれない!とおもったら、以前「&lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;http://www.nicovideo.jp/tag/%E5%8D%91%E6%80%AF%E3%81%AA%E3%82%B5%E3%82%AF%E3%83%A9%E3%81%A1%E3%82%83%E3%82%93&quot;&gt;卑怯なサクラちゃん&lt;/a&gt;」で真ボス出現するか!?に挑んでいた人なのだけど、リスタートを駆使して引きずり出してくれた!素晴らしい!&lt;br&gt;
+ にしてもコレはひどい。出す条件がひどく難しいから、手加減無しじゃないか!&lt;br&gt;
+ でもボムが効くから、これならごり押しできないでもないのかな・・・・・。&lt;br&gt;
+ ・・・・・にしてもこの人も十分立ち回りがおかしいくらい上手い。うーん。&lt;br&gt;
+&lt;br&gt;
+ 横洗濯機に横シンデレラアンバーとはありがたやありがたや・・・・・。&lt;br&gt;
+&lt;br&gt;
+ &lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;./xml/img/2009/20090602_01.jpg&quot;&gt;&lt;img alt=&quot;&quot; style=&quot;width: 120px; height: 90px;&quot; src=&quot;./xml/img/2009/20090602_01.jpg&quot; vspace=&quot;&quot; border=&quot;0&quot; hspace=&quot;&quot;&gt;&lt;/a&gt;&lt;br&gt;
+ こっちはケロちゃん暴風雨に負けず。いや、実は東風戦であっという間に連続で詰まれて3位とかになったりしていたのだけど、このごろはケロちゃん。&lt;br&gt;
+ まずい配牌を、素変換を噛まして上手いことカヴァーしようという。&lt;br&gt;
+ &lt;br&gt;
+ この頃全然起動していないというか、、まったくやっていないPSUどうしよう!というか実は課金が切れました(&lt;span style=&quot;font-weight: bold;&quot;&gt;きりました&lt;/span&gt;)。いやあだってイベントも無いし、GBRはしょっぱかったし・・・・・。&lt;br&gt;
+ そういやウィッチテイルが欲しいから今週こそ売っていることを祈って買いに行こう。・・・・・にゃ、そんならAmazonがいいかな?&lt;br&gt;</content>
 </entry>
 
 <entry>
-<id>urn:uuid:sample;2008-10-24T21:03:18+09:00</id>
-<title>にっきてすと</title>
-<summary>この日記はテストです。</summary>
-<published>2008-10-24T21:03:18+09:00</published>
-<updated>2008-10-24T21:03:18+09:00</updated>
-<link href="../index.html#urn:uuid:sample;2008-10-24T21:03:18+09:00" />
-<content type="html"> この日記はテスト日記です。
- 基本的な機能、及び正常に表示できているかを確認するのにご使用下さい。
-</content>
+<id>http://lunardial.sakura.ne.jp/index.html?2009-06-01T21:21:15+09:00</id>
+<title>2009.06.01</title>
+<summary></summary>
+<published>2009-06-01T21:21:15+09:00</published>
+<updated>2009-06-01T23:38:49+09:00</updated>
+<link href="http://lunardial.sakura.ne.jp/index.html#http://lunardial.sakura.ne.jp/index.html?2009-06-01T21:21:15+09:00" />
+<content type="html"> あっという間に6月になってしまいました。紅葉です。&lt;br&gt;
+&lt;br&gt;
+ 取り敢えずそろそろ、エヴァンゲリオン : 破の公開が迫ってきて、予告画像にまた半裸のカヲル君が写っていて、「&lt;span style=&quot;font-weight: bold; color: #FF0000;&quot;&gt;じゃあボーナスでカヲル君だけ100回見よう!&lt;/span&gt;」とか思って計算すると、実際には100回見れるくらいは貰うけどもったいないし云々かんぬん。&lt;br&gt;
+ 真剣な話ボーナスで何をしよう。と思ったんだけど、今のモニターの組み合わせが&lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;http://www.mitsubishielectric.co.jp/home/display/product/mdt242wg/index.html&quot;&gt;MDT242WG&lt;/a&gt;と、&lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;http://www.mitsubishielectric.co.jp/home/display/product/rdt1713s/&quot;&gt;RDT1713S&lt;/a&gt;の組み合わせで、Dualなのに左右非対称なのよね。&lt;br&gt;
+ なのでRDT1713Sのほうを親に上げて、MDT243WGを買って左右対称WUXGAにするか計画中。やっぱりゲームやるときとか、サブモニターが狭くて。&lt;br&gt;
+&lt;br&gt;
+ &lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;./xml/img/2009/20090601_01.jpg&quot;&gt;&lt;img alt=&quot;&quot; style=&quot;width: 120px; height: 90px;&quot; src=&quot;./xml/img/2009/20090601_01.jpg&quot; vspace=&quot;&quot; border=&quot;0&quot; hspace=&quot;&quot;&gt;&lt;/a&gt;&lt;br&gt;
+ やっぱりラス親は勝負どころなのかしら私。&lt;br&gt;
+ 西家とかだと運が無い。とにかく運が無い。起親か、ラス親あたりだと運が回ってくる。のは、ただの確率なのかしら。それともラストだとがっつくからなのかしら。&lt;br&gt;
+ むしろ西なりでも、がっつけるようにするべきなのかしら。うーん&lt;br&gt;
+&lt;br&gt;
+ &lt;span style=&quot;font-weight: bold;&quot;&gt;追記&lt;/span&gt; : とか書いてたら勝った。やっぱがっつくべきみたいな。&lt;br&gt;
+ &lt;a name=&quot;&quot; target=&quot;_blank&quot; classname=&quot;&quot; class=&quot;&quot; href=&quot;./xml/img/2009/20090601_02.jpg&quot;&gt;&lt;img alt=&quot;&quot; style=&quot;width: 120px; height: 90px;&quot; src=&quot;./xml/img/2009/20090601_02.jpg&quot; vspace=&quot;&quot; border=&quot;0&quot; hspace=&quot;&quot;&gt;&lt;/a&gt;&lt;br&gt;
+&lt;br&gt;
+▼ MassEffectは面白いよね…AIは邪魔だけどwそこに居たら俺攻撃できないだろ…ってのがねw&lt;br&gt;
+○ たまに味方にハンドガン打ち込んだり、味方にショットガンぶち込まれたりするよね(&lt;br&gt;
+ 私はアデプトだから、適当に味方を前進させて、スロウなりステーシスなりで止めるけど。というかいい加減ハンドガンだけで戦うのは飽きてきました!&lt;br&gt;
+&lt;br&gt;
+▼ なんだこのMBLの秘密の実績・・・無理すぎる・・・!&lt;br&gt;
+○ いい加減裏2ALLくらいの実力は必要な感じが!&lt;br&gt;
+ LV999どころか、それを絶するモノとな。さすがにあきらめました!&lt;br&gt;</content>
 </entry>
 
-</feed>
+</feed>
\ No newline at end of file