Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onerror = function(message, url, lineNumber) {
- alert("Error: "+message+" in "+url+" at line "+lineNumber);
- }
- var almuftah = Dom7;
- var app = new Framework7();
- var endPoint = 'http://10.6.1.218/AlmuftahERP/web/index.php/';
- document.addEventListener('deviceready',function() {
- //when device is ready
- window.plugins.uniqueDeviceID.get( fnDeviceIdReceived, fnDeviceIdNotReceived );
- },false);
- function fnDeviceIdReceived(deviceId) {
- almuftah('#login-btn').click(
- function() {
- var unameInput = almuftah('#uname');
- var pwdInput = almuftah('#pwd');
- var uname = unameInput.val();
- var pwd = pwdInput.val();
- uname = uname.trim();
- pwd = pwd.trim();
- var message = '';
- if(uname == '') {
- message = 'Please enter your username';
- } else if(pwd == '' ) {
- message = 'Please enter your password';
- }
- if(message != '') {
- var toast = app.toast(message, {});
- toast.show();
- } else {
- login(uname,pwd,deviceId);
- }
- }
- );
- }
- function fnDeviceIdNotReceived() {
- var toast = app.toast("Problem accessing device", {});
- toast.show();
- }
- function login(uname,password,deviceId) {
- password = CryptoJS.SHA1(password);
- password = password.toString();
- var url = endPoint+"login/authenticate";
- var data = {
- username:uname,
- password:password,
- device_id:deviceId
- };
- var options = {
- data:data,
- url:url,
- method:'POST',
- success :function(response) {
- alert(response);
- },
- error :function() {
- alert('failed');
- }
- };
- almuftah.ajax(options);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement