convert this string into array of objects

using the JSON native parser, as it is not only faster than the eval(), it's also more secure.

Native JSON parser is already available in:

Firefox 3.5+ IE 8+ Opera 10.5+ Safari Safari 4.0.3+ Chrome (don't know which version)

 

var myJSONString = '{ "a": 1, "b": 2 }';
myObject = JSON.parse(myJSONString);

 

http://stackoverflow.com/questions/3473639/best-way-to-convert-string-to-array-of-object-in-javascript

 

반응형

'Frontend > HTML5' 카테고리의 다른 글

Get Start Less  (0) 2014.09.02
.prependTo()  (0) 2014.08.22
make an Interactive Website 5 coding  (0) 2014.08.22
margin by codecademy  (0) 2014.08.21
ASP.NET MVC4 WEB API  (1) 2013.10.22




http://lesscss.org/



Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.

Less runs inside Node, in the browser and inside Rhino. There are also many 3rd party tools that allow you to compile your files and watch for changes.

For example:

@base: #f938ab;

.box-shadow(@style, @c) when (iscolor(@c)) {
  -webkit-box-shadow: @style @c;
  box-shadow:         @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
  .box-shadow(@style, rgba(0, 0, 0, @alpha));
}
.box {
  color: saturate(@base, 5%);
  border-color: lighten(@base, 30%);
  div { .box-shadow(0 0 5px, 30%) }
}

compiles to

.box {
  color: #fe33ac;
  border-color: #fdcdea;
}
.box div {
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

Less can be used on the command line via npm, downloaded as a script file for the browser or used in a wide variety of third party tools. See the Usage section for more detailed information.

Installation

The easiest way to install Less on the server, is via npm, the node.js package manager, as so:

$ npm install -g less

Command-line usage

Once installed, you can invoke the compiler from the command-line, as such:

$ lessc styles.less

This will output the compiled CSS to stdout, you may then redirect it to a file of your choice:

$ lessc styles.less > styles.css

To output minified CSS, simply pass the -x option. If you would like more involved minification, the Clean CSS is also available with the --clean-css option.

To see all the command line options run lessc without parameters.

Usage in Code

You can invoke the compiler from node, as such:

var less = require('less');

less.render('.class { width: (1 + 1) }', function (e, css) {
  console.log(css);
});

which will output

.class {
  width: 2;
}

you may also manually invoke the parser and compiler:

var parser = new(less.Parser);

parser.parse('.class { width: (1 + 1) }', function (err, tree) {
  if (err) {
    return console.error(err)
  }
  console.log(tree.toCSS());
});

Configuration

You may pass some options to the compiler:

var parser = new(less.Parser)({
  paths: ['.', './lib'], // Specify search paths for @import directives
  filename: 'style.less' // Specify a filename, for better error messages
});

parser.parse('.class { width: (1 + 1) }', function (e, tree) {
  tree.toCSS({
    // Minify CSS output
    compress: true
  });
});

Third party tools

See the Usage section for details of other tools.

Command-line With Rhino

Each less.js release contains also rhino-compatible version.

Command line rhino version requires two files:

  • less-rhino-.js - compiler implementation,
  • lessc-rhino-.js - command line support.

Command to run the compiler:

java -jar js.jar -f less-rhino-<version>.js lessc-rhino-<version>.js styles.less styles.css

This will compile styles.less file and save the result to styles.css file. The output file parameter is optional. If it is missing, less will output the result to stdout.

Client-side usage

Using less.js in the browser is great for development, but it's not recommended for production

Client-side is the easiest way to get started and good for developing with Less, but in production, when performance and reliability is important, we recommend pre-compiling using node.js or one of the many third party tools available.

To start off, link your .less stylesheets with the rel attribute set to "stylesheet/less":

<link rel="stylesheet/less" type="text/css" href="styles.less" />

Next, download less.js and include it in a <script></script> tag in the <head> element of your page:

<script src="less.js" type="text/javascript"></script>

Tips

  • Make sure you include your stylesheets before the script.
  • When you link more than one .less stylesheet each of them is compiled independently. So any variables, mixins or namespaces you define in a stylesheet are not accessible in any other.

Browser Options

Options are defined by setting them on a global less object before the <script src="less.js"></script>:

<!-- set options before less.js script -->
<script>
  less = {
    env: "development",
    async: false,
    fileAsync: false,
    poll: 1000,
    functions: {},
    dumpLineNumbers: "comments",
    relativeUrls: false,
    rootpath: ":/a.com/"
  };
</script>
<script src="less.js"></script>

Learn more about Browser Options

Browser downloads

Download Less.js v1.7.4

Download source code

Get the latest Less.js source code by downloading it directly from GitHub.

Clone or fork via GitHub

Fork the project and send us a pull request!

Install with Bower

Install the Less.js project and JavaScript by running the following in the command line:

bower install less

Less CDN

<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.7.4/less.min.js"></script>

Less.js is released under the Apache 2 License (though there are plans to dual license it). Copyright 2009-2014, Alexis Sellier and the Less Core Team (see about). Boiled down to smaller chunks, it can be described with the following conditions.

It allows you to:

  • Freely download and use Less.js, in whole or in part, for personal, company internal or commercial purposes
  • Use Less.js in packages or distributions that you create

It forbids you to:

  • Redistribute any piece of Less.js without proper attribution

It requires you to:

  • Include a copy of the license in any redistribution you may make that includes Less.js
  • Provide clear attribution to The Less Core Team for any distributions that include Less.js

It does not require you to:

  • Include the source of Less.js itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it
  • Submit changes that you make to Less.js back to the Less.js project (though such feedback is encouraged)

The full Less.js license is located in the project repository for more information.


반응형

'Frontend > HTML5' 카테고리의 다른 글

[JS] JSON.parse : Convert this string into array of objects  (0) 2016.08.20
.prependTo()  (0) 2014.08.22
make an Interactive Website 5 coding  (0) 2014.08.22
margin by codecademy  (0) 2014.08.21
ASP.NET MVC4 WEB API  (1) 2013.10.22




Create a new li element  : $('<li>');

Select the h2 element nested insind the <div class="article"> ... </div> element. : $('.article h2');

Text

 





반응형

'Frontend > HTML5' 카테고리의 다른 글

[JS] JSON.parse : Convert this string into array of objects  (0) 2016.08.20
Get Start Less  (0) 2014.09.02
make an Interactive Website 5 coding  (0) 2014.08.22
margin by codecademy  (0) 2014.08.21
ASP.NET MVC4 WEB API  (1) 2013.10.22
Preview

Let's use jQuery to build a news reader.

  • The file index.html contains the page structure and content
  • The file style.css has the styling for the page
  • Click on the first article.
  • Use the n keyboard shortcut to go to the next article.
  • Then use the o keyboard shortcut to open the article description.
  • If you have issues, check out the hint!
  • Click Save & Submit Code to get started!
  1. Click on the first article.
  2. Use the n keyboard shortcut to go to the next article.
  3. Then use the o keyboard shortcut to open the article description.
  4. If you have issues, check out the hint!
  5. Click Save & Submit Code to get started!
?
Hint

If the keyboard shortcuts do not work, look at your code and see if you have a bunch of n's and o's which should not be there!

Delete those n's and o's. Then make sure you click on an article before you press the n's and o's. Hopefully it works now!



Program skeleton

The index.html file has two scriptelements right before the closing </body>tag:

  • The first script loads jQuery.
  • The second script loads app.js. The fileapp.js is where we'll write jQuery code for our news reader.


var main = function() {

};


$(document).ready(main);





























반응형

'Frontend > HTML5' 카테고리의 다른 글

Get Start Less  (0) 2014.09.02
.prependTo()  (0) 2014.08.22
margin by codecademy  (0) 2014.08.21
ASP.NET MVC4 WEB API  (1) 2013.10.22
Javascript / text / cs 연결할 때  (59) 2013.08.30

margin

The properties margin-left, andmargin-right are available to set themargin on either side of an HTML element. If one of these properties is set to auto, then it will take as much as possible.

To move the HTML element to the far left of the screen, use margin-right: auto. This will maximize the amount of space there is on the right side margin, pushing the element to the far left.

To center an element, setmargin-right: auto and margin-left: auto. The margin to the left and right will be equal and the element will be centered.


스크린의 왼쪽으로 떨어트리고 싶을때는 ,  margin-right: auto

오른쪽의 margin 공백을 최대치로 두기때문에, 왼쪽으로 이동하게 된다. 


요소를 중앙으로 데려오고 싶을 경우, margin-right: auto and margin-left: auto

 하게되면, 그 요소들이 각각 동일하게 여백이 적용될 것이라, 중간에 올 것이다. 



반응형

'Frontend > HTML5' 카테고리의 다른 글

.prependTo()  (0) 2014.08.22
make an Interactive Website 5 coding  (0) 2014.08.22
ASP.NET MVC4 WEB API  (1) 2013.10.22
Javascript / text / cs 연결할 때  (59) 2013.08.30
jQuery의 정의 셀렉터를 사용한 radio 버튼 값 가져오기  (60) 2013.08.29

 

WEB API

SOAP, WS 보다 기본적인 HTTP 위에 노출된 서비스와 같은RESTful 서비스 개발 가능

 

  1. 프로젝트 만들기
    1. ASP.NET MVC 4 PROJECT > project name : 'WorkManagerSimple '
    2. PROJECT TEMPLATE > Web API

      *NuGet 사용 : 패키지관리솔루션

       

  2. Controller > ValuesController.cs
  3. Models > Add > Class > WorkManager.cs 생성
    1. Entity Framework의 code First 컨벤션을 사용
      1. public class WorkManager
      2. {
      3. public int id { get; set; }
      4. public string name { get; set; }
      5. public string detail { get; set; }
      6. }
  4. Controller에서 폴더 추가하여 Web API컨트롤러 분리시킨다.
    1. Controller > new folder > Apis
    2. Apis > add > Controller
      1. Controller name : workmgtController
      2. Tamplate : MVC controller with read/write actions and views, using Entity Framework
      3. Model class :
      4. ..... http://www.youtube.com/watch?v=Dkgr3lpE_LY
반응형

 

무슨 말인고 하니.

 

<input type="radio" id="rdoList"> 이렇게 선언을 하고,

라디오버튼을 선택한 값을 cs단에 넘겨 무엇인가 이벤트를 하려고 할 때,

 

<script>

selectedValue = $(":input:radio[name=rdoIDList]:checked").val();

 

//document.getElementById('<%=hdnUSERID.ClientID%>').value = selectedValue;

document.getElementById('hdnUSERID').value = selectedValue;

document.getElementById("<%=ibtnSearchLastID.ClientID%>").click();

</script>

 

<body>

<input type="hidden" runat="server" id="hdnUSERID" />

</body>

 

 

//document.getElementById('<%=hdnUSERID.ClientID%>').value = selectedValue;

경우로 type hidden으로 주면 에러가 난다.

document.getElementById('hdnUSERID').value = selectedValue;

반응형

'Frontend > HTML5' 카테고리의 다른 글

margin by codecademy  (0) 2014.08.21
ASP.NET MVC4 WEB API  (1) 2013.10.22
jQuery의 정의 셀렉터를 사용한 radio 버튼 값 가져오기  (60) 2013.08.29
Alert 안에서 공백/줄바꿈  (55) 2013.08.28
팝업 종료 후 부모창 리로드  (58) 2013.07.04

jQuery의 정의 셀렉터를 사용한 radio 버튼 값 가져오기. by Coder

  • 2008/12/25 15:33 
  • 0 comments

    jQuery에서 제공해주는 정의 필터 셀렉터를 사용해서 radio버튼의 value값을 가져오는 방식은 아래와 같다.

      $(":input:radio[name=sample]:checked").val()

    <input type="radio" name ="sample" value="Y" checked>
    <input type="radio" name ="sample" value="N">


    보기엔 길어보이지만 간단하게 설명된다.
    최초 input 엘리먼트를 선택후 radio 버튼을 가져온다음 name 속성의 값이 sample 것중에서 선택된 값의 value 가져온다.
    위의 경우 value 값은 "Y" 출력된다.
    아무것도 선택하지 않은상태에선 value값은 'undefined' 반환된다.

    마찬가지로 radio대신 checkbox등의 체크값을 가져오는 방식도 위와 동일하다 하겠다.

반응형

'Frontend > HTML5' 카테고리의 다른 글

ASP.NET MVC4 WEB API  (1) 2013.10.22
Javascript / text / cs 연결할 때  (59) 2013.08.30
Alert 안에서 공백/줄바꿈  (55) 2013.08.28
팝업 종료 후 부모창 리로드  (58) 2013.07.04
apple이 보여주는 html5  (0) 2011.09.11

 

공백 &nbsp;

줄바꿈

Alert ('안녕 \n반가워');

반응형

리스트페이지에서 상세뷰를 누를경우 
상세페이지의 내용은 이미지를 보여주고 있음.
이미지를 클릭할경우 팝업을 띄어서
이미지 수정시 해당팝업을 종료시키면서 
상세페이지의 이미지 바뀐걸 갱신 시켜주고자 할때
updateDataInfo를 호출하면 
수정이 된후 팝업창을 닫으면서 부모창의 reloadPage()함수를
호출 갱신시킨다.


//----------------------------------------------
// 수정 (팝업창에 있는 함수)
//----------------------------------------------
function updateDataInfo() {
    var objFrm = document.getElementById('childForm');

    //     spring에 매핑되는 modelAndView             
    objFrm.action="<%=request.getContextPath()%>/album/albumUpdateEXEC.do"; 
    objFrm.submit();
    opener.reloadPage();
    self.close();
}


//----------------------------------------------
// 페이지를 갱신시킨다. (자식창에서 호출하는 함수 )
//----------------------------------------------
function reloadPage() {
    location.reload(); 
}


반응형

'Frontend > HTML5' 카테고리의 다른 글

ASP.NET MVC4 WEB API  (1) 2013.10.22
Javascript / text / cs 연결할 때  (59) 2013.08.30
jQuery의 정의 셀렉터를 사용한 radio 버튼 값 가져오기  (60) 2013.08.29
Alert 안에서 공백/줄바꿈  (55) 2013.08.28
apple이 보여주는 html5  (0) 2011.09.11
반응형

+ Recent posts