個人常用外掛:
- AdvancedNewFile
- Alignment
- All Autocomplete
- BracketHighlighter
- ConvertToUTF8
- HexViewer
- Highlight
- HTML-CSS-JS Prettify
- JSHint
- JsMinifier
- KeymapManager
- SideBarEnhancements
- SublimeCodeIntel
- Tag
- Terminal
- Theme - Soda
- Sublimerge Pro
// 建立實體
window.simrou = new Simrou();
// 設定 deep-linking 規則
var postRoute = window.simrou.addRoute('/post/:id');
// 定義某 deep-linking 規則的事件處理
postRoute.get(function(event, params){
// alert(params.id);
});
window.simrou.start();
<a href="#/post/12">第 12 則<</a>
window.simrou.navigate('/post/'+myid);
<?php $this->beginContent('//layouts/main'); ?>
<div>
<?php echo $content ?>
</div>
<div class="sidebar">
<ul>
<li>option 1</li>
<li>option 2</li>
</ul>
</div>
<?php $this->endContent() ?>
beginContent('//layouts/main') 表示以 main 為佈局,在 beginContent() 和 endContent() 之間為 content 呈現的修改。 beginContent() 和 endContent() 之外的範圍不建議加入 HTML,否則會在 main.php 內容的前面或後面(<html> 標籤之前或 </html> 標籤之後)。public function actionMylayout() {
$this->layout = 'mylayout';
$this->render('//site/index');
}
表示以 mylayout.php 為佈局,views/site/index.php 為內容。<table>
<tr>
<td>Name</td>
<td>Phone</td>
</tr>
<tr>
<td><?php echo !empty($name) ? $name : 'anonymous'; ?></td>
<td><?php echo !empty($phone) ? $phone : ''; ?></td>
</tr>
</table>
<?php
$this->renderPartial('//common/part1', array(
'name' => 'John',
'phone'=> '123456',
));
?>
renderPartial() 是 controller 的方法,所以也可以在 controller 裡面使用。defined('YII_DEBUG') or define('YII_DEBUG',true);
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
array(
'class'=>'CWebLogRoute',
'categories'=>'application',
),
),
),
<html ng-app>
<meta charset="utf-8">
<body ng-controller='myController'>
<input ng-model="my.input" placeholder="填入整數" />
<p>填入值: {{my.input}}</p>
<p ng-bind="my.dots"></p>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script>
function myController($scope) {
$scope.my = {
input: 0,
dots: ''
};
$scope.$watch('my.input', function(newValue, oldValue, scope) {
// console.log(':::', newValue, oldValue, scope);
alert('new value:' + newValue);
var dot = '◎';
var i = parseInt($scope.my.input);
$scope.my.dots = '';
while (i-- > 0) {
$scope.my.dots += dot;
}
});
}
</script>
</body>
</html>
範例 ng_scope_watch.htm
<html ng-app='myApp'><!-- 設定模組名稱為 myApp -->
<meta charset="utf-8">
<body ng-controller='myController'>
<p>Hello {{txt}}</p>
<p ng-bind=" 'Hi ' + txt"></p><!-- 未完成動作前無顯示內容 -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script>
// 建立名稱為 myApp 的模組。第二個參數空陣列表示 "建立", 沒有給表示 "取得"
var myAppModule = angular.module('myApp', []);
// 設定 controller
myAppModule.controller('myController',
function($scope) {
$scope.txt = "John";
});
</script>
</body>
</html>
AngularJS 非全域 controller 設定方式:http://graph.facebook.com/?ids=http://stackoverflow.com/,http://qops.blogspot.tw/
{
http://stackoverflow.com/: {
id: "http://stackoverflow.com/",
shares: 14867,
comments: 9
},
http://qops.blogspot.tw/: {
id: "http://qops.blogspot.tw/",
shares: 13
}
}
<?php
$links = array(
'http://stackoverflow.com/',
'http://qops.blogspot.tw/',
);
$my_graph = 'http://graph.facebook.com/?ids=' . implode(',', $links);
$likes_info = json_decode( file_get_contents($my_graph), true );
foreach($links as $link) {
printf("%s<br/>%s<br/>", $link, $likes_info[ $link ]['shares']);
}
var b = 10;
var b:Number;
// variable1.fla 影格 圖層1:1
var b:Number = 10;
b = true;
trace(b);
| 型別(類型)不符的錯誤 |
| 程式碼提示 |
基本資料型別
|
預設值
|
Boolean
|
false
|
int
|
0
|
uint
|
0
|
Number
|
Number.NaN
|
String
|
null
|
var b1:Boolean = true;
var b2:Boolean = 7>3;
// number1.fla 影格 圖層 1:1
var n1:Number = 5;
var n2:Number = 5.000000000000000001;
var n3:Number = 0.123456789123456789;
var n4:Number = 1e2;
trace("n1=", n1);
trace("n1/2=", n1/2);
trace("n2=", n2);
trace("n3=", n3);
trace("n4=", n4);
| number1.fla 執行結果 |
// number2.fla 影格 圖層 1:1
var i:int = 0x66;
var u:uint = 0x66;
var n:Number = 0x66;
trace("i=", i);
trace("u=", u);
trace("n=", n);
| number2.fla 執行結果 |
// number3.fla 影格 圖層 1:1
trace("int.MAX_VALUE=", int.MAX_VALUE);
trace("int.MIN_VALUE=", int.MIN_VALUE);
var i:int = int.MAX_VALUE+1;
var j:* = int.MAX_VALUE+1;
trace("i=", i);
trace("j=", j);
trace("uint.MAX_VALUE=", uint.MAX_VALUE);
trace("uint.MIN_VALUE=", uint.MIN_VALUE);
trace("Number.MAX_VALUE=", Number.MAX_VALUE);
trace("Number.MIN_VALUE=", Number.MIN_VALUE);
| number3.fla 執行結果 |
// number4.fla 影格 圖層 1:1
var m:Number = -2;
var n:Number = -1.23;
var i:int = m;
var j:int = n;
var u:uint = m;
var v:uint = n;
trace(i, u);
trace(j, v);
| number4.fla 執行結果 |
// string1.fla 影格 圖層 1:1
var s1:String = "abc";
var s2:String = '您好啊';
var s3:String = "qop's blog";
var s4:String = '>"<';
trace("s1=", s1);
trace("s2=", s2);
trace("s3=", s3);
trace("s4=", s4);
| string1.fla 執行結果 |
跳脫表示法
|
說明
|
\”
|
雙引號
|
\’
|
單引號
|
\\
|
反斜線
|
\t
|
相當於按下「Tab」跳格
|
\n
|
相當於按下「Enter」換行
|
\r
|
和
\n
相同
|
\uXXXX
|
以Unicode字元編碼表示一個字元,XXXX為四位的十六進位數值
|
| 設定名為tf_txt的TextField物件 |
// String2.fla 影格 圖層1:1
var s1:String = "單引號\' 和雙引號\"換行\n";
var s2:String = '反斜線\\跳格\t換行\r';
var s3:String = "\u798f氣";
trace(s1+s2+s3);
tf_txt.text = s1+s2+s3;
| string2.fla 執行結果 |
String的方法
|
說明
|
charAt(index)
|
回傳字串中索引值為index的字元。
|
charCodeAt(index)
|
回傳字串中索引值為index的字元字碼。
|
concat(s)
|
字串本身連接字串s。和執行「+=s」運算相同。
|
fromCharCode(c)
|
String的靜態方法,將c字碼轉換成字串。
|
indexOf(s,
start)
|
從索引值為start處開始尋找子字串s。若start省略則從頭開始找。找到子字串回傳子字串索引,若否則回傳
-1。
|
lastIndexOf(s)
|
尋找子字串最後的索引。
|
slice(start,
end)
|
擷取索引index至end的字串。若end省略則擷取至最後一個字元。
|
search(pattern)
|
使用正規表示法(Regular
Expression)尋找子字串。回傳子字串索引,若找不到則回傳
-1。
|
split(s)
|
將字串依特定字串s分割成元素,回傳字串陣列。
|
substr(index,
length)
|
從索引為index處擷取長度為length的字串。
|
substring(start,
end)
|
擷取索引index至end的字串。若end省略則擷取至最後一個字元。
|
toLowerCase()
|
轉換為小寫字母。
|
toUpperCase()
|
轉換為大寫字母。
|
// string3.fla 影格 圖層 1:1
var s1:String = '感覺\'Happy\'就是\"幸福\"';
trace("s1的字元數為: "+s1.length);
trace(s1.charAt(0)+": "+s1.charCodeAt(0));
trace('\\u611f : '+ '\u611f');
trace( String.fromCharCode( s1.charCodeAt(0) ) );
trace(s1.slice(2, 9));
trace(s1.substring(11));
trace(s1.toUpperCase());
trace(s1.toLowerCase());
var s2:String = "12-34-567";
trace(s2.split("-"));
| string3.fla 執行結果 |
| 目錄 |