mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
@ -1,47 +0,0 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {Control, ControlGroup} from 'angular2/common';
|
||||
|
||||
import {App, Storage, LocalStorage, SqlStorage} from 'ionic/ionic';
|
||||
|
||||
let testUrl = 'https://ionic-api-tester.herokuapp.com/json';
|
||||
let testUrl404 = 'https://ionic-api-tester.herokuapp.com/404';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class IonicApp {
|
||||
constructor() {
|
||||
this.local = new Storage(LocalStorage);
|
||||
this.sql = new Storage(SqlStorage);
|
||||
}
|
||||
getLocal() {
|
||||
this.local.get('name').then(value => {
|
||||
alert('Your name is: ' + value);
|
||||
});
|
||||
}
|
||||
setLocal() {
|
||||
let name = prompt('Your name?');
|
||||
|
||||
this.local.set('name', name);
|
||||
}
|
||||
removeLocal() {
|
||||
this.local.remove('name');
|
||||
}
|
||||
|
||||
getSql() {
|
||||
this.sql.get('name').then(value => {
|
||||
alert('Your name is: ' + value);
|
||||
}, (errResult) => {
|
||||
console.error('Unable to get item from SQL db:', errResult);
|
||||
});
|
||||
}
|
||||
setSql() {
|
||||
let name = prompt('Your name?');
|
||||
|
||||
this.sql.set('name', name);
|
||||
}
|
||||
removeSql() {
|
||||
this.sql.remove('name');
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<ion-view>
|
||||
<ion-content padding>
|
||||
<h2>Local Storage</h2>
|
||||
<button primary (click)="getLocal()">Get</button>
|
||||
<button primary (click)="setLocal()">Set</button>
|
||||
<button primary (click)="removeLocal()">Remove</button>
|
||||
|
||||
<h2>SQL Storage</h2>
|
||||
<button primary (click)="getSql()">Get</button>
|
||||
<button primary (click)="setSql()">Set</button>
|
||||
<button primary (click)="removeSql()">Remove</button>
|
||||
</ion-content>
|
||||
</ion-view>
|
@ -1,102 +0,0 @@
|
||||
import {App} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EApp {
|
||||
|
||||
tapTest(eleType) {
|
||||
console.debug('test click', eleType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function onEvent(ev) {
|
||||
var c = pointerCoord(ev);
|
||||
var l = '(' + c.x + ',' + c.y + ')';
|
||||
if (ev.isIonicTap) {
|
||||
l += ' isIonicTap';
|
||||
}
|
||||
console.debug(ev.type, l);
|
||||
}
|
||||
|
||||
function pointerCoord(ev) {
|
||||
// get coordinates for either a mouse click
|
||||
// or a touch depending on the given event
|
||||
let c = { x: 0, y: 0 };
|
||||
if (ev) {
|
||||
const touches = ev.touches && ev.touches.length ? ev.touches : [ev];
|
||||
const e = (ev.changedTouches && ev.changedTouches[0]) || touches[0];
|
||||
if (e) {
|
||||
c.x = e.clientX || e.pageX || 0;
|
||||
c.y = e.clientY || e.pageY || 0;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
document.addEventListener('touchstart', onEvent);
|
||||
document.addEventListener('touchcancel', onEvent);
|
||||
document.addEventListener('touchend', onEvent);
|
||||
document.addEventListener('mousedown', onEvent);
|
||||
document.addEventListener('mouseup', onEvent);
|
||||
document.addEventListener('click', onEvent);
|
||||
|
||||
|
||||
var msgs = [];
|
||||
var index = 0;
|
||||
var timeId;
|
||||
var winConsoleError = console.error;
|
||||
|
||||
console.error = function() {
|
||||
winConsoleError.apply(this, arguments);
|
||||
var args = ['ERROR!'];
|
||||
for (var i = 0, j = arguments.length; i < j; i++){
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
console.debug.apply(this, args);
|
||||
};
|
||||
|
||||
console.debug = function() {
|
||||
index++;
|
||||
var msg = [];
|
||||
msg.push(index);
|
||||
for (var i = 0, j = arguments.length; i < j; i++){
|
||||
msg.push(arguments[i]);
|
||||
}
|
||||
msg.push(getTime());
|
||||
|
||||
msg = msg.join(', ');
|
||||
|
||||
if(arguments[0] === 'ERROR!') msg = '<span style="color:red;font-weight:bold">' + msg + '</span>';
|
||||
|
||||
if(arguments[0] === 'touchstart') msg = '<span style="color:blue">' + msg + '</span>';
|
||||
if(arguments[0] === 'touchend') msg = '<span style="color:darkblue">' + msg + '</span>';
|
||||
|
||||
if(arguments[0] === 'mousedown') msg = '<span style="color:red">' + msg + '</span>';
|
||||
if(arguments[0] === 'mouseup') msg = '<span style="color:maroon">' + msg + '</span>';
|
||||
|
||||
if(arguments[0] === 'click') msg = '<span style="color:purple">' + msg + '</span>';
|
||||
|
||||
if(arguments[0] === 'test click') msg = '<span style="color:orange">' + msg + '</span>';
|
||||
|
||||
msgs.unshift( msg );
|
||||
|
||||
if(msgs.length > 25) {
|
||||
msgs.splice(25);
|
||||
}
|
||||
|
||||
// do this so we try not to interfere with the device performance
|
||||
clearTimeout(timeId);
|
||||
timeId = setTimeout(function(){
|
||||
document.getElementById('logs').innerHTML = msgs.join('<br>');
|
||||
}, 100);
|
||||
|
||||
}
|
||||
|
||||
function getTime() {
|
||||
var d = new Date();
|
||||
return d.getSeconds() + '.' + d.getMilliseconds();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
|
||||
<ion-row>
|
||||
|
||||
<ion-col>
|
||||
<button (click)="tapTest('button')" block>
|
||||
<div><div><p>Button</p></div></div>
|
||||
</button>
|
||||
</ion-col>
|
||||
|
||||
<ion-col>
|
||||
<a button (click)="tapTest('link')" block>
|
||||
Link
|
||||
</a>
|
||||
</ion-col>
|
||||
|
||||
</ion-row>
|
||||
|
||||
<ion-row>
|
||||
|
||||
<ion-col>
|
||||
<div button (click)="tapTest('div')" block>
|
||||
Div w/ (click)
|
||||
</div>
|
||||
</ion-col>
|
||||
|
||||
<ion-col>
|
||||
<div button block>
|
||||
Div w/out (click)
|
||||
</div>
|
||||
</ion-col>
|
||||
|
||||
</ion-row>
|
||||
|
||||
|
||||
<div id="logs"></div>
|
||||
|
||||
<style>
|
||||
.activated {
|
||||
background-color: yellow !important;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user