728x90


php 언어는 

대표적인 서버 사이드 스크립트 언어중 하나입니다.

즉, 서버에서 실행되는 언어입니다.


서버에서 실행되는 언어라는 의미를 이해하기 위해서는

우선, 서버에 대해서 알아야할 것 같습니다.


우와 그래서 Server가 뭐야~ 


예 그렇습니다.

서버는 어떤 '업무'를 수행하기 위해 

설정되어있는 컴퓨터라고 볼 수 있습니다.


여러분이 웹 사이트를 하나 운영한다고 해보겠습니다.



이처럼 Client로 부터 요청이 오면

Server는 Client로부터 들어온 요청에 대한 서비스를 제공해줍니다.


아~ 이러한 서버에서 사용되는 언어가 서버 사이드언어라고 하구나~


예~ 그 중에 삽잡이는 PHP 언어에 대해서 언급을 한 것이구요



Javascript는 성격이 조금 다릅니다.

바로 클라이언트 사이드 스크립트 언어이기 때문입니다.

즉, Client에서 실행이 되는 언어입니다.


여기서 Client라고 하면 

브라우저라고 이해하셔도 무방할 것 같습니다.


Client의 동작들에 대한 이벤트 및 기타 등등의 작업들을

Javascript와 같은 클라이언트 사이드 언어에서 처리를 해줍니다.


서버가 없이도 실행이 가능한 Javascript....


이에 비해 PHP는 

서버의 데이터베이스를 포함한 

내부에 공개되서는 안되는 데이터들을 

관리하는데 용이합니다.


예... 그렇습니다. 

아무튼 이와 같이 

PHP와 Javascript에 대해 간략하게 알아봤습니다.


그런데 왜 오늘은 뭘 하려고...

이렇게 언어의 특성부터 알아본 것일까요?


뭐야~ 뭐야~ 궁금하게~


오늘은 Javascript에 PHP 데이터를 넘겨보려고합니다.


뭐야~ 둘이 성격이 다르다며... 


예 그런데... 가끔은 필요할 때가...


Javascript에서 PHP로 변수를 넘기기 위해서는

우리는 흔히 Ajax를 사용하여 서버로 데이터를 넘기곤 합니다.


왜냐하면, PHP는 서버 사이드 스크립트 언어이기에 

클라이언트에서 서버로 바로 전송될 수 있다고 장담할 수가 없습니다.

이에 Ajax를 사용하며 Server로부터 응답을 받곤 합니다.



자... 그런데!

이와 반대일 때는 어떻게 해야하냐 이거죠!



우선, PHP 언어에서 Javascript로 전송을 합니다.


1
2
3
//php
$sName = "삽잡이";
echo ("<script language=javascript> getName($sName);</script>");
cs


이렇게 Javascript로 데이터를 넘기게 되면

Javascript에서는 값을 받으면 됩니다.


참고로, 쌍 따옴표 ("")가 필요할 때에는 반드시

escape 처리(\)해줘야한다는 사실!

잊지마시길 바랍니다.


1
2
3
4
5
//javascript
var sName;
function getName(_sName) {
    sName = _sName;
}
cs

그리고 Javascript에서 PHP로 부터 받은 데이터를

동적으로 웹 브라우저에 뿌려줄 수 있겠지요.



PHP에서 Javascript의 함수 호출이 가능한 이유는 

바로, echo 문을 사용하여 Javascript를 선언하고 

함수를 호출해줬기 때문입니다.


값이 유동적으로 바뀌어야되는 상황이라면... 

즉, PHP 코드가 다 실행 되고서도

Javascript 언어를 통해 

동적으로 '무언가'의 처리가 가능하다는 소리입니다.


그리고 javascript의 메서드 선언이 

호출보다 우선이 되어야겠지요!?


참고하시고~


우리 모두~

유용하게 한번 사용해봅시다~



출처: http://shovelman.tistory.com/811 [한글로는 삽잡이, 영어로는 shovelMan]

출처: http://shovelman.tistory.com/811 [한글로는 삽잡이, 영어로는 shovelMan]

728x90


Make a flip book with HTML5

  • Works on most browsers and devices
  • Simple and clean API
  • Lightweight, 10K

Download

↑ Click a book or magazine to see turn.js in action

Turn.js is a JavaScript library that will make your content look like a real book or magazine using all the advantages of HTML5. The web is getting beautiful with new user interfaces based in HTML5; turn.js is the best fit for a magazine, book or catalog based in HTML5.

Let's code

<div id="flipbook">
	<div class="hard"> Turn.js </div>
	<div class="hard"></div>
	<div> Page 1 </div>
	<div> Page 2 </div>
	<div> Page 3 </div>
	<div> Page 4 </div>
	<div class="hard"></div>
	<div class="hard"></div>
</div>
<script type="text/javascript">
	$("#flipbook").turn({
		width: 400,
		height: 300,
		autoCenter: true
	});
</script>

Features

  • ✓   Works on iPad and iPhone.
  • ✓   Simple, beautiful and powerful API.
  • ✓   Allows to load pages dynamically through Ajax requests.
  • ✓   Pure HTML5/CSS3 content.
  • ✓   Two transition effects.
  • ✓   Works in old browsers such as IE 8 with turn.html4.js

Requirements

jQuery 1.3 or above.

Browser Support

Safari 5Chrome 16Firefox 10IE 10, 9, 8

Devices

  • ✓   All iOS (iPad, iPhone, iPod)
  • ✓   Android (Chrome for Android)

Improvements

Turn.js 4 includes a set of significant performance improvements on its core.

  • ✓   Effects are now quite smoother on the browser platform.
  • ✓   The new DOM composition guarantees the same performance no matter the amount of pages.

Complements

turn.html4.js - The HTML4 version of turn.js.

zoom.js - The new zoom feature of turn.js, See a sample.

scissors.js - Cuts a page in two parts for turn.js.

hash.js - Controls the navigation history using pushState and URI hashes.

API Documentation

The turn.js API was conveniently built as an UI plugin for jQuery, it provides access to a set of features and allows you to define the user interaction. 
The complete documentation is available here, it's also available in PDF format.

Support

You can browse all issues on GitHub
If you'd rather report issues using your email, you could contact us to: support@turnjs.com

Licensing

The turn.js project is released under the BSD license and it's available on GitHub. This license doesn't include features of the 4th release.

About

Hello Everyone, 

I'm Emmanuel García, a front-end developer from Venezuela, who loves to push the web forward with new technologies.

I look forward to releasing new projects. One of those will allow you to split HTML content into pages depending on the size of the pages. While loading pages with turn.js, this library would have an infinity potential. Think about detecting the number of pages automatically, creating a table of contents that knows where every page is, and adding functions like font size.

I'm also interested in using pdf.js and node.js for a new library that will convert pdf files into pure HTML5 (text/CSS3) files to provide content for the frontend with turn.js.

Follow me on Twitter: @blasten or Github 
Reach me out: blasten@gmail.com

©2012 All rights reserved - A production of @blasten


728x90


I'd like to find source files (*.c, *.cpp, *.h) that contain in Linux/MinGW/Cygwin, and recursively in all sub directories.

My basic idea is using find and grep. However, building a regular expression that can check given file name is either *.c, *.cpp, or *.h isn't easy. Could you help me out?

This should work:

find Linux/MinGW/Cygwin -name '*.c' -o -name '*.cpp' -o -name '*.h'
find -regex '.*/.*\.\(c\|cpp\|h\)$'

I would use:

find . -regex '.*\.\(c\|cpp\|h\)$' -print
  • 1
    In my macbook, the script without a -E can't find anything. you might need add a -E (as extended) to make it more portable, just like find -E . -regex '.*\.(c|h|cpp)' -print. ;-) – YanTing_ThePandaMay 1 '17 at 9:17

Quick and dirty, and avoids directory names:

find . -type f -name *.[c\|h]
  • 2
    There are three problems with this command: 1. It won't find *.cpp files. 2. It will find *.| files. 3. The glob will expand if there are matching files in the current directory. Quoting prevents that. – Dennis Dec 17 '13 at 15:48

I use a mac pro which also works in bash. But every time I type in the command line:

find -name

it says illegal option. So I just simplified it as:

find *.c *.cpp *.h

and found it really worked!

You can use a slightly simpler regex:

find . -type f -regex ".*\.[ch]\(pp\)?$"


728x90


I am trying to make an animated scroll to a bottom button using jQuery that fades out when the page is located at the bottom. I have found this code on the internet and modified it, but I could not get it work.

 <script>
    //to bottom
    $(document).ready(function(){

        // hide #back-top first

        $("#back-bottom").show();

        // fade in #back-top
        $(function () {
            $(window).scroll(function () {
                if ($(this).scrollTop()  1) {
                    $('#back-bottom').hide();
                } else {
                    $('#back-bottom').show();
                }
            });

            // scroll body to 0px on click
            $('#back-bottom a').click(function () {
                $('body,html').animate({ scrollTop: 0 }, 800);
                return false;
            });
        });

    });
    </script>

I think you need to calculate body height and pass that to the scrollTop parameter in the animate

$('body,html').animate({ scrollTop: $('body').height() }, 800);

Check here the working demo

$('#back-bottom a').click(function () {
                $('body,html').animate({ scrollTop: $('body').height() }, 500);
                return false;
            });

i think it will work for you

  • Should work for scrolling to the bottom, but there was also an error in the code for showing the button when not at the bottom. – Michael Peterson Sep 8 '12 at 4:58
  • thanks soo much it works great howerever 2 problems 1 it does not scroll smooth and 2 it does not fade out please tell me how to achive that thanks – user1656139 Sep 8 '12 at 4:59
  • first think u needed is smooth scroll for that 500 increase to 1000 or how much u needed depending upon that – Anudeep Sep 8 '12 at 5:06 
  • for fade out use this code $('#back-bottom a').fadeOut('slow'); (after this code use fade out code $('body,html').animate({ scrollTop: $('body').height() }, 500); ) – Anudeep Sep 8 '12 at 5:08 

Created an example fiddle that works:

http://jsfiddle.net/z5JNc/

Changed the condition to hide the button to: if($(window).scrollTop() + $(window).height() == $(document).height())

To scroll back to the top, added a variable that gets the height of the body: var $elem = $('body')Then when the link is clicked, changed the value to be: scrollTop: $elem.height()


'WEB > jQuery' 카테고리의 다른 글

jQuery Select Box Control  (0) 2018.04.13
turn.js  (0) 2018.03.08
.load()  (0) 2018.02.22
jQuery 페이지 부분 새로고침 | Refresh Part of Page by jQuery  (0) 2018.02.21
[jQuery] 테이블의 특정 행(row)의 값 가져오기  (0) 2018.02.18

+ Recent posts