[JavaScript] javascript WYSISYG editor

insert html
ie10까지는 pasteHtml을 사용하면 되고,다른 브라우저는 execcommand를 사용하면

되지만 ie11은 둘다 지원하지 않기 때문에 별도의 개발이 필요하다.

하지만 이미 있으니 가져다 쓰면 되겠다.

https://gist.github.com/sergi/126762

insertNodeAtSelection : function(win, insertNode, _container, _pos)
{
// get current selection
var sel = this._getSelection(); var doc = this._getDoc();
 
// get the first range of the selection (there's almost always only
// one range)
var range = sel.getRangeAt(0);
 
// deselect everything
sel.removeAllRanges();
 
// remove content of current selection from document
range.deleteContents();
 
// get location of current selection
var container = _container ? _container : range.startContainer; var
pos = _pos ? _pos : range.startOffset;
 
// make a new range for the new selection
range=doc.createRange();
 
if (container.nodeType==3 && insertNode.nodeType==3) {
// if we insert text in a textnode, do optimized insertion
container.insertData(pos, insertNode.nodeValue);
 
// put cursor after inserted text
range.setEnd(container, pos+insertNode.length);
range.setStart(container, pos+insertNode.length);
 
} else {
var afterNode;
if (container.nodeType==3) {
// when inserting into a textnode we create 2 new textnodes and
// put the insertNode in between
 
var textNode = container; container = textNode.parentNode; var
text = textNode.nodeValue;
 
// text before the split
var textBefore = text.substr(0,pos);
// text after the split
var textAfter = text.substr(pos);
 
var beforeNode = doc.createTextNode(textBefore); afterNode =
doc.createTextNode(textAfter);
 
// insert the 3 new nodes before the old one
container.insertBefore(afterNode, textNode);
container.insertBefore(insertNode, afterNode);
container.insertBefore(beforeNode, insertNode);
 
// remove the old node
container.removeChild(textNode);
} else {
// else simply insert the node
afterNode = container.childNodes[pos];
container.insertBefore(insertNode, afterNode);
}
range.setEnd(afterNode, 0); range.setStart(afterNode, 0);
}
sel.addRange(range); return {c:container, p:pos};
}














검색해도 잘 안나오는 것만
작성중......


1. WebNote(구 spac editor)
http://www.webeditor.kr/
http://www.phpwork.kr/downloads/viewdow ··· Fwebnote

2. jwysiwyg
https://github.com/jwysiwyg/jwysiwyg
jQuery 기반

3. cheditor(유료)
http://www.chcode.com/products/cheditor.shtml
http://www.chcode.com/cheditor/demo.shtml

4. jqte
http://jqueryte.com/
http://jqueryte.com/demos



execCommand 테스트
http://www.quirksmode.org/dom/execCommand/
브라우저 호환성
http://www.quirksmode.org/dom/execCommand.html


http://www-archive.mozilla.org/editor/midas-spec.html


http://msdn.microsoft.com/en-us/library/aa741314%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/aa969729%28v=vs.85%29.aspx#basic
http://msdn.microsoft.com/en-us/library/ms536419%28v=vs.85%29.aspx


HTML Clipboard Format
http://msdn.microsoft.com/en-us/library/aa767917%28v=vs.85%29.aspx



ie inserthtml
http://stackoverflow.com/questions/3398378/execcommand-inserthtml-in-internet-explorer
http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div/6691294#6691294
http://jsfiddle.net/timdown/jwvha/527/


Rich-Text Editing in Mozilla
https://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla

Posted by incree

2014/01/11 08:41 2014/01/11 08:41
, ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/251

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

// 자바 스크립트
FB.getLoginStatus(function(response) {
    if (response.status == "connected"){
        // 좋아요 여부 확인
        FB.api('/me/likes/likeId', function(likeResponse) {
            if(likeResponse == null || likeResponse == undefined || likeResponse.data[0] == null || likeResponse.data[0] == undefined) {
                setNotliked();
            }
            else {
                setLiked();
            }
        });
    }
    else if (response.status == "not_authorized") {
        console.debug(response);
    }
    else {
        console.debug(response);
    }
});


// php signed request
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if($data["page"]["liked"]) {
    /* is pan */
}
else {
 /* Not Fan */
}

/*

Array
(
    [algorithm] => HMAC-SHA256
    [issued_at] => 1387699889
    [page] => Array
        (
            [id] => **6***0677***56
            [liked] => 1
            [admin] =>
        )
    [user] => Array
        (
            [country] => kr
            [locale] => en_US
            [age] => Array
                (
                    [min] => 21
                )
        )
)
*/


// php api
$fbObj = new FaceBook(array('appId' => $appId, 'secret' => $appSecret, 'cookie' => true));
$isPageLike = $fbObj->api("/me/likes/$pageId");
or
$isPageLike = $fbObj->api("/$uid/likes/$pageId");
    if($isPageLike['data'][0]) {
    /* is pan */
}
else {
 /* Not Fan */
}

Posted by incree

2013/12/22 17:13 2013/12/22 17:13
, ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/164

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[PHP] Apache mod_rewrite 사용하기

./configure --enable-rewrite

사용자 삽입 이미지


<Directory "/document_root">
        AllowOverride FileInfo   # or All
    </Directory>

RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9])$ $1.php
# 희안하게 RewriteBase 를 설정안하면 작동을 안한다. 원래 그런가...


# 텍스트규브 .htaccess
#<IfModule mod_url.c>
#CheckURL Off
#</IfModule>
#SetEnv PRELOAD_CONFIG 1
RewriteEngine On
RewriteBase /tc/
RewriteRule ^(thumbnail)/([0-9]+/.+)$ cache/$1/$2 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(cache)+/+(.+[^/]).(cache|xml|txt|log)$ - [NC,F,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ rewrite.php [L,QSA]



Posted by incree

2013/10/30 15:34 2013/10/30 15:34
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/290

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

// 페이지 기본 정보 읽어오기
FB.api('/' + pageId, function(response) {
    console.log(response);
});

// 페이지의 모든 feed 읽어오기
FB.api({
        method: 'fql.query',
        query: 'SELECT * FROM stream WHERE source_id=' + pageId + ' LIMIT 1000'
    },
    function(response) {
        console.log(response);
    }
);

// 페이지 owner가 작성한 feed 읽어오기
FB.api({
        method: 'fql.query',
        query: 'SELECT * FROM stream WHERE filter_key='owner' AND source_id=' + pageId
    },
    function(response) {
        console.log(response);
    }
);

// 다른 사용자가 페이지에 작성한 feed 읽어오기(filter_key만 할 경우 owner이 작성한 것도 가져오는 경우가 있다. 따라서 actor_id 조건과 같이 사용)
FB.api({
        method: 'fql.query',
        query: 'SELECT * FROM stream WHERE filter_key='others' AND actor_id!=' + pageId + ' AND source_id=' + pageId
    },
    function(response) {
        console.log(response);
    }
);

// 페이지의 feed에 달린 모든 댓글 가져오기
FB.api({
        method: 'fql.query',
        query: 'SELECT * FROM comment WHERE post_id IN (SELECT post_id FROM stream WHERE source_id=' + pageId + ')'
    },
    function(response) {
        console.log(response);
    }
);

// 페이지의 feed에 달린 댓글에 달린 답글 모두 가져오기
FB.api({
        method: 'fql.query',
        query: 'SELECT * FROM comment WHERE parent_id IN (SELECT id FROM comment WHERE post_id IN (SELECT post_id FROM stream WHERE source_id=' + pageId + ')'
    },
    function(response) {
        console.log(response);
    }
);

Posted by incree

2013/10/28 11:50 2013/10/28 11:50
, , , , , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/289

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

.fb_edge_widget_with_comment span { height: 21px !important; overflow: hidden; }

Posted by incree

2013/10/27 05:26 2013/10/27 05:26
, , , , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/288

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[SNS] 페이스북 page tabapp signed request

page tabapp에서 signed request를 받으려면

페이지 탭 URL, 페이지 탭 URL (HTTPS 보안) 설정시 주의

마지막 슬래쉬 없이 디렉토리명으로 끝나면 받을 수 없다

원래 주소가 http://www.incree.com/tabapp/index.php 일 경우

웹서버 설정에 따라 http://www.incree.com/tabapp 와 같이 입력해도

접속은 되지만 signed request 는 받을 수 없다

받드지 전체 url을 입력하거나 http://www.incree.com/tabapp/와 같이 입력해야 된다

Posted by incree

2013/10/27 02:45 2013/10/27 02:45
, , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/287

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[PHP] Apache, MySQL, PHP install

1. mysql 설치
http://forums.mysql.com/read.php?11,153632,153632

yum install mysql mysql-server mysql-devel
chgrp -R mysql /var/lib/mysql
chmod -R 770 /var/lib/mysql

2. apache 설치
http://httpd.apache.org/download.cgi
http://apr.apache.org/download.cgi
http://package/forge.net/projects/pcre/files/pcre/
http://www.openssl.org/package/

cd /package/
tar -zxvf httpd-2.4.6.tar.gz
tar -zxvf apr-1.4.8.tar.gz
tar -zxvf apr-util-1.5.2.tar.gz
tar -zxvf pcre-8.33.tar.gz
tar -zxvf openssl-1.0.1e.tar.gz

cd /package/
mv apr-1.4.8 /package/httpd-2.4.6/srclib/apr
mv apr-util-1.5.2 /package/httpd-2.4.6/srclib/apr-util

cd /package/pcre-8.33
./configure
make
make install

cd /package/openssl-1.0.1e
./config
make
make install


cd /package/httpd-2.4.6
./configure --enable-module=all --enable-so --prefix=/usr/local/apache2 --enable-modules=ssl --enable-ssl --with-ssl=/usr/local/ssl   --enable-module=most
make
make install


3. php 설치
http://www.php.net/downloads.php
http://www.xmlsoft.org/downloads.html
http://sourceforge.net/projects/mcrypt/
http://code.google.com/p/quirkysoft/downloads/detail?name=jpegsrc.v6b.tar.gz&can=2&q=
http://curl.haxx.se/download.html

cd /package/
tar -zxvf php-5.5.5.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
tar -zxvf libxml2-2.9.1.tar.gz
tar -zxvf jpegsrc.v6b.tar.gz
tar -zxvf curl-7.33.0.tar.gz

cd /package/
yum install freetype-devel
yum install libjpeg-turbo-devel
yum install libpng-devel

cd /package/libmcrypt-2.5.8
./configure
make
make install

cd /package/libxml2-2.9.1
./configure
make
make install

cd /package/jpeg-6b
mkdir /usr/local/man/man1
./configure
make
make install

cd /package/curl-7.33.0
./configure
make
make install


cd /package/php-5.5.5
./configure --prefix=/usr/local/php5 --with-openssl --with-apxs2=/usr/local/apache2/bin/apxs --enable-ftp --disable-debug --with-zlib --with-jpeg-dir=/usr/local --with-gd --enable-mbstring --enable-sockets --with-mcrypt=/usr/local --with-curl --with-mysql --enable-pdo --with-pdo-mysql --enable-zip --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --enable-exif
make
make install

4. apache conf
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so 주석제거
LoadModule ssl_module modules/mod_ssl.so 주석제거


5. start
service mysqld start
/usr/local/apache2/bin/apachectl start

Posted by incree

2013/10/26 15:19 2013/10/26 15:19
, ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/286

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

1. 목록 가져오기
/page_id/promotable_posts?is_published=0

is_published 파라미터가 없는 경우는 예약된 이후에 publishing된 목록도 같이 가져온다

2. 현재 시간으로 posting 하기
FB.api('/' + post_id, 'POST', {is_published:true}, function(response) {
 console.log(response); // 성공하면 true
}

3. publishing time 수정
FB.api('/' + post_id, 'POST', {scheduled_publish_time:newTime}, function(response) {
 console.log(response); // 성공하면 true
}

4. 삭제하기
FB.api('/' + post_id, 'DELETE', function(response) {
 console.log(response); // 성공하면 true
}

Posted by incree

2013/10/18 16:13 2013/10/18 16:13
, , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/282

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[SNS] 페이스북 access tokens 관련 url

How-To: Handle expired access tokens
https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/


Removal of offline_access permission
https://developers.facebook.com/roadmap/offline-access-removal/


Facebook PHP-SDK have added simple way of extending access_token
https://github.com/facebook/facebook-php-sdk/commit/1270f0debaab3b93d683a9817c7adbc7e9e5cdc0


How to extend access token validity since offline_access deprecation
http://stackoverflow.com/questions/8982025/how-to-extend-access-token-validity-since-offline-access-deprecation

Posted by incree

2013/10/11 10:11 2013/10/11 10:11
, , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/277

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[SNS] 페이스북 tab app api 관련 url

Add Page Tab Dialog(페이지에 탭앱 추가하기)
https://developers.facebook.com/docs/reference/dialogs/add_to_page/

FB.ui({
  method: 'pagetab',
  redirect_uri: 'YOUR_URL'
}, function(response){});

https://www.facebook.com/dialog/pagetab?
  app_id=YOUR_APP_ID
  &redirect_uri=YOUR_URL
https://www.facebook.com/dialog/pagetab?app_id=449768265140751&redirect_uri=http://facebook.com


Realtime Updates

https://developers.facebook.com/docs/reference/api/realtime/
https://developers.facebook.com/docs/reference/api/realtime/#subscribingviagraphapi

https://developers.facebook.com/docs/reference/api/page/#realtime
사용자 삽입 이미지
변경가능 항목
name
category_list
picture
checkins
feed


Connections tabs
https://developers.facebook.com/docs/reference/api/page/#connections
https://developers.facebook.com/docs/reference/api/page/#tabs

Create

You can install a profile_tab at the end of the current list of installed tabs for a page by issuing an HTTP POST request to PAGE_ID/tabs with a Page Access Token:

Parameter Description Type Required
app_id ID of the application for which to install the tab. string Y

If the create is successful, you get the following return:

Description Type
If the create succeeded boolean

Update

You can update an installed profile_tab for a page by issuing an HTTP POST request to /PAGE_ID/tabs/TAB_ID with Page Access Token and the following parameters:

Parameter Description Type Required
position Order in which the tab will appear on the profile. Must be after permanent tabs and less than the number of installed tabs. Index starts at 0 integer N
custom_name Name to be used for the tab. If this is set to an empty string, the tab will use the application’s default tab name. string N
is_non_connection_landing_tab Set this tab as the default landing tab for users who have not liked and are not admins of the Page. If provided, value must be true. boolean N
custom_image_url URL for an image to be used as a custom icon for this Page app. Note that either custom_image_url or custom_image can be set, but not both. string N
custom_image The name of an image file to be used as a custom icon for this Page app. Note that either custom_image_url or custom_image can be set, but not both. image file N

If the edit is successful, you get the following return.

Description Type
If the edit succeeded boolean

Delete

You can delete an installed profile_tab where is_permanent is not true for a page by issuing an HTTP DELETE request to /PAGE_ID/tabs/TAB_ID object with a Page Access Token.

If the delete is successful, you get the following return.

Description Type
If the delete is successful boolean



tabapp: {
            create: function(pageId, tabappId, pageAccessToken, callback) {
                FB.api('/' + pageId + '/tabs', 'POST', {access_token: pageAccessToken, app_id: tabappId}, function(response) {
                    if(callback) callback.apply(this, [response]);
                });
            },
            update: function(pageId, tabappId, pageAccessToken, updateData, callback) {
                updateData.access_token = pageAccessToken;
                FB.api('/' + pageId + '/tabs/app_' + tabappId, 'POST', updateData, function(response) {
                    if(callback) callback.apply(this, [response]);
                });
            },
            delete: function(pageId, tabappId, pageAccessToken, callback) {
                FB.api('/' + pageId + '/tabs/app_' + tabappId, 'DELETE', {access_token: pageAccessToken}, function(response) {
                    if(callback) callback.apply(this, [response]);
                });
            }
        }

Posted by incree

2013/10/09 09:44 2013/10/09 09:44
, , , , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/276

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

« Previous : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : ... 13 : Next »