格式上的调整, 现在可以分开写,但发布时打成一个js提高性能

weixin_login
guange 9 years ago
parent b1791f4531
commit ada15b4212

@ -13,6 +13,8 @@
<script type="text/javascript">
window.g_openid = '<%= @wechat_user.openid %>';
window.g_debug = false; //调试标志,如果在本地请置为true
window.apiUrl = '/api/v1/';
</script>
</head>
@ -21,7 +23,7 @@
</div>
<script src="/javascripts/wechat/build/angular.all.min.js"></script>
<script src="/javascripts/wechat/app.js"></script>
<script src="/javascripts/wechat/build/app.min.js"></script>
</body>
</html>

@ -2,7 +2,7 @@
<html ng-app="wechat">
<head>
<base href="/">
<title>我的动态</title>
<title>仅供本地调试使用</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
@ -17,7 +17,15 @@
<div ng-view>
</div>
<script type="text/javascript">
window.g_openid = 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg';
window.g_debug = true; //调试标志,如果在本地请置为true
window.apiUrl = 'http://localhost:3000/api/v1/';
</script>
<script src="/javascripts/wechat/build/angular.all.min.js"></script>
<!--<script src="/javascripts/wechat/build/app.min.js"></script>-->
<script src="/javascripts/wechat/app.js"></script>
<script src="/javascripts/wechat/others/factory.js"></script>
@ -33,6 +41,9 @@
<script src="/javascripts/wechat/controllers/issue.js"></script>
<script src="/javascripts/wechat/controllers/journals.js"></script>
<script src="/javascripts/wechat/others/routes.js"></script>
</body>
</html>

@ -1,8 +1 @@
var app = angular.module('wechat', ['ngRoute']);
var apiUrl = '/api/v1/';
var debug = true; //调试标志,如果在本地请置为true
if(debug===true){
apiUrl = 'http://localhost:3000/api/v1/';
//apiUrl = 'http://www.trustie.net/api/v1/';
}

File diff suppressed because one or more lines are too long

@ -1,5 +1,7 @@
app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){
app.controller('ActivityController',
['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common',
function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){
$scope.replaceUrl = function(url){
return url;
};
@ -63,4 +65,4 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
$scope.decreasePraise = function(act){
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,5 +1,7 @@
app.controller('BlogController', function($scope, $http, $routeParams, auth, common){
app.controller('BlogController',
['$scope', '$http', '$routeParams', 'auth', 'common',
function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -35,4 +37,4 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com
console.log(act);
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,4 +1,5 @@
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){
app.controller('CourseNoticeController', ['$scope', '$http', '$routeParams', 'auth', 'common',
function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -32,4 +33,4 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a
$scope.decreasePraise = function(act){
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,5 +1,5 @@
app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){
app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -33,4 +33,4 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut
$scope.decreasePraise = function(act){
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,5 +1,5 @@
app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){
app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -33,4 +33,4 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth,
$scope.decreasePraise = function(act){
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,4 +1,4 @@
app.controller('IssueController', function($scope, $http, $routeParams, auth, common){
app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -33,4 +33,4 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co
$scope.decreasePraise = function(act){
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,4 +1,4 @@
app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){
app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
$scope.formData = {comment: ''};
var loadData = function(id){
@ -34,4 +34,4 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth,
console.log(act);
common.decreaseCommonPraise(act);
};
});
}]);

@ -1,14 +1,10 @@
app.factory('auth', function($http,$routeParams, $q){
app.factory('auth', ['$http','$routeParams', '$q', function($http,$routeParams, $q){
var _openid = '';
if(typeof g_openid !== 'undefined'){
_openid = g_openid;
}
if(debug===true){
_openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; //guange的帐号
}
var getOpenId = function() {
var deferred = $q.defer();
if (typeof _openid !== 'undefined' && _openid.length > 0){
@ -32,7 +28,7 @@ app.factory('auth', function($http,$routeParams, $q){
return _openid;
};
return {getOpenId: getOpenId, openid: openid};
});
}]);
app.factory('rms', function(){
@ -48,7 +44,7 @@ app.factory('rms', function(){
return {save: save, get: get};
});
app.factory('common', function($http, auth, $routeParams){
app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){
var addCommonReply = function(id, type, data, cb){
if(!data.comment || data.comment.length<=0){
@ -117,4 +113,4 @@ app.factory('common', function($http, auth, $routeParams){
};
return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
});
}]);

@ -1,5 +1,5 @@
app.filter('safeHtml', function ($sce) {
app.filter('safeHtml', ['$sce',function ($sce) {
return function (input) {
return $sce.trustAsHtml(input);
}
});
}]);

@ -43,7 +43,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou
});
//监听异步请求,实现加载中显隐标记
$httpProvider.interceptors.push(function ($q, $rootScope) {
$httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) {
if ($rootScope.activeCalls == undefined) {
$rootScope.activeCalls = 0;
}
@ -66,5 +66,5 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou
return rejection;
}
};
});
}]);
}]);

@ -1,57 +0,0 @@
/**
* Created by root on 3/25/16.
*/
$(document).ready(function(){
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var apiUrl = '/api/v1/';
var loadDataFromServer = function(id, page){
getOpenId(function(openid){
$.ajax({
url: apiUrl + 'activities',
data: {openid: openid, page: page},
type: 'POST',
dataType: 'json',
success: function(data){
setTemplate(data.data, data.all_count, data.count, data.page);
},
error: function(xhr,status,err){
console.log(err);
}
});
})
};
var setTemplate = function(data, all_count, count, page){
console.log(data);
var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page});
if (page == 0) {
$('#container').prepend(html);
} else {
$("#more_activities").remove();
$('#container').append(html);
}
descToggle();
};
//内容全部显示与部分隐藏
var descToggle = function(){
$(".post-all-content").each(function(){
var postHeight = $(this).height();
if (postHeight > 90){
$(this).parent().next().css("display","block");
$(this).parent().next().toggle(function(){
$(this).text("点击隐藏");
$(this).prev().css("height",postHeight);
},function(){
$(this).text("点击展开");
$(this).prev().css("height",90);
});
}
});
}
loadDataFromServer(8686, 0);
});

@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd public/javascripts/wechat && gulp && gulp minify
Loading…
Cancel
Save